diff --git a/interface/wx/window.h b/interface/wx/window.h index 4fb7195870..09f275316e 100644 --- a/interface/wx/window.h +++ b/interface/wx/window.h @@ -1217,11 +1217,12 @@ public: factor under the other platforms. Note that dividing an integer value by scale factor doesn't always - yield an integer value. This function always round the resulting value - up, e.g. 15 physical pixels are translated to 8, not 7, logical pixels - in 200% DPI scaling. This ensures that a physical bitmap of size 15 is - not truncated if the result of this function is used to create a window - to show it, but it does mean that there will be one extra pixel left. + yield an integer value. This function rounds the resulting value to + the closest integer, e.g. 15 physical pixels are translated to 8, not + 7, logical pixels in 200% DPI scaling. This ensures that a physical + bitmap of size 15 is not truncated if the result of this function is + used to create a window to show it, but it does mean that there will be + one extra pixel, not covered by this bitmap, left. @see FromDIP(), ToPhys() diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 50eb1be142..92cf9bbdac 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -2905,15 +2905,10 @@ wxSize wxWindowBase::FromPhys(wxSize sz, const wxWindowBase* w) if ( scale != 1.0 ) { - // We prefer to round up the size so that conversion from physical - // pixels to logical and back doesn't result in smaller value, as this - // would e.g. truncate the bitmap of odd size when drawing it at 200% - // scaling. Leaving an extra pixel in this case seems like a lesser - // evil, even if not ideal. if ( sz.x != wxDefaultCoord ) - sz.x = ceil(sz.x) / scale; + sz.x = wxRound(sz.x / scale); if ( sz.y != wxDefaultCoord ) - sz.y = ceil(sz.y) / scale; + sz.y = wxRound(sz.y / scale); } return sz; @@ -2927,9 +2922,9 @@ wxSize wxWindowBase::ToPhys(wxSize sz, const wxWindowBase* w) if ( scale != 1.0 ) { if ( sz.x != wxDefaultCoord ) - sz.x *= scale; + sz.x = wxRound(sz.x * scale); if ( sz.y != wxDefaultCoord ) - sz.y *= scale; + sz.y = wxRound(sz.y * scale); } return sz;