From 98f056daf59f93ffdc42b5e73d38e4a96f7d71d6 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 21 Oct 2021 15:30:32 +0200 Subject: [PATCH] using GetPreferredSizeAtScale when assembling native NSImage from a bitmap bundle --- src/osx/core/bmpbndl.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/osx/core/bmpbndl.mm b/src/osx/core/bmpbndl.mm index 362d2ac367..70f3483d83 100644 --- a/src/osx/core/bmpbndl.mm +++ b/src/osx/core/bmpbndl.mm @@ -249,12 +249,14 @@ WXImage wxOSXGetImageFromBundle(const wxBitmapBundle& bundle) wxBitmap bmp = const_cast(impl)->GetBitmap(sz); image = wxOSXImageFromBitmap(bmp); - // unconditionally try to add a 2x version - double scale = 2.0; - wxSize doublesz = sz * scale; - bmp = const_cast(impl)->GetBitmap(doublesz); - if ( bmp.IsOk() && bmp.GetSize() != sz ) - wxOSXAddBitmapToImage(image, bmp); + // unconditionally try to add a 2x version, if there really is a different one + wxSize doublesz = impl->GetPreferredSizeAtScale(2.0); + if ( doublesz != sz ) + { + bmp = const_cast(impl)->GetBitmap(doublesz); + if ( bmp.IsOk() ) + wxOSXAddBitmapToImage(image, bmp); + } #else double scale = wxOSXGetMainScreenContentScaleFactor(); wxSize scaledSize = sz * scale;