From: Robin Dunn Date: Tue, 31 May 2005 23:53:09 +0000 (+0000) Subject: Convert alpha (if any) to mask in wxBitmapToIconOrCursor. Note that X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0806fc2071c2b6fcdd3ffd355c8b76ed4cf59081 Convert alpha (if any) to mask in wxBitmapToIconOrCursor. Note that it is possible to put alpha in the icon instead of using a mask, but I don't have time to figure that out today. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index bfcddabf48..f4681af5ea 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -1639,7 +1639,23 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, return 0; } - wxMask *mask = bmp.GetMask(); + wxMask* mask; + wxBitmap newbmp; + if ( bmp.HasAlpha() ) + { + // Convert alpha to a mask. NOTE: It would be better to actually put + // the alpha into the icon instead of making a mask, but I don't have + // time to figure that out today. + wxImage img = bmp.ConvertToImage(); + img.ConvertAlphaToMask(); + newbmp = wxBitmap(img); + mask = newbmp.GetMask(); + } + else + { + mask = bmp.GetMask(); + } + if ( !mask ) { // we must have a mask for an icon, so even if it's probably incorrect, @@ -1676,7 +1692,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, HICON hicon = ::CreateIconIndirect(&iconInfo); - if ( !bmp.GetMask() ) + if ( !bmp.GetMask() && !bmp.HasAlpha() ) { // we created the mask, now delete it delete mask;