]> granicus.if.org Git - imagemagick/commitdiff
Don't store background color in the colormap if there are already 256
authorglennrp <glennrp@git.imagemagick.org>
Fri, 11 Mar 2011 18:03:44 +0000 (18:03 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Fri, 11 Mar 2011 18:03:44 +0000 (18:03 +0000)
colors present and we are writing a PNG8.

ChangeLog
coders/png.c

index ce182713189fb22de8f0de6743bc1475d61912cd..aa198553674330557f6fa136dae17dfcd07246bb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-11  6.6.8-4 Glenn Randers-Pehrson <glennrp@image...>
+  * Don't try to store a bKGD chunk in a PNG8 when there are already
+    256 colors in the palette and the background colors is not in that
+    palette (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18199);
+
 2011-03-10  6.6.8-4 Cristy  <quetzlzacatenango@image...>
   * Fx is a mathematicals function.  Do not treat transparency as black.
 
index b4eb16cf0f3f549542a33e31f9dfcb5c059d676b..cd66d0dc7b54dc7040ad38f017cb317b26015d29 100644 (file)
@@ -7189,8 +7189,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
           */
           for (i=0; i<number_opaque; i++)
           {
-             if (IsColorEqual(opaque+i,
-                &image->background_color))
+             if (IsColorEqual(opaque+i, &image->background_color))
              break;
           }
 
@@ -7200,10 +7199,20 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
                opaque[i].opacity = OpaqueOpacity;
                number_opaque++;
             }
+          else if (logging != MagickFalse)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "      No room in the colormap to add background color");
        }
 
      image_colors=number_opaque+number_transparent+number_semitransparent;
 
+     if (mng_info->write_png8 != MagickFalse && image_colors > 256)
+       {
+         /* No room for the background color; remove it. */
+         number_opaque--;
+         image_colors--;
+       }
+
      if (logging != MagickFalse)
        {
          if (image_colors > 256)