mirror of
https://github.com/reactos/wine.git
synced 2025-01-22 11:54:47 +00:00
windowscodecs: Implement conversion from 8bppIndexed to 32bppBGRA.
This commit is contained in:
parent
9c1db8d828
commit
4d1e72d0b3
@ -38,6 +38,7 @@ struct FormatConverter;
|
||||
enum pixelformat {
|
||||
format_1bppIndexed,
|
||||
format_4bppIndexed,
|
||||
format_8bppIndexed,
|
||||
format_16bppBGR555,
|
||||
format_16bppBGR565,
|
||||
format_24bppBGR,
|
||||
@ -189,6 +190,59 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
|
||||
return res;
|
||||
}
|
||||
return S_OK;
|
||||
case format_8bppIndexed:
|
||||
if (prc)
|
||||
{
|
||||
HRESULT res;
|
||||
UINT x, y;
|
||||
BYTE *srcdata;
|
||||
UINT srcstride, srcdatasize;
|
||||
const BYTE *srcrow;
|
||||
const BYTE *srcbyte;
|
||||
BYTE *dstrow;
|
||||
DWORD *dstpixel;
|
||||
WICColor colors[256];
|
||||
IWICPalette *palette;
|
||||
UINT actualcolors;
|
||||
|
||||
res = PaletteImpl_Create(&palette);
|
||||
if (FAILED(res)) return res;
|
||||
|
||||
res = IWICBitmapSource_CopyPalette(This->source, palette);
|
||||
if (SUCCEEDED(res))
|
||||
res = IWICPalette_GetColors(palette, 256, colors, &actualcolors);
|
||||
|
||||
IWICPalette_Release(palette);
|
||||
|
||||
if (FAILED(res)) return res;
|
||||
|
||||
srcstride = prc->Width;
|
||||
srcdatasize = srcstride * prc->Height;
|
||||
|
||||
srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize);
|
||||
if (!srcdata) return E_OUTOFMEMORY;
|
||||
|
||||
res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
|
||||
|
||||
if (SUCCEEDED(res))
|
||||
{
|
||||
srcrow = srcdata;
|
||||
dstrow = pbBuffer;
|
||||
for (y=0; y<prc->Height; y++) {
|
||||
srcbyte=(const BYTE*)srcrow;
|
||||
dstpixel=(DWORD*)dstrow;
|
||||
for (x=0; x<prc->Width; x++)
|
||||
*dstpixel++ = colors[*srcbyte++];
|
||||
srcrow += srcstride;
|
||||
dstrow += cbStride;
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, srcdata);
|
||||
|
||||
return res;
|
||||
}
|
||||
return S_OK;
|
||||
case format_16bppBGR555:
|
||||
if (prc)
|
||||
{
|
||||
@ -370,6 +424,7 @@ static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRec
|
||||
static const struct pixelformatinfo supported_formats[] = {
|
||||
{format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
|
||||
{format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL},
|
||||
{format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, NULL},
|
||||
{format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL},
|
||||
{format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL},
|
||||
{format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL},
|
||||
|
@ -791,6 +791,7 @@ static struct regsvr_decoder const decoder_list[] = {
|
||||
static GUID const * const converter_formats[] = {
|
||||
&GUID_WICPixelFormat1bppIndexed,
|
||||
&GUID_WICPixelFormat4bppIndexed,
|
||||
&GUID_WICPixelFormat8bppIndexed,
|
||||
&GUID_WICPixelFormat16bppBGR555,
|
||||
&GUID_WICPixelFormat16bppBGR565,
|
||||
&GUID_WICPixelFormat24bppBGR,
|
||||
|
Loading…
x
Reference in New Issue
Block a user