Dmitry Timoshkov : windowscodecs: Add support for generating WICBitmapPaletteTypeFixedGray16 palette.

Alexandre Julliard julliard at winehq.org
Thu Jul 12 18:00:33 CDT 2012


Module: wine
Branch: master
Commit: 179ed52bd39df7436688a8b7db9150e3b4d99ca6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=179ed52bd39df7436688a8b7db9150e3b4d99ca6

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Jul 12 16:55:53 2012 +0900

windowscodecs: Add support for generating WICBitmapPaletteTypeFixedGray16 palette.

---

 dlls/windowscodecs/palette.c       |   22 ++++++++++++++++++++++
 dlls/windowscodecs/tests/palette.c |   19 +++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dlls/windowscodecs/palette.c b/dlls/windowscodecs/palette.c
index ffd5877..03f5774a 100644
--- a/dlls/windowscodecs/palette.c
+++ b/dlls/windowscodecs/palette.c
@@ -98,6 +98,23 @@ static ULONG WINAPI PaletteImpl_Release(IWICPalette *iface)
     return ref;
 }
 
+static WICColor *generate_gray16_palette(UINT *count)
+{
+    WICColor *entries;
+    UINT i;
+
+    *count = 16;
+    entries = HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(WICColor));
+    if (!entries) return NULL;
+
+    for (i = 0; i < 16; i++)
+    {
+        entries[i] = 0xff000000;
+        entries[i] |= (i<<20) | (i<<16) | (i<<12) | (i<<8) | (i<<4) | i;
+    }
+    return entries;
+}
+
 static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
     WICBitmapPaletteType type, BOOL add_transparent)
 {
@@ -127,6 +144,11 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
         colors[3] = 0xffffffff;
         break;
 
+    case WICBitmapPaletteTypeFixedGray16:
+        colors = generate_gray16_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 1768e1a..aba8168 100644
--- a/dlls/windowscodecs/tests/palette.c
+++ b/dlls/windowscodecs/tests/palette.c
@@ -17,6 +17,7 @@
  */
 
 #include <stdarg.h>
+#include <assert.h>
 
 #define COBJMACROS
 
@@ -148,6 +149,19 @@ static void test_custom_palette(void)
     IWICImagingFactory_Release(factory);
 }
 
+static void generate_gray16_palette(DWORD *entries, UINT count)
+{
+    UINT i;
+
+    assert(count == 16);
+
+    for (i = 0; i < 16; i++)
+    {
+        entries[i] = 0xff000000;
+        entries[i] |= (i << 20) | (i << 16) | (i << 12) | (i << 8) | (i << 4) | i;
+    }
+}
+
 static void test_predefined_palette(void)
 {
     static struct test_data
@@ -161,6 +175,7 @@ static void test_predefined_palette(void)
         { WICBitmapPaletteTypeFixedBW, 1, 1, 2, { 0xff000000, 0xffffffff } },
         { WICBitmapPaletteTypeFixedGray4, 0, 1, 4,
           { 0xff000000, 0xff555555, 0xffaaaaaa, 0xffffffff } },
+        { WICBitmapPaletteTypeFixedGray16, 0, 1, 16, { 0 } },
     };
     IWICImagingFactory *factory;
     IWICPalette *palette;
@@ -210,6 +225,10 @@ static void test_predefined_palette(void)
         if (ret == td[i].count)
         {
             UINT j;
+
+            if (td[i].type == WICBitmapPaletteTypeFixedGray16)
+                generate_gray16_palette(td[i].color, td[i].count);
+
             for (j = 0; j < count; j++)
             {
                 ok(color[j] == td[i].color[j], "%u:[%u]: expected %#x, got %#x\n",




More information about the wine-cvs mailing list