Skip to content

Commit 4f31d78

Browse files
author
Cristy
committed
https://github.com/ImageMagick/ImageMagick/issues/1629
1 parent 3592bcf commit 4f31d78

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

Diff for: magick/layer.c

+29-27
Original file line numberDiff line numberDiff line change
@@ -1639,45 +1639,47 @@ MagickExport void OptimizeImageTransparency(const Image *image,
16391639
% o exception: return any errors or warnings in this structure.
16401640
%
16411641
*/
1642-
MagickExport void RemoveDuplicateLayers(Image **images,
1643-
ExceptionInfo *exception)
1642+
MagickExport void RemoveDuplicateLayers(Image **images,ExceptionInfo *exception)
16441643
{
1645-
register Image
1646-
*curr,
1647-
*next;
1648-
16491644
RectangleInfo
16501645
bounds;
16511646

1647+
register Image
1648+
*image,
1649+
*next;
1650+
16521651
assert((*images) != (const Image *) NULL);
16531652
assert((*images)->signature == MagickCoreSignature);
16541653
if ((*images)->debug != MagickFalse)
1655-
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*images)->filename);
1654+
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1655+
(*images)->filename);
16561656
assert(exception != (ExceptionInfo *) NULL);
16571657
assert(exception->signature == MagickCoreSignature);
1658-
1659-
curr=GetFirstImageInList(*images);
1660-
for (; (next=GetNextImageInList(curr)) != (Image *) NULL; curr=next)
1658+
image=GetFirstImageInList(*images);
1659+
for ( ; (next=GetNextImageInList(image)) != (Image *) NULL; image=next)
16611660
{
1662-
if ( curr->columns != next->columns || curr->rows != next->rows
1663-
|| curr->page.x != next->page.x || curr->page.y != next->page.y )
1661+
if ((image->columns != next->columns) || (image->rows != next->rows) ||
1662+
(image->page.x != next->page.x) || (image->page.y != next->page.y))
16641663
continue;
1665-
bounds=CompareImageBounds(curr,next,CompareAnyLayer,exception);
1666-
if ( bounds.x < 0 ) {
1667-
/*
1668-
the two images are the same, merge time delays and delete one.
1669-
*/
1670-
size_t time;
1671-
time = curr->delay*1000/curr->ticks_per_second;
1672-
time += next->delay*1000/next->ticks_per_second;
1673-
next->ticks_per_second = 100L;
1674-
next->delay = time*curr->ticks_per_second/1000;
1675-
next->iterations = curr->iterations;
1676-
*images = curr;
1677-
(void) DeleteImageFromList(images);
1678-
}
1664+
bounds=CompareImageBounds(image,next,CompareAnyLayer,exception);
1665+
if (bounds.x < 0)
1666+
{
1667+
/*
1668+
Two images are the same, merge time delays and delete one.
1669+
*/
1670+
size_t
1671+
time;
1672+
1673+
time=1000*image->delay*PerceptibleReciprocal(image->ticks_per_second);
1674+
time+=1000*next->delay*PerceptibleReciprocal(next->ticks_per_second);
1675+
next->ticks_per_second=100L;
1676+
next->delay=time*image->ticks_per_second/1000;
1677+
next->iterations=image->iterations;
1678+
*images=image;
1679+
(void) DeleteImageFromList(images);
1680+
}
16791681
}
1680-
*images = GetFirstImageInList(*images);
1682+
*images=GetFirstImageInList(*images);
16811683
}
16821684

16831685
/*

0 commit comments

Comments
 (0)