Re: cairo context for pixbuf



----- Original Message ----- Subject: Re: goocanvas vs crcanvas,which better?


Is there standard facility for creating cairo context for pixbuf? Like gdk_cairo_create() for drawables.

pixels = gdk_pixbuf_get_pixels (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
surface = cairo_image_surface_create_for_data (
 pixels,
 CAIRO_FORMAT_ARGB32,
 width, height, rowstride
);

This works if the the pixbuf has alpha;
the only flaw is that the red and blue component are exchanged,
so the function

cairo_set_source_rgb (cr, red, green, blue);

must be used as if it would be

cairo_set_source_rgb (cr, blue, green, red);

P.A.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]