Fix creating wxBitmap from monochrome icon or cursor in wxMSW.
Handle the "AND" and "XOR" masks inside monochrome icons/cursors correctly instead of simply copying the monochrome data which didn't work at all. See #16512. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -508,14 +508,34 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon,
|
|||||||
}
|
}
|
||||||
else // we only have monochrome icon/cursor
|
else // we only have monochrome icon/cursor
|
||||||
{
|
{
|
||||||
// Then we need to create our own empty bitmap, which will be modified
|
// For monochrome icons/cursor bitmap mask is of height 2*h
|
||||||
// by the mask below.
|
// and contains both AND and XOR masks.
|
||||||
wxDIB dib(w, h, wxDisplayDepth());
|
// AND mask: 0 <= y <= h-1
|
||||||
if ( dib.IsOk() )
|
// XOR mask: h <= y <= 2*h-1
|
||||||
|
// First we need to extract and store XOR mask from this bitmap.
|
||||||
|
// AND mask will be extracted later at creation of inverted mask.
|
||||||
|
HBITMAP hbmp = ::CreateBitmap(w, h, 1, wxDisplayDepth(), NULL);
|
||||||
|
if ( !hbmp )
|
||||||
{
|
{
|
||||||
memset(dib.GetData(), 0, wxDIB::GetLineSize(w, dib.GetDepth())*h);
|
wxLogLastError(wxT("wxBitmap::CopyFromIconOrCursor - CreateBitmap"));
|
||||||
refData->AssignDIB(dib);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MemoryHDC dcSrc;
|
||||||
|
MemoryHDC dcDst;
|
||||||
|
SelectInHDC selSrc(dcSrc, iconInfo.hbmMask);
|
||||||
|
SelectInHDC selDst(dcDst, hbmp);
|
||||||
|
if ( !::BitBlt((HDC)dcDst, 0, 0, w, h,
|
||||||
|
(HDC)dcSrc, 0, h,
|
||||||
|
SRCCOPY) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("wxBitmap::CopyFromIconOrCursor - BitBlt"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refData->m_width = w;
|
||||||
|
refData->m_height = h;
|
||||||
|
refData->m_depth = wxDisplayDepth();
|
||||||
|
refData->m_hBitmap = hbmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( transp )
|
switch ( transp )
|
||||||
|
Reference in New Issue
Block a user