From f56b8a99a6283ad1e4ebec1306ed03208e42f93a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 2 Jun 2022 23:06:12 +0100 Subject: [PATCH] Allow upscaling wxArtProvider bitmaps by integer scale factor While upscaling the bitmaps by factors smaller than 2 results in truly awful results, upscaling them by 2, or 3, is better on high DPI screens than using tiny bitmaps that are difficult to read in high resolution, so do scale them up in this case. This finally makes wxBitmapBundleImplArt::GetBitmap() work as expected, as it now returns the upscaled bitmap rather than the original small bitmap in the middle of a bigger canvas. --- src/common/artprov.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/artprov.cpp b/src/common/artprov.cpp index fff39e7370..e2aaa50a2a 100644 --- a/src/common/artprov.cpp +++ b/src/common/artprov.cpp @@ -309,7 +309,11 @@ wxArtProvider::RescaleOrResizeIfNeeded(wxBitmap& bmp, const wxSize& sizeNeeded) return; #if wxUSE_IMAGE - if ((bmp_w <= sizeNeeded.x) && (bmp_h <= sizeNeeded.y)) + // Allow upscaling by an integer factor: this looks not too horribly and is + // needed to use reasonably-sized bitmaps in the code not yet updated to + // use wxBitmapBundle but using custom art providers. + if ((bmp_w <= sizeNeeded.x) && (bmp_h <= sizeNeeded.y) && + (sizeNeeded.x % bmp_w || sizeNeeded.y % bmp_h)) { // the caller wants default size, which is larger than // the image we have; to avoid degrading it visually by @@ -319,7 +323,7 @@ wxArtProvider::RescaleOrResizeIfNeeded(wxBitmap& bmp, const wxSize& sizeNeeded) img.Resize(sizeNeeded, offset); bmp = wxBitmap(img); } - else // scale (down or mixed, but not up) + else // scale (down or mixed, but not up, or at least not by an int factor) #endif // wxUSE_IMAGE { wxBitmap::Rescale(bmp, sizeNeeded);