X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5a60b5f0414e4b5663d968344b1aaae861a0797f..810ca882569c59d537f75a982aaac0e218076bb0:/src/msw/bitmap.cpp diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 015c8309bd..f4681af5ea 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -337,7 +337,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon) #endif if ( !refData->m_hasAlpha ) { - // the mask returned by GetIconInfo() is inversed compared to the usual + // the mask returned by GetIconInfo() is inverted compared to the usual // wxWin convention refData->SetMask(wxInvertMask(iconInfo.hbmMask, w, h)); } @@ -435,7 +435,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) { // we assume that it is in XBM format which is not quite the same as // the format CreateBitmap() wants because the order of bytes in the - // line is inversed! + // line is reversed! const size_t bytesPerLine = (width + 7) / 8; const size_t padding = bytesPerLine % 2; const size_t len = height * ( padding + bytesPerLine ); @@ -1639,7 +1639,23 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, return 0; } - wxMask *mask = bmp.GetMask(); + wxMask* mask; + wxBitmap newbmp; + if ( bmp.HasAlpha() ) + { + // Convert alpha to a mask. NOTE: It would be better to actually put + // the alpha into the icon instead of making a mask, but I don't have + // time to figure that out today. + wxImage img = bmp.ConvertToImage(); + img.ConvertAlphaToMask(); + newbmp = wxBitmap(img); + mask = newbmp.GetMask(); + } + else + { + mask = bmp.GetMask(); + } + if ( !mask ) { // we must have a mask for an icon, so even if it's probably incorrect, @@ -1676,7 +1692,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, HICON hicon = ::CreateIconIndirect(&iconInfo); - if ( !bmp.GetMask() ) + if ( !bmp.GetMask() && !bmp.HasAlpha() ) { // we created the mask, now delete it delete mask;