]> git.saurik.com Git - wxWidgets.git/commitdiff
Round the values in wxDC coordinate calculations.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Jun 2011 15:13:52 +0000 (15:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Jun 2011 15:13:52 +0000 (15:13 +0000)
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

index e0e1ec6523475415acc22f3a6de4b47c28ff85d7..962054ae85524e9a6cf76deb63fa74b2afdef09c 100644 (file)
@@ -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);