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:
@@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
WXHBITMAP GetHBITMAP() const ;
|
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 ) ;
|
bool OSXCreate(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -1511,19 +1511,23 @@ void wxMask::RealizeNative()
|
|||||||
#endif
|
#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)
|
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);
|
DoCreateMaskBitmap(width, height, bytesPerRow);
|
||||||
|
void* destdata = GetRawAccess();
|
||||||
|
wxCHECK( destdata, false );
|
||||||
|
|
||||||
RealizeNative() ;
|
memcpy(destdata, srcdata, dataLen);
|
||||||
|
return true;
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a mask from a mono bitmap (copies the bitmap).
|
||||||
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
|
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
int m_width, m_height, m_bytesPerRow;
|
int m_width, m_height, m_bytesPerRow;
|
||||||
|
Reference in New Issue
Block a user