From 73e915a5735e9b664187d4966ce931b16958d8cd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Aug 2014 15:14:18 +0000 Subject: [PATCH] Fix creation of wxBitmap from monochrome wxIcon or wxCursor in wxMSW. Don't suppose that we always have hbmColor because this is not true for monochrome icons/cursors. Create our own bitmap in this case. Closes #16512. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77517 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/bitmap.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 268d0b3993..49af364e2d 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -499,11 +499,24 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, int w = icon.GetWidth(), h = icon.GetHeight(); - refData->m_width = w; - refData->m_height = h; - refData->m_depth = wxDisplayDepth(); - - refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor; + if ( iconInfo.hbmColor ) + { + refData->m_width = w; + refData->m_height = h; + refData->m_depth = wxDisplayDepth(); + refData->m_hBitmap = (WXHBITMAP)iconInfo.hbmColor; + } + else // we only have monochrome icon/cursor + { + // Then we need to create our own empty bitmap, which will be modified + // by the mask below. + wxDIB dib(w, h, wxDisplayDepth()); + if ( dib.IsOk() ) + { + memset(dib.GetData(), 0, wxDIB::GetLineSize(w, dib.GetDepth())*h); + refData->AssignDIB(dib); + } + } switch ( transp ) {