Vincent Povirk : windowscodecs: Support conversion of 8bppGray to 32bppBGRA .

Alexandre Julliard julliard at winehq.org
Tue Aug 25 08:44:16 CDT 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Aug 24 13:22:23 2009 -0500

windowscodecs: Support conversion of 8bppGray to 32bppBGRA.

---

 dlls/windowscodecs/converter.c |   44 ++++++++++++++++++++++++++++++++++++++++
 dlls/windowscodecs/regsvr.c    |    1 +
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index 7db56ea..f8efd45 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -39,6 +39,7 @@ enum pixelformat {
     format_1bppIndexed,
     format_4bppIndexed,
     format_8bppIndexed,
+    format_8bppGray,
     format_16bppBGR555,
     format_16bppBGR565,
     format_24bppBGR,
@@ -190,6 +191,48 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
             return res;
         }
         return S_OK;
+    case format_8bppGray:
+        if (prc)
+        {
+            HRESULT res;
+            UINT x, y;
+            BYTE *srcdata;
+            UINT srcstride, srcdatasize;
+            const BYTE *srcrow;
+            const BYTE *srcbyte;
+            BYTE *dstrow;
+            DWORD *dstpixel;
+
+            srcstride = prc->Width;
+            srcdatasize = srcstride * prc->Height;
+
+            srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize);
+            if (!srcdata) return E_OUTOFMEMORY;
+
+            res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
+
+            if (SUCCEEDED(res))
+            {
+                srcrow = srcdata;
+                dstrow = pbBuffer;
+                for (y=0; y<prc->Height; y++) {
+                    srcbyte=(const BYTE*)srcrow;
+                    dstpixel=(DWORD*)dstrow;
+                    for (x=0; x<prc->Width; x++)
+                    {
+                        *dstpixel++ = 0xff000000|(*srcbyte<<16)|(*srcbyte<<8)|*srcbyte;
+                        srcbyte++;
+                    }
+                    srcrow += srcstride;
+                    dstrow += cbStride;
+                }
+            }
+
+            HeapFree(GetProcessHeap(), 0, srcdata);
+
+            return res;
+        }
+        return S_OK;
     case format_8bppIndexed:
         if (prc)
         {
@@ -425,6 +468,7 @@ static const struct pixelformatinfo supported_formats[] = {
     {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL},
     {format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL},
     {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, NULL},
+    {format_8bppGray, &GUID_WICPixelFormat8bppGray, NULL},
     {format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL},
     {format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL},
     {format_24bppBGR, &GUID_WICPixelFormat24bppBGR, NULL},
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index fe6fc1c..2ee1a89 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -880,6 +880,7 @@ static GUID const * const converter_formats[] = {
     &GUID_WICPixelFormat1bppIndexed,
     &GUID_WICPixelFormat4bppIndexed,
     &GUID_WICPixelFormat8bppIndexed,
+    &GUID_WICPixelFormat8bppGray,
     &GUID_WICPixelFormat16bppBGR555,
     &GUID_WICPixelFormat16bppBGR565,
     &GUID_WICPixelFormat24bppBGR,




More information about the wine-cvs mailing list