From: Juan José García-Ripoll Date: Sat, 18 Apr 2020 08:41:42 +0000 (+0200) Subject: Fix loading multi-frame TIFF images via GDI+ X-Git-Tag: emacs-28.0.90~7553 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a0c8c274d354f3901f076d163d3828ae55d13a2d;p=emacs.git 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. --- diff --git a/src/w32image.c b/src/w32image.c index 0a2a55d3f6f..95d8ddfe117 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! */