comctl32/imagelist: Correctly handle alpha channel of 32bpp image.

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Ziqing Hui 2020-03-02 10:31:05 +08:00 committed by Alexandre Julliard
parent 5784343db8
commit 61b9209221
2 changed files with 10 additions and 16 deletions

View File

@ -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;

View File

@ -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],