[cairo] drawing a subimage

Jeff Bezanson jeffbez at comcast.net
Sun May 7 14:38:00 PDT 2006


First, thank you all for your excellent work on Cairo.
In my application, I need to draw part of an image. Something like
XCopyArea would be ideal, where you can specify a source width and
height. Right now I'm doing this with Cairo like so:

    cairo_rectangle(cr, 0, 0, w, h);
    cairo_set_source(cr, pt);
    cairo_matrix_init_translate(&matrix, xoffs, yoffs);
    cairo_pattern_set_matrix(pt, &matrix);

in other words clipping the output and shifting the image to draw only
the correct part of it. However, the performance I'm getting suggests
that the library (somewhere) is touching the entire image, since display
gets significantly slower as the image gets larger even though the
visible portion is the same size.

Searching the archives of this list I've seen the function
cairo_surface_clip_rectangle() mentioned, but it does not seem to exist.

Is there a better way to do this?

thank you,


More information about the cairo mailing list