Commit 496d6347 authored by Oleg Krylov's avatar Oleg Krylov Committed by Alexandre Julliard

comctl32: Fix ImageList_Replace function to correctly apply image mask.

parent 5ffb0174
......@@ -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;
StretchBlt (himl->hdcMask, i * himl->cx, 0, himl->cx, himl->cy,
hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
hdcTemp = CreateCompatibleDC(0);
hOldBitmapTemp = SelectObject(hdcTemp, hbmMask);
StretchBlt (himl->hdcMask, i * himl->cx, 0, himl->cx, himl->cy,
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment