]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
Reorganize wxCollapsiblePane event and layout code under GTK+
[wxWidgets.git] / src / common / image.cpp
index b3883e6a49586cbb8e3b6d1a28a1606c0cb5249a..d3bf74c5c47c4738a1e1dee452c74c50f5a3fd2f 100644 (file)
@@ -1905,16 +1905,28 @@ bool wxImage::SetMaskFromImage(const wxImage& mask,
 
 bool wxImage::ConvertAlphaToMask(unsigned char threshold)
 {
-    if (!HasAlpha())
+    if ( !HasAlpha() )
         return true;
 
     unsigned char mr, mg, mb;
-    if (!FindFirstUnusedColour(&mr, &mg, &mb))
+    if ( !FindFirstUnusedColour(&mr, &mg, &mb) )
     {
         wxLogError( _("No unused colour in image being masked.") );
         return false;
     }
 
+    ConvertAlphaToMask(mr, mg, mb, threshold);
+    return true;
+}
+
+void wxImage::ConvertAlphaToMask(unsigned char mr,
+                                 unsigned char mg,
+                                 unsigned char mb,
+                                 unsigned char threshold)
+{
+    if ( !HasAlpha() )
+        return;
+
     AllocExclusive();
 
     SetMask(true);
@@ -1939,13 +1951,11 @@ bool wxImage::ConvertAlphaToMask(unsigned char threshold)
         }
     }
 
-    if( !M_IMGDATA->m_staticAlpha )
+    if ( !M_IMGDATA->m_staticAlpha )
         free(M_IMGDATA->m_alpha);
 
     M_IMGDATA->m_alpha = NULL;
     M_IMGDATA->m_staticAlpha = false;
-
-    return true;
 }
 
 // ----------------------------------------------------------------------------