[cairo] rotating GdkPixbuf with cairo
LRN
lrn1986 at gmail.com
Tue Apr 1 09:49:11 PDT 2008
I want to load image from file into pixbuf, apply some cairo
transformations to it (for example - cairo_rotate) and then save it back
into file. Is it possible to use cairo in that way, or cairo_rotate
works only on vector objects?
I tried this:
GdkPixbuf *pbuf = gdk_pixbuf_new_from_file("g.png",NULL);
int width = gdk_pixbuf_get_width(pbuf);
int height = gdk_pixbuf_get_height(pbuf);
cairo_surface_t *srf =
cairo_image_surface_create(CAIRO_FORMAT_RGB24,width,height);
cairo_t *cr = cairo_create(srf);
gdk_cairo_set_source_pixbuf(cr, pbuf, 0, 0);
cairo_translate(cr,width,0);
cairo_rotate(cr,M_PI/4);
cairo_paint(cr);
cairo_destroy(cr);
gdk_pixbuf_save(pbuf,"g_rotated.png","png",NULL);
but resulting file is the same as source file. Did i missed something?
More information about the cairo
mailing list