Vincent Povirk : windowscodecs: Implement conversion from CMYK to RGB.

Alexandre Julliard julliard at winehq.org
Mon Sep 13 17:14:44 CDT 2010


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Sat Sep 11 16:03:12 2010 -0500

windowscodecs: Implement conversion from CMYK to RGB.

---

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

diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index b1c0952..86cdf55 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -52,6 +52,7 @@ enum pixelformat {
     format_32bppBGRA,
     format_48bppRGB,
     format_64bppRGBA,
+    format_32bppCMYK,
 };
 
 typedef HRESULT (*copyfunc)(struct FormatConverter *This, const WICRect *prc,
@@ -673,6 +674,27 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
             return res;
         }
         return S_OK;
+    case format_32bppCMYK:
+        if (prc)
+        {
+            HRESULT res;
+            UINT x, y;
+
+            res = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
+            if (FAILED(res)) return res;
+
+            for (y=0; y<prc->Height; y++)
+                for (x=0; x<prc->Width; x++)
+                {
+                    BYTE *pixel = pbBuffer+cbStride*y+4*x;
+                    BYTE c=pixel[0], m=pixel[1], y=pixel[2], k=pixel[3];
+                    pixel[0] = (255-y)*(255-k)/255; /* blue */
+                    pixel[1] = (255-m)*(255-k)/255; /* green */
+                    pixel[2] = (255-c)*(255-k)/255; /* red */
+                    pixel[3] = 255; /* alpha */
+                }
+        }
+        return S_OK;
     default:
         return WINCODEC_ERR_UNSUPPORTEDOPERATION;
     }
@@ -710,6 +732,7 @@ static const struct pixelformatinfo supported_formats[] = {
     {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
     {format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
     {format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL},
+    {format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL},
     {0}
 };
 
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 61ed96e..ac84368 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1231,6 +1231,7 @@ static GUID const * const converter_formats[] = {
     &GUID_WICPixelFormat32bppBGRA,
     &GUID_WICPixelFormat48bppRGB,
     &GUID_WICPixelFormat64bppRGBA,
+    &GUID_WICPixelFormat32bppCMYK,
     NULL
 };
 




More information about the wine-cvs mailing list