[cairo] How can I draw with a cairo_surface_t?

Boris Popov boris at deepcovelabs.com
Mon Jan 23 11:06:55 PST 2006

Meryl Silverburgh wrote:
> If I have a cairo_surface_t *, how can I draw with it?
> the cairo draw functions take a "cairo_t".

You'll need to create cairo_t via cairo_create, which is


cairo_t*   cairo_create   (cairo_surface_t *target);

Creates a new cairo_t with all graphics state parameters set to default 
values and with target as a target surface. The target surface should be 
constructed with a backend-specific function such as 
cairo_image_surface_create() (or any other 
cairo_<backend>_surface_create variant).

This function references target, so you can immediately call 
cairo_surface_destroy() on it if you don't need to maintain a separate 
reference to it.

target :     target surface for the context
Returns :     a newly allocated cairo_t with a reference count of 1. The 
initial reference count should be released with cairo_destroy() when you 
are done using the cairo_t. This function never returns NULL. If memory 
cannot be allocated, a special cairo_t object will be returned on which 
cairo_status() returns CAIRO_STATUS_NO_MEMORY. You can use this object 
normally, but no drawing will be done.




DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5

boris at deepcovelabs.com


This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any

Thank you.

More information about the cairo mailing list