[cairo] Starting from something other than the origin of a source surface

Matt Hoosier matt.hoosier at gmail.com
Thu Oct 23 08:42:02 PDT 2008


Hi,

I have what feels like an obvious question, but I'm having trouble to locate
the API that does what I want.

Suppose I have some arbitrary pre-drawn data in a cairo_surface_t. I want to
blit some subrectangle not starting at the origin of this source surface,
into the target cairo_t.

The setup for this looks like:

    /* pre-existing source image */
    cairo_surface_t *source;

    cairo_t *cr = ....; /* hook up to your window system */

    /* Restrict size of paint to subrectangle requested */
    cairo_rectangle(cr, dest_x, dest_y, width, height);
    cairo_clip(cr);

    cairo_set_source_surface(cr, source, dest_x, dest_y);

    cairo_paint(cr);


But this always takes a subrectangle of source starting at (0, 0). It feels
like I want to supply an extra X,Y pair to cairo_set_source_surface() that
tells where in the source image to begin blitting. But the parameters
allowed just affect the output translation.

Am I missing something?


--Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20081023/3b55b8b5/attachment.htm 


More information about the cairo mailing list