using GetPreferredSizeAtScale when assembling native NSImage from a bitmap bundle

This commit is contained in:
Stefan Csomor
2021-10-21 15:30:32 +02:00
parent 6f2a1fa55d
commit 98f056daf5

View File

@@ -249,12 +249,14 @@ WXImage wxOSXGetImageFromBundle(const wxBitmapBundle& bundle)
wxBitmap bmp = const_cast<wxBitmapBundleImpl*>(impl)->GetBitmap(sz);
image = wxOSXImageFromBitmap(bmp);
// unconditionally try to add a 2x version
double scale = 2.0;
wxSize doublesz = sz * scale;
bmp = const_cast<wxBitmapBundleImpl*>(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<wxBitmapBundleImpl*>(impl)->GetBitmap(doublesz);
if ( bmp.IsOk() )
wxOSXAddBitmapToImage(image, bmp);
}
#else
double scale = wxOSXGetMainScreenContentScaleFactor();
wxSize scaledSize = sz * scale;