From 2b147475fddb530a24e1deb2fbab6e0ee71798a9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Apr 2014 22:39:01 +0000 Subject: [PATCH] Fix precision in wxGraphicsContext::{Stroke,Draw}Lines() under MSW. Use floating point coordinates instead of ints which were used for some reason, resulting in a loss of precision. Closes #16187. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/graphics.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 640114f82a..6e6100b7d5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -655,6 +655,7 @@ wxMSW: - Fix expander in non left-most position in wxDataViewCtrl (Laurent Poujoulat). - Don't fail when using large paper sizes in print preview. - Fix wxRichMessageDialog return value for dialog with only "OK" button. +- Fix precision loss in wxGraphicsContext::{Draw,Stroke}Lines() (tibo_). wxOSX: diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index e0af6a5d10..e46c3709c3 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1488,11 +1488,11 @@ void wxGDIPlusContext::StrokeLines( size_t n, const wxPoint2DDouble *points) if ( !m_pen.IsNull() ) { wxGDIPlusOffsetHelper helper( m_context , ShouldOffset() ); - Point *cpoints = new Point[n]; + PointF *cpoints = new PointF[n]; for (size_t i = 0; i < n; i++) { - cpoints[i].X = (int)(points[i].m_x ); - cpoints[i].Y = (int)(points[i].m_y ); + cpoints[i].X = static_cast(points[i].m_x); + cpoints[i].Y = static_cast(points[i].m_y); } // for (size_t i = 0; i < n; i++) m_context->DrawLines( ((wxGDIPlusPenData*)m_pen.GetGraphicsData())->GetGDIPlusPen() , cpoints , n ) ; @@ -1506,11 +1506,11 @@ void wxGDIPlusContext::DrawLines( size_t n, const wxPoint2DDouble *points, wxPol return; wxGDIPlusOffsetHelper helper( m_context , ShouldOffset() ); - Point *cpoints = new Point[n]; + PointF *cpoints = new PointF[n]; for (size_t i = 0; i < n; i++) { - cpoints[i].X = (int)(points[i].m_x ); - cpoints[i].Y = (int)(points[i].m_y ); + cpoints[i].X = static_cast(points[i].m_x); + cpoints[i].Y = static_cast(points[i].m_y); } // for (int i = 0; i < n; i++) if ( !m_brush.IsNull() )