comctl32:imagelist: ImageList_Replace mask fixes
Oleg Krylov
oleg.krylov at gmail.com
Thu Jul 27 08:09:42 CDT 2006
comctl32:imagelist: ImageList_Replace mask fixes
changelog: 27.07.2006. by Oleg Krylov <oleg.krylov at gmail.com>
Fix ImageList_Replace function if mask is supplied.
Code mostly copied from ImageList_Add function.
Changes include: create addidional temporary DC for mask and apply mask
with BitBlt, not with StretchBlt.
Fixes second part of a Bug#: 4947:
"several toolbar buttons do not show the button
icon but are instead completely black"
===============
diff -urN wine/dlls/comctl32/imagelist.c wineNew/dlls/comctl32/imagelist.c
--- wine/dlls/comctl32/imagelist.c 2006-05-23 15:47:37.000000000 +0300
+++ wineNew/dlls/comctl32/imagelist.c 2006-07-27 13:54:30.000000000 +0300
@@ -2158,6 +2158,7 @@
{
HDC hdcImage;
BITMAP bmp;
+ HBITMAP hOldBitmap;
TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask);
@@ -2175,29 +2176,34 @@
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);
-
- StretchBlt (himl->hdcMask, i * himl->cx, 0, himl->cx, himl->cy,
- hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
-
-
- /* Remove the background from the image
- */
- StretchBlt (himl->hdcImage,
- i*himl->cx, 0, himl->cx, himl->cy,
- hdcImage,
- 0, 0, bmp.bmWidth, bmp.bmHeight,
- 0x220326); /* NOTSRCAND */
+ HDC hdcTemp;
+ HBITMAP hOldBitmapTemp;
+
+ 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
+ */
+ 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;
More information about the wine-patches
mailing list