[cairo] Crop a picture/surface

Kalle Vahlman kalle.vahlman at gmail.com
Thu Nov 22 02:46:59 PST 2007


2007/11/22, Nguyen Vu Hung <vuhung16plus at gmail.com>:
> Hi all,
>
> To crop an image, currently I have to pass a surface from cairo to
> GraphicsMagick and use GM's crop() method to crop it.
>
> For example, GM's crop can be used to crop a 300x500 pixel sub-picture
> from a 600x800 picture.
>
> I wonder if this can be done with cairo? If we can, then how?

AFAIK, you'll need to create a new surface, set up the desired
transformation and paint() the old surface to it.

In the generic case[1], there is no way to resize a surface in cairo.

[1] Some surface types have size-related functions (like the xlib
surface) but they are not useful for general-purpose cropping

-- 
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi


More information about the cairo mailing list