comctl32/imagelist: Don't pre-multiply the stored image, do it only at blending time.
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index c1ea00a..27d95f5 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -212,20 +212,6 @@
{
if (himl->has_alpha) himl->has_alpha[pos + n] = 1;
- /* pre-multiply by the alpha channel */
- for (i = 0; i < height; i++)
- {
- for (j = n * width; j < (n + 1) * width; j++)
- {
- DWORD argb = bits[i * bm.bmWidth + j];
- DWORD alpha = argb >> 24;
- bits[i * bm.bmWidth + j] = ((argb & 0xff000000) |
- (((argb & 0x00ff0000) * alpha / 255) & 0x00ff0000) |
- (((argb & 0x0000ff00) * alpha / 255) & 0x0000ff00) |
- (((argb & 0x000000ff) * alpha / 255)));
- }
- }
-
if (mask_info && himl->hbmMask) /* generate the mask from the alpha channel */
{
for (i = 0; i < height; i++)
@@ -247,6 +233,7 @@
done:
if (hdcMask) DeleteDC( hdcMask );
HeapFree( GetProcessHeap(), 0, info );
+ HeapFree( GetProcessHeap(), 0, mask_info );
HeapFree( GetProcessHeap(), 0, bits );
HeapFree( GetProcessHeap(), 0, mask_bits );
return ret;
@@ -1195,7 +1182,19 @@
SelectObject( hdc, bmp );
BitBlt( hdc, 0, 0, cx, cy, himl->hdcImage, src_x, src_y, SRCCOPY );
- if (himl->hbmMask)
+ if (himl->uBitsPixel == 32) /* 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++)
+ {
+ DWORD alpha = *ptr >> 24;
+ *ptr = ((*ptr & 0xff000000) |
+ (((*ptr & 0x00ff0000) * alpha / 255) & 0x00ff0000) |
+ (((*ptr & 0x0000ff00) * alpha / 255) & 0x0000ff00) |
+ (((*ptr & 0x000000ff) * alpha / 255)));
+ }
+ }
+ else if (himl->hbmMask)
{
unsigned int width_bytes = (cx + 31) / 32 * 4;
/* generate alpha channel from the mask */
@@ -1311,12 +1310,8 @@
if (bIsTransparent)
{
- if (himl->uBitsPixel == 32) /* we already have an alpha channel in this case */
- bResult = GdiAlphaBlend( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
- himl->hdcImage, pt.x, pt.y, cx, cy, func );
- else
- bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
- pt.x, pt.y, cx, cy, func );
+ bResult = alpha_blend_image( himl, pimldp->hdcDst, pimldp->x, pimldp->y,
+ pt.x, pt.y, cx, cy, func );
goto end;
}
colour = pimldp->rgbBk;
@@ -1325,10 +1320,7 @@
hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour));
PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
- if (himl->uBitsPixel == 32)
- GdiAlphaBlend( hImageDC, 0, 0, cx, cy, himl->hdcImage, pt.x, pt.y, cx, cy, func );
- else
- alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func );
+ alpha_blend_image( himl, hImageDC, 0, 0, pt.x, pt.y, cx, cy, func );
DeleteObject (SelectObject (hImageDC, hOldBrush));
bResult = BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, SRCCOPY );
goto end;