create mask from alpha channel if the bitmap has no mask, this is better than using grey as transparent colour

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43786 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-04 02:09:59 +00:00
parent 1c304f30b9
commit e4a84806c6

View File

@@ -340,6 +340,10 @@ wxIcon wxImageList::GetIcon(int index) const
static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask)
{
#if wxUSE_IMAGE
wxBitmap bitmapWithMask;
#endif // wxUSE_IMAGE
HBITMAP hbmpMask;
wxMask *pMask;
bool deleteMask = false;
@@ -352,6 +356,23 @@ static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask)
else
{
pMask = bitmap.GetMask();
#if wxUSE_IMAGE
// check if we don't have alpha in this bitmap -- we can create a mask
// from it (and we need to do it for the older systems which don't
// support 32bpp bitmaps natively)
if ( !pMask )
{
wxImage img(bitmap.ConvertToImage());
if ( img.HasAlpha() )
{
img.ConvertAlphaToMask();
bitmapWithMask = wxBitmap(img);
pMask = bitmapWithMask.GetMask();
}
}
#endif // wxUSE_IMAGE
if ( !pMask )
{
// use the light grey count as transparent: the trouble here is