Make wxBitmap::Rescale() less horrible for commonly used icons

Make the results look somewhat better by using wxIMAGE_QUALITY_NEAREST
which preserves sharp horizontal and vertical edges in the images which
are common in the icons, with which this function is often used, instead
of blurring them as wxIMAGE_QUALITY_HIGH does.

This is also much (factor of ~40) faster, which shouldn't hurt neither.
This commit is contained in:
Vadim Zeitlin
2022-02-23 00:04:02 +00:00
parent 4e05ee9c5a
commit 84cb293e71
2 changed files with 6 additions and 3 deletions

View File

@@ -70,8 +70,11 @@ void wxBitmapHelpers::Rescale(wxBitmap& bmp, const wxSize& sizeNeeded)
wxCHECK_RET( sizeNeeded.IsFullySpecified(), wxS("New size must be given") );
#if wxUSE_IMAGE
// Note that we use "nearest" rescale mode here to preserve sharp edges in
// the icons for which this function is often used. It's also consistent
// with what wxDC::DrawBitmap() does, i.e. the fallback method below.
wxImage img = bmp.ConvertToImage();
img.Rescale(sizeNeeded.x, sizeNeeded.y, wxIMAGE_QUALITY_HIGH);
img.Rescale(sizeNeeded.x, sizeNeeded.y, wxIMAGE_QUALITY_NEAREST);
bmp = wxBitmap(img);
#else // !wxUSE_IMAGE
// Fallback method of scaling the bitmap