comctl32: Fix a regression in ImageList_AddMasked().
This commit is contained in:
parent
501e2dcc99
commit
7486f47b19
|
@ -331,7 +331,7 @@ INT WINAPI
|
||||||
ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
||||||
{
|
{
|
||||||
HDC hdcMask, hdcBitmap;
|
HDC hdcMask, hdcBitmap;
|
||||||
INT nIndex, nImageCount;
|
INT i, nIndex, nImageCount;
|
||||||
BITMAP bmp;
|
BITMAP bmp;
|
||||||
HBITMAP hOldBitmap;
|
HBITMAP hOldBitmap;
|
||||||
HBITMAP hMaskBitmap=0;
|
HBITMAP hMaskBitmap=0;
|
||||||
|
@ -356,68 +356,50 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
||||||
himl->cCurImage += nImageCount;
|
himl->cCurImage += nImageCount;
|
||||||
|
|
||||||
hdcBitmap = CreateCompatibleDC(0);
|
hdcBitmap = CreateCompatibleDC(0);
|
||||||
|
|
||||||
|
|
||||||
hOldBitmap = SelectObject(hdcBitmap, hBitmap);
|
hOldBitmap = SelectObject(hdcBitmap, hBitmap);
|
||||||
if(himl->hbmMask)
|
|
||||||
{
|
/* Create a temp Mask so we can remove the background of the Image */
|
||||||
hdcMask = himl->hdcMask;
|
hdcMask = CreateCompatibleDC(0);
|
||||||
imagelist_point_from_index( himl, nIndex, &pt );
|
hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL);
|
||||||
}
|
SelectObject(hdcMask, hMaskBitmap);
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Create a temp Mask so we can remove the background of
|
|
||||||
the Image (Windows does this even if there is no mask)
|
|
||||||
*/
|
|
||||||
hdcMask = CreateCompatibleDC(0);
|
|
||||||
hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL);
|
|
||||||
SelectObject(hdcMask, hMaskBitmap);
|
|
||||||
imagelist_point_from_index( himl, 0, &pt );
|
|
||||||
}
|
|
||||||
/* create monochrome image to the mask bitmap */
|
/* create monochrome image to the mask bitmap */
|
||||||
bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
|
bkColor = (clrMask != CLR_DEFAULT) ? clrMask : GetPixel (hdcBitmap, 0, 0);
|
||||||
GetPixel (hdcBitmap, 0, 0);
|
|
||||||
SetBkColor (hdcBitmap, bkColor);
|
SetBkColor (hdcBitmap, bkColor);
|
||||||
BitBlt (hdcMask,
|
BitBlt (hdcMask, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcBitmap, 0, 0, SRCCOPY);
|
||||||
pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
|
|
||||||
hdcBitmap, 0, 0,
|
|
||||||
SRCCOPY);
|
|
||||||
|
|
||||||
SetBkColor(hdcBitmap, RGB(255,255,255));
|
SetBkColor(hdcBitmap, RGB(255,255,255));
|
||||||
/*Remove the background from the image
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
WINDOWS BUG ALERT!!!!!!
|
* Remove the background from the image
|
||||||
The statement below should not be done in common practice
|
*
|
||||||
but this is how ImageList_AddMasked works in Windows.
|
* WINDOWS BUG ALERT!!!!!!
|
||||||
It overwrites the original bitmap passed, this was discovered
|
* The statement below should not be done in common practice
|
||||||
by using the same bitmap to iterate the different styles
|
* but this is how ImageList_AddMasked works in Windows.
|
||||||
on windows where it failed (BUT ImageList_Add is OK)
|
* It overwrites the original bitmap passed, this was discovered
|
||||||
This is here in case some apps rely on this bug
|
* by using the same bitmap to iterate the different styles
|
||||||
*/
|
* on windows where it failed (BUT ImageList_Add is OK)
|
||||||
BitBlt(hdcBitmap,
|
* This is here in case some apps rely on this bug
|
||||||
0, 0, bmp.bmWidth, bmp.bmHeight,
|
*
|
||||||
hdcMask,
|
* Blt mode 0x220326 is NOTSRCAND
|
||||||
pt.x, pt.y,
|
*/
|
||||||
0x220326); /* NOTSRCAND */
|
BitBlt(hdcBitmap, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcMask, 0, 0, 0x220326);
|
||||||
/* Copy result to the imagelist
|
|
||||||
*/
|
/* Copy result to the imagelist */
|
||||||
imagelist_point_from_index( himl, nIndex, &pt );
|
for (i=0; i<nImageCount; i++)
|
||||||
BitBlt (himl->hdcImage,
|
{
|
||||||
pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
|
imagelist_point_from_index( himl, nIndex + i, &pt );
|
||||||
hdcBitmap,
|
BitBlt(himl->hdcImage, pt.x, pt.y, himl->cx, bmp.bmHeight,
|
||||||
0, 0,
|
hdcBitmap, i*himl->cx, 0, SRCCOPY);
|
||||||
SRCCOPY);
|
BitBlt(himl->hdcMask, pt.x, pt.y, himl->cx, bmp.bmHeight,
|
||||||
/* Clean up
|
hdcMask, i*himl->cx, 0, SRCCOPY);
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
/* Clean up */
|
||||||
SelectObject(hdcBitmap, hOldBitmap);
|
SelectObject(hdcBitmap, hOldBitmap);
|
||||||
DeleteDC(hdcBitmap);
|
DeleteDC(hdcBitmap);
|
||||||
if(!himl->hbmMask)
|
DeleteObject(hMaskBitmap);
|
||||||
{
|
DeleteDC(hdcMask);
|
||||||
DeleteObject(hMaskBitmap);
|
|
||||||
DeleteDC(hdcMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nIndex;
|
return nIndex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue