Fix creating wxMask image from raw data

In the function wxMask::OSXCreate() to create a mask image, data copying
from the supplied memory buffer was not actually implemented and therefore
created mask was invalid.

Closes #18513.
This commit is contained in:
Artur Wieczorek
2019-09-29 16:21:45 +02:00
parent 96cb3b6714
commit ac9c4d06e2
2 changed files with 11 additions and 7 deletions

View File

@@ -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:

View File

@@ -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;