diff options
| author | Juan José García-Ripoll | 2020-04-18 10:41:42 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2020-04-18 12:43:51 +0300 |
| commit | a0c8c274d354f3901f076d163d3828ae55d13a2d (patch) | |
| tree | f8ed610496670261c87148037800b3a68928db8a /src | |
| parent | 93decaa131e3fc9de27b4f1fd5b56dc5f78ff198 (diff) | |
| download | emacs-a0c8c274d354f3901f076d163d3828ae55d13a2d.tar.gz emacs-a0c8c274d354f3901f076d163d3828ae55d13a2d.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32image.c | 42 |
1 files changed, 24 insertions, 18 deletions
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) | |||
| 245 | { | 245 | { |
| 246 | UINT size; | 246 | UINT size; |
| 247 | PropertyItem *propertyItem; | 247 | PropertyItem *propertyItem; |
| 248 | double delay = 0.0; | 248 | double delay = -1.0; |
| 249 | 249 | ||
| 250 | /* Assume that the image has a property item of type PropertyItemEquipMake. | 250 | /* Assume that the image has a property item of type PropertyItemEquipMake. |
| 251 | Get the size of that property item. */ | 251 | Get the size of that property item. This can fail for multi-frame TIFF |
| 252 | GdipGetPropertyItemSize (pBitmap, PropertyTagFrameDelay, &size); | 252 | images. */ |
| 253 | GpStatus status = GdipGetPropertyItemSize (pBitmap, PropertyTagFrameDelay, | ||
| 254 | &size); | ||
| 253 | 255 | ||
| 254 | /* Allocate a buffer to receive the property item. */ | 256 | if (status == Ok) |
| 255 | propertyItem = malloc (size); | ||
| 256 | if (propertyItem != NULL) | ||
| 257 | { | 257 | { |
| 258 | /* Get the property item. */ | 258 | /* Allocate a buffer to receive the property item. */ |
| 259 | GdipGetPropertyItem (pBitmap, PropertyTagFrameDelay, size, propertyItem); | 259 | propertyItem = malloc (size); |
| 260 | delay = decode_delay (propertyItem, frame); | 260 | if (propertyItem != NULL) |
| 261 | if (delay <= 0) | 261 | { |
| 262 | { | 262 | /* Get the property item. */ |
| 263 | /* In GIF files, unfortunately, delay is only specified for the first | 263 | GdipGetPropertyItem (pBitmap, PropertyTagFrameDelay, size, |
| 264 | frame. */ | 264 | propertyItem); |
| 265 | delay = decode_delay (propertyItem, 0); | 265 | delay = decode_delay (propertyItem, frame); |
| 266 | } | 266 | if (delay <= 0) |
| 267 | delay /= 100.0; | 267 | { |
| 268 | free (propertyItem); | 268 | /* In GIF files, unfortunately, delay is only specified |
| 269 | for the first frame. */ | ||
| 270 | delay = decode_delay (propertyItem, 0); | ||
| 271 | } | ||
| 272 | delay /= 100.0; | ||
| 273 | free (propertyItem); | ||
| 274 | } | ||
| 269 | } | 275 | } |
| 270 | return delay; | 276 | return delay; |
| 271 | } | 277 | } |
| @@ -372,7 +378,7 @@ w32_load_image (struct frame *f, struct image *img, | |||
| 372 | { | 378 | { |
| 373 | if (nframes > 1) | 379 | if (nframes > 1) |
| 374 | metadata = Fcons (Qcount, Fcons (make_fixnum (nframes), metadata)); | 380 | metadata = Fcons (Qcount, Fcons (make_fixnum (nframes), metadata)); |
| 375 | if (delay) | 381 | if (delay >= 0) |
| 376 | metadata = Fcons (Qdelay, Fcons (make_float (delay), metadata)); | 382 | metadata = Fcons (Qdelay, Fcons (make_float (delay), metadata)); |
| 377 | } | 383 | } |
| 378 | else if (status == Win32Error) /* FIXME! */ | 384 | else if (status == Win32Error) /* FIXME! */ |