This patch fixes applications that draws 32 bpp icons manually.
v3: create 8-bit intermediate mask from alpha instead of 32-bit.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/user32/cursoricon.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 0adb73bf56..5d63a42373 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1296,6 +1296,41 @@ static HICON create_icon_from_bmi( const BITMAPINFO *bmi, DWORD maxsize, HMODULE 0, 0, bmi_width, bmi_height, mask_bits, bmi_copy, DIB_RGB_COLORS, SRCCOPY ); } + else + { + if (bmi_has_alpha( bmi, color_bits )) + { + DWORD alpha_mask_bits_size = bmi_width * bmi_height; + unsigned char *alpha_mask_bits = HeapAlloc( GetProcessHeap(), 0, alpha_mask_bits_size ); + + if (alpha_mask_bits) + { + const unsigned char *src = color_bits; + unsigned char *dst = alpha_mask_bits; + + while (alpha_mask_bits_size--) + { + *dst++ = src[3] == 0xff ? 0 : 1; + src += 4; + } + + /* DIB palette and color count are already initialized correctly + * for the monochrome case, so just correct the bit depth. + */ + if (bmi_copy->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) + bmi_copy->bmiHeader.biBitCount = 8; + else + ((BITMAPCOREINFO *)bmi_copy)->bmciHeader.bcBitCount = 8; + + SelectObject( hdc, mask ); + StretchDIBits( hdc, 0, 0, width, height, + 0, 0, bmi_width, bmi_height, + alpha_mask_bits, bmi_copy, DIB_RGB_COLORS, SRCCOPY ); + + HeapFree( GetProcessHeap(), 0, alpha_mask_bits ); + } + } + } ret = TRUE;
done: