Oleg Krylov : comctl32: Fix ImageList_Replace function to correctly apply image mask.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 18 05:40:01 CDT 2006


Module: wine
Branch: master
Commit: 496d63473520ed203c4ba1f2d371b725d7bb879b
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=496d63473520ed203c4ba1f2d371b725d7bb879b

Author: Oleg Krylov <oleg.krylov at gmail.com>
Date:   Thu Aug 17 16:08:22 2006 +0300

comctl32: Fix ImageList_Replace function to correctly apply image mask.

---

 dlls/comctl32/imagelist.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index cbd8f34..cc3078e 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -2158,6 +2158,7 @@ ImageList_Replace (HIMAGELIST himl, INT 
 {
     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 
     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;




More information about the wine-cvs mailing list