Dmitry Timoshkov : windowscodecs: Use predefined WICBitmapPaletteTypeFixedGray16 palette instead of a handmade one .

Alexandre Julliard julliard at winehq.org
Fri Jul 13 14:11:18 CDT 2012


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Jul 13 10:08:58 2012 +0900

windowscodecs: Use predefined WICBitmapPaletteTypeFixedGray16 palette instead of a handmade one.

---

 dlls/windowscodecs/converter.c |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index bd83be3..98e727e 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -82,16 +82,6 @@ static inline FormatConverter *impl_from_IWICFormatConverter(IWICFormatConverter
     return CONTAINING_RECORD(iface, FormatConverter, IWICFormatConverter_iface);
 }
 
-static void make_grayscale_palette(WICColor *colors, UINT num_colors)
-{
-    int i, v;
-    for (i=0; i<num_colors; i++)
-    {
-        v = i * 255 / (num_colors-1);
-        colors[i] = 0xff000000 | v<<16 | v<<8 | v;
-    }
-}
-
 static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRect *prc,
     UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
 {
@@ -248,21 +238,19 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
             IWICPalette *palette;
             UINT actualcolors;
 
-            if (source_format == format_4bppIndexed)
-            {
-                res = PaletteImpl_Create(&palette);
-                if (FAILED(res)) return res;
+            res = PaletteImpl_Create(&palette);
+            if (FAILED(res)) return res;
 
+            if (source_format == format_4bppIndexed)
                 res = IWICBitmapSource_CopyPalette(This->source, palette);
-                if (SUCCEEDED(res))
-                    res = IWICPalette_GetColors(palette, 16, colors, &actualcolors);
+            else
+                res = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedGray16, FALSE);
 
-                IWICPalette_Release(palette);
+            if (SUCCEEDED(res))
+                res = IWICPalette_GetColors(palette, 16, colors, &actualcolors);
 
-                if (FAILED(res)) return res;
-            }
-            else
-                make_grayscale_palette(colors, 16);
+            IWICPalette_Release(palette);
+            if (FAILED(res)) return res;
 
             srcstride = (prc->Width+1)/2;
             srcdatasize = srcstride * prc->Height;




More information about the wine-cvs mailing list