I am trying to read an image from an internet URL. Wouldn’t know what it’s type is, so cannot know any metadata about it. Tried reading the image using "soup_session_send_and_read_{async,finish}" which returns a GBytes*. However this cannot be directly used in "gdk_pixbuf_new_from_bytes()", as "gdk_pixbuf_new_from_bytes()" needs lot of image specific metadata to be passed to it.
Why cannot gdk_pixbuf_new_from_bytes() detect all metadata from the "Bytes*" in-memory buffer, when "gdk_pixbuf_new_from_stream()" can do it ?
I currently use "g_memory_input_stream_new_from_bytes()" to build a stream out of the "Bytes*" buffer and use "gdk_pixbuf_new_from_stream()", so it works.
But still want to understand what’s the actual use of "gdk_pixbuf_new_from_bytes()" ?
The new_from_bytes() constructor is convenience around the new_from_data() constructor; both constructors take a buffer of “image data in 8-bit/sample packed format”, as the documentation says. In other words: the new_from_bytes() constructor expects the actual RGBA pixel data, not an encoded image data format.
In GIO, generally there are a lot of constructors of the form "Foo.new_from_sourceX()", "Foo.new_from_sourceY()" etc, which normally gives the impression that the Foo data-sink object supports reading data bytes from different sources.
But, "new_from_bytes()" / "new_from_data()" names are generic but they’re not. They are totally specialized functions which expect raw uncompressed / un-encoded RGBA pixel data. The point that these are grouped with generic "new_from_stream()" / "new_from_file()" is what is confusing here.
Ideally, "new_from_bytes()" name should be given to a constructor which does