Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
6e856b69
Commit
6e856b69
authored
Aug 15, 2013
by
Lars Magne Ingebrigtsen
Browse files
* image.c (imagemagick_compute_animated_image): Implement animated images.
Fixes: debbugs:14700
parent
d5a1acfa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
4 deletions
+80
-4
src/ChangeLog
src/ChangeLog
+5
-0
src/image.c
src/image.c
+75
-4
No files found.
src/ChangeLog
View file @
6e856b69
2013-08-15 Lars Magne Ingebrigtsen <larsi@gnus.org>
* image.c (imagemagick_compute_animated_image): Implement animated
images (bug#14700).
2013-08-15 Dmitry Antipov <dmantipov@yandex.ru>
2013-08-15 Dmitry Antipov <dmantipov@yandex.ru>
* lisp.h (FOR_EACH_ALIST_VALUE): New macro
* lisp.h (FOR_EACH_ALIST_VALUE): New macro
...
...
src/image.c
View file @
6e856b69
...
@@ -7864,6 +7864,75 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent])
...
@@ -7864,6 +7864,75 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent])
return hint_buffer;
return hint_buffer;
}
}
/* Animated images (e.g., GIF89a) are composed from one "master image"
(which is the first one, and then there's a number of images that
follow. If following images have non-transparent colors, these are
composed "on top" of the master image. So, in general, one has to
compute ann the preceding images to be able to display a particular
sub-image. */
static MagickWand *
imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
{
MagickWand *composite_wand;
MagickSetIteratorIndex (super_wand, 0);
composite_wand = MagickGetImage (super_wand);
for (int i = 1; i <= ino; i++) {
MagickWand *sub_wand;
PixelIterator *source_iterator, *dest_iterator;
PixelWand **source, **dest;
long source_width, dest_width;
MagickPixelPacket pixel;
MagickSetIteratorIndex (super_wand, i);
sub_wand = MagickGetImage (super_wand);
source_iterator = NewPixelIterator (sub_wand);
if (! source_iterator)
{
DestroyMagickWand (composite_wand);
DestroyMagickWand (sub_wand);
image_error ("Imagemagick pixel iterator creation failed",
Qnil, Qnil);
return NULL;
}
dest_iterator = NewPixelIterator (composite_wand);
if (! dest_iterator)
{
DestroyMagickWand (composite_wand);
DestroyMagickWand (sub_wand);
DestroyPixelIterator (source_iterator);
image_error ("Imagemagick pixel iterator creation failed",
Qnil, Qnil);
return NULL;
}
while (source = PixelGetNextIteratorRow (source_iterator, &source_width)) {
dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
for (int x = 0; x < source_width; x++)
{
/* Copy over non-transparent pixels. */
if (PixelGetAlpha (source[x]))
{
PixelGetMagickColor (source[x], &pixel);
PixelSetMagickColor (dest[x], &pixel);
}
}
PixelSyncIterator(dest_iterator);
}
DestroyPixelIterator (source_iterator);
DestroyPixelIterator (dest_iterator);
DestroyMagickWand (sub_wand);
}
return composite_wand;
}
/* Helper function for imagemagick_load, which does the actual loading
/* Helper function for imagemagick_load, which does the actual loading
given contents and size, apart from frame and image structures,
given contents and size, apart from frame and image structures,
passed from imagemagick_load. Uses librimagemagick to do most of
passed from imagemagick_load. Uses librimagemagick to do most of
...
@@ -7965,12 +8034,14 @@ imagemagick_load_image (struct frame *f, struct image *img,
...
@@ -7965,12 +8034,14 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* If we have an animated image, get the new wand based on the
/* If we have an animated image, get the new wand based on the
"super-wand". */
"super-wand". */
if (
ino
>
0
)
if (
MagickGetNumberImages (image_wand)
>
1
)
{
{
MagickWand *super_wand = image_wand;
MagickWand *super_wand = image_wand;
MagickSetIteratorIndex (super_wand, ino);
image_wand = imagemagick_compute_animated_image (super_wand, ino);
image_wand = MagickGetImage (super_wand);
if (! image_wand)
DestroyMagickWand (super_wand);
image_wand = super_wand;
else
DestroyMagickWand (super_wand);
}
}
/* Retrieve the frame's background color, for use later. */
/* Retrieve the frame's background color, for use later. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment