From 2edc119be3723571a39220acf6d82ce9d7c753a1 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Garcia Date: Mon, 7 Feb 2000 23:26:29 +0000 Subject: [PATCH] Fixed transparency problem when masked area was not black git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/icon.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/msw/icon.cpp b/src/msw/icon.cpp index 03fe2ebb13..30edc93816 100644 --- a/src/msw/icon.cpp +++ b/src/msw/icon.cpp @@ -107,6 +107,22 @@ void wxIcon::CopyFromBitmap(const wxBitmap& bmp) iconInfo.hbmMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap()); iconInfo.hbmColor = GetHbitmapOf(bmp); + /* GRG: black out the transparent area to preserve background + * colour, because Windows blits the original bitmap using + * SRCINVERT (XOR) after applying the mask to the dest rect. + */ + HDC dcSrc = ::CreateCompatibleDC(NULL); + HDC dcDst = ::CreateCompatibleDC(NULL); + SelectObject(dcSrc, (HBITMAP)mask->GetMaskBitmap()); + SelectObject(dcDst, iconInfo.hbmColor); + + BitBlt(dcDst, 0, 0, bmp.GetWidth(), bmp.GetHeight(), dcSrc, 0, 0, SRCAND); + + SelectObject(dcDst, NULL); + SelectObject(dcSrc, NULL); + DeleteDC(dcDst); + DeleteDC(dcSrc); + HICON hicon = ::CreateIconIndirect(&iconInfo); if ( !hicon ) {