[gdk-pixbuf] gif: Fix thumbnailing GIF animations



commit 04c02024fcfbbe99901020ed7074bf177cf90d7d
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Sep 26 19:50:25 2015 +0200

    gif: Fix thumbnailing GIF animations
    
    When using progressive loading, the GIF loader seems to expect us to
    load every single frame of the image before being "done". That's really
    not the case when thumbnailing, as we only want the first frame in that
    case.
    
    Return the GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION error when not all the
    frames have been decoded, so that users of the API can ignore it, like
    gnome-desktop's thumbnailer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755672

 gdk-pixbuf/gdk-pixbuf-core.h |    4 +++-
 gdk-pixbuf/io-gif.c          |   11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-core.h b/gdk-pixbuf/gdk-pixbuf-core.h
index c4726d1..5d41a15 100644
--- a/gdk-pixbuf/gdk-pixbuf-core.h
+++ b/gdk-pixbuf/gdk-pixbuf-core.h
@@ -192,6 +192,7 @@ typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
  * @GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: Don't know how to perform the
  *  given operation on the type of image at hand.
  * @GDK_PIXBUF_ERROR_FAILED: Generic failure code, something went wrong.
+ * @GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION: Only part of the animation was loaded.
  * 
  * An error code in the #GDK_PIXBUF_ERROR domain. Many gdk-pixbuf
  * operations can cause errors in this domain, or in the #G_FILE_ERROR
@@ -208,7 +209,8 @@ typedef enum {
         GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
         /* unsupported operation (load, save) for image type */
         GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
-        GDK_PIXBUF_ERROR_FAILED
+        GDK_PIXBUF_ERROR_FAILED,
+        GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION
 } GdkPixbufError;
 
 GQuark gdk_pixbuf_error_quark (void);
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 1ce9dfd..00d18e2 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -1556,15 +1556,22 @@ gdk_pixbuf__gif_image_stop_load (gpointer data, GError **error)
        GifContext *context = (GifContext *) data;
         gboolean retval = TRUE;
         
-        if (context->state != GIF_DONE || context->animation->frames == NULL) {
+        if (context->animation->frames == NULL) {
                 g_set_error_literal (error,
                                      GDK_PIXBUF_ERROR,
                                      GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
                                      _("GIF image was truncated or incomplete."));
 
                 retval = FALSE;
+        } else if (context->state != GIF_DONE) {
+                g_set_error_literal (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION,
+                                     _("Not all frames of the GIF image were loaded."));
+
+                retval = FALSE;
         }
-        
+
         g_object_unref (context->animation);
 
        g_free (context->buf);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]