(imagemagick_compute_animated_image): Allow certain degenerate images

(imagemagick_compute_animated_image): Allow images that say they
have sub-images that are bigger than the main image, but just crop
them.
parent 1d18b1e6
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
when sub-images are smaller than the main image. when sub-images are smaller than the main image.
(imagemagick_compute_animated_image): Setting the iterator row to (imagemagick_compute_animated_image): Setting the iterator row to
zero is apparently not allowed. zero is apparently not allowed.
(imagemagick_compute_animated_image): Allow images that say they
have sub-images that are bigger than the main image, but just crop
them.
2013-08-15 Jan Djärv <jan.h.d@swipnet.se> 2013-08-15 Jan Djärv <jan.h.d@swipnet.se>
......
...@@ -7900,6 +7900,7 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) ...@@ -7900,6 +7900,7 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
ssize_t source_left, source_top; ssize_t source_left, source_top;
MagickPixelPacket pixel; MagickPixelPacket pixel;
DisposeType dispose; DisposeType dispose;
ptrdiff_t lines = 0;
MagickSetIteratorIndex (super_wand, i); MagickSetIteratorIndex (super_wand, i);
sub_wand = MagickGetImage (super_wand); sub_wand = MagickGetImage (super_wand);
...@@ -7907,17 +7908,6 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) ...@@ -7907,17 +7908,6 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
MagickGetImagePage (sub_wand, &source_width, &source_height, MagickGetImagePage (sub_wand, &source_width, &source_height,
&source_left, &source_top); &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); dispose = MagickGetImageDispose (sub_wand);
source_iterator = NewPixelIterator (sub_wand); source_iterator = NewPixelIterator (sub_wand);
...@@ -7946,17 +7936,26 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino) ...@@ -7946,17 +7936,26 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
/* The sub-image may not start at origo, so move the destination /* The sub-image may not start at origo, so move the destination
iterator to where the sub-image should start. */ iterator to where the sub-image should start. */
if (source_top > 0) if (source_top > 0)
PixelSetIteratorRow (dest_iterator, source_top); {
PixelSetIteratorRow (dest_iterator, source_top);
lines = source_top;
}
while ((source = PixelGetNextIteratorRow (source_iterator, &source_width)) while ((source = PixelGetNextIteratorRow (source_iterator, &source_width))
!= NULL) != NULL)
{ {
ptrdiff_t x; ptrdiff_t x;
/* Sanity check. This shouldn't happen, but apparently
does in some pictures. */
if (++lines >= dest_height)
break;
dest = PixelGetNextIteratorRow (dest_iterator, &dest_width); dest = PixelGetNextIteratorRow (dest_iterator, &dest_width);
for (x = 0; x < source_width; x++) for (x = 0; x < source_width; x++)
{ {
/* Sanity check. This shouldn't happen, but apparently /* Sanity check. This shouldn't happen, but apparently
does in some pictures. */ also does in some pictures. */
if (x + source_left > dest_width) if (x + source_left > dest_width)
break; break;
/* Normally we only copy over non-transparent pixels, /* Normally we only copy over non-transparent pixels,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment