[cairo] Drawing selected data?

Ian Britten britten at caris.com
Mon Feb 9 06:17:16 PST 2009

Ian Britten wrote:
> Question:
> If I have a second surface containing the polygon (Which I assume
> would be full-colour), is there a way I can render that on the
> first surface such that it behaves as if it was 1-bit data, using
> a single (different) colour and an alpha?

In case anyone is wondering, here's what I came up with (cairomm)

        // Draw selected data to 'selectionSurface', as desired

        finalContext->set_source_rgba(r, g, b, a);
        finalContext->mask(selectionSurface, 0, 0);

Pretty straightforward, once you know how!

In a usage like this, where I just want my 'selectionSurface' to be
1-bit data, would it make sense to expose some sort of
CAIRO_CONTENT_A1 option for cairo_surface_create_similar(), similar
to the existing CAIRO_FORMAT_A1 parameter to
When working with huge surfaces, and only 1-bit capabilities are
needed, I'd think it could/would represent a large memory savings.

Anyways, just a thought...

More information about the cairo mailing list