Opened 5 months ago

Closed 4 months ago

Last modified 4 months ago

#16187 closed defect (fixed)

wxGDIPlusContext::StrokeLines() wrongly truncates floating point coordinates

Reported by: tibo_ Owned by: VZ
Priority: normal Milestone:
Component: wxMSW Version: dev-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

The GDI+ implementation of wxGraphicsContext uses its own fast-path implementation of StrokeLines() and DrawLines(). These call native functions directly rather than creating a wxGraphicsPath and calling StrokePath().

For some reason, the current implementation, taking its input as doubles, truncates them with a typecast to int, before storing them in the native Point type (which uses integer coordinates).

Given that GDI+ exposes the PointF type - similar to Point, but using floating point coordinates - and that there is no apparent reason for this - as all coordinates of wxGraphicsContext are assumed to be doubles - it seems natural to remove the cast-to-int.

The provided patch (against trunk) removes the cast, and replaces Point instances with PointF, using a cast to REAL (as it's the underlying floating point type) to make sure no warning is emitted by the compiler. GDI+ can't use doubles anyway.

Attachments (1)

graphics.cpp.patch download (1.2 KB) - added by tibo_ 5 months ago.

Download all attachments as: .zip

Change History (4)

Changed 5 months ago by tibo_

comment:1 Changed 4 months ago by vadz

Thanks a lot for noticing and fixing this!

Will apply soon.

comment:2 Changed 4 months ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from new to closed

In 76405:

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.

comment:3 Changed 4 months ago by VZ

In 76420:

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.

Note: See TracTickets for help on using tickets.