diff options
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 86 |
1 files changed, 45 insertions, 41 deletions
diff --git a/src/image.c b/src/image.c index 21b6f8979ee..3cab72edf74 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7877,6 +7877,7 @@ static int animation_index = 0; | |||
| 7877 | static MagickWand * | 7877 | static MagickWand * |
| 7878 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | 7878 | imagemagick_compute_animated_image (MagickWand *super_wand, int ino) |
| 7879 | { | 7879 | { |
| 7880 | int i; | ||
| 7880 | MagickWand *composite_wand; | 7881 | MagickWand *composite_wand; |
| 7881 | 7882 | ||
| 7882 | MagickSetIteratorIndex (super_wand, 0); | 7883 | MagickSetIteratorIndex (super_wand, 0); |
| @@ -7886,56 +7887,59 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) | |||
| 7886 | else | 7887 | else |
| 7887 | composite_wand = animation_cache; | 7888 | composite_wand = animation_cache; |
| 7888 | 7889 | ||
| 7889 | for (int i = max (1, animation_index); i <= ino; i++) { | 7890 | for (i = max (1, animation_index); i <= ino; i++) |
| 7890 | MagickWand *sub_wand; | 7891 | { |
| 7891 | PixelIterator *source_iterator, *dest_iterator; | 7892 | MagickWand *sub_wand; |
| 7892 | PixelWand **source, **dest; | 7893 | PixelIterator *source_iterator, *dest_iterator; |
| 7893 | size_t source_width, dest_width; | 7894 | PixelWand **source, **dest; |
| 7894 | MagickPixelPacket pixel; | 7895 | size_t source_width, dest_width; |
| 7896 | MagickPixelPacket pixel; | ||
| 7895 | 7897 | ||
| 7896 | MagickSetIteratorIndex (super_wand, i); | 7898 | MagickSetIteratorIndex (super_wand, i); |
| 7897 | sub_wand = MagickGetImage (super_wand); | 7899 | sub_wand = MagickGetImage (super_wand); |
| 7898 | 7900 | ||
| 7899 | source_iterator = NewPixelIterator (sub_wand); | 7901 | source_iterator = NewPixelIterator (sub_wand); |
| 7900 | if (! source_iterator) | 7902 | if (! source_iterator) |
| 7901 | { | 7903 | { |
| 7902 | DestroyMagickWand (composite_wand); | 7904 | DestroyMagickWand (composite_wand); |
| 7903 | DestroyMagickWand (sub_wand); | 7905 | DestroyMagickWand (sub_wand); |
| 7904 | image_error ("Imagemagick pixel iterator creation failed", | 7906 | image_error ("Imagemagick pixel iterator creation failed", |
| 7905 | Qnil, Qnil); | 7907 | Qnil, Qnil); |
| 7906 | return NULL; | 7908 | return NULL; |
| 7907 | } | 7909 | } |
| 7908 | 7910 | ||
| 7909 | dest_iterator = NewPixelIterator (composite_wand); | 7911 | dest_iterator = NewPixelIterator (composite_wand); |
| 7910 | if (! dest_iterator) | 7912 | if (! dest_iterator) |
| 7911 | { | 7913 | { |
| 7912 | DestroyMagickWand (composite_wand); | 7914 | DestroyMagickWand (composite_wand); |
| 7913 | DestroyMagickWand (sub_wand); | 7915 | DestroyMagickWand (sub_wand); |
| 7914 | DestroyPixelIterator (source_iterator); | 7916 | DestroyPixelIterator (source_iterator); |
| 7915 | image_error ("Imagemagick pixel iterator creation failed", | 7917 | image_error ("Imagemagick pixel iterator creation failed", |
| 7916 | Qnil, Qnil); | 7918 | Qnil, Qnil); |
| 7917 | return NULL; | 7919 | return NULL; |
| 7918 | } | 7920 | } |
| 7919 | 7921 | ||
| 7920 | while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) | 7922 | while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) |
| 7921 | != NULL) { | 7923 | != NULL) |
| 7922 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); | ||
| 7923 | for (int x = 0; x < source_width; x++) | ||
| 7924 | { | 7924 | { |
| 7925 | /* Copy over non-transparent pixels. */ | 7925 | ptrdiff_t x; |
| 7926 | if (PixelGetAlpha (source[x])) | 7926 | dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); |
| 7927 | for (x = 0; x < source_width; x++) | ||
| 7927 | { | 7928 | { |
| 7928 | PixelGetMagickColor (source[x], &pixel); | 7929 | /* Copy over non-transparent pixels. */ |
| 7929 | PixelSetMagickColor (dest[x], &pixel); | 7930 | if (PixelGetAlpha (source[x])) |
| 7931 | { | ||
| 7932 | PixelGetMagickColor (source[x], &pixel); | ||
| 7933 | PixelSetMagickColor (dest[x], &pixel); | ||
| 7934 | } | ||
| 7930 | } | 7935 | } |
| 7936 | PixelSyncIterator(dest_iterator); | ||
| 7931 | } | 7937 | } |
| 7932 | PixelSyncIterator(dest_iterator); | ||
| 7933 | } | ||
| 7934 | 7938 | ||
| 7935 | DestroyPixelIterator (source_iterator); | 7939 | DestroyPixelIterator (source_iterator); |
| 7936 | DestroyPixelIterator (dest_iterator); | 7940 | DestroyPixelIterator (dest_iterator); |
| 7937 | DestroyMagickWand (sub_wand); | 7941 | DestroyMagickWand (sub_wand); |
| 7938 | } | 7942 | } |
| 7939 | 7943 | ||
| 7940 | /* Cache a copy for the next iteration. The current wand will be | 7944 | /* Cache a copy for the next iteration. The current wand will be |
| 7941 | destroyed by the caller. */ | 7945 | destroyed by the caller. */ |