[cairo] Re: Options for disabling antialiasing (was: Re: Cairo developers conference call...)

Carl Worth cworth at cworth.org
Mon Oct 18 07:53:37 PDT 2004


On Mon, 18 Oct 2004 16:11:53 +0530, Ravindra wrote:
> Following is a URL where I have blogged about it with some screenshots,
> http://www.gnomebangalore.org/?q=node/view/495

Thank you very much for posting these screenshots. This helps make the
conversation much more concrete.

>                                                              Some of the
> differences that we want to bring out are, line thickness, line color
> (white does not come out as pure white), fonts, tick mark inside a
> checkbox (it's a line basically) etc. In simple words, our main concerns
> are drawing small font text and stroking thin lines.

Yes. To emulate those graphics precisely, you are wanting to draw
pixel-aligned lines with a width of 1 device pixel. You're instead
getting lines of a less saturated color, blurred over two pixels. This
is a frequent problem, so we recently added a FAQ to the web page with
the answer to just this one question:

	http://cairographics.org/FAQ

The answer here is not to "turn off antialiasing", but instead to adjust
your geometry as needed to align with the device pixels. I've put
together a little demo to show how this can be achieved with no changes
to cairo. I've attached source code and its output as a PNG image. The
code is also available in cairo-demo/png in CVS.

As can be seen in the image, the horizontal and vertical lines are drawn
precisely as desired. Additionally, the antialiasing actually improves
the rendering of the checkmark. So I consider thise result superior to
what result from new code to disable antialiasing in cairo.

The demo only deals with the geometry, not the text. (I didn't find the
rendering of the text in your screenshots objectionable.)

> I like the generic snapping approach with a switch, if it can fulfill
> our requirement of getting an output similar to MS. FYI, with MS GDI+,
> if we draw a 1-pixel line or 0 width line, we get one device pixel on
> the screen.

As I talk about in the comment in the sample code, it may still be
beneficial to add some automatic snapping to cairo. It would simply make
it easier to achieve effects such as this---and in particular, to
achieve these effects regardless of what scaling the current
transformation might be performing.

I hope this helps.

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bevels.png
Type: image/png
Size: 529 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20041018/6bf8814b/bevels.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bevels.c
Type: text/x-c
Size: 6458 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20041018/6bf8814b/bevels.bin


More information about the cairo mailing list