Bug 12395 - Support for writing to GdkPixbufs.
Summary: Support for writing to GdkPixbufs.
Status: RESOLVED WONTFIX
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.5.1
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-11 13:03 UTC by Björn Lindqvist
Modified: 2008-10-10 05:36 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Björn Lindqvist 2007-09-11 13:03:10 UTC
Lots of API:s uses GdkPixbufs. So I would like to be able to use cairo to write on GdkPixbufs. It could be accomplished by adding CAIRO_FORMAT_PIXBUF_RGB and CAIRO_FORMAT_PIXBUF_RGBA to cairo_format_t. Then you could wrap your pixbuf in an ImageSurface with:

cairo_image_surface_create_for_data(gdk_pixbuf_get_pixels(pixbuf),
                                    CAIRO_FORMAT_PIXBUF_RGB,
                                    gdk_pixbuf_get_width(pixbuf),
                                    gdk_pixbuf_get_height(pixbuf),
                                    gdk_pixbuf_get_rowstride(pixbuf));
Comment 1 Behdad Esfahbod 2007-09-11 13:06:04 UTC
Problem is, pixbufs use non-premultiplied alpha while cairo uses premultiplied.  We don't have the drawing code to deal with non-premultiplied.  The only way to draw to pixbufs is to convert back and forth.

This all may change in the future when we switch to a jitblt pixman.  But not soon.
Comment 2 Björn Lindqvist 2007-09-17 12:17:17 UTC
I understand, that's a good reason. But if cairo can not support GdkPixbufs natively, I think it should still be able to export and import them. Cairo seem to be a superior alternative to GDK, but it is very hard to port existing API:s using GdkPixbuf to Cairo because you want to keep compatibility. For example, GtkSelectionData that has the methods get_pixbuf() and set_pixbuf() could use an cairo ImageSurface internally and then use the import and export functions.

I know that it is not that hard to write the functions yourself, but it would really help if cairo had some highly optimized and screamingly fast functions for it.

Comment 3 Chris Wilson 2008-10-10 05:13:42 UTC
But hasn't the precedent been set for GDK to create cairo surfaces from Pixbufs. This seems to be the sensible approach to leave cairo as the low-level library for interfacing with the various target devices and leave GdkPixbuf as the library for manipulating pixel data (which should mirror cairo and provide pre-multiplied ARGB if wants to ultimately push pixels to hardware).

Closing as WONTFIX is a purely personal opinion from a cairo PoV. I suggest to raise the topic once again on the various gnome developer lists and the cairo mailing list to encourage a resolution to this long standing issue.
Comment 4 Björn Lindqvist 2008-10-10 05:36:42 UTC
Yup, that is more sensible. Especially since GdkPixbufs unpadded RGB and RGBA formats are quite uncommon. But the problem is still there and it is still hard to integrate cairo with gdk. Unfortunately no one seems to be willing to work on any solution. :(


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.