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:
@@ -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;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user