emacs-diffs
[Top][All Lists]
Advanced

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

master a0c8c27: Fix loading multi-frame TIFF images via GDI+


From: Eli Zaretskii
Subject: master a0c8c27: Fix loading multi-frame TIFF images via GDI+
Date: Sat, 18 Apr 2020 05:45:06 -0400 (EDT)

branch: master
commit a0c8c274d354f3901f076d163d3828ae55d13a2d
Author: Juan José García-Ripoll <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix loading multi-frame TIFF images via GDI+
    
    * src/w32image.c (w32_frame_delay): Don't try to compute frame
    delay if GdipGetPropertyItemSize fails for PropertyTagFrameDelay.
    (w32_load_image): Don't add 'delay' member to metadata if the
    delay could not be determined.
---
 src/w32image.c | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/w32image.c b/src/w32image.c
index 0a2a55d..95d8ddf 100644
--- a/src/w32image.c
+++ b/src/w32image.c
@@ -245,27 +245,33 @@ w32_frame_delay (GpBitmap *pBitmap, int frame)
 {
   UINT size;
   PropertyItem *propertyItem;
-  double delay = 0.0;
+  double delay = -1.0;
 
   /* Assume that the image has a property item of type PropertyItemEquipMake.
-     Get the size of that property item.  */
-  GdipGetPropertyItemSize (pBitmap, PropertyTagFrameDelay, &size);
+     Get the size of that property item.  This can fail for multi-frame TIFF
+     images.  */
+  GpStatus status = GdipGetPropertyItemSize (pBitmap, PropertyTagFrameDelay,
+                                            &size);
 
-  /* Allocate a buffer to receive the property item.  */
-  propertyItem = malloc (size);
-  if (propertyItem != NULL)
+  if (status == Ok)
     {
-      /* Get the property item.  */
-      GdipGetPropertyItem (pBitmap, PropertyTagFrameDelay, size, propertyItem);
-      delay = decode_delay (propertyItem, frame);
-      if (delay <= 0)
-        {
-          /* In GIF files, unfortunately, delay is only specified for the first
-             frame.  */
-          delay = decode_delay (propertyItem, 0);
-        }
-      delay /= 100.0;
-      free (propertyItem);
+      /* Allocate a buffer to receive the property item.  */
+      propertyItem = malloc (size);
+      if (propertyItem != NULL)
+       {
+         /* Get the property item.  */
+         GdipGetPropertyItem (pBitmap, PropertyTagFrameDelay, size,
+                              propertyItem);
+         delay = decode_delay (propertyItem, frame);
+         if (delay <= 0)
+           {
+             /* In GIF files, unfortunately, delay is only specified
+                for the first frame.  */
+             delay = decode_delay (propertyItem, 0);
+           }
+         delay /= 100.0;
+         free (propertyItem);
+       }
     }
   return delay;
 }
@@ -372,7 +378,7 @@ w32_load_image (struct frame *f, struct image *img,
         {
           if (nframes > 1)
             metadata = Fcons (Qcount, Fcons (make_fixnum (nframes), metadata));
-          if (delay)
+          if (delay >= 0)
             metadata = Fcons (Qdelay, Fcons (make_float (delay), metadata));
         }
       else if (status == Win32Error) /* FIXME! */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]