From: yaoyongjie <yaoyongjie@uniontech.com> Add conversion from PixelFormat32bppCMYK to PixelFormat32bppARGB in convert_pixels(), using the standard subtractive color model formula where RGB = (255 - CMY) * (255 - K) / 255. Signed-off-by: yaoyongjie <yaoyongjie@uniontech.com> Change-Id: I4b0991ccd50b648a5bafc6feca723755ca691301 --- dlls/gdiplus/image.c | 33 +++++++++++++++++++++++++++++++++ dlls/gdiplus/tests/image.c | 14 +++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 17e1437eb5f..b1a3c4a7bd8 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -312,6 +312,15 @@ static inline void getpixel_64bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, } } +static inline void getpixel_32bppCMYK(BYTE *c, BYTE *m, BYTE *y, BYTE *k, + const BYTE *row, UINT x) +{ + *c = row[x*4]; + *m = row[x*4+1]; + *y = row[x*4+2]; + *k = row[x*4+3]; +} + GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, ARGB *color) { @@ -654,6 +663,21 @@ GpStatus convert_pixels(INT width, INT height, return Ok; \ } while (0); +#define convert_cmyk_to_rgb(getpixel_function, setpixel_function) do { \ + for (y=0; y<height; y++) \ + for (x=0; x<width; x++) { \ + BYTE r, g, b, a; \ + BYTE cc, cm, cy, ck; \ + getpixel_function(&cc, &cm, &cy, &ck, src_bits+src_stride*y, x); \ + r = (255-cc) * (255-ck)/255; \ + g = (255-cm) * (255-ck)/255; \ + b = (255-cy) * (255-ck)/255; \ + a = 255; \ + setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x); \ + } \ + return Ok; \ +} while (0); + switch (src_format) { case PixelFormat1bppIndexed: @@ -1091,6 +1115,15 @@ GpStatus convert_pixels(INT width, INT height, break; } break; + case PixelFormat32bppCMYK: + switch (dst_format) + { + case PixelFormat32bppARGB: + convert_cmyk_to_rgb(getpixel_32bppCMYK, setpixel_32bppARGB); + default: + break; + } + break; default: break; } diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 510bf0f5c63..1febd509c3d 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -5521,19 +5521,19 @@ static void test_CMYK_conversion(void) memset(&data, 0, sizeof(data)); status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat32bppARGB, &data); - todo_wine ok(status == Ok, "LockBits CMYK->ARGB failed, status=%d\n", status); - todo_wine_if (status == Ok) + ok(status == Ok, "LockBits CMYK->ARGB failed, status=%d\n", status); + if (status == Ok) { - todo_wine ok(data.Width == 4, "expected width 4, got %d\n", data.Width); - todo_wine ok(data.Height == 1, "expected height 1, got %d\n", data.Height); - todo_wine ok(data.PixelFormat == PixelFormat32bppARGB, + ok(data.Width == 4, "expected width 4, got %d\n", data.Width); + ok(data.Height == 1, "expected height 1, got %d\n", data.Height); + ok(data.PixelFormat == PixelFormat32bppARGB, "expected PixelFormat32bppARGB, got %#x\n", data.PixelFormat); bits = data.Scan0; if (bits) { match = !memcmp(bits, expected_argb, sizeof(expected_argb)); - todo_wine ok(match, "CMYK to ARGB conversion mismatch\n"); + ok(match, "CMYK to ARGB conversion mismatch\n"); } if (!match && bits) { @@ -5550,7 +5550,7 @@ static void test_CMYK_conversion(void) } status = GdipBitmapUnlockBits(bitmap, &data); - todo_wine expect(Ok, status); + expect(Ok, status); GdipDisposeImage((GpImage *)bitmap); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10835