Ensure bitmap image exists while querying for a row stride

Obtaining bytes per row makes sense only for bitmap image representation
so we have to ensure that the bitmap represenation exists before querying
for its row stride length. NSImage per se cannot provide this information.

Closes #18606.
This commit is contained in:
Artur Wieczorek
2019-12-01 22:58:18 +01:00
parent a1cc2056bc
commit 7143ff46b0

View File

@@ -324,14 +324,14 @@ int wxBitmapRefData::GetDepth() const
else
return 32; // a bitmap converted from an nsimage would have this depth
}
int wxBitmapRefData::GetBytesPerRow() const
{
wxCHECK_MSG( IsOk() , 0 , "Invalid Bitmap");
if ( m_hBitmap )
return (int) CGBitmapContextGetBytesPerRow(m_hBitmap);
else
return (int) GetBestBytesPerRow( GetWidth() * 4);
// Row stride length makes sense only for a bitmap representation
EnsureBitmapExists();
return (int) CGBitmapContextGetBytesPerRow(m_hBitmap);
}
bool wxBitmapRefData::HasAlpha() const