comctl32: Fix ImageList_Replace function to correctly apply image mask.

This commit is contained in:
Oleg Krylov 2006-08-17 16:08:22 +03:00 committed by Alexandre Julliard
parent 5ffb0174b0
commit 496d634735
1 changed files with 15 additions and 9 deletions

View File

@ -2158,6 +2158,7 @@ ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage,
{
HDC hdcImage;
BITMAP bmp;
HBITMAP hOldBitmap;
TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask);
@ -2175,29 +2176,34 @@ ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage,
GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp);
/* Replace Image */
SelectObject (hdcImage, hbmImage);
hOldBitmap = SelectObject (hdcImage, hbmImage);
StretchBlt (himl->hdcImage, i * himl->cx, 0, himl->cx, himl->cy,
hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
if (himl->hbmMask)
{
/* Replace Mask */
SelectObject (hdcImage, hbmMask);
HDC hdcTemp;
HBITMAP hOldBitmapTemp;
hdcTemp = CreateCompatibleDC(0);
hOldBitmapTemp = SelectObject(hdcTemp, hbmMask);
StretchBlt (himl->hdcMask, i * himl->cx, 0, himl->cx, himl->cy,
hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
hdcTemp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
SelectObject(hdcTemp, hOldBitmapTemp);
DeleteDC(hdcTemp);
/* Remove the background from the image
*/
StretchBlt (himl->hdcImage,
i*himl->cx, 0, himl->cx, himl->cy,
hdcImage,
0, 0, bmp.bmWidth, bmp.bmHeight,
BitBlt (himl->hdcImage,
i*himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
himl->hdcMask,
i*himl->cx, 0,
0x220326); /* NOTSRCAND */
}
SelectObject (hdcImage, hOldBitmap);
DeleteDC (hdcImage);
return TRUE;