From: glennrp Date: Wed, 23 Feb 2011 14:58:06 +0000 (+0000) Subject: Eliminate a redundant test and add a "TO DO" comment in coders/png.c X-Git-Tag: 7.0.1-0~8105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97fd3d052fbd2e629d5d2387f26de9e250dd3e32;p=imagemagick Eliminate a redundant test and add a "TO DO" comment in coders/png.c --- diff --git a/coders/png.c b/coders/png.c index f5e0cd7ac..69b1eb81f 100644 --- a/coders/png.c +++ b/coders/png.c @@ -7066,6 +7066,15 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, if (q == (PixelPacket *) NULL) break; + /* Worst case is black-and-white; we are looking at every + * pixel twice. + * + * TO DO: Do the following 2 loops over the colormap, if + * possible, after it has been generated, instead of over + * the pixels. Only resort to looping over the pixels + * when more than 256 colors (or gray levels) are present. + */ + if (ping_have_color == MagickFalse) { s=q; @@ -7086,9 +7095,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, s=q; for (x=0; x < (ssize_t) image->columns; x++) { - if (s->red != 0 && s->red != QuantumRange && - s->green != 0 && s->green != QuantumRange && - s->blue != 0 && s->blue != QuantumRange) + if (s->red != 0 && s->red != QuantumRange) { ping_have_non_bw=MagickTrue; break;