Fix CreateWithLogicalSize() to set correct scale in wxMSW too

Unlike under Mac (see previous commit), this never worked correctly in
wxMSW at all, only SetScaleFactor() could be used to change the scale
factor of the bitmaps there.

Fix this and make CreateWithLogicalSize(..., scale) result in
GetScaleFactor() returning the same scale for the resulting bitmap, as
expected, under MSW too.

Also add a unit test verifying that this holds.
This commit is contained in:
Vadim Zeitlin
2022-02-11 16:47:19 +00:00
parent 6f5ac3c594
commit 20f82e2ccb
2 changed files with 13 additions and 3 deletions

View File

@@ -172,8 +172,13 @@ TEST_CASE("BitmapBundle::Scale", "[bmpbundle][scale]")
// This is not a wxBitmapBundle test, strictly speaking, but check that
// setting scale factor works correctly for bitmaps, as wxBitmapBundle does
// this internally.
wxBitmap bmp(16, 16);
bmp.SetScaleFactor(2);
wxBitmap bmp;
bmp.CreateWithLogicalSize(8, 8, 2);
#ifdef wxHAS_DPI_INDEPENDENT_PIXELS
CHECK( bmp.GetLogicalSize() == wxSize(8, 8) );
#endif
CHECK( bmp.GetDIPSize() == wxSize(8, 8) );
CHECK( bmp.GetSize() == wxSize(16, 16) );
CHECK( bmp.GetScaleFactor() == 2 );
wxBitmap bmp2(bmp);