Module: wine
Branch: master
Commit: 7486f47b1971a40d5ef4fe56f099143053e4d96f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7486f47b1971a40d5ef4fe56f…
Author: Mike McCormack <mike(a)codeweavers.com>
Date: Wed Nov 8 18:27:56 2006 +0900
comctl32: Fix a regression in ImageList_AddMasked().
---
dlls/comctl32/imagelist.c | 90 ++++++++++++++++++---------------------------
1 files changed, 36 insertions(+), 54 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 1cc886e..36fe384 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -331,7 +331,7 @@ INT WINAPI
ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
{
HDC hdcMask, hdcBitmap;
- INT nIndex, nImageCount;
+ INT i, nIndex, nImageCount;
BITMAP bmp;
HBITMAP hOldBitmap;
HBITMAP hMaskBitmap=0;
@@ -356,69 +356,51 @@ ImageList_AddMasked (HIMAGELIST himl, HB
himl->cCurImage += nImageCount;
hdcBitmap = CreateCompatibleDC(0);
+ hOldBitmap = SelectObject(hdcBitmap, hBitmap);
+ /* Create a temp Mask so we can remove the background of the Image */
+ hdcMask = CreateCompatibleDC(0);
+ hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL);
+ SelectObject(hdcMask, hMaskBitmap);
- hOldBitmap = SelectObject(hdcBitmap, hBitmap);
- if(himl->hbmMask)
- {
- hdcMask = himl->hdcMask;
- imagelist_point_from_index( himl, nIndex, &pt );
- }
- 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 */
- bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
- GetPixel (hdcBitmap, 0, 0);
+ bkColor = (clrMask != CLR_DEFAULT) ? clrMask : GetPixel (hdcBitmap, 0, 0);
SetBkColor (hdcBitmap, bkColor);
- BitBlt (hdcMask,
- pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
- hdcBitmap, 0, 0,
- SRCCOPY);
+ BitBlt (hdcMask, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcBitmap, 0, 0, SRCCOPY);
SetBkColor(hdcBitmap, RGB(255,255,255));
- /*Remove the background from the image
- */
+
/*
- WINDOWS BUG ALERT!!!!!!
- The statement below should not be done in common practice
- but this is how ImageList_AddMasked works in Windows.
- It overwrites the original bitmap passed, this was discovered
- by using the same bitmap to iterate the different styles
- on windows where it failed (BUT ImageList_Add is OK)
- This is here in case some apps rely on this bug
- */
- BitBlt(hdcBitmap,
- 0, 0, bmp.bmWidth, bmp.bmHeight,
- hdcMask,
- pt.x, pt.y,
- 0x220326); /* NOTSRCAND */
- /* Copy result to the imagelist
- */
- imagelist_point_from_index( himl, nIndex, &pt );
- BitBlt (himl->hdcImage,
- pt.x, pt.y, bmp.bmWidth, bmp.bmHeight,
- hdcBitmap,
- 0, 0,
- SRCCOPY);
- /* Clean up
- */
- SelectObject(hdcBitmap, hOldBitmap);
- DeleteDC(hdcBitmap);
- if(!himl->hbmMask)
+ * Remove the background from the image
+ *
+ * WINDOWS BUG ALERT!!!!!!
+ * The statement below should not be done in common practice
+ * but this is how ImageList_AddMasked works in Windows.
+ * It overwrites the original bitmap passed, this was discovered
+ * by using the same bitmap to iterate the different styles
+ * on windows where it failed (BUT ImageList_Add is OK)
+ * This is here in case some apps rely on this bug
+ *
+ * Blt mode 0x220326 is NOTSRCAND
+ */
+ BitBlt(hdcBitmap, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcMask, 0, 0, 0x220326);
+
+ /* Copy result to the imagelist */
+ for (i=0; i<nImageCount; i++)
{
- DeleteObject(hMaskBitmap);
- DeleteDC(hdcMask);
+ imagelist_point_from_index( himl, nIndex + i, &pt );
+ BitBlt(himl->hdcImage, pt.x, pt.y, himl->cx, bmp.bmHeight,
+ hdcBitmap, i*himl->cx, 0, SRCCOPY);
+ BitBlt(himl->hdcMask, pt.x, pt.y, himl->cx, bmp.bmHeight,
+ hdcMask, i*himl->cx, 0, SRCCOPY);
}
+ /* Clean up */
+ SelectObject(hdcBitmap, hOldBitmap);
+ DeleteDC(hdcBitmap);
+ DeleteObject(hMaskBitmap);
+ DeleteDC(hdcMask);
+
return nIndex;
}