[cairo] drawing inconsistency

Bill Spitzak spitzak at thefoundry.co.uk
Mon Jan 21 13:10:28 PST 2008



Adi Oanca wrote:

> IMO it should be like this: (at least that what I expect, but I can adapt)
> 
> -------------------------
> |   |   |   |   |   |   |
> -------------------------
> |   | + | - | - | + |   |
> -------------------------
> |   | | |   |   | | |   |
> -------------------------
> |   | + | - | - | + |   |
> -------------------------
> 
> The 1.0 horizontal(/vertical) line would go through the middle of the
> pixels. 0.5 would also paint the pixels at row 1, as it would 1.49.
> 0.9 would paint the pixel on line 0 and 1.50 the pixel on line 2.
> 
> I need pixel precision, so could you please point me to a
> page/document on how cairo maps logical coordinates to physical
> pixels?
> If there is none, then I hope you would not mind if we continue to
> discuss the information you gave me on your first reply. :)

It took awhile to figure this out, but I think you are talking about 
your expected results when antialiasing is turned off, which is that it 
should round edges of .5 right and down. Cairo may be using rint which 
has the unfortunate effect of rounding to the nearest even number. It is 
true that it should always round to the right/down in order to match 
other software and this is what you are requesting.

I believe the best way to use Cairo is to *not* turn antialiasing off, 
but to position the lines at .5 centers so they fill the pixels you 
want. This will allow your diagram to draw reasonably on other devices 
with other scales.


More information about the cairo mailing list