]> granicus.if.org Git - imagemagick/commitdiff
Fixed case where black is written as transparent by the PNG encoder.
authorglennrp <glennrp@git.imagemagick.org>
Tue, 25 Jan 2011 21:53:13 +0000 (21:53 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Tue, 25 Jan 2011 21:53:13 +0000 (21:53 +0000)
ChangeLog
coders/png.c

index f24a9c515222477803dd2d5e8b9f35d2a8816454..7e6cbd46e55e71ad7d4ce7a813c4d99221610bb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
     only there for debugging purposes and was consuming a huge amount
     of CPU time. (reference
     http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=17799).
+  * Sometimes black was still written as transparent, when the PNG
+    encoder receives an image with image->matte on but no transparent
+    pixels are present. (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=17913);
 
 2011-01-24  6.6.7-3 Cristy  <quetzlzacatenango@image...>
   * Remove memory leak from ThrowFileException() macro (reference
index 2545e39221fbe5a4d621a4a6fd70f27046840609..457993d4abe3262d0ff8d6b704a95f81621cd93f 100644 (file)
@@ -1692,6 +1692,12 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
     (void)LogMagickEvent(CoderEvent,GetMagickModule(),
       "  image->matte=%d",(int) image->matte);
 
+  /* Set to an out-of-range color unless tRNS chunk is present */
+  transparent_color.red=65537;
+  transparent_color.green=65537;
+  transparent_color.blue=65537;
+  transparent_color.opacity=65537;
+
   /*
     Allocate the PNG structures
   */
@@ -2165,12 +2171,6 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
     }
 #endif
 
-  /* Set to an out-of-range color unless tRNS chunk is present */
-  transparent_color.red=65537;
-  transparent_color.green=65537;
-  transparent_color.blue=65537;
-  transparent_color.opacity=65537;
-
   if (png_get_valid(ping,ping_info,PNG_INFO_tRNS))
     {
       /*
@@ -8541,10 +8541,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
           "  Added an opaque matte channel");
     }
 
-  if (image->matte == MagickTrue)
+  if (number_transparent != 0 || number_semitransparent != 0)
     {
       if (ping_color_type < 4)
-        if (ping_color_type != 3 || ping_num_trans > 0)
         {
            ping_have_tRNS=MagickTrue;
            if (logging != MagickFalse)