From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/gdiplus/graphics.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 700914e6f6e..2a053a80408 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -550,6 +550,27 @@ static GpStatus alpha_blend_bmp_pixels(GpGraphics *graphics, INT dst_x, INT dst_ return Ok; }
+static void blend_32bppARGB(UINT width, UINT height, BYTE *dst_bits, + INT dst_stride, const BYTE *src_bits, INT src_stride) +{ + INT x, y; + for (y = 0; y < height; y++) + { + const BYTE *src = src_bits + y * src_stride; + BYTE *dst = dst_bits + y * dst_stride; + for (x = 0; x < width; x++) + { + BYTE alpha = src[3]; + /* blend to white background */ + *dst++ = (*src++ * alpha + 127) / 255 + (255 - alpha); + *dst++ = (*src++ * alpha + 127) / 255 + (255 - alpha); + *dst++ = (*src++ * alpha + 127) / 255 + (255 - alpha); + *dst++ = 255; + src++; + } + } +} + static GpStatus alpha_blend_hdc_pixels(GpGraphics *graphics, INT dst_x, INT dst_y, const BYTE *src, INT src_width, INT src_height, INT src_stride, PixelFormat fmt) { @@ -582,7 +603,8 @@ static GpStatus alpha_blend_hdc_pixels(GpGraphics *graphics, INT dst_x, INT dst_ GetDeviceCaps(graphics->hdc, TECHNOLOGY) == DT_RASPRINTER && GetDeviceCaps(graphics->hdc, SHADEBLENDCAPS) == SB_NONE) || fmt & PixelFormatPAlpha) - memcpy(temp_bits, src, src_width * src_height * 4); + blend_32bppARGB(src_width, src_height, temp_bits, + 4 * src_width, src, src_stride); else convert_32bppARGB_to_32bppPARGB(src_width, src_height, temp_bits, 4 * src_width, src, src_stride);
[gdip_print.tar.bz2](/uploads/f1b7ace82f2dcec9407610a5108a0e0b/gdip_print.tar.bz2) is a sample application that could be used for testing.
{width=6 height=6} is an actual image that is being printed. It's a 32bpp ARGB PNG that contains only an alpha channel (a mask), and it's currently printed as a black square because alpha is completely ignored for a printer device.
This merge request was approved by Esme Povirk.