]> git.saurik.com Git - wxWidgets.git/commitdiff
Convert alpha (if any) to mask in wxBitmapToIconOrCursor. Note that
authorRobin Dunn <robin@alldunn.com>
Tue, 31 May 2005 23:53:09 +0000 (23:53 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 31 May 2005 23:53:09 +0000 (23:53 +0000)
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

src/msw/bitmap.cpp

index bfcddabf48d1ef3f9c3a0a45c99b0fd239ee31f5..f4681af5eafde14da03c3f8a05cf841152c7fc9d 100644 (file)
@@ -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;