windowscodecs: Add support for CMYK to BGR conversion.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
048474b15e
commit
812d03129d
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "wincodecs_private.h"
|
||||
|
||||
#include "wine/heap.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
||||
|
@ -1121,6 +1122,48 @@ static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRec
|
|||
}
|
||||
return S_OK;
|
||||
|
||||
case format_32bppCMYK:
|
||||
if (prc)
|
||||
{
|
||||
BYTE *srcdata;
|
||||
UINT srcstride, srcdatasize;
|
||||
|
||||
srcstride = 4 * prc->Width;
|
||||
srcdatasize = srcstride * prc->Height;
|
||||
|
||||
srcdata = heap_alloc(srcdatasize);
|
||||
if (!srcdata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
INT x, y;
|
||||
BYTE *src = srcdata, *dst = pbBuffer;
|
||||
|
||||
for (y = 0; y < prc->Height; y++)
|
||||
{
|
||||
BYTE *cmyk = src;
|
||||
BYTE *bgr = dst;
|
||||
|
||||
for (x = 0; x < prc->Width; x++)
|
||||
{
|
||||
BYTE c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
|
||||
bgr[0] = (255 - y) * (255 - k) / 255; /* B */
|
||||
bgr[1] = (255 - m) * (255 - k) / 255; /* G */
|
||||
bgr[2] = (255 - c) * (255 - k) / 255; /* R */
|
||||
cmyk += 4;
|
||||
bgr += 3;
|
||||
}
|
||||
src += srcstride;
|
||||
dst += cbStride;
|
||||
}
|
||||
}
|
||||
|
||||
heap_free(srcdata);
|
||||
return hr;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
default:
|
||||
FIXME("Unimplemented conversion path!\n");
|
||||
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
||||
|
|
Loading…
Reference in New Issue