From 54b37e2e8bdb7b41eee67ed4c31542aaa685d185 Mon Sep 17 00:00:00 2001 From: "Unknown (CR)" Date: Wed, 3 Nov 1999 03:52:12 +0000 Subject: [PATCH] Fixed inverse masking on MSW imagelist git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/imaglist.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 540c176058..6c80416dd8 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -91,13 +91,36 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) HBITMAP hBitmap2 = 0; if ( mask.Ok() ) hBitmap2 = (HBITMAP) mask.GetHBITMAP(); + else if (bitmap.GetMask()) + hBitmap2 = (HBITMAP) bitmap.GetMask()->GetMaskBitmap(); - int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2); + HBITMAP hBitmapI=0; + if(hBitmap2!=0) { + // Microsoft imagelist masks are inverted from wxWindows mask standard (white is mask color) + BITMAP bm; + ::GetObject(hBitmap2,sizeof(BITMAP),(LPVOID)&bm); + int w=bm.bmWidth; + int h=bm.bmHeight; + HDC hdc = ::CreateCompatibleDC(NULL); + HDC hdci = ::CreateCompatibleDC(NULL); + hBitmapI = ::CreateCompatibleBitmap(hdci, w, h); + ::SelectObject(hdc, hBitmap2); + ::SelectObject(hdci, hBitmapI); + ::BitBlt(hdci, 0, 0, w, h, hdc, 0, 0, NOTSRCCOPY); + ::DeleteDC(hdc); + ::DeleteDC(hdci); + } + + int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmapI); if ( index == -1 ) { wxLogError(_("Couldn't add an image to the image list.")); } + // Clean up inverted mask + if(hBitmapI!=0) + ::DeleteObject(hBitmapI); + return index; }