Vincent Povirk : windowscodecs: Implement conversion from BlackWhite to 32bppBGRA.

Alexandre Julliard julliard at winehq.org
Fri Aug 28 10:18:11 CDT 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu Aug 27 12:46:13 2009 -0500

windowscodecs: Implement conversion from BlackWhite to 32bppBGRA.

---

 dlls/windowscodecs/converter.c |   25 ++++++++++++++++++-------
 dlls/windowscodecs/regsvr.c    |    1 +
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index f8efd45..af6827c 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -39,6 +39,7 @@ enum pixelformat {
     format_1bppIndexed,
     format_4bppIndexed,
     format_8bppIndexed,
+    format_BlackWhite,
     format_8bppGray,
     format_16bppBGR555,
     format_16bppBGR565,
@@ -72,6 +73,7 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
     switch (source_format)
     {
     case format_1bppIndexed:
+    case format_BlackWhite:
         if (prc)
         {
             HRESULT res;
@@ -86,16 +88,24 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
             IWICPalette *palette;
             UINT actualcolors;
 
-            res = PaletteImpl_Create(&palette);
-            if (FAILED(res)) return res;
+            if (source_format == format_1bppIndexed)
+            {
+                res = PaletteImpl_Create(&palette);
+                if (FAILED(res)) return res;
 
-            res = IWICBitmapSource_CopyPalette(This->source, palette);
-            if (SUCCEEDED(res))
-                res = IWICPalette_GetColors(palette, 2, colors, &actualcolors);
+                res = IWICBitmapSource_CopyPalette(This->source, palette);
+                if (SUCCEEDED(res))
+                    res = IWICPalette_GetColors(palette, 2, colors, &actualcolors);
 
-            IWICPalette_Release(palette);
+                IWICPalette_Release(palette);
 
-            if (FAILED(res)) return res;
+                if (FAILED(res)) return res;
+            }
+            else
+            {
+                colors[0] = 0xff000000;
+                colors[1] = 0xffffffff;
+            }
 
             srcstride = (prc->Width+7)/8;
             srcdatasize = srcstride * prc->Height;
@@ -468,6 +478,7 @@ static const struct pixelformatinfo supported_formats[] = {
     {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
     {format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL},
     {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, NULL},
+    {format_BlackWhite, &GUID_WICPixelFormatBlackWhite, NULL},
     {format_8bppGray, &GUID_WICPixelFormat8bppGray, NULL},
     {format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL},
     {format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL},
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 81218b9..7218c07 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -920,6 +920,7 @@ static GUID const * const converter_formats[] = {
     &GUID_WICPixelFormat1bppIndexed,
     &GUID_WICPixelFormat4bppIndexed,
     &GUID_WICPixelFormat8bppIndexed,
+    &GUID_WICPixelFormatBlackWhite,
     &GUID_WICPixelFormat8bppGray,
     &GUID_WICPixelFormat16bppBGR555,
     &GUID_WICPixelFormat16bppBGR565,




More information about the wine-cvs mailing list