Commit 61b92092 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

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

parent 5784343d
...@@ -215,16 +215,7 @@ static void add_dib_bits( HIMAGELIST himl, int pos, int count, int width, int he ...@@ -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++) for (j = n * width; j < (n + 1) * width; j++)
if ((has_alpha = ((bits[i * stride + j] & 0xff000000) != 0))) break; if ((has_alpha = ((bits[i * stride + j] & 0xff000000) != 0))) break;
if (!has_alpha) /* generate alpha channel from the mask */ if (has_alpha)
{
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
{ {
himl->has_alpha[pos + n] = 1; himl->has_alpha[pos + n] = 1;
...@@ -1251,7 +1242,7 @@ ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, ...@@ -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, 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, 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; BOOL ret = FALSE;
HDC hdc; HDC hdc;
...@@ -1302,7 +1293,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des ...@@ -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 */ /* pre-multiply by the alpha channel */
for (i = 0, ptr = bits; i < cx * cy; i++, ptr++) 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 ...@@ -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; if ((((BYTE *)mask_bits)[i * width_bytes + j / 8] << (j % 8)) & 0x80) *ptr = 0;
else *ptr |= 0xff000000; 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 ); ret = GdiAlphaBlend( dest_dc, dest_x, dest_y, cx, cy, hdc, 0, 0, cx, cy, func );
...@@ -1446,7 +1442,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) ...@@ -1446,7 +1442,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
if (bIsTransparent) if (bIsTransparent)
{ {
bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y, 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; goto end;
} }
colour = pimldp->rgbBk; colour = pimldp->rgbBk;
...@@ -1455,7 +1451,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) ...@@ -1455,7 +1451,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour)); hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY ); 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)); DeleteObject (SelectObject (hImageDC, hOldBrush));
bResult = BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, SRCCOPY ); bResult = BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, SRCCOPY );
goto end; goto end;
......
...@@ -2316,8 +2316,6 @@ static void test_alpha(void) ...@@ -2316,8 +2316,6 @@ static void test_alpha(void)
DeleteObject(hbm_test); DeleteObject(hbm_test);
get_image_alpha(himl, i / 2, 2, 1, alpha); 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]), 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", "Bitmap [%08X, %08X] returned alpha value [%02X, %02X], expected [%02X, %02X]\n",
test_bitmaps[i], test_bitmaps[i + 1], alpha[0], alpha[1], test_bitmaps[i], test_bitmaps[i + 1], alpha[0], alpha[1],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment