Skip to content

Commit 1ddcf2e

Browse files
author
Cristy
committed
https://github.com/ImageMagick/ImageMagick/issues/1629
1 parent 82c685a commit 1ddcf2e

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

Diff for: MagickCore/layer.c

+29-27
Original file line numberDiff line numberDiff line change
@@ -1584,45 +1584,47 @@ MagickExport void OptimizeImageTransparency(const Image *image,
15841584
% o exception: return any errors or warnings in this structure.
15851585
%
15861586
*/
1587-
MagickExport void RemoveDuplicateLayers(Image **images,
1588-
ExceptionInfo *exception)
1587+
MagickExport void RemoveDuplicateLayers(Image **images,ExceptionInfo *exception)
15891588
{
1590-
register Image
1591-
*curr,
1592-
*next;
1593-
15941589
RectangleInfo
15951590
bounds;
15961591

1592+
register Image
1593+
*image,
1594+
*next;
1595+
15971596
assert((*images) != (const Image *) NULL);
15981597
assert((*images)->signature == MagickCoreSignature);
15991598
if ((*images)->debug != MagickFalse)
1600-
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*images)->filename);
1599+
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1600+
(*images)->filename);
16011601
assert(exception != (ExceptionInfo *) NULL);
16021602
assert(exception->signature == MagickCoreSignature);
1603-
1604-
curr=GetFirstImageInList(*images);
1605-
for (; (next=GetNextImageInList(curr)) != (Image *) NULL; curr=next)
1603+
image=GetFirstImageInList(*images);
1604+
for ( ; (next=GetNextImageInList(image)) != (Image *) NULL; image=next)
16061605
{
1607-
if ( curr->columns != next->columns || curr->rows != next->rows
1608-
|| curr->page.x != next->page.x || curr->page.y != next->page.y )
1606+
if ((image->columns != next->columns) || (image->rows != next->rows) ||
1607+
(image->page.x != next->page.x) || (image->page.y != next->page.y))
16091608
continue;
1610-
bounds=CompareImagesBounds(curr,next,CompareAnyLayer,exception);
1611-
if ( bounds.x < 0 ) {
1612-
/*
1613-
the two images are the same, merge time delays and delete one.
1614-
*/
1615-
size_t time;
1616-
time = curr->delay*1000/curr->ticks_per_second;
1617-
time += next->delay*1000/next->ticks_per_second;
1618-
next->ticks_per_second = 100L;
1619-
next->delay = time*curr->ticks_per_second/1000;
1620-
next->iterations = curr->iterations;
1621-
*images = curr;
1622-
(void) DeleteImageFromList(images);
1623-
}
1609+
bounds=CompareImagesBounds(image,next,CompareAnyLayer,exception);
1610+
if (bounds.x < 0)
1611+
{
1612+
/*
1613+
Two images are the same, merge time delays and delete one.
1614+
*/
1615+
size_t
1616+
time;
1617+
1618+
time=1000*image->delay*PerceptibleReciprocal(image->ticks_per_second);
1619+
time+=1000*next->delay*PerceptibleReciprocal(next->ticks_per_second);
1620+
next->ticks_per_second=100L;
1621+
next->delay=time*image->ticks_per_second/1000;
1622+
next->iterations=image->iterations;
1623+
*images=image;
1624+
(void) DeleteImageFromList(images);
1625+
}
16241626
}
1625-
*images = GetFirstImageInList(*images);
1627+
*images=GetFirstImageInList(*images);
16261628
}
16271629

16281630
/*

0 commit comments

Comments
 (0)