diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index ae48064330..fa78d2b1b0 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -765,7 +765,12 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc) bool wxBitmap::CreateWithLogicalSize(const wxSize& size, double scale, int depth) { - return Create(size*scale, depth); + if ( !Create(size*scale, depth) ) + return false; + + GetBitmapData()->m_scaleFactor = scale; + + return true; } bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) diff --git a/tests/graphics/bmpbundle.cpp b/tests/graphics/bmpbundle.cpp index 9d8dcabb41..38c1622161 100644 --- a/tests/graphics/bmpbundle.cpp +++ b/tests/graphics/bmpbundle.cpp @@ -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);