From 56e077897f2c8d6821724de4b846b69f7f052747 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 9 Dec 2016 12:52:36 +0800
Subject: [PATCH] windowscodecs: Add support for 32bppCMYK and 64bppCMYK
 formats to TIFF decoder.

---
 dlls/windowscodecs/regsvr.c     | 13 +++++++++++++
 dlls/windowscodecs/tiffformat.c | 25 ++++++++++++++++++++++++-
 include/wincodec.idl            |  1 +
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index cfb3e26..4ea51f6 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1224,6 +1224,8 @@ static GUID const * const tiff_decode_formats[] = {
     &GUID_WICPixelFormat48bppRGB,
     &GUID_WICPixelFormat64bppRGBA,
     &GUID_WICPixelFormat64bppPRGBA,
+    &GUID_WICPixelFormat32bppCMYK,
+    &GUID_WICPixelFormat64bppCMYK,
     &GUID_WICPixelFormat128bppRGBAFloat,
     NULL
 };
@@ -2024,6 +2026,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
         WICPixelFormatNumericRepresentationUnsignedInteger,
         0
     },
+    {   &GUID_WICPixelFormat64bppCMYK,
+        "The Wine Project",
+        "64bpp CMYK",
+        NULL, /* no version */
+        &GUID_VendorMicrosoft,
+        64, /* bitsperpixel */
+        4, /* channel count */
+        channel_masks_16bit,
+        WICPixelFormatNumericRepresentationUnsignedInteger,
+        0
+    },
     {   &GUID_WICPixelFormat128bppRGBAFloat,
         "The Wine Project",
         "128bpp RGBAFloat",
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 7d7c620..090db31 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -507,8 +507,31 @@ static HRESULT tiff_get_decode_info(TIFF *tiff, tiff_decode_info *decode_info)
             return E_NOTIMPL;
         }
         break;
+
+    case 5: /* Separated */
+        if (samples != 4)
+        {
+            FIXME("unhandled Separated sample count %u\n", samples);
+            return E_FAIL;
+        }
+
+        decode_info->bpp = bps * samples;
+        switch(bps)
+        {
+        case 8:
+            decode_info->format = &GUID_WICPixelFormat32bppCMYK;
+            break;
+        case 16:
+            decode_info->format = &GUID_WICPixelFormat64bppCMYK;
+            break;
+
+        default:
+            WARN("unhandled Separated bit count %u\n", bps);
+            return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT;
+        }
+        break;
+
     case 4: /* Transparency mask */
-    case 5: /* CMYK */
     case 6: /* YCbCr */
     case 8: /* CIELab */
     default:
diff --git a/include/wincodec.idl b/include/wincodec.idl
index c283301..29e0968 100644
--- a/include/wincodec.idl
+++ b/include/wincodec.idl
@@ -232,6 +232,7 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppPRGBA, 0x6fddc324,0x4e03,0x4bfe,0
 cpp_quote("DEFINE_GUID(GUID_WICPixelFormat128bppRGBAFloat, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x19);")
 
 cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppCMYK, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x1c);")
+cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppCMYK, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x1f);")
 
 cpp_quote("#if 0")
 typedef DWORD *D2D1_PIXEL_FORMAT;
-- 
1.9.1

