From 1da74cbcd21817a8b9fdb9a0c40a41b47d6628d3 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 3 May 2017 16:04:05 +0200 Subject: [PATCH] Fix setting color depth of wxBitmap created from HBITMAP When HBITMAP is assigned to wxBitmap with SetHBITMAP(), internal data member representing wxBitmap's color depth should be set afterwards to the bitmap color depth, not to the number of planes. --- src/msw/bitmap.cpp | 2 +- src/msw/clipbrd.cpp | 2 +- src/msw/ole/dataobj.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 8d12ce9070..3ac130dbd9 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -1630,7 +1630,7 @@ wxBitmap wxMask::GetBitmap() const wxBitmap bmp; bmp.SetHBITMAP((WXHBITMAP)hNewBitmap); bmp.SetSize(bm.bmWidth, bm.bmHeight); - bmp.SetDepth(bm.bmPlanes); + bmp.SetDepth(bm.bmBitsPixel); return bmp; } diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index 1cab19ba1b..854d20a1c2 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -478,7 +478,7 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap); wxBM->SetWidth(bm.bmWidth); wxBM->SetHeight(bm.bmHeight); - wxBM->SetDepth(bm.bmPlanes); + wxBM->SetDepth(bm.bmBitsPixels); retval = wxBM; break; } diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 9807b50c45..870fd71f4f 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -1122,7 +1122,7 @@ bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf) wxLogLastError(wxT("GetObject(HBITMAP)")); } - wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes); + wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmBitsPixel); bitmap.SetHBITMAP((WXHBITMAP)hbmp); if ( !bitmap.IsOk() ) { @@ -1231,6 +1231,7 @@ bool wxBitmapDataObject::SetData(const wxDataFormat& format, m_bitmap.SetWidth(pbmih->biWidth); m_bitmap.SetHeight(pbmih->biHeight); + m_bitmap.SetDepth(pbmih->biBitCount); } else // CF_BITMAP { @@ -1245,7 +1246,7 @@ bool wxBitmapDataObject::SetData(const wxDataFormat& format, m_bitmap.SetWidth(bmp.bmWidth); m_bitmap.SetHeight(bmp.bmHeight); - m_bitmap.SetDepth(bmp.bmPlanes); + m_bitmap.SetDepth(bmp.bmBitsPixel); } m_bitmap.SetHBITMAP((WXHBITMAP)hbmp);