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;
}
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();
// 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 )
{
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,