Module: wine Branch: master Commit: 08c1e6cd96064a2025f62dbc046b888b63b73b62 URL: http://source.winehq.org/git/wine.git/?a=commit;h=08c1e6cd96064a2025f62dbc04...
Author: Vincent Povirk vincent@codeweavers.com Date: Tue Mar 17 16:09:56 2015 -0500
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..4ed25c9 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)