X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fc3762b5fcc2a9fea2ea53702e2b943d9e3c3cc7..b53aea81d2e102224b452ef5bf7aee1132f37c6f:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index b3883e6a49..d3bf74c5c4 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -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; } // ----------------------------------------------------------------------------