]> granicus.if.org Git - imagemagick/commitdiff
Only loop through the colormap colors when the background color can be added.
authorDirk Lemstra <dirk@lemstra.org>
Tue, 20 Aug 2019 18:50:16 +0000 (20:50 +0200)
committerDirk Lemstra <dirk@lemstra.org>
Tue, 20 Aug 2019 20:04:39 +0000 (22:04 +0200)
coders/png.c

index 183504105c702256e811040a0d0585c62dbbc518..d92e9d0d0fa510eb589b494f10b1a54d5b0ffbe0 100644 (file)
@@ -9167,24 +9167,27 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
                   (int) image->background_color.green,
                   (int) image->background_color.blue);
             }
-          for (i=0; i<number_opaque; i++)
-          {
-             if (opaque[i].red == image->background_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; i<number_opaque; i++)
+              {
+                 if (opaque[i].red == image->background_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(),