Ziqing Hui : comctl32/imagelist: Correctly handle alpha channel of 32bpp image.
Alexandre Julliard
julliard at winehq.org
Tue Mar 3 16:24:51 CST 2020
Module: wine
Branch: master
Commit: 61b9209221d28d5d02379791ac1316c1fc2ca3b7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=61b9209221d28d5d02379791ac1316c1fc2ca3b7
Author: Ziqing Hui <zhui at codeweavers.com>
Date: Mon Mar 2 10:31:05 2020 +0800
comctl32/imagelist: Correctly handle alpha channel of 32bpp image.
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/imagelist.c | 24 ++++++++++--------------
dlls/comctl32/tests/imagelist.c | 2 --
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 9a6ea3bbff..3cf7cc8c7f 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -215,16 +215,7 @@ static void add_dib_bits( HIMAGELIST himl, int pos, int count, int width, int he
for (j = n * width; j < (n + 1) * width; j++)
if ((has_alpha = ((bits[i * stride + j] & 0xff000000) != 0))) break;
- if (!has_alpha) /* generate alpha channel from the mask */
- {
- for (i = 0; i < height; i++)
- for (j = n * width; j < (n + 1) * width; j++)
- if (!mask_info || !((mask_bits[i * mask_stride + j / 8] << (j % 8)) & 0x80))
- bits[i * stride + j] |= 0xff000000;
- else
- bits[i * stride + j] = 0;
- }
- else
+ if (has_alpha)
{
himl->has_alpha[pos + n] = 1;
@@ -1251,7 +1242,7 @@ ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int dest_y,
int src_x, int src_y, int cx, int cy, BLENDFUNCTION func,
- UINT style, COLORREF blend_col )
+ UINT style, COLORREF blend_col, BOOL has_alpha )
{
BOOL ret = FALSE;
HDC hdc;
@@ -1302,7 +1293,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
}
}
- if (himl->has_alpha) /* we already have an alpha channel in this case */
+ if (has_alpha) /* we already have an alpha channel in this case */
{
/* pre-multiply by the alpha channel */
for (i = 0, ptr = bits; i < cx * cy; i++, ptr++)
@@ -1338,6 +1329,11 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
if ((((BYTE *)mask_bits)[i * width_bytes + j / 8] << (j % 8)) & 0x80) *ptr = 0;
else *ptr |= 0xff000000;
}
+ else
+ {
+ for (i = 0, ptr = bits; i < cx * cy; i++, ptr++)
+ *ptr |= 0xff000000;
+ }
ret = GdiAlphaBlend( dest_dc, dest_x, dest_y, cx, cy, hdc, 0, 0, cx, cy, func );
@@ -1446,7 +1442,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
if (bIsTransparent)
{
bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
- pt.x, pt.y, cx, cy, func, fStyle, blend_col );
+ pt.x, pt.y, cx, cy, func, fStyle, blend_col, has_alpha );
goto end;
}
colour = pimldp->rgbBk;
@@ -1455,7 +1451,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
- alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col );
+ alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func, fStyle, blend_col, has_alpha );
DeleteObject (SelectObject (hImageDC, hOldBrush));
bResult = BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, SRCCOPY );
goto end;
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 9271354edb..aa563574ed 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -2316,8 +2316,6 @@ static void test_alpha(void)
DeleteObject(hbm_test);
get_image_alpha(himl, i / 2, 2, 1, alpha);
-
- todo_wine_if(i == 0)
ok(alpha[0] == GetAValue(test_bitmaps[i]) && alpha[1] == GetAValue(test_bitmaps[i + 1]),
"Bitmap [%08X, %08X] returned alpha value [%02X, %02X], expected [%02X, %02X]\n",
test_bitmaps[i], test_bitmaps[i + 1], alpha[0], alpha[1],
More information about the wine-cvs
mailing list