From: Vadim Zeitlin Date: Thu, 16 Jun 2011 15:13:52 +0000 (+0000) Subject: Round the values in wxDC coordinate calculations. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1fdce0aeb9c0411184c786bfffc7c47900834c63 Round the values in wxDC coordinate calculations. Make the conversion of logical coordinates to the device ones more precise by avoiding errors due to truncation of floating point values to integer ones. See #13284. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index e0e1ec6523..962054ae85 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -34,6 +34,7 @@ #include "wx/bitmap.h" #include "wx/dcmemory.h" #include "wx/log.h" + #include "wx/math.h" #include "wx/icon.h" #include "wx/dcprint.h" #include "wx/module.h" @@ -1978,24 +1979,24 @@ void wxMSWDCImpl::RealizeScaleAndOrigin() logExtX, logExtY; // Window, i.e. logical coordinate space, extents. if ( m_scaleX >= 1 ) { - devExtX = VIEWPORT_EXTENT*m_scaleX; + devExtX = wxRound(VIEWPORT_EXTENT*m_scaleX); logExtX = m_signX*VIEWPORT_EXTENT; } else { devExtX = VIEWPORT_EXTENT; - logExtX = m_signX*VIEWPORT_EXTENT/m_scaleX; + logExtX = wxRound(m_signX*VIEWPORT_EXTENT/m_scaleX); } if ( m_scaleY >= 1 ) { - devExtY = VIEWPORT_EXTENT*m_scaleY; + devExtY = wxRound(VIEWPORT_EXTENT*m_scaleY); logExtY = m_signY*VIEWPORT_EXTENT; } else { devExtY = VIEWPORT_EXTENT; - logExtY = m_signY*VIEWPORT_EXTENT/m_scaleY; + logExtY = wxRound(m_signY*VIEWPORT_EXTENT/m_scaleY); } ::SetViewportExtEx(GetHdc(), devExtX, devExtY, NULL);