[1/2] gdiplus: Do not access Bitmap bits when drawing transparent pixels.
Vincent Povirk
madewokherd at gmail.com
Tue Mar 17 16:16:19 CDT 2015
For bug 37689.
-------------- next part --------------
From b25c8128916df65dba58acc838d8c3ed5087b4ac Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 17 Mar 2015 16:09:56 -0500
Subject: [PATCH 1/2] gdiplus: Do not access Bitmap bits when drawing
transparent pixels.
---
dlls/gdiplus/graphics.c | 6 +++++-
dlls/gdiplus/tests/graphics.c | 21 +++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 68a4ee5..01f5fa3 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -365,8 +365,12 @@ static GpStatus alpha_blend_bmp_pixels(GpGraphics *graphics, INT dst_x, INT dst_
for (y=0; y<src_height; y++)
{
ARGB dst_color, src_color;
- GdipBitmapGetPixel(dst_bitmap, x+dst_x, y+dst_y, &dst_color);
src_color = ((ARGB*)(src + src_stride * y))[x];
+
+ if (!(src_color & 0xff000000))
+ continue;
+
+ GdipBitmapGetPixel(dst_bitmap, x+dst_x, y+dst_y, &dst_color);
GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, color_over(dst_color, src_color));
}
}
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index fd4cf80..e0bd615 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -2417,6 +2417,27 @@ static void test_fromMemoryBitmap(void)
GdipDeleteGraphics(graphics);
GdipDisposeImage((GpImage*)bitmap);
+
+ /* If we don't draw to the HDC, the bits are never accessed */
+ status = GdipCreateBitmapFromScan0(4, 4, 12, PixelFormat24bppRGB, (BYTE*)1, &bitmap);
+ expect(Ok, status);
+
+ status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, status);
+
+ status = GdipGetDC(graphics, &hdc);
+ expect(Ok, status);
+ ok(hdc != NULL, "got NULL hdc\n");
+
+ color = GetPixel(hdc, 0, 0);
+ todo_wine expect(0x0c0b0d, color);
+
+ status = GdipReleaseDC(graphics, hdc);
+ expect(Ok, status);
+
+ GdipDeleteGraphics(graphics);
+
+ GdipDisposeImage((GpImage*)bitmap);
}
static void test_GdipIsVisiblePoint(void)
--
2.1.0
More information about the wine-patches
mailing list