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:
@@ -340,6 +340,10 @@ wxIcon wxImageList::GetIcon(int index) const
|
|||||||
|
|
||||||
static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask)
|
static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask)
|
||||||
{
|
{
|
||||||
|
#if wxUSE_IMAGE
|
||||||
|
wxBitmap bitmapWithMask;
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
HBITMAP hbmpMask;
|
HBITMAP hbmpMask;
|
||||||
wxMask *pMask;
|
wxMask *pMask;
|
||||||
bool deleteMask = false;
|
bool deleteMask = false;
|
||||||
@@ -352,6 +356,23 @@ static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pMask = bitmap.GetMask();
|
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 )
|
if ( !pMask )
|
||||||
{
|
{
|
||||||
// use the light grey count as transparent: the trouble here is
|
// use the light grey count as transparent: the trouble here is
|
||||||
|
Reference in New Issue
Block a user