comctl32/toolbar: Correctly draw disabled button which contains 32 bpp bitmap with alpha channel.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=24784
Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-03-31 17:45:42 +03:00 committed by Alexandre Julliard
parent bb3d06760a
commit 3192fb5396
3 changed files with 38 additions and 4 deletions

View File

@ -191,6 +191,7 @@ INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen) DECLSPEC_HIDDEN;
INT Str_GetPtrAtoW (LPCSTR lpSrc, LPWSTR lpDest, INT nMaxLen) DECLSPEC_HIDDEN; INT Str_GetPtrAtoW (LPCSTR lpSrc, LPWSTR lpDest, INT nMaxLen) DECLSPEC_HIDDEN;
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) DECLSPEC_HIDDEN; BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) DECLSPEC_HIDDEN;
BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc) DECLSPEC_HIDDEN; BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc) DECLSPEC_HIDDEN;
BOOL imagelist_has_alpha(HIMAGELIST, UINT) DECLSPEC_HIDDEN;
#define COMCTL32_VERSION_MINOR 81 #define COMCTL32_VERSION_MINOR 81

View File

@ -143,6 +143,11 @@ static BOOL is_valid(HIMAGELIST himl);
#define TILE_COUNT 4 #define TILE_COUNT 4
BOOL imagelist_has_alpha( HIMAGELIST himl, UINT index )
{
return himl->item_flags[index] & ILIF_ALPHA;
}
static inline UINT imagelist_height( UINT count ) static inline UINT imagelist_height( UINT count )
{ {
return ((count + TILE_COUNT - 1)/TILE_COUNT); return ((count + TILE_COUNT - 1)/TILE_COUNT);

View File

@ -675,18 +675,45 @@ TOOLBAR_DrawPattern (const RECT *lpRect, const NMTBCUSTOMDRAW *tbcd)
static void TOOLBAR_DrawMasked(HIMAGELIST himl, int index, HDC hdc, INT x, INT y, UINT draw_flags) static void TOOLBAR_DrawMasked(HIMAGELIST himl, int index, HDC hdc, INT x, INT y, UINT draw_flags)
{ {
IMAGELISTDRAWPARAMS draw_params = { 0 };
INT cx, cy; INT cx, cy;
HBITMAP hbmMask, hbmImage; HBITMAP hbmMask, hbmImage;
HDC hdcMask, hdcImage; HDC hdcMask, hdcImage;
ImageList_GetIconSize(himl, &cx, &cy); ImageList_GetIconSize(himl, &cx, &cy);
draw_params.cbSize = sizeof(draw_params);
draw_params.himl = himl;
draw_params.i = index;
draw_params.hdcDst = hdc;
draw_params.x = x;
draw_params.y = y;
draw_params.cx = cx;
draw_params.cy = cy;
draw_params.rgbBk = CLR_NONE;
draw_params.rgbFg = CLR_NONE;
draw_params.fStyle = draw_flags;
draw_params.fState = ILS_NORMAL;
/* 32bpp image with alpha channel is converted to grayscale */
if (imagelist_has_alpha(himl, index))
{
draw_params.fState = ILS_SATURATE;
ImageList_DrawIndirect(&draw_params);
return;
}
/* Create src image */ /* Create src image */
hdcImage = CreateCompatibleDC(hdc); hdcImage = CreateCompatibleDC(hdc);
hbmImage = CreateCompatibleBitmap(hdc, cx, cy); hbmImage = CreateCompatibleBitmap(hdc, cx, cy);
SelectObject(hdcImage, hbmImage); SelectObject(hdcImage, hbmImage);
ImageList_DrawEx(himl, index, hdcImage, 0, 0, cx, cy,
RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags); draw_params.x = 0;
draw_params.y = 0;
draw_params.rgbBk = RGB(0xff, 0xff, 0xff);
draw_params.rgbFg = RGB(0,0,0);
draw_params.hdcDst = hdcImage;
ImageList_DrawIndirect(&draw_params);
/* Create Mask */ /* Create Mask */
hdcMask = CreateCompatibleDC(0); hdcMask = CreateCompatibleDC(0);
@ -694,8 +721,9 @@ static void TOOLBAR_DrawMasked(HIMAGELIST himl, int index, HDC hdc, INT x, INT y
SelectObject(hdcMask, hbmMask); SelectObject(hdcMask, hbmMask);
/* Remove the background and all white pixels */ /* Remove the background and all white pixels */
ImageList_DrawEx(himl, index, hdcMask, 0, 0, cx, cy, draw_params.fStyle = ILD_MASK;
RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_MASK); draw_params.hdcDst = hdcMask;
ImageList_DrawIndirect(&draw_params);
SetBkColor(hdcImage, RGB(0xff, 0xff, 0xff)); SetBkColor(hdcImage, RGB(0xff, 0xff, 0xff));
BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, NOTSRCERASE); BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, NOTSRCERASE);