Round physical bitmap size in wxGTK wxBitmap::CreateScaled()
Round the result of the multiplication by possibly non-integer scaling factor rather than truncating it. This is more consistent with wxMSW and other ports not using DIPs (wxOSX doesn't matter, as the scale factor can only be an integer there anyhow) and seems to be more useful. E.g. previously creating a bitmap of logical size 5 at 150% DPI scaling would create a 7px bitmap, for which GetLogicalWidth() would return 4.66 that would be truncated to 4, and not 5, when assigning it to an int, while now a 8px bitmap will be created and both rounding or truncating its GetLogicalWidth() value of 5.33 results in the more expected 5.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "wx/cursor.h"
|
||||
#endif
|
||||
|
||||
#include "wx/math.h"
|
||||
#include "wx/rawbmp.h"
|
||||
|
||||
#include "wx/gtk/private/object.h"
|
||||
@@ -991,7 +992,7 @@ void wxBitmap::SetMask( wxMask *mask )
|
||||
#ifdef __WXGTK3__
|
||||
bool wxBitmap::CreateScaled(int w, int h, int depth, double scale)
|
||||
{
|
||||
Create(int(w * scale), int(h * scale), depth);
|
||||
Create(wxRound(w * scale), wxRound(h * scale), depth);
|
||||
M_BMPDATA->m_scaleFactor = scale;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user