diff --git a/docs/changes.txt b/docs/changes.txt index 5d24d45e2b..346fc4319f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -92,6 +92,10 @@ Changes in behaviour not resulting in compilation errors made is behaviour there incompatible with the other platforms. Please call wxWebRequest::EnablePersistentStorage() explicitly if you need it. +- In wxMSW, behaviour of wxBitmap::Create(size, dc) overload has changed to + not scale the size by the content scale factor of the DC any longer, as the + size here is expressed in physical pixels and not in DIPs. + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 66f455acc6..5e8164071b 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -751,12 +751,10 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc) { wxCHECK_MSG( dc.IsOk(), false, wxT("invalid HDC in wxBitmap::Create()") ); - const double scale = dc.GetContentScaleFactor(); - - if ( !DoCreate(wxRound(width*scale), wxRound(height*scale), -1, dc.GetHDC()) ) + if ( !DoCreate(width, height, -1, dc.GetHDC()) ) return false; - GetBitmapData()->m_scaleFactor = scale; + GetBitmapData()->m_scaleFactor = dc.GetContentScaleFactor(); return true; } diff --git a/tests/graphics/bitmap.cpp b/tests/graphics/bitmap.cpp index 7f9e901d5d..5dd92cb530 100644 --- a/tests/graphics/bitmap.cpp +++ b/tests/graphics/bitmap.cpp @@ -1839,7 +1839,11 @@ TEST_CASE("Bitmap::ScaleFactor", "[bitmap][dc][scale]") // A bitmap "compatible" with this DC should also use the same scale factor. wxBitmap bmp2(4, 4, dc); CHECK( bmp2.GetScaleFactor() == 2 ); +#ifdef wxHAS_DPI_INDEPENDENT_PIXELS CHECK( bmp2.GetSize() == wxSize(8, 8) ); +#else + CHECK( bmp2.GetSize() == wxSize(4, 4) ); +#endif // A compatible bitmap created from wxImage and this DC should also inherit // the same scale factor, but its size should be still the same as that of