Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
3899c3e2
Commit
3899c3e2
authored
Jul 06, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Jul 07, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowscodecs: Implement CopyPalette for BMP decoder.
parent
9d9c505a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
4 deletions
+123
-4
bmpdecode.c
dlls/windowscodecs/bmpdecode.c
+98
-4
bmpformat.c
dlls/windowscodecs/tests/bmpformat.c
+24
-0
wincodec.idl
include/wincodec.idl
+1
-0
No files found.
dlls/windowscodecs/bmpdecode.c
View file @
3899c3e2
...
...
@@ -189,8 +189,101 @@ static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
static
HRESULT
WINAPI
BmpFrameDecode_CopyPalette
(
IWICBitmapFrameDecode
*
iface
,
IWICPalette
*
pIPalette
)
{
FIXME
(
"(%p,%p): stub
\n
"
,
iface
,
pIPalette
);
return
E_NOTIMPL
;
HRESULT
hr
;
BmpFrameDecode
*
This
=
(
BmpFrameDecode
*
)
iface
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
pIPalette
);
if
(
This
->
bih
.
bV5Size
==
sizeof
(
BITMAPCOREHEADER
))
{
BITMAPCOREHEADER
*
bch
=
(
BITMAPCOREHEADER
*
)
&
This
->
bih
;
if
(
bch
->
bcBitCount
<=
8
)
{
/* 2**n colors in BGR format after the header */
int
count
=
1
<<
bch
->
bcBitCount
;
WICColor
*
wiccolors
;
ULONG
tablesize
,
bytesread
;
RGBTRIPLE
*
bgrcolors
;
LARGE_INTEGER
offset
;
int
i
;
wiccolors
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WICColor
)
*
count
);
tablesize
=
sizeof
(
RGBTRIPLE
)
*
count
;
bgrcolors
=
HeapAlloc
(
GetProcessHeap
(),
0
,
tablesize
);
if
(
!
wiccolors
||
!
bgrcolors
)
{
HeapFree
(
GetProcessHeap
(),
0
,
wiccolors
);
HeapFree
(
GetProcessHeap
(),
0
,
bgrcolors
);
return
E_OUTOFMEMORY
;
}
offset
.
QuadPart
=
sizeof
(
BITMAPFILEHEADER
)
+
sizeof
(
BITMAPCOREHEADER
);
hr
=
IStream_Seek
(
This
->
stream
,
offset
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hr
))
return
hr
;
hr
=
IStream_Read
(
This
->
stream
,
bgrcolors
,
tablesize
,
&
bytesread
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
bytesread
!=
tablesize
)
return
E_FAIL
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
wiccolors
[
i
]
=
0xff000000
|
(
bgrcolors
[
i
].
rgbtRed
<<
16
)
|
(
bgrcolors
[
i
].
rgbtGreen
<<
8
)
|
bgrcolors
[
i
].
rgbtBlue
;
}
hr
=
IWICPalette_InitializeCustom
(
pIPalette
,
wiccolors
,
count
);
HeapFree
(
GetProcessHeap
(),
0
,
wiccolors
);
HeapFree
(
GetProcessHeap
(),
0
,
bgrcolors
);
return
hr
;
}
else
{
return
WINCODEC_ERR_PALETTEUNAVAILABLE
;
}
}
else
{
if
(
This
->
bih
.
bV5BitCount
<=
8
)
{
int
count
;
WICColor
*
wiccolors
;
ULONG
tablesize
,
bytesread
;
LARGE_INTEGER
offset
;
int
i
;
if
(
This
->
bih
.
bV5ClrUsed
==
0
)
count
=
1
<<
This
->
bih
.
bV5BitCount
;
else
count
=
This
->
bih
.
bV5ClrUsed
;
tablesize
=
sizeof
(
WICColor
)
*
count
;
wiccolors
=
HeapAlloc
(
GetProcessHeap
(),
0
,
tablesize
);
if
(
!
wiccolors
)
return
E_OUTOFMEMORY
;
offset
.
QuadPart
=
sizeof
(
BITMAPFILEHEADER
)
+
This
->
bih
.
bV5Size
;
hr
=
IStream_Seek
(
This
->
stream
,
offset
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hr
))
return
hr
;
hr
=
IStream_Read
(
This
->
stream
,
wiccolors
,
tablesize
,
&
bytesread
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
bytesread
!=
tablesize
)
return
E_FAIL
;
/* convert from BGR to BGRA by setting alpha to 100% */
for
(
i
=
0
;
i
<
count
;
i
++
)
wiccolors
[
i
]
|=
0xff000000
;
hr
=
IWICPalette_InitializeCustom
(
pIPalette
,
wiccolors
,
count
);
HeapFree
(
GetProcessHeap
(),
0
,
wiccolors
);
return
hr
;
}
else
{
return
WINCODEC_ERR_PALETTEUNAVAILABLE
;
}
}
}
static
HRESULT
WINAPI
BmpFrameDecode_CopyPixels
(
IWICBitmapFrameDecode
*
iface
,
...
...
@@ -536,8 +629,9 @@ static HRESULT WINAPI BmpDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
static
HRESULT
WINAPI
BmpDecoder_CopyPalette
(
IWICBitmapDecoder
*
iface
,
IWICPalette
*
pIPalette
)
{
FIXME
(
"(%p,%p): stub
\n
"
,
iface
,
pIPalette
);
return
E_NOTIMPL
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
pIPalette
);
return
WINCODEC_ERR_PALETTEUNAVAILABLE
;
}
static
HRESULT
WINAPI
BmpDecoder_GetMetadataQueryReader
(
IWICBitmapDecoder
*
iface
,
...
...
dlls/windowscodecs/tests/bmpformat.c
View file @
3899c3e2
...
...
@@ -98,6 +98,9 @@ static void test_decode_24bpp(void)
ok
(
SUCCEEDED
(
hr
),
"GetFrame failed, hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
IWICImagingFactory
*
factory
;
IWICPalette
*
palette
;
hr
=
IWICBitmapFrameDecode_GetSize
(
framedecode
,
&
width
,
&
height
);
ok
(
SUCCEEDED
(
hr
),
"GetSize failed, hr=%x
\n
"
,
hr
);
ok
(
width
==
2
,
"expected width=2, got %u
\n
"
,
width
);
...
...
@@ -112,6 +115,27 @@ static void test_decode_24bpp(void)
ok
(
SUCCEEDED
(
hr
),
"GetPixelFormat failed, hr=%x
\n
"
,
hr
);
ok
(
IsEqualGUID
(
&
guidresult
,
&
GUID_WICPixelFormat24bppBGR
),
"unexpected pixel format
\n
"
);
hr
=
CoCreateInstance
(
&
CLSID_WICImagingFactory
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IWICImagingFactory
,
(
void
**
)
&
factory
);
ok
(
SUCCEEDED
(
hr
),
"CoCreateInstance failed, hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
IWICImagingFactory_CreatePalette
(
factory
,
&
palette
);
ok
(
SUCCEEDED
(
hr
),
"CreatePalette failed, hr=%x
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
{
hr
=
IWICBitmapDecoder_CopyPalette
(
decoder
,
palette
);
ok
(
hr
==
WINCODEC_ERR_PALETTEUNAVAILABLE
,
"expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x
\n
"
,
hr
);
hr
=
IWICBitmapFrameDecode_CopyPalette
(
framedecode
,
palette
);
ok
(
hr
==
WINCODEC_ERR_PALETTEUNAVAILABLE
,
"expected WINCODEC_ERR_PALETTEUNAVAILABLE, got %x
\n
"
,
hr
);
IWICPalette_Release
(
palette
);
}
IWICImagingFactory_Release
(
factory
);
}
rc
.
X
=
0
;
rc
.
Y
=
0
;
rc
.
Width
=
3
;
...
...
include/wincodec.idl
View file @
3899c3e2
...
...
@@ -95,6 +95,7 @@ typedef UINT32 WICColor;
cpp_quote
(
"#define WINCODEC_ERR_WRONGSTATE 0x88982f04"
)
cpp_quote
(
"#define WINCODEC_ERR_CODECNOTHUMBNAIL 0x88982f44"
)
cpp_quote
(
"#define WINCODEC_ERR_PALETTEUNAVAILABLE 0x88982f45"
)
interface
IWICBitmap
;
interface
IWICComponentInfo
;
...
...
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