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:
parent
6f5ac3c594
commit
20f82e2ccb
2 changed files with 13 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue