From a5b5f73f32a8af8a45a252ed13a381d7526ad1b7 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Thu, 15 Aug 2013 19:20:06 +0200 Subject: [PATCH] (imagemagick_compute_animated_image): Respect the GIF disposal methods. --- src/ChangeLog | 5 +++++ src/image.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c12b32ebc71..028c33848a4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-08-15 Lars Magne Ingebrigtsen + + * image.c (imagemagick_compute_animated_image): Respect the GIF + disposal methods. + 2013-08-15 Ken Brown * emacs.c (main): Update comment about G_SLICE_ALWAYS_MALLOC. diff --git a/src/image.c b/src/image.c index 3cab72edf74..3c5ee4ce66f 100644 --- a/src/image.c +++ b/src/image.c @@ -7887,17 +7887,20 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) else composite_wand = animation_cache; - for (i = max (1, animation_index); i <= ino; i++) + for (i = max (1, animation_index + 1); i <= ino; i++) { MagickWand *sub_wand; PixelIterator *source_iterator, *dest_iterator; PixelWand **source, **dest; size_t source_width, dest_width; MagickPixelPacket pixel; + DisposeType dispose; MagickSetIteratorIndex (super_wand, i); sub_wand = MagickGetImage (super_wand); + dispose = MagickGetImageDispose (sub_wand); + source_iterator = NewPixelIterator (sub_wand); if (! source_iterator) { @@ -7926,12 +7929,20 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); for (x = 0; x < source_width; x++) { - /* Copy over non-transparent pixels. */ - if (PixelGetAlpha (source[x])) + if (dispose == BackgroundDispose) { PixelGetMagickColor (source[x], &pixel); PixelSetMagickColor (dest[x], &pixel); } + else + { + /* Copy over non-transparent pixels. */ + if (PixelGetAlpha (source[x])) + { + PixelGetMagickColor (source[x], &pixel); + PixelSetMagickColor (dest[x], &pixel); + } + } } PixelSyncIterator(dest_iterator); } -- 2.39.2