comctl32: Save and restore colours when adding masked images

Peter Urbanec winehq.org at urbanec.net
Wed Feb 4 07:26:29 CST 2009


This patch will save and restore the colours when adding a masked image
to ImageList.

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index c2f4f7b..7292e17 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -335,7 +335,7 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP
hBitmap, COLORREF clrMask)
     BITMAP bmp;
     HBITMAP hOldBitmap;
     HBITMAP hMaskBitmap=0;
-    COLORREF bkColor;
+    COLORREF bkColor, oldBkColor, oldTxColor;
     POINT  pt;

     TRACE("himl=%p hbitmap=%p clrmask=%x\n", himl, hBitmap, clrMask);
@@ -365,10 +365,11 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP
hBitmap, COLORREF clrMask)

     /* create monochrome image to the mask bitmap */
     bkColor = (clrMask != CLR_DEFAULT) ? clrMask : GetPixel (hdcBitmap,
0, 0);
-    SetBkColor (hdcBitmap, bkColor);
+    oldBkColor = SetBkColor (hdcBitmap, bkColor);
     BitBlt (hdcMask, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcBitmap, 0, 0,
SRCCOPY);

     SetBkColor(hdcBitmap, RGB(255,255,255));
+    oldTxColor = SetTextColor(hdcBitmap, 0);

     /*
      * Remove the background from the image
@@ -395,6 +396,9 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP
hBitmap, COLORREF clrMask)
                 hdcMask, i*himl->cx, 0, SRCCOPY);
     }

+    SetBkColor(hdcBitmap, oldBkColor);
+    SetTextColor(hdcBitmap, oldTxColor);
+
     /* Clean up */
     SelectObject(hdcBitmap, hOldBitmap);
     DeleteDC(hdcBitmap);




More information about the wine-patches mailing list