]> granicus.if.org Git - imagemagick/commitdiff
Eliminate a redundant test and add a "TO DO" comment in coders/png.c
authorglennrp <glennrp@git.imagemagick.org>
Wed, 23 Feb 2011 14:58:06 +0000 (14:58 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Wed, 23 Feb 2011 14:58:06 +0000 (14:58 +0000)
coders/png.c

index f5e0cd7ac7468af802c404ca4e73f571f708c37f..69b1eb81f4d9eba0b2b2f1e0e448a9cb39771fa2 100644 (file)
@@ -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;