[cairo] [Cairo] Question about anti-alias

Andrea Canciani ranma42 at gmail.com
Mon Mar 21 00:04:24 PDT 2011


On Mon, Mar 21, 2011 at 6:18 AM, Taekyun Kim <podain77 at gmail.com> wrote:
> Hi,
>
> I have some questions about exact semantics of anti-alias.
>
> General anti-alias steps:
> 1. calculate coverage of a pixel
> 2. apply coverage to source pixel
> 3. composite with destination
>
> So my question is
>
> In step 2, how are the coverages applied to source pixels?

It depends on the operator: http://www.cairographics.org/operators/
The coverage is the mask, so it is basically used to "modulate" the
amount of source transferred to the destination.

> If the source pixel has no alpha (something like rgb_24), does cairo
> treat it same with rgba_32 with 1.0 alpha?

Yes

> Coverage will be multiplied to source alpha channel as well as source rgb
> color channels to keep them in premultiplied form, right?
This is exact for all operators except CLEAR and SOURCE.
They use the "Bounded" formula from http://www.cairographics.org/operators/,
so the mask is basically multiplied to the clip.

>
> In step 3, if the operator is SRC and the destination format is rgb_24, what
> about source pixels with coverage less than 1.0?
> They are blended or not?
> I think this is the same problem with compositing rgba_32(premultiplied) to
> rgb_24 with operator SRC.
> Are they converted into unpremultiplied form or just copyed rgb to rgb?

The are blended according to the formulas above.
No unpremultiplication is ever performed. If a partially transparent color is
painted to an opaque surface, the alpha channel is discarded, so it will end
up as if mixed with black.

>
> I think just turning on anti-alias should not cause huge visual difference.
> (that's just a hint as written in cairo API reference manual)

It should not. It should only affect the edges of the shapes you fill/stroke.

Andrea
>
> Thanks in advance.
> --
> Best Regards,
> Taekyun Kim
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list