comctl32: Only support an alpha channel for 32-bpp DIB-based imagelists.

This commit is contained in:
Alexandre Julliard 2010-06-02 12:21:41 +02:00
parent eb3c81fd69
commit 95c529dee6
2 changed files with 13 additions and 12 deletions

View File

@ -153,8 +153,9 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count,
if (!GetObjectW( hbmImage, sizeof(bm), &bm )) return FALSE;
/* if neither the imagelist nor the source bitmap can have an alpha channel, bail out now */
if (himl->uBitsPixel != 32 && bm.bmBitsPixel != 32) return FALSE;
/* if either the imagelist or the source bitmap don't have an alpha channel, bail out now */
if (!himl->has_alpha) return FALSE;
if (bm.bmBitsPixel != 32) return FALSE;
SelectObject( hdc, hbmImage );
mask_width = (bm.bmWidth + 31) / 32 * 4;
@ -208,7 +209,7 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count,
}
else
{
if (himl->has_alpha) himl->has_alpha[pos + n] = 1;
himl->has_alpha[pos + n] = 1;
if (mask_info && himl->hbmMask) /* generate the mask from the alpha channel */
{
@ -751,7 +752,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
else
himl->hbmMask = 0;
if (himl->uBitsPixel == 32)
if (ilc == ILC_COLOR32)
himl->has_alpha = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->cMaxImage );
else
himl->has_alpha = NULL;
@ -1204,7 +1205,7 @@ static BOOL alpha_blend_image( HIMAGELIST himl, HDC dest_dc, int dest_x, int des
}
}
if (himl->uBitsPixel == 32) /* we already have an alpha channel in this case */
if (himl->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++)
@ -2515,7 +2516,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon)
if (hdcImage == 0)
ERR("invalid hdcImage!\n");
if (himl->uBitsPixel == 32)
if (himl->has_alpha)
{
if (!ii.hbmColor)
{
@ -2525,13 +2526,13 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon)
SelectObject( hdcImage, color );
SelectObject( hdcMask, ii.hbmMask );
BitBlt( hdcImage, 0, 0, bmp.bmWidth, height, hdcMask, 0, height, SRCCOPY );
add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, height, color, ii.hbmMask );
ret = add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, height, color, ii.hbmMask );
DeleteDC( hdcMask );
DeleteObject( color );
if (ret) goto done;
}
else add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, bmp.bmHeight, ii.hbmColor, ii.hbmMask );
goto done;
else if (add_with_alpha( himl, hdcImage, nIndex, 1, bmp.bmWidth, bmp.bmHeight,
ii.hbmColor, ii.hbmMask )) goto done;
}
imagelist_point_from_index(himl, nIndex, &pt);

View File

@ -2757,7 +2757,7 @@ TOOLBAR_CheckImageListIconSize(TOOLBAR_INFO *infoPtr)
cx, cy, infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
himlNew = ImageList_Create(infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
ILC_COLORDDB|ILC_MASK, 8, 2);
ILC_COLOR32|ILC_MASK, 8, 2);
for (i = 0; i < infoPtr->nNumBitmapInfos; i++)
TOOLBAR_AddBitmapToImageList(infoPtr, himlNew, &infoPtr->bitmaps[i]);
TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlNew, 0);
@ -2854,7 +2854,7 @@ TOOLBAR_AddBitmap (TOOLBAR_INFO *infoPtr, INT count, const TBADDBITMAP *lpAddBmp
TRACE ("creating default image list!\n");
himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
ILC_COLORDDB | ILC_MASK, info.nButtons, 2);
ILC_COLOR32 | ILC_MASK, info.nButtons, 2);
TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
infoPtr->himlInt = himlDef;
}