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

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


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

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

windowscodecs: Add support for generating WICBitmapPaletteTypeFixedHalftone64 palette.

---

 dlls/windowscodecs/palette.c       |   33 +++++++++++++++++++++++++++++++++
 dlls/windowscodecs/tests/palette.c |   27 +++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/dlls/windowscodecs/palette.c b/dlls/windowscodecs/palette.c
index 9280aa1..a024cd1 100644
--- a/dlls/windowscodecs/palette.c
+++ b/dlls/windowscodecs/palette.c
@@ -160,6 +160,34 @@ static WICColor *generate_halftone8_palette(UINT *count)
     return entries;
 }
 
+static WICColor *generate_halftone64_palette(UINT *count)
+{
+    WICColor *entries;
+    UINT i;
+
+    *count = 72;
+    entries = HeapAlloc(GetProcessHeap(), 0, 72 * sizeof(WICColor));
+    if (!entries) return NULL;
+
+    for (i = 0; i < 64; i++)
+    {
+        static const BYTE halftone_values[4] = { 0x00,0x55,0xaa,0xff };
+        entries[i] = 0xff000000;
+        entries[i] |= halftone_values[i%4];
+        entries[i] |= halftone_values[(i/4)%4] << 8;
+        entries[i] |= halftone_values[(i/16)%4] << 16;
+    }
+
+    for (i = 64; i < 72; i++)
+    {
+        static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
+                                           0x000080, 0x808000, 0x800080, 0x008080 };
+        entries[i] = 0xff000000;
+        entries[i] |= halftone[i-64];
+    }
+    return entries;
+}
+
 static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
     WICBitmapPaletteType type, BOOL add_transparent)
 {
@@ -204,6 +232,11 @@ static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface,
         if (!colors) return E_OUTOFMEMORY;
         break;
 
+    case WICBitmapPaletteTypeFixedHalftone64:
+        colors = generate_halftone64_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 e92c871..e97ffc6 100644
--- a/dlls/windowscodecs/tests/palette.c
+++ b/dlls/windowscodecs/tests/palette.c
@@ -199,6 +199,30 @@ static void generate_halftone8_palette(DWORD *entries, UINT count)
     }
 }
 
+static void generate_halftone64_palette(DWORD *entries, UINT count)
+{
+    static const BYTE halftone_values[4] = { 0x00,0x55,0xaa,0xff };
+    UINT i;
+
+    assert(count == 72);
+
+    for (i = 0; i < 64; i++)
+    {
+        entries[i] = 0xff000000;
+        entries[i] |= halftone_values[i%4];
+        entries[i] |= halftone_values[(i/4)%4] << 8;
+        entries[i] |= halftone_values[(i/16)%4] << 16;
+    }
+
+    for (i = 64; i < 72; i++)
+    {
+        static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
+                                           0x000080, 0x808000, 0x800080, 0x008080 };
+        entries[i] = 0xff000000;
+        entries[i] |= halftone[i-64];
+    }
+}
+
 static void test_predefined_palette(void)
 {
     static struct test_data
@@ -215,6 +239,7 @@ static void test_predefined_palette(void)
         { WICBitmapPaletteTypeFixedGray16, 0, 1, 16, { 0 } },
         { WICBitmapPaletteTypeFixedGray256, 0, 1, 256, { 0 } },
         { WICBitmapPaletteTypeFixedHalftone8, 0, 0, 16, { 0 } },
+        { WICBitmapPaletteTypeFixedHalftone64, 0, 0, 72, { 0 } },
     };
     IWICImagingFactory *factory;
     IWICPalette *palette;
@@ -271,6 +296,8 @@ static void test_predefined_palette(void)
                 generate_gray256_palette(td[i].color, td[i].count);
             else if (td[i].type == WICBitmapPaletteTypeFixedHalftone8)
                 generate_halftone8_palette(td[i].color, td[i].count);
+            else if (td[i].type == WICBitmapPaletteTypeFixedHalftone64)
+                generate_halftone64_palette(td[i].color, td[i].count);
 
             for (j = 0; j < count; j++)
             {




More information about the wine-cvs mailing list