Fix bug with wrong GetIndexToUpscale() return value

Only assign known good values of the index to "indexLast" as otherwise
we could end up returning an invalid index value from it if "indexBest"
was never set and the last index wasn't a valid one, as it happened in
wxBitmapBundleImplSet containing an original bitmap and a x2 scaled copy
of it, which shouldn't be used for further scaling.

Add a unit test checking that this bug is fixed now.
This commit is contained in:
Vadim Zeitlin
2022-06-03 00:44:59 +01:00
parent f56b8a99a6
commit 538eafc78b
2 changed files with 16 additions and 1 deletions

View File

@@ -50,6 +50,15 @@ TEST_CASE("BitmapBundle::FromBitmaps", "[bmpbundle]")
CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) );
}
TEST_CASE("BitmapBundle::GetBitmap", "[bmpbundle]")
{
const wxBitmapBundle b = wxBitmapBundle::FromBitmap(wxBitmap(16, 16));
CHECK( b.GetBitmap(wxSize(16, 16)).GetSize() == wxSize(16, 16) );
CHECK( b.GetBitmap(wxSize(32, 32)).GetSize() == wxSize(32, 32) );
CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) );
}
// Helper functions for the test below.
namespace
{