aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorJoakim Verona2013-08-15 18:41:51 +0200
committerJoakim Verona2013-08-15 18:41:51 +0200
commitd7d5ffd611d0fbeb9d55180d328e9203f3a1e199 (patch)
treeccad369b6a77e325d728c2e4cdeaa0f321d7a0f3 /src/image.c
parent50bedb930dc5a15cb7cb5d689d9f1726a14fb158 (diff)
parent0fe73012cda7153f85cff32db8df442a0859fa5b (diff)
downloademacs-d7d5ffd611d0fbeb9d55180d328e9203f3a1e199.tar.gz
emacs-d7d5ffd611d0fbeb9d55180d328e9203f3a1e199.zip
merge from trunk
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c97
1 files changed, 57 insertions, 40 deletions
diff --git a/src/image.c b/src/image.c
index c534f181e5c..3cab72edf74 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7871,63 +7871,80 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent])
7871 compute ann the preceding images to be able to display a particular 7871 compute ann the preceding images to be able to display a particular
7872 sub-image. */ 7872 sub-image. */
7873 7873
7874static MagickWand *animation_cache = NULL;
7875static int animation_index = 0;
7876
7874static MagickWand * 7877static MagickWand *
7875imagemagick_compute_animated_image (MagickWand *super_wand, int ino) 7878imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
7876{ 7879{
7880 int i;
7877 MagickWand *composite_wand; 7881 MagickWand *composite_wand;
7878 7882
7879 MagickSetIteratorIndex (super_wand, 0); 7883 MagickSetIteratorIndex (super_wand, 0);
7880 composite_wand = MagickGetImage (super_wand);
7881 7884
7882 for (int i = 1; i <= ino; i++) { 7885 if (ino == 0 || animation_cache == NULL)
7883 MagickWand *sub_wand; 7886 composite_wand = MagickGetImage (super_wand);
7884 PixelIterator *source_iterator, *dest_iterator; 7887 else
7885 PixelWand **source, **dest; 7888 composite_wand = animation_cache;
7886 long source_width, dest_width;
7887 MagickPixelPacket pixel;
7888 7889
7889 MagickSetIteratorIndex (super_wand, i); 7890 for (i = max (1, animation_index); i <= ino; i++)
7890 sub_wand = MagickGetImage (super_wand); 7891 {
7892 MagickWand *sub_wand;
7893 PixelIterator *source_iterator, *dest_iterator;
7894 PixelWand **source, **dest;
7895 size_t source_width, dest_width;
7896 MagickPixelPacket pixel;
7891 7897
7892 source_iterator = NewPixelIterator (sub_wand); 7898 MagickSetIteratorIndex (super_wand, i);
7893 if (! source_iterator) 7899 sub_wand = MagickGetImage (super_wand);
7894 {
7895 DestroyMagickWand (composite_wand);
7896 DestroyMagickWand (sub_wand);
7897 image_error ("Imagemagick pixel iterator creation failed",
7898 Qnil, Qnil);
7899 return NULL;
7900 }
7901 7900
7902 dest_iterator = NewPixelIterator (composite_wand); 7901 source_iterator = NewPixelIterator (sub_wand);
7903 if (! dest_iterator) 7902 if (! source_iterator)
7904 { 7903 {
7905 DestroyMagickWand (composite_wand); 7904 DestroyMagickWand (composite_wand);
7906 DestroyMagickWand (sub_wand); 7905 DestroyMagickWand (sub_wand);
7907 DestroyPixelIterator (source_iterator); 7906 image_error ("Imagemagick pixel iterator creation failed",
7908 image_error ("Imagemagick pixel iterator creation failed", 7907 Qnil, Qnil);
7909 Qnil, Qnil); 7908 return NULL;
7910 return NULL; 7909 }
7911 } 7910
7911 dest_iterator = NewPixelIterator (composite_wand);
7912 if (! dest_iterator)
7913 {
7914 DestroyMagickWand (composite_wand);
7915 DestroyMagickWand (sub_wand);
7916 DestroyPixelIterator (source_iterator);
7917 image_error ("Imagemagick pixel iterator creation failed",
7918 Qnil, Qnil);
7919 return NULL;
7920 }
7912 7921
7913 while (source = PixelGetNextIteratorRow (source_iterator, &source_width)) { 7922 while ((source = PixelGetNextIteratorRow (source_iterator, &source_width))
7914 dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); 7923 != NULL)
7915 for (int x = 0; x < source_width; x++)
7916 { 7924 {
7917 /* Copy over non-transparent pixels. */ 7925 ptrdiff_t x;
7918 if (PixelGetAlpha (source[x])) 7926 dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
7927 for (x = 0; x < source_width; x++)
7919 { 7928 {
7920 PixelGetMagickColor (source[x], &pixel); 7929 /* Copy over non-transparent pixels. */
7921 PixelSetMagickColor (dest[x], &pixel); 7930 if (PixelGetAlpha (source[x]))
7931 {
7932 PixelGetMagickColor (source[x], &pixel);
7933 PixelSetMagickColor (dest[x], &pixel);
7934 }
7922 } 7935 }
7936 PixelSyncIterator(dest_iterator);
7923 } 7937 }
7924 PixelSyncIterator(dest_iterator); 7938
7939 DestroyPixelIterator (source_iterator);
7940 DestroyPixelIterator (dest_iterator);
7941 DestroyMagickWand (sub_wand);
7925 } 7942 }
7926 7943
7927 DestroyPixelIterator (source_iterator); 7944 /* Cache a copy for the next iteration. The current wand will be
7928 DestroyPixelIterator (dest_iterator); 7945 destroyed by the caller. */
7929 DestroyMagickWand (sub_wand); 7946 animation_cache = CloneMagickWand (composite_wand);
7930 } 7947 animation_index = ino;
7931 7948
7932 return composite_wand; 7949 return composite_wand;
7933} 7950}