[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113901: image.c animation touchups
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] trunk r113901: image.c animation touchups |
Date: |
Thu, 15 Aug 2013 18:34:26 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113901
revision-id: address@hidden
parent: address@hidden
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Thu 2013-08-15 20:34:23 +0200
message:
image.c animation touchups
* image.c (imagemagick_compute_animated_image): Animate correctly
when sub-images are smaller than the main image.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/image.c image.c-20091113204419-o5vbwnq5f7feedwu-2969
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-08-15 17:36:45 +0000
+++ b/src/ChangeLog 2013-08-15 18:34:23 +0000
@@ -1,3 +1,8 @@
+2013-08-15 Lars Magne Ingebrigtsen <address@hidden>
+
+ * image.c (imagemagick_compute_animated_image): Animate correctly
+ when sub-images are smaller than the main image.
+
2013-08-15 Jan Djärv <address@hidden>
* nsmenu.m (menuWillOpen:): Fix preprocessor test (Bug#15001).
=== modified file 'src/image.c'
--- a/src/image.c 2013-08-15 17:26:34 +0000
+++ b/src/image.c 2013-08-15 18:34:23 +0000
@@ -7879,6 +7879,7 @@
{
int i;
MagickWand *composite_wand;
+ size_t dest_width, dest_height;
MagickSetIteratorIndex (super_wand, 0);
@@ -7887,18 +7888,36 @@
else
composite_wand = animation_cache;
+ dest_width = MagickGetImageWidth (composite_wand);
+ dest_height = MagickGetImageHeight (composite_wand);
+
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;
+ size_t source_width, source_height;
+ ssize_t source_left, source_top;
MagickPixelPacket pixel;
DisposeType dispose;
MagickSetIteratorIndex (super_wand, i);
sub_wand = MagickGetImage (super_wand);
+ MagickGetImagePage (sub_wand, &source_width, &source_height,
+ &source_left, &source_top);
+
+ /* Sanity check. The sub-image should not be bigger than the
+ base image. */
+ if (source_height + source_top > dest_height)
+ {
+ DestroyMagickWand (composite_wand);
+ DestroyMagickWand (sub_wand);
+ animation_cache = NULL;
+ image_error ("Inconsinstent animation size", Qnil, Qnil);
+ return NULL;
+ }
+
dispose = MagickGetImageDispose (sub_wand);
source_iterator = NewPixelIterator (sub_wand);
@@ -7906,6 +7925,7 @@
{
DestroyMagickWand (composite_wand);
DestroyMagickWand (sub_wand);
+ animation_cache = NULL;
image_error ("Imagemagick pixel iterator creation failed",
Qnil, Qnil);
return NULL;
@@ -7917,11 +7937,16 @@
DestroyMagickWand (composite_wand);
DestroyMagickWand (sub_wand);
DestroyPixelIterator (source_iterator);
+ animation_cache = NULL;
image_error ("Imagemagick pixel iterator creation failed",
Qnil, Qnil);
return NULL;
}
+ /* The sub-image may not start at origo, so move the destination
+ iterator to where the sub-image should start. */
+ PixelSetIteratorRow (dest_iterator, source_top);
+
while ((source = PixelGetNextIteratorRow (source_iterator,
&source_width))
!= NULL)
{
@@ -7929,6 +7954,10 @@
dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
for (x = 0; x < source_width; x++)
{
+ /* Sanity check. This shouldn't happen, but apparently
+ does in some pictures. */
+ if (x + source_left > dest_width)
+ break;
/* Normally we only copy over non-transparent pixels,
but if the disposal method is "Background", then we
copy over all pixels. */
@@ -7936,7 +7965,7 @@
PixelGetAlpha (source[x]))
{
PixelGetMagickColor (source[x], &pixel);
- PixelSetMagickColor (dest[x], &pixel);
+ PixelSetMagickColor (dest[x + source_left], &pixel);
}
}
PixelSyncIterator(dest_iterator);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113901: image.c animation touchups,
Lars Ingebrigtsen <=