From 1fdce0aeb9c0411184c786bfffc7c47900834c63 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Jun 2011 15:13:52 +0000 Subject: [PATCH] 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 --- src/msw/dc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); -- 2.45.2