[PATCH 0/1] MR10835: gdiplus: Add support for CMYK to ARGB pixel format conversion.
Add conversion from PixelFormat32bppCMYK to PixelFormat32bppARGB in convert_pixels(), using the standard subtractive color model formula where RGB = (255 - CMY) * (255 - K) / 255. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10835
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 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10835
participants (2)
-
yaoyongjie -
Yongjie Yao (@yaoyongjie)