After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 74291 - Feature request: gdk_pixbuf_new_from_raw_data ()
Feature request: gdk_pixbuf_new_from_raw_data ()
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other All
: Normal enhancement
: ---
Assigned To: gdk-pixbuf-maint
gdk-pixbuf-maint
Depends on:
Blocks:
 
 
Reported: 2002-03-12 00:05 UTC by Bryan W. Headley
Modified: 2013-12-19 03:29 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
A possible initial implementation. (1.61 KB, patch)
2007-11-07 17:05 UTC, Ivan Baldo
none Details | Review
Implement pixbuf_new_from_buffer in gdk-pixbuf (2.64 KB, patch)
2008-10-20 12:06 UTC, Christian Dywan
none Details | Review

Description Bryan W. Headley 2002-03-12 00:05:55 UTC
Like to have convenience function that behaves like
gdk_pixbuf_new_from_file(), except uses in-memory buffer.

GdkPixbufLoader can do this, but I'm the third idiot who missed that in the
docs, and Havoc suggests maybe a convenience function do to this.

Alternative is better documentation around gdk_pixbuf_new_from_file(),
except that things will fall apart in function index. So maybe a function
is indeed the way to go..
Comment 1 Matthias Clasen 2002-09-11 13:36:22 UTC
How about 

GdkPixbuf *
gdk_pixbuf_new_from_io_channel (GIOChannel 
*channel, GError **error);

together with

GIOChannel 
*
g_io_channel_new_from_memory (gchar *mem, gsize size, gchar *mode);

This 
would even allow us to deprecate gdk_pixbuf_new_from_file in the long run.
Comment 2 Havoc Pennington 2002-09-11 14:29:03 UTC
Even with new_from_io_channel I'd keep new_from_file and add
new_from_memory, as the io_channel thing is fairly inconvenient.
Comment 3 Matthias Clasen 2002-09-11 14:40:31 UTC
Why are io channels inconvenient ? 

One argument for keeping new_from_file is 
that some image libs
only accept a FILE *, e.g. libtiff.
Comment 4 Havoc Pennington 2002-09-11 15:20:42 UTC
pixbuf = pixbuf_new_from_file() is just easier to 
learn and use than:

iochannel = iochannel_new_from_file()
pixbuf = pixbuf_new_from_iochannel()
iochannel_unref ()
Comment 5 Owen Taylor 2002-09-23 21:39:00 UTC
Shoving this one off; I think we have sufficient API work
for gdk-pixbuf for this release already.
Comment 6 Ivan Baldo 2007-11-07 17:05:48 UTC
Created attachment 98727 [details] [review]
A possible initial implementation.

I too think that a function like this would be practical and useful, so here is my incarnation.
Feel free to add to your programs or to GTK+ maybe.
Comment 7 Christian Dywan 2008-10-20 12:06:55 UTC
Created attachment 120921 [details] [review]
Implement pixbuf_new_from_buffer in gdk-pixbuf

I actually had a use for this code recently and now happen to find this bug while doing BugTriaging. So I implemented gdk_pixbuf_new_from_buffer in GdkPixbuf proper based on the example implementation.

I added a mime_type argument, since if you for instance need to load ICO files GdkPixbuf is likely to reject them as "unknown format", which would make the function only half as good without the argument.

If others would prefer a _new_with_buffer_and_mime_type instead, I can modify the patch appropriately but I'm not sure if that's needed. The current function accepts a NULL mime type which practicely means it will ignore it.
Comment 8 Matthias Clasen 2013-12-19 03:29:30 UTC
we have grown a variety of new api in this area in the meantime:
gdk_pixbuf_new_from_stream and variants. So I think this need has been addressed.