allow specifying the mask colour in wxImage::ConvertAlphaToMask() (closes #10143)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58404 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-25 17:23:39 +00:00
parent 4b2214224f
commit c1099d9254
3 changed files with 56 additions and 12 deletions

View 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;
}
// ----------------------------------------------------------------------------