Module: wine Branch: master Commit: ca126c069fcbf388acac0326d18ea3fb6343bb12 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ca126c069fcbf388acac0326d1...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Thu Jul 12 16:09:26 2012 +0900
windowscodecs: Add support for generating WICBitmapPaletteTypeFixedGray256 palette.
---
dlls/windowscodecs/palette.c | 22 ++++++++++++++++++++++ dlls/windowscodecs/tests/palette.c | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/dlls/windowscodecs/palette.c b/dlls/windowscodecs/palette.c index 03f5774a..9d3b8ee 100644 --- a/dlls/windowscodecs/palette.c +++ b/dlls/windowscodecs/palette.c @@ -115,6 +115,23 @@ static WICColor *generate_gray16_palette(UINT *count) return entries; }
+static WICColor *generate_gray256_palette(UINT *count) +{ + WICColor *entries; + UINT i; + + *count = 256; + entries = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(WICColor)); + if (!entries) return NULL; + + for (i = 0; i < 256; i++) + { + entries[i] = 0xff000000; + entries[i] |= (i<<16) | (i<<8) | i; + } + return entries; +} + static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface, WICBitmapPaletteType type, BOOL add_transparent) { @@ -149,6 +166,11 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface, if (!colors) return E_OUTOFMEMORY; break;
+ case WICBitmapPaletteTypeFixedGray256: + colors = generate_gray256_palette(&count); + if (!colors) return E_OUTOFMEMORY; + break; + default: FIXME("(%p,%u,%d): stub\n", iface, type, add_transparent); return E_NOTIMPL; diff --git a/dlls/windowscodecs/tests/palette.c b/dlls/windowscodecs/tests/palette.c index aba8168..ef21307 100644 --- a/dlls/windowscodecs/tests/palette.c +++ b/dlls/windowscodecs/tests/palette.c @@ -162,6 +162,19 @@ static void generate_gray16_palette(DWORD *entries, UINT count) } }
+static void generate_gray256_palette(DWORD *entries, UINT count) +{ + UINT i; + + assert(count == 256); + + for (i = 0; i < 256; i++) + { + entries[i] = 0xff000000; + entries[i] |= (i << 16) | (i << 8) | i; + } +} + static void test_predefined_palette(void) { static struct test_data @@ -176,6 +189,7 @@ static void test_predefined_palette(void) { WICBitmapPaletteTypeFixedGray4, 0, 1, 4, { 0xff000000, 0xff555555, 0xffaaaaaa, 0xffffffff } }, { WICBitmapPaletteTypeFixedGray16, 0, 1, 16, { 0 } }, + { WICBitmapPaletteTypeFixedGray256, 0, 1, 256, { 0 } }, }; IWICImagingFactory *factory; IWICPalette *palette; @@ -228,6 +242,8 @@ static void test_predefined_palette(void)
if (td[i].type == WICBitmapPaletteTypeFixedGray16) generate_gray16_palette(td[i].color, td[i].count); + else if (td[i].type == WICBitmapPaletteTypeFixedGray256) + generate_gray256_palette(td[i].color, td[i].count);
for (j = 0; j < count; j++) {