[cairo] Trying to figure out some rasterization problems

Behdad Esfahbod behdad at behdad.org
Sun Apr 21 07:18:59 PDT 2013


Hi David,

Long time!  Comments below.

On 13-04-21 09:49 AM, David Kastrup wrote:
> 
> a) creating a path and filling it (or clipping with it) leads to results
> that are too thin on a subpixel base.
> 
> The PostScript/PDF imaging model is pretty clear about clip/fill
> regions: every pixel that has any part, no matter how small, inside of
> the path belongs to the region.  So if I am not using strokeadjust, and
> I am stroking a path, clipping by its outline is not supposed to change
> any pixel.  And using strokeadjust will only _reduce_ the area covered
> by a stroke, so again, clipping and stroking should not make a
> difference as opposed to only stroking.

You are jumping to conclusions here.  What's strokeadjust?  Cairo doesn't
implement PostScript/PDF exactly...


> Unfortunately, it _does_ make a difference.  Why do we care?  Because
> note stems are rectangles with rounded corners.  Not completely circular
> stroke ends, just rounded corners.  If we care for stroke adjustment
> (which we do), that means our actual shape needs to be represented as an
> intersection of a stroke-adjusted rectangle and clipping off the rounded
> corners.  That clipping apparently removes too much.  An easy solution
> appears to be to restroke the middle part of the rectangle without any
> clipping.  Which comes to problem b) which I think Cairo might be
> responsible for:

I still have no idea what you are talking about.  Perhaps some images would help?


> Now I can't figure out the strategy used by Cairo for antialiased
> rendering from the docs and code so far: is it drawing on a higher
> resolution canvas?  Or is it some heuristic juggling with greyness
> levels?  If the latter, what are the heuristics?

The latter.  The "independence" heuristic I'd call it.  Google for Porter-Duff.

-- 
behdad
http://behdad.org/


More information about the cairo mailing list