diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2013-03-30 17:48:33 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2013-03-30 19:17:00 +0000 |
commit | 7e5ee66091e17fb006d4933a3634083d09666862 (patch) | |
tree | 1c4ef01c0c3543c0a0a40d0da6412ef9a0e11a91 /gdk-pixbuf/gdk-pixbuf-loader.c | |
parent | 09032b0d635498779df97414fbffc890a29245e6 (diff) | |
download | gdk-pixbuf-7e5ee66091e17fb006d4933a3634083d09666862.tar.gz |
loader: Add gdk_pixbuf_loader_write_bytes()
A GBytes variant to gdk_pixbuf_loader_write(), which allows language
bindings to actually be able to use the Gio GInputStream.read_bytes()
method with GdkPixbufLoader.
https://bugzilla.gnome.org/show_bug.cgi?id=696917
Diffstat (limited to 'gdk-pixbuf/gdk-pixbuf-loader.c')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-loader.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c index 2461ec42e..9acb10deb 100644 --- a/gdk-pixbuf/gdk-pixbuf-loader.c +++ b/gdk-pixbuf/gdk-pixbuf-loader.c @@ -544,6 +544,42 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader, } /** + * gdk_pixbuf_loader_write_bytes: + * @loader: A pixbuf loader. + * @buffer: The image data as a #GBytes + * @error: return location for errors + * + * This will cause a pixbuf loader to parse a buffer inside a #GBytes + * for an image. It will return %TRUE if the data was loaded successfully, + * and %FALSE if an error occurred. In the latter case, the loader + * will be closed, and will not accept further writes. If %FALSE is + * returned, @error will be set to an error from the #GDK_PIXBUF_ERROR + * or #G_FILE_ERROR domains. + * + * See also: gdk_pixbuf_loader_write() + * + * Return value: %TRUE if the write was successful, or %FALSE if the loader + * cannot parse the buffer. + * + * Since: 2.30 + */ +gboolean +gdk_pixbuf_loader_write_bytes (GdkPixbufLoader *loader, + GBytes *buffer, + GError **error) +{ + g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), FALSE); + + g_return_val_if_fail (buffer != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + return gdk_pixbuf_loader_write (loader, + g_bytes_get_data (buffer, NULL), + g_bytes_get_size (buffer), + error); +} + +/** * gdk_pixbuf_loader_new: * * Creates a new pixbuf loader object. |