]> granicus.if.org Git - imagemagick/commitdiff
Sometimes black would be written in the PNG tRNS chunk when some other
authorglennrp <glennrp@git.imagemagick.org>
Thu, 9 Jun 2011 04:21:43 +0000 (04:21 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Thu, 9 Jun 2011 04:21:43 +0000 (04:21 +0000)
gray level was supposed to be, on Q16 or Q32 builds, 1-, 2-, or 4-bit files.

ChangeLog
coders/png.c

index fb08368d173511dc69ea2ce28f9fae00fd7a54f0..57691e4a6ca21780e921a9eddf53384c62cfe649 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-05-20  6.7.0-7 Glenn Randers-Pehrson <glennrp@image...>
+  * The PNG encoder would sometimes make black transparent when some
+    other gray level was supposed to be the transparent color (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18900).
+    This occurred only with 1, 2, 4-bit grayscale images with Q16 or Q32
+    builds.
+
 2011-06-08  6.7.0-6 Cristy  <quetzlzacatenango@image...>
   * New version 6.7.0-6.
 
index 2bde571d52f5dbe69f4694ab6047a48c701644a8..143f08492f4bfc342416e652ac03a779dc119741 100644 (file)
         }
 
 
-#if MAGICKCORE_QUANTUM_DEPTH > 8
 /* LBR08: Replicate top 8 bits */
 
 #define LBR08RedPixelPacketComponent(pixelpacket) \
         LBR08RGBPixelComponent((pixel)); \
         LBR08OpacityPixelComponent((pixel)); \
         }
-#endif /* MAGICKCORE_QUANTUM_DEPTH > 8 */
 
 
-#if MAGICKCORE_QUANTUM_DEPTH > 16
 /* LBR16: Replicate top 16 bits */
 
 #define LBR16RedPixelPacketComponent(pixelpacket) \
         LBR16RGBPixelComponent((pixel)); \
         LBR16OpacityPixelComponent((pixel)); \
         }
-#endif /* MAGICKCORE_QUANTUM_DEPTH > 16 */
 
 /*
   Establish thread safety.
@@ -9525,7 +9521,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
          {
 
          ping_background.gray=(png_uint_16)
-           (QuantumScale*(maxval*(PixelIntensity(&image->background_color))));
+           ((1./255.)*(maxval*(PixelIntensity(&image->background_color))));
 
          if (logging != MagickFalse)
            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -9537,8 +9533,20 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
          ping_have_bKGD = MagickTrue;
          }
 
-         ping_trans_color.gray=(png_uint_16) (QuantumScale*(maxval*
-           ping_trans_color.gray));
+#if 1
+   
+         if (logging != MagickFalse)
+           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+             "  Scaling ping_trans_color.gray from %d",
+             (int)ping_trans_color.gray);
+
+         ping_trans_color.gray=(png_uint_16) ((1./255.)*(maxval*
+           ping_trans_color.gray)+.5);
+
+         if (logging != MagickFalse)
+           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+             "      to %d", (int)ping_trans_color.gray);
+#endif
       }
 
   if (ping_exclude_bKGD == MagickFalse)