[3/3] gdiplus: Bitmaps created from a 32-bit dib should be PARGB.
Vincent Povirk
madewokherd at gmail.com
Mon Dec 3 17:14:08 CST 2012
-------------- next part --------------
From 143d174b608650d995198c84d69562c9cce0397c Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Mon, 3 Dec 2012 16:10:32 -0600
Subject: [PATCH 3/3] gdiplus: Bitmaps created from a 32-bit dib should be
PARGB.
---
dlls/gdiplus/image.c | 5 ++++-
dlls/gdiplus/tests/image.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 73f08b9..8310a9f 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -4675,7 +4675,10 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
format = PixelFormat24bppRGB;
break;
case 32:
- format = PixelFormat32bppRGB;
+ if (bm.bmBits)
+ format = PixelFormat32bppPARGB;
+ else
+ format = PixelFormat32bppRGB;
break;
case 48:
format = PixelFormat48bppRGB;
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 46e250d..27144ae 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -942,6 +942,30 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
DeleteObject(hpal);
DeleteObject(hbm);
+ /* 32-bit dib, rgb */
+ bmi.bi.bmiHeader.biBitCount = 32;
+
+ hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
+ ok(hbm != NULL, "CreateDIBSection failed\n");
+
+ bits[0] = 0;
+
+ stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
+ expect(Ok, stat);
+ expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
+ expectf(WIDTH1, width);
+ expectf(HEIGHT1, height);
+ if (stat == Ok)
+ {
+ stat = GdipGetImagePixelFormat((GpImage*)gpbm, &format);
+ expect(Ok, stat);
+ expect(PixelFormat32bppPARGB, format);
+
+ GdipDisposeImage((GpImage*)gpbm);
+ }
+
+ DeleteObject(hbm);
+
/* 16-bit 555 dib, rgb */
bmi.bi.bmiHeader.biBitCount = 16;
bmi.bi.bmiHeader.biCompression = BI_RGB;
@@ -1027,6 +1051,34 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
}
DeleteObject(hbm);
+ /* 32-bit dib, bitfields */
+ bmi.bi.bmiHeader.biSize = sizeof(bmi);
+ bmi.bi.bmiHeader.biBitCount = 32;
+ bmi.bf.masks[0] = 0xff0000;
+ bmi.bf.masks[1] = 0xff00;
+ bmi.bf.masks[2] = 0xff;
+
+ hbm = CreateDIBSection(hdc, &bmi.bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
+ ok(hbm != NULL, "CreateDIBSection failed\n");
+
+ bits[0] = 0;
+
+ stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
+ expect(Ok, stat);
+ expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
+ expectf(WIDTH1, width);
+ expectf(HEIGHT1, height);
+ if (stat == Ok)
+ {
+ stat = GdipGetImagePixelFormat((GpImage*)gpbm, &format);
+ expect(Ok, stat);
+ expect(PixelFormat32bppPARGB, format);
+
+ GdipDisposeImage((GpImage*)gpbm);
+ }
+
+ DeleteObject(hbm);
+
DeleteDC(hdc);
}
--
1.7.10.4
More information about the wine-patches
mailing list