Applied patch [ 1378522 ] fixed bitmap w/alpha->icon/cursor conversion
Vince Harron git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36942 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1636,23 +1636,33 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
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
|
||||
// Create an empty mask bitmap.
|
||||
// it doesn't seem to work if we mess with the mask at all.
|
||||
HBITMAP hMonoBitmap = CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL);
|
||||
|
||||
ICONINFO iconInfo;
|
||||
wxZeroMemory(iconInfo);
|
||||
iconInfo.fIcon = iconWanted; // do we want an icon or a cursor?
|
||||
if ( !iconWanted )
|
||||
{
|
||||
mask = bmp.GetMask();
|
||||
iconInfo.xHotspot = hotSpotX;
|
||||
iconInfo.yHotspot = hotSpotY;
|
||||
}
|
||||
|
||||
iconInfo.hbmMask = hMonoBitmap;
|
||||
iconInfo.hbmColor = GetHbitmapOf(bmp);
|
||||
|
||||
HICON hicon = ::CreateIconIndirect(&iconInfo);
|
||||
|
||||
::DeleteObject(hMonoBitmap);
|
||||
|
||||
return hicon;
|
||||
}
|
||||
|
||||
wxMask* mask = bmp.GetMask();
|
||||
|
||||
if ( !mask )
|
||||
{
|
||||
// we must have a mask for an icon, so even if it's probably incorrect,
|
||||
|
Reference in New Issue
Block a user