[Mono-dev] RE: [Mono-winforms-list] Help contributing to libgdiplus and Cairointegration
Jonathan S. Chambers
Jonathan.Chambers at ansys.com
Wed Oct 5 15:27:43 EDT 2005
I took a look at the paper and tried some things out. It didn't seem to solve the issue at hand. There seems to be two problems.
1. The issue of line thickness. This problem is handled by the Hobby pens described in the paper (lines of uniform thickness will be produced).
2. The more noticeable issue. Cairo handles pixels at halves instead of integers (so (0,0) is really (.5,.5) ), or so I have been told. From what I understand this is causing the issue. The Hobby paper (as well as the average user of System.Drawing) assumes that pixel centers are at integer coordinates. This seems to be what is causing the funny looking lines.
Notice that the Hobby pen for a line of diameter 1 is the same polygon pen that is generated by Cairo at this time, a diamond with vertices at points (.5,0),(0,.5),(-.5,0),(0,-.5). So until Cairo works right with a pen of width 1, there is still an issue.
So I think the Hobby pens would help eventually if implemented, but I don't think they will work correctly until issue 2 is resolved in some manner.
Also, I am not an expert nor claim to be :-)
From: mono-winforms-list-bounces at lists.ximian.com [mailto:mono-winforms-list-bounces at lists.ximian.com] On Behalf Of Jordi Mas
Sent: Wednesday, October 05, 2005 9:15 AM
To: mono-winforms-list at lists.ximian.com
Subject: [Mono-winforms-list] Help contributing to libgdiplus and Cairointegration
As you probably know Cairo 1.0 includes antialiasing support. This is
something important for libgdiplus because all the drawing operations in
System.Windows.Forms are based on the old Windows GDI and they use no
After turning antialiasing off in Cairo 1.0 we noticed that DrawLine and
other functions basic drawing functions started to work different that
expected. With antialiasing off in Cairo lines that are supposed to be a
single pixel width have various variations in width.
This a well-know and documented issue. John Hobby did his PhD on the
solution to this problem. There is a shorten version of PhD findings on
[Hobby89] John D. Hobby, Rasterizing Curves of Constant Width, JACM
In order to fix this problem the best solution is to implement an
algorithm to generate Hobby's "Pen polygons". These respect the desired
width and will make us to look right when AA is off. According to Cairo
hacker's, a hack in cairo-pen.c:_cairo_pen_init with Hobby's algorithm
will fix the problem.
We are looking for someone that wants to contribute to the Mono project
in graphics area and help us implementing Hobby's Pen polygons in Cairo.
Jordi Mas i Hernàndez - Mono development team - http://www.mono-project.com
Homepage and LiveJournal at http://www.softcatala.org/~jmas
Mono-winforms-list maillist - Mono-winforms-list at lists.ximian.com
More information about the Mono-devel-list