From e9d9ef591b490a8b4eb173df34b10a6977f45b6d Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 18 Mar 2015 15:52:18 -0500 Subject: [PATCH] gdiplus: GdipGetDC doesn't set the alpha channel for a 32-bit dib. --- dlls/gdiplus/graphics.c | 2 +- dlls/gdiplus/tests/graphics.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 6d86e3a0d83..5284b99edaa 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5713,7 +5713,7 @@ GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc) { stat = METAFILE_GetDC((GpMetafile*)graphics->image, hdc); } - else if (!graphics->hdc || graphics->alpha_hdc || + else if (!graphics->hdc || (graphics->image && graphics->image->type == ImageTypeBitmap && ((GpBitmap*)graphics->image)->format & PixelFormatAlpha)) { /* Create a fake HDC and fill it with a constant color. */ diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index e0bd6152ea1..77de9e41df3 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -4445,12 +4445,13 @@ static void test_measured_extra_space(void) static void test_alpha_hdc(void) { GpStatus status; - HDC hdc; + HDC hdc, gp_hdc; HBITMAP hbm, old_hbm; GpGraphics *graphics; ULONG *bits; BITMAPINFO bmi; GpRectF bounds; + COLORREF colorref; hdc = CreateCompatibleDC(0); ok(hdc != NULL, "CreateCompatibleDC failed\n"); @@ -4484,6 +4485,21 @@ static void test_alpha_hdc(void) expect(0xffaaaaaa, bits[0]); + bits[0] = 0xdeadbeef; + + status = GdipGetDC(graphics, &gp_hdc); + expect(Ok, status); + + colorref = GetPixel(gp_hdc, 0, 4); + expect(0xefbead, colorref); + + SetPixel(gp_hdc, 0, 4, 0xffffff); + + expect(0xffffff, bits[0]); + + status = GdipReleaseDC(graphics, gp_hdc); + expect(Ok, status); + SelectObject(hdc, old_hbm); bits[0] = 0xdeadbeef; -- 2.11.4.GIT