[cairo] Drawing diagonal lines with antialiasing off
Jonathan S. Chambers
Jonathan.Chambers at ansys.com
Tue Oct 18 12:02:36 PDT 2005
Carl,
I would be glad to work on this part of the code if some direction is given.
You previously mentioned 3 points for non-AA drawing:
<Carl>
There are at least three things that will have to be right if you want to get nice-looking non-antialiased lines:
1) The lines will have to be positioned properly with respect to the
device pixel grid, (that is, likely centered on half-integer
coordinates for width 1 lines). So that's a matter of the
application code getting things right.
2) A correct implementation of Hobby's pen polygons. If you're just
dropping in his explicit pens, that should be working fine.
3) Appropriately careful rasterization. There are some edge conditions
that need to be just right here. I don't know that the depth 1
rasterization implementation has ever been carefully examined to
provide the result you'll want here.
</Carl>
Point 3 is where I could use some advice, if anyone is offering.
- Jonathan
-----Original Message-----
From: cairo-bounces at cairographics.org [mailto:cairo-bounces at cairographics.org] On Behalf Of Carl Worth
Sent: Tuesday, October 18, 2005 2:41 PM
To: Øyvind Kolås
Cc: cairo at cairographics.org; Jordi Mas
Subject: Re: [cairo] Drawing diagonal lines with antialiasing off
On Tue, 27 Sep 2005 10:55:37 +0200, Øyvind Kolås wrote:
> On 9/27/05, Jordi Mas <jordi at ximian.com> wrote:
> >
> > When turning off the antialiasing (CAIRO_ANTIALIAS_NONE) and drawing a
> > vertical line, it gets rendered as two pixel width instead of one.
> > Is there any way using a cairo function to override this behaviour?
> >
> > I'm attaching a very simple case to reproduce the issue and the
> > generated image.
>
> Your issue is very related to the first entry in the FAQ[1]. Changing
> your code to:
>
> ...
> cairo_move_to (cr, 5.0, 5.5);
> cairo_move_to (cr, 10.0, 10.5);
> ...
>
> Will render the image you expect.
I think there's another issue here. The rounding rules for
rasterization of trapezoids to an A1 mask should yield a 1-pixel-wide
result even with the original code.
I think that details of non-antialiased rendering just haven't been
dealt with very carefully yet. (Personally, I've been leaving the work
to improve the quality of that drawing to those who care more about
it.)
-Carl
More information about the cairo
mailing list