diff --git a/include/wx/osx/bitmap.h b/include/wx/osx/bitmap.h index 85f6a87e04..34137f0a4c 100644 --- a/include/wx/osx/bitmap.h +++ b/include/wx/osx/bitmap.h @@ -66,7 +66,7 @@ public: WXHBITMAP GetHBITMAP() const ; - // implementation helper only : construct a mask from a 32 bit memory buffer + // implementation helper only : construct a mask from a 8 bpp memory buffer bool OSXCreate(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; protected: diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index b2ff394de3..f57944908e 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1511,19 +1511,23 @@ void wxMask::RealizeNative() #endif } -// Create a mask from a mono bitmap (copies the bitmap). - +// Construct a mask from a 8 bpp memory buffer bool wxMask::OSXCreate(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) { - wxASSERT( data.GetDataLen() == (size_t)(height * bytesPerRow) ) ; + size_t dataLen = data.GetDataLen(); + wxCHECK( dataLen == (size_t)(height * bytesPerRow), false ); + const void* srcdata = data.GetData(); + wxCHECK( srcdata, false ); DoCreateMaskBitmap(width, height, bytesPerRow); + void* destdata = GetRawAccess(); + wxCHECK( destdata, false ); - RealizeNative() ; - - return true ; + memcpy(destdata, srcdata, dataLen); + return true; } +// Create a mask from a mono bitmap (copies the bitmap). bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap) { int m_width, m_height, m_bytesPerRow;