Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
46bbbd27
Commit
46bbbd27
authored
Aug 14, 2012
by
Vincent Povirk
Committed by
Alexandre Julliard
Aug 15, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Implement getters on IWICBitmapLock.
parent
297c10a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
32 deletions
+103
-32
bitmap.c
dlls/windowscodecs/bitmap.c
+78
-7
bitmap.c
dlls/windowscodecs/tests/bitmap.c
+25
-25
No files found.
dlls/windowscodecs/bitmap.c
View file @
46bbbd27
...
...
@@ -39,12 +39,18 @@ typedef struct BitmapImpl {
IWICPalette
*
palette
;
int
palette_set
;
LONG
lock
;
/* 0 if not locked, -1 if locked for writing, count if locked for reading */
BYTE
*
data
;
UINT
width
,
height
;
UINT
stride
;
UINT
bpp
;
}
BitmapImpl
;
typedef
struct
BitmapLockImpl
{
IWICBitmapLock
IWICBitmapLock_iface
;
LONG
ref
;
BitmapImpl
*
parent
;
UINT
width
,
height
;
BYTE
*
data
;
}
BitmapLockImpl
;
static
inline
BitmapImpl
*
impl_from_IWICBitmap
(
IWICBitmap
*
iface
)
...
...
@@ -144,25 +150,46 @@ static ULONG WINAPI BitmapLockImpl_Release(IWICBitmapLock *iface)
static
HRESULT
WINAPI
BitmapLockImpl_GetSize
(
IWICBitmapLock
*
iface
,
UINT
*
puiWidth
,
UINT
*
puiHeight
)
{
FIXME
(
"(%p,%p,%p)
\n
"
,
iface
,
puiWidth
,
puiHeight
);
BitmapLockImpl
*
This
=
impl_from_IWICBitmapLock
(
iface
);
TRACE
(
"(%p,%p,%p)
\n
"
,
iface
,
puiWidth
,
puiHeight
);
return
E_NOTIMPL
;
if
(
!
puiWidth
||
!
puiHeight
)
return
E_INVALIDARG
;
*
puiWidth
=
This
->
width
;
*
puiHeight
=
This
->
height
;
return
S_OK
;
}
static
HRESULT
WINAPI
BitmapLockImpl_GetStride
(
IWICBitmapLock
*
iface
,
UINT
*
pcbStride
)
{
FIXME
(
"(%p,%p)
\n
"
,
iface
,
pcbStride
);
BitmapLockImpl
*
This
=
impl_from_IWICBitmapLock
(
iface
);
TRACE
(
"(%p,%p)
\n
"
,
iface
,
pcbStride
);
return
E_NOTIMPL
;
if
(
!
pcbStride
)
return
E_INVALIDARG
;
*
pcbStride
=
This
->
parent
->
stride
;
return
S_OK
;
}
static
HRESULT
WINAPI
BitmapLockImpl_GetDataPointer
(
IWICBitmapLock
*
iface
,
UINT
*
pcbBufferSize
,
BYTE
**
ppbData
)
{
FIXME
(
"(%p,%p,%p)
\n
"
,
iface
,
pcbBufferSize
,
ppbData
);
BitmapLockImpl
*
This
=
impl_from_IWICBitmapLock
(
iface
);
TRACE
(
"(%p,%p,%p)
\n
"
,
iface
,
pcbBufferSize
,
ppbData
);
return
E_NOTIMPL
;
if
(
!
pcbBufferSize
||
!
ppbData
)
return
E_INVALIDARG
;
*
pcbBufferSize
=
This
->
parent
->
stride
*
(
This
->
height
-
1
)
+
((
This
->
parent
->
bpp
*
This
->
width
)
+
7
)
/
8
;
*
ppbData
=
This
->
data
;
return
S_OK
;
}
static
HRESULT
WINAPI
BitmapLockImpl_GetPixelFormat
(
IWICBitmapLock
*
iface
,
...
...
@@ -227,6 +254,7 @@ static ULONG WINAPI BitmapImpl_Release(IWICBitmap *iface)
if
(
ref
==
0
)
{
if
(
This
->
palette
)
IWICPalette_Release
(
This
->
palette
);
HeapFree
(
GetProcessHeap
(),
0
,
This
->
data
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -282,12 +310,31 @@ static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock,
{
BitmapImpl
*
This
=
impl_from_IWICBitmap
(
iface
);
BitmapLockImpl
*
result
;
WICRect
rc
;
TRACE
(
"(%p,%p,%x,%p)
\n
"
,
iface
,
prcLock
,
flags
,
ppILock
);
if
(
!
(
flags
&
(
WICBitmapLockRead
|
WICBitmapLockWrite
))
||
!
ppILock
)
return
E_INVALIDARG
;
if
(
!
prcLock
)
{
rc
.
X
=
rc
.
Y
=
0
;
rc
.
Width
=
This
->
width
;
rc
.
Height
=
This
->
height
;
prcLock
=
&
rc
;
}
else
if
(
prcLock
->
X
>=
This
->
width
||
prcLock
->
Y
>=
This
->
height
||
prcLock
->
X
+
prcLock
->
Width
>
This
->
width
||
prcLock
->
Y
+
prcLock
->
Height
>
This
->
height
||
prcLock
->
Width
<=
0
||
prcLock
->
Height
<=
0
)
return
E_INVALIDARG
;
else
if
(((
prcLock
->
X
*
This
->
bpp
)
%
8
)
!=
0
)
{
FIXME
(
"Cannot lock at an X coordinate not at a full byte
\n
"
);
return
E_FAIL
;
}
result
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
BitmapLockImpl
));
if
(
!
result
)
return
E_OUTOFMEMORY
;
...
...
@@ -301,6 +348,10 @@ static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock,
result
->
IWICBitmapLock_iface
.
lpVtbl
=
&
BitmapLockImpl_Vtbl
;
result
->
ref
=
1
;
result
->
parent
=
This
;
result
->
width
=
prcLock
->
Width
;
result
->
height
=
prcLock
->
Height
;
result
->
data
=
This
->
data
+
This
->
stride
*
prcLock
->
Y
+
(
This
->
bpp
*
prcLock
->
X
)
/
8
;
IWICBitmap_AddRef
(
&
This
->
IWICBitmap_iface
);
*
ppILock
=
&
result
->
IWICBitmapLock_iface
;
...
...
@@ -363,16 +414,36 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
REFWICPixelFormatGUID
pixelFormat
,
WICBitmapCreateCacheOption
option
,
IWICBitmap
**
ppIBitmap
)
{
HRESULT
hr
;
BitmapImpl
*
This
;
UINT
bpp
,
stride
,
datasize
;
BYTE
*
data
;
hr
=
get_pixelformat_bpp
(
pixelFormat
,
&
bpp
);
if
(
FAILED
(
hr
))
return
hr
;
stride
=
(((
bpp
*
uiWidth
)
+
31
)
/
32
)
*
4
;
datasize
=
stride
*
uiHeight
;
This
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
BitmapImpl
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
datasize
);
if
(
!
This
||
!
data
)
{
HeapFree
(
GetProcessHeap
(),
0
,
This
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
return
E_OUTOFMEMORY
;
}
This
->
IWICBitmap_iface
.
lpVtbl
=
&
BitmapImpl_Vtbl
;
This
->
ref
=
1
;
This
->
palette
=
NULL
;
This
->
palette_set
=
0
;
This
->
lock
=
0
;
This
->
data
=
data
;
This
->
width
=
uiWidth
;
This
->
height
=
uiHeight
;
This
->
stride
=
stride
;
This
->
bpp
=
bpp
;
*
ppIBitmap
=
&
This
->
IWICBitmap_iface
;
...
...
dlls/windowscodecs/tests/bitmap.c
View file @
46bbbd27
...
...
@@ -95,25 +95,25 @@ static void test_createbitmap(void)
rc
.
Width
=
4
;
rc
.
Height
=
3
;
hr
=
IWICBitmap_Lock
(
bitmap
,
&
rc
,
WICBitmapLockRead
,
&
lock
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
IWICBitmapLock_Release
(
lock
);
rc
.
Width
=
3
;
rc
.
Height
=
4
;
hr
=
IWICBitmap_Lock
(
bitmap
,
&
rc
,
WICBitmapLockRead
,
&
lock
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
IWICBitmapLock_Release
(
lock
);
rc
.
Height
=
3
;
rc
.
X
=
4
;
hr
=
IWICBitmap_Lock
(
bitmap
,
&
rc
,
WICBitmapLockRead
,
&
lock
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
IWICBitmapLock_Release
(
lock
);
rc
.
X
=
0
;
rc
.
Y
=
4
;
hr
=
IWICBitmap_Lock
(
bitmap
,
&
rc
,
WICBitmapLockRead
,
&
lock
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
E_INVALIDARG
,
"IWICBitmap_Lock failed hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
IWICBitmapLock_Release
(
lock
);
/* NULL lock rect */
...
...
@@ -124,9 +124,9 @@ static void test_createbitmap(void)
{
/* entire bitmap is locked */
hr
=
IWICBitmapLock_GetSize
(
lock
,
&
width
,
&
height
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
width
==
3
,
"got %d, expected 3
\n
"
,
width
);
todo_wine
ok
(
height
==
3
,
"got %d, expected 3
\n
"
,
height
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
ok
(
width
==
3
,
"got %d, expected 3
\n
"
,
width
);
ok
(
height
==
3
,
"got %d, expected 3
\n
"
,
height
);
IWICBitmapLock_Release
(
lock
);
}
...
...
@@ -140,15 +140,15 @@ static void test_createbitmap(void)
if
(
SUCCEEDED
(
hr
))
{
hr
=
IWICBitmapLock_GetStride
(
lock
,
&
lock_buffer_stride
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetStride failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetStride failed hr=%x
\n
"
,
hr
);
/* stride is divisible by 4 */
todo_wine
ok
(
lock_buffer_stride
==
12
,
"got %i, expected 12
\n
"
,
lock_buffer_stride
);
ok
(
lock_buffer_stride
==
12
,
"got %i, expected 12
\n
"
,
lock_buffer_stride
);
hr
=
IWICBitmapLock_GetDataPointer
(
lock
,
&
lock_buffer_size
,
&
lock_buffer
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
/* buffer size does not include padding from the last row */
todo_wine
ok
(
lock_buffer_size
==
33
,
"got %i, expected 33
\n
"
,
lock_buffer_size
);
todo_wine
ok
(
lock_buffer
!=
NULL
,
"got NULL data pointer
\n
"
);
ok
(
lock_buffer_size
==
33
,
"got %i, expected 33
\n
"
,
lock_buffer_size
);
ok
(
lock_buffer
!=
NULL
,
"got NULL data pointer
\n
"
);
base_lock_buffer
=
lock_buffer
;
hr
=
IWICBitmapLock_GetPixelFormat
(
lock
,
&
pixelformat
);
...
...
@@ -156,9 +156,9 @@ static void test_createbitmap(void)
todo_wine
ok
(
IsEqualGUID
(
&
pixelformat
,
&
GUID_WICPixelFormat24bppBGR
),
"unexpected pixel format
\n
"
);
hr
=
IWICBitmapLock_GetSize
(
lock
,
&
width
,
&
height
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
width
==
3
,
"got %d, expected 3
\n
"
,
width
);
todo_wine
ok
(
height
==
3
,
"got %d, expected 3
\n
"
,
height
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
ok
(
width
==
3
,
"got %d, expected 3
\n
"
,
width
);
ok
(
height
==
3
,
"got %d, expected 3
\n
"
,
height
);
/* We can have multiple simultaneous read locks */
hr
=
IWICBitmap_Lock
(
bitmap
,
&
rc
,
WICBitmapLockRead
,
&
lock2
);
...
...
@@ -167,8 +167,8 @@ static void test_createbitmap(void)
if
(
SUCCEEDED
(
hr
))
{
hr
=
IWICBitmapLock_GetDataPointer
(
lock2
,
&
lock_buffer_size
,
&
lock_buffer
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
lock_buffer_size
==
33
,
"got %i, expected 33
\n
"
,
lock_buffer_size
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
ok
(
lock_buffer_size
==
33
,
"got %i, expected 33
\n
"
,
lock_buffer_size
);
ok
(
lock_buffer
==
base_lock_buffer
,
"got %p, expected %p
\n
"
,
lock_buffer
,
base_lock_buffer
);
IWICBitmapLock_Release
(
lock2
);
...
...
@@ -219,22 +219,22 @@ static void test_createbitmap(void)
}
hr
=
IWICBitmapLock_GetStride
(
lock
,
&
lock_buffer_stride
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetStride failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
lock_buffer_stride
==
12
,
"got %i, expected 12
\n
"
,
lock_buffer_stride
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetStride failed hr=%x
\n
"
,
hr
);
ok
(
lock_buffer_stride
==
12
,
"got %i, expected 12
\n
"
,
lock_buffer_stride
);
hr
=
IWICBitmapLock_GetDataPointer
(
lock
,
&
lock_buffer_size
,
&
lock_buffer
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
lock_buffer_size
==
15
,
"got %i, expected 15
\n
"
,
lock_buffer_size
);
todo_wine
ok
(
lock_buffer
==
base_lock_buffer
+
6
,
"got %p, expected %p+6
\n
"
,
lock_buffer
,
base_lock_buffer
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetDataPointer failed hr=%x
\n
"
,
hr
);
ok
(
lock_buffer_size
==
15
,
"got %i, expected 15
\n
"
,
lock_buffer_size
);
ok
(
lock_buffer
==
base_lock_buffer
+
6
,
"got %p, expected %p+6
\n
"
,
lock_buffer
,
base_lock_buffer
);
hr
=
IWICBitmapLock_GetPixelFormat
(
lock
,
&
pixelformat
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetPixelFormat failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
IsEqualGUID
(
&
pixelformat
,
&
GUID_WICPixelFormat24bppBGR
),
"unexpected pixel format
\n
"
);
hr
=
IWICBitmapLock_GetSize
(
lock
,
&
width
,
&
height
);
todo_wine
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
todo_wine
ok
(
width
==
1
,
"got %d, expected 1
\n
"
,
width
);
todo_wine
ok
(
height
==
2
,
"got %d, expected 2
\n
"
,
height
);
ok
(
hr
==
S_OK
,
"IWICBitmapLock_GetSize failed hr=%x
\n
"
,
hr
);
ok
(
width
==
1
,
"got %d, expected 1
\n
"
,
width
);
ok
(
height
==
2
,
"got %d, expected 2
\n
"
,
height
);
IWICBitmapLock_Release
(
lock
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment