Allow rescaling larger images in Win64 builds

Use wxUIntPtr rather than (unsigned) long in wxImage::ResampleNearest()
as long is still 32 bits under Win64 and so doesn't allow the code there
to work with images larger than 2^16 in either direction, when it could
be allowed in this case.

Document the current limits on the size of the image and add a unit test
checking that resizing images of size greater than 2^16 works in 64 bits.

See #18550.
This commit is contained in:
Vadim Zeitlin
2021-09-01 20:00:48 +01:00
parent 39e1cae617
commit 44a5cf78d1
3 changed files with 34 additions and 8 deletions

View File

@@ -2249,6 +2249,18 @@ TEST_CASE("wxImage::ChangeColours", "[image]")
CHECK_THAT(test, RGBSameAs(expected));
}
TEST_CASE("wxImage::SizeLimits", "[image]")
{
#if SIZEOF_VOID_P == 8
// Check that we can resample an image of size greater than 2^16, which is
// the limit used in 32-bit code to avoid integer overflows.
wxImage image(100000, 2);
REQUIRE_NOTHROW( image = image.ResampleNearest(100000, 1) );
CHECK( image.GetWidth() == 100000 );
CHECK( image.GetHeight() == 1 );
#endif // SIZEOF_VOID_P == 8
}
/*
TODO: add lots of more tests to wxImage functions
*/