From: Dirk Lemstra Date: Tue, 20 Aug 2019 18:50:16 +0000 (+0200) Subject: Only loop through the colormap colors when the background color can be added. X-Git-Tag: 7.0.8-62~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=720cfd4542b1896fc8cd1a6e10c876d4b4bd0351;p=imagemagick Only loop through the colormap colors when the background color can be added. --- 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(),