From 7143ff46b024cda34c01dbe58c392df0b6dfcc35 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 1 Dec 2019 22:58:18 +0100 Subject: [PATCH] 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. --- src/osx/core/bitmap.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index bb8b8da564..550fc9c6d1 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -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