[PATCH v3] comctl32: Pre-multiply static control bitmap image by alpha for GdiAlphaBlend.
Jinoh Kang
jinoh.kang.kr at gmail.com
Mon Mar 14 13:35:12 CDT 2022
Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---
Notes:
v1 -> v2: fix commit message
v2 -> v3: remove fixed todo_wine
dlls/comctl32/static.c | 11 +++++++++++
dlls/comctl32/tests/static.c | 2 --
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/static.c b/dlls/comctl32/static.c
index 7a3ac958111..9b20e6a8b66 100644
--- a/dlls/comctl32/static.c
+++ b/dlls/comctl32/static.c
@@ -203,6 +203,17 @@ static HBITMAP create_alpha_bitmap( HBITMAP hbitmap )
DeleteObject( alpha );
alpha = 0;
}
+ else
+ {
+ /* pre-multiply by alpha */
+ for (i = 0, ptr = bits; i < bm.bmWidth * bm.bmHeight; i++, ptr += 4)
+ {
+ unsigned int alpha = ptr[3];
+ ptr[0] = (ptr[0] * alpha + 127) / 255;
+ ptr[1] = (ptr[1] * alpha + 127) / 255;
+ ptr[2] = (ptr[2] * alpha + 127) / 255;
+ }
+ }
}
DeleteDC( hdc );
diff --git a/dlls/comctl32/tests/static.c b/dlls/comctl32/tests/static.c
index b8f43142d6b..7b6ac679c92 100644
--- a/dlls/comctl32/tests/static.c
+++ b/dlls/comctl32/tests/static.c
@@ -165,7 +165,6 @@ static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult, BOOL is_alph
ok(bm.bmBits != NULL, "bmBits is NULL\n");
memcpy(bits, bm.bmBits, 4);
if (is_premult)
- todo_wine
ok(bits[0] == 0x05 && bits[1] == 0x09 && bits[2] == 0x0e && bits[3] == 0x44,
"bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]);
else if (is_alpha)
@@ -195,7 +194,6 @@ static void test_image(HBITMAP image, BOOL is_dib, BOOL is_premult, BOOL is_alph
DeleteDC(hdc);
if (is_premult)
- todo_wine
ok(bits[0] == 0x05 && bits[1] == 0x09 && bits[2] == 0x0e && bits[3] == 0x44,
"bits: %02x %02x %02x %02x\n", bits[0], bits[1], bits[2], bits[3]);
else if (is_alpha)
--
2.34.1
More information about the wine-devel
mailing list