From 720cfd4542b1896fc8cd1a6e10c876d4b4bd0351 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 20 Aug 2019 20:50:16 +0200 Subject: [PATCH] Only loop through the colormap colors when the background color can be added. --- coders/png.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/coders/png.c b/coders/png.c index 183504105..d92e9d0d0 100644 --- a/coders/png.c +++ b/coders/png.c @@ -9167,24 +9167,27 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, (int) image->background_color.green, (int) image->background_color.blue); } - for (i=0; ibackground_color.red && - opaque[i].green == image->background_color.green && - opaque[i].blue == image->background_color.blue) - break; - } - if (number_opaque < 259 && i == number_opaque) + if (number_opaque < 259) { - opaque[i] = image->background_color; - ping_background.index = i; - number_opaque++; - if (logging != MagickFalse) - { - (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " background_color index is %d",(int) i); - } + for (i=0; ibackground_color.red && + opaque[i].green == image->background_color.green && + opaque[i].blue == image->background_color.blue) + break; + } + if (i == number_opaque) + { + opaque[i] = image->background_color; + ping_background.index = i; + number_opaque++; + if (logging != MagickFalse) + { + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " background_color index is %d",(int) i); + } + } } else if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), -- 2.40.0