diff options
author | Matthias Clasen <maclas@gmx.de> | 2003-11-09 22:08:33 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-11-09 22:08:33 +0000 |
commit | 95f163d7d2201eb06913cd39c991c21970ac9c32 (patch) | |
tree | 149ec6b1bf2208c6e9671d8a956db763407b9103 /gdk-pixbuf | |
parent | 0af9579ea253ccccd24c31f30827ee99150386f6 (diff) | |
download | gtk+-95f163d7d2201eb06913cd39c991c21970ac9c32.tar.gz |
If neither load nor begin_load are available fall back to load_animation
Sun Nov 9 23:07:05 2003 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-io.c (_gdk_pixbuf_generic_image_load): If neither
load nor begin_load are available fall back to load_animation
and use gdk_pixbuf_animation_get_static_image() to obtain a
pixbuf. Inefficient, but at least doesn't crash.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 7 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 57 |
2 files changed, 45 insertions, 19 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index f5747e2eaa..929904a098 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,10 @@ +Sun Nov 9 23:07:05 2003 Matthias Clasen <maclas@gmx.de> + + * gdk-pixbuf-io.c (_gdk_pixbuf_generic_image_load): If neither + load nor begin_load are available fall back to load_animation + and use gdk_pixbuf_animation_get_static_image() to obtain a + pixbuf. Inefficient, but at least doesn't crash. + Sun Nov 9 21:56:20 2003 Matthias Clasen <maclas@gmx.de> * queryloaders.c (write_loader_info): New function to write diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index f77c2bebcb..dc96b44d28 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -647,34 +647,53 @@ _gdk_pixbuf_generic_image_load (GdkPixbufModule *module, guchar buffer[4096]; size_t length; GdkPixbuf *pixbuf = NULL; + GdkPixbufAnimation *animation = NULL; gpointer context; if (module->load != NULL) return (* module->load) (f, error); - context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error); - - if (!context) - return NULL; + if (module->begin_load != NULL) { + + context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error); - while (!feof (f)) { - length = fread (buffer, 1, sizeof (buffer), f); - if (length > 0) - if (!module->load_increment (context, buffer, length, error)) { - module->stop_load (context, NULL); - if (pixbuf != NULL) - g_object_unref (pixbuf); - return NULL; - } + if (!context) + return NULL; + + while (!feof (f)) { + length = fread (buffer, 1, sizeof (buffer), f); + if (length > 0) + if (!module->load_increment (context, buffer, length, error)) { + module->stop_load (context, NULL); + if (pixbuf != NULL) + g_object_unref (pixbuf); + return NULL; + } + } + + if (!module->stop_load (context, error)) { + if (pixbuf != NULL) + g_object_unref (pixbuf); + return NULL; + } + + return pixbuf; } + + if (module->load_animation != NULL) { + animation = (* module->load_animation) (f, error); + if (animation != NULL) { + pixbuf = gdk_pixbuf_animation_get_static_image (animation); - if (!module->stop_load (context, error)) { - if (pixbuf != NULL) - g_object_unref (pixbuf); - return NULL; + g_object_ref (pixbuf); + + g_object_unref (animation); + + return pixbuf; + } } - - return pixbuf; + + return NULL; } /** |