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:
Julian Smart
2006-01-17 20:06:00 +00:00
parent 99cc862c0f
commit 074308476d

View File

@@ -1636,23 +1636,33 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp,
return 0; return 0;
} }
wxMask* mask;
wxBitmap newbmp;
if ( bmp.HasAlpha() ) if ( bmp.HasAlpha() )
{ {
// Convert alpha to a mask. NOTE: It would be better to actually put // Create an empty mask bitmap.
// the alpha into the icon instead of making a mask, but I don't have // it doesn't seem to work if we mess with the mask at all.
// time to figure that out today. HBITMAP hMonoBitmap = CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL);
wxImage img = bmp.ConvertToImage();
img.ConvertAlphaToMask(); ICONINFO iconInfo;
newbmp = wxBitmap(img); wxZeroMemory(iconInfo);
mask = newbmp.GetMask(); iconInfo.fIcon = iconWanted; // do we want an icon or a cursor?
} if ( !iconWanted )
else {
{ iconInfo.xHotspot = hotSpotX;
mask = bmp.GetMask(); iconInfo.yHotspot = hotSpotY;
}
iconInfo.hbmMask = hMonoBitmap;
iconInfo.hbmColor = GetHbitmapOf(bmp);
HICON hicon = ::CreateIconIndirect(&iconInfo);
::DeleteObject(hMonoBitmap);
return hicon;
} }
wxMask* mask = bmp.GetMask();
if ( !mask ) if ( !mask )
{ {
// we must have a mask for an icon, so even if it's probably incorrect, // we must have a mask for an icon, so even if it's probably incorrect,