From e4a84806c650d56258e9ccc5fb27c42cbd18632a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Dec 2006 02:09:59 +0000 Subject: [PATCH] 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 --- src/msw/imaglist.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index ff36d8bbb2..317bc0f788 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -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 -- 2.47.2