[Cairo] Image functions

Carl Worth cworth at east.isi.edu
Wed Oct 15 08:46:33 PDT 2003

On Oct 14, Alexandre Pigolkine wrote:
 > I think that cairo_move_to specifies a position on the destination
 > surface where to put a bitmap and I am missing a way to 
 > specify a position on the source surface from where to start.
 > Something like:
 > copy from source pos xs, ys, width, height to 
 > destination pos xd,yd. 

Ah, I see what you want. And yes, cairo_show_surface is a rather
fixed-purpose convenience function. You can get more general behavior
by instead using cairo_set_pattern followed by cairo_fill.

For example, this function should do something like what you want:

	show_partial_image (cairo_t *cr, cairo_surface_t *surface,
			    int x_source, int y_source,
			    int width, int height,
			    int x_dest, int y_dest)
	    cairo_move_to (cr, x_dest-x_source, y_dest-y_source);
	    cairo_set_pattern (cr, surface);
	    cairo_rectangle (cr, x_dest, y_dest, width, height);
	    cairo_fill (cr);

Even more general effects can be obtained by using


PS. It may make sense to implement cairo_show_surface with code similar
to the above. This would let us simplify the surface backend interface
by dropping _cairo_surface_composite and instead force all drawing
through _cairo_surface_composite_trapezoids.

More information about the cairo mailing list