[gimp] Bug 773450 - Animated WEBP images should be able to set frame delay...



commit 5e6a1083fd7f707f178a6786fed35b9aec1f5e4e
Author: Pascal Massimino <pascal massimino gmail com>
Date:   Tue Nov 8 17:21:55 2016 +0100

    Bug 773450 - Animated WEBP images should be able to set frame delay...
    
    ...in the export dialog
    
    Read back timestamps into layer names. Adds the exact duration to the
    layer names. Previously, they were not reloaded correctly.

 plug-ins/file-webp/file-webp-load.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/file-webp/file-webp-load.c b/plug-ins/file-webp/file-webp-load.c
index af335cb..72372c3 100644
--- a/plug-ins/file-webp/file-webp-load.c
+++ b/plug-ins/file-webp/file-webp-load.c
@@ -158,7 +158,8 @@ load_image (const gchar *filename,
       WebPAnimInfo           anim_info;
       WebPAnimDecoderOptions dec_options;
       gint                   frame_num = 1;
-
+      WebPDemuxer           *demux     = NULL;
+      WebPIterator           iter      = { 0, };
 
       if (! WebPAnimDecoderOptionsInit (&dec_options))
         {
@@ -166,6 +167,12 @@ load_image (const gchar *filename,
           if (dec)
             WebPAnimDecoderDelete (dec);
 
+          if (demux)
+            {
+              WebPDemuxReleaseIterator (&iter);
+              WebPDemuxDelete (demux);
+            }
+
           return -1;
         }
 
@@ -187,6 +194,10 @@ load_image (const gchar *filename,
           goto error;
         }
 
+      demux = WebPDemux (&wp_data);
+      if (! demux || ! WebPDemuxGetFrame (demux, 1, &iter))
+        goto error;
+
       /* Attempt to decode the data as a WebP animation image */
       while (WebPAnimDecoderHasMoreFrames (dec))
         {
@@ -202,14 +213,17 @@ load_image (const gchar *filename,
               goto error;
             }
 
-          name = g_strdup_printf (_("Frame %d"), frame_num);
+          name = g_strdup_printf (_("Frame %d (%dms)"), frame_num, iter.duration);
           create_layer (image_ID, outdata, 0, name, width, height);
           g_free (name);
 
           frame_num++;
+          WebPDemuxNextFrame (&iter);
         }
 
       WebPAnimDecoderDelete (dec);
+      WebPDemuxReleaseIterator (&iter);
+      WebPDemuxDelete (demux);
     }
 
   /* Free the original compressed data */


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