diff options
author | Benjamin Otte <otte@redhat.com> | 2013-01-30 15:09:08 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-01-30 15:09:08 +0100 |
commit | 38fe0dd043de3503462aea1c425368d31a1e61cc (patch) | |
tree | 10e25ccb810ae20cc500ea8836ba40c67ccc3160 | |
parent | cf8fdae73bfa959748a6fc6eec26a7d3fc6b3e2d (diff) | |
download | gdk-pixbuf-38fe0dd043de3503462aea1c425368d31a1e61cc.tar.gz |
io: Split out a function for use by animations
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 53 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-private.h | 2 |
2 files changed, 34 insertions, 21 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 2dc7cd8f0..dac21b8fa 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -1646,29 +1646,9 @@ gdk_pixbuf_new_from_stream (GInputStream *stream, return pixbuf; } -/** - * gdk_pixbuf_new_from_resource: - * @resource_path: the path of the resource file - * @error: Return location for an error - * - * Creates a new pixbuf by loading an image from an resource. - * - * The file format is detected automatically. If %NULL is returned, then - * @error will be set. - * - * Return value: A newly-created pixbuf, or %NULL if any of several error - * conditions occurred: the file could not be opened, the image format is - * not supported, there was not enough memory to allocate the image buffer, - * the stream contained invalid data, or the operation was cancelled. - * - * Since: 2.26 - **/ GdkPixbuf * -gdk_pixbuf_new_from_resource (const char *resource_path, - GError **error) +_gdk_pixbuf_new_from_resource_try_mmap (const char *resource_path) { - GInputStream *stream; - GdkPixbuf *pixbuf; guint32 flags; gsize data_size; GBytes *bytes; @@ -1699,6 +1679,37 @@ gdk_pixbuf_new_from_resource (const char *resource_path, } } + return NULL; +} + +/** + * gdk_pixbuf_new_from_resource: + * @resource_path: the path of the resource file + * @error: Return location for an error + * + * Creates a new pixbuf by loading an image from an resource. + * + * The file format is detected automatically. If %NULL is returned, then + * @error will be set. + * + * Return value: A newly-created pixbuf, or %NULL if any of several error + * conditions occurred: the file could not be opened, the image format is + * not supported, there was not enough memory to allocate the image buffer, + * the stream contained invalid data, or the operation was cancelled. + * + * Since: 2.26 + **/ +GdkPixbuf * +gdk_pixbuf_new_from_resource (const char *resource_path, + GError **error) +{ + GInputStream *stream; + GdkPixbuf *pixbuf; + + pixbuf = _gdk_pixbuf_new_from_resource_try_mmap (resource_path); + if (pixbuf) + return pixbuf; + stream = g_resources_open_stream (resource_path, 0, error); if (stream == NULL) return NULL; diff --git a/gdk-pixbuf/gdk-pixbuf-private.h b/gdk-pixbuf/gdk-pixbuf-private.h index 001e747ee..e13426d91 100644 --- a/gdk-pixbuf/gdk-pixbuf-private.h +++ b/gdk-pixbuf/gdk-pixbuf-private.h @@ -100,6 +100,8 @@ GdkPixbufFormat *_gdk_pixbuf_get_format (GdkPixbufModule *image_module); #endif /* GDK_PIXBUF_ENABLE_BACKEND */ +GdkPixbuf * _gdk_pixbuf_new_from_resource_try_mmap (const char *resource_path); + #endif /* GDK_PIXBUF_PRIVATE_H */ |