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 | |
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
-rw-r--r-- | docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt | 1 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-loader.c | 36 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-loader.h | 3 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.symbols | 1 |
4 files changed, 41 insertions, 0 deletions
diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt index 97085d2f0..3b087b105 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt @@ -213,6 +213,7 @@ gdk_pixbuf_loader_new_with_type gdk_pixbuf_loader_new_with_mime_type gdk_pixbuf_loader_get_format gdk_pixbuf_loader_write +gdk_pixbuf_loader_write_bytes gdk_pixbuf_loader_set_size gdk_pixbuf_loader_get_pixbuf gdk_pixbuf_loader_get_animation 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. diff --git a/gdk-pixbuf/gdk-pixbuf-loader.h b/gdk-pixbuf/gdk-pixbuf-loader.h index c9a161239..c71f3ca4e 100644 --- a/gdk-pixbuf/gdk-pixbuf-loader.h +++ b/gdk-pixbuf/gdk-pixbuf-loader.h @@ -94,6 +94,9 @@ gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, gsize count, GError **error); +gboolean gdk_pixbuf_loader_write_bytes (GdkPixbufLoader *loader, + GBytes *buffer, + GError **error); GdkPixbuf * gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader); GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader); gboolean gdk_pixbuf_loader_close (GdkPixbufLoader *loader, diff --git a/gdk-pixbuf/gdk-pixbuf.symbols b/gdk-pixbuf/gdk-pixbuf.symbols index bd98d4db6..66ef07b45 100644 --- a/gdk-pixbuf/gdk-pixbuf.symbols +++ b/gdk-pixbuf/gdk-pixbuf.symbols @@ -199,6 +199,7 @@ gdk_pixbuf_loader_new_with_mime_type gdk_pixbuf_loader_new_with_type gdk_pixbuf_loader_set_size gdk_pixbuf_loader_write +gdk_pixbuf_loader_write_bytes #endif #endif |