]> granicus.if.org Git - imagemagick/commitdiff
Correct the bKGD chunk reading (scaling was incorrect)
authorglennrp <glennrp@git.imagemagick.org>
Wed, 2 Jun 2010 04:37:24 +0000 (04:37 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Wed, 2 Jun 2010 04:37:24 +0000 (04:37 +0000)
ChangeLog
coders/png.c

index 628440aa1b3d8480c94041fd7316b893183a98e1..6a423c003251e197b2a61341c18c1b4024c1f781 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,18 @@
+2010-06-01  6.6.2-2 Glenn Randers-Pehrson <glennrp@image...>
+  * Properly scale color components of the PNG bKGD chunk.
+  * Prevent MNG divide by zero in calculation of frame_timeout.  Set
+    both frame_delay and frame_timeout to infinite when ticks_per_second
+    is zero, as required by the MNG spec.
+
 2010-05-31  6.6.2-2 Cristy  <quetzlzacatenango@image...>
   * Add x:silent option to prevent beeps when reading the X image format.
   * Recognize TTF for GetMagicInfo().
   * Ensure the +set option deletes the image artifact.
-  * Prevent MNG divide by zero in calculation of frame_timeout.  Set
-    both frame_delay and frame_timeout to infinite when ticks_per_second
-    is zero, as required by the MNG spec.
 
-2010-05-28  6.6.2.1 Glenn Randers-Pehrson <glennrp@image...>
+2010-05-28  6.6.2-1 Glenn Randers-Pehrson <glennrp@image...>
   * Prevent coders/png.c from attempting to write an empty tRNS chunk.
 
-2010-05-25  6.6.2.1 Anthony Thyssen <A.Thyssen@griffith...>
+2010-05-25  6.6.2-1 Anthony Thyssen <A.Thyssen@griffith...>
   * Finish for Square Array Rotates (off center origin rotate)
   * Added HitAndMiss kernel Ridges2 to find 2 pixel thick ridges
   * Added FreiChen:0,{angle}  FreiChen:{angle} and FreiChen:-1 variations
@@ -26,7 +29,7 @@
   * Prevent MNG divide by zero in calculation of frame_delay (reference
     http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=16320).
 
-2010-05-23  6.6.2.0 Anthony Thyssen <A.Thyssen@griffith...>
+2010-05-23  6.6.2-0 Anthony Thyssen <A.Thyssen@griffith...>
   * Third Re-write of MorphologyApply() to better handle compound methods.
   * Implemented  -set option:morphology:compose for merging results of
     multiple kernels. "None" means re-iterate results with next kernel.
@@ -40,7 +43,7 @@
   * ExpandKernelInfo() (rotation expand) now groks symmetrical kernels.
     So the above will only produce a list of 2 kernels, not 4 kernels
 
-2010-05-18  6.6.2.0 Anthony Thyssen <A.Thyssen@griffith...>
+2010-05-18  6.6.2-0 Anthony Thyssen <A.Thyssen@griffith...>
   * Separation of internal function MorphologyAppy() from
     MorphologyImageChannel() to calls to convolve without user settings.
   * Rewrite of MorphologyApply() to output better 'verbose' messages
index a7bd06dbb78f1ac3254f6894aba34c2c63d07146..613fc826990591804c866a394e11e5570db413dc 100644 (file)
@@ -2132,20 +2132,57 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
       if (logging != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "    Reading PNG bKGD chunk.");
-      if (ping_bit_depth <= MAGICKCORE_QUANTUM_DEPTH)
+      if (ping_bit_depth == MAGICKCORE_QUANTUM_DEPTH)
         {
           image->background_color.red=ping_background->red;
           image->background_color.green=ping_background->green;
           image->background_color.blue=ping_background->blue;
         }
-      else
+      else /* Scale background components to 16-bit */
         {
+          unsigned int
+            bkgd_scale;
+
+          if (logging != MagickFalse)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+              "    raw ping_background=(%d,%d,%d).",ping_background->red,
+              ping_background->green,ping_background->blue);
+
+          bkgd_scale = 1;
+          if (ping_bit_depth == 1)
+             bkgd_scale = 255;
+          else if (ping_bit_depth == 2)
+             bkgd_scale = 85;
+          else if (ping_bit_depth == 4)
+             bkgd_scale = 17;
+          if (ping_bit_depth <= 8)
+             bkgd_scale *= 257;
+
+          ping_background->red *= bkgd_scale;
+          ping_background->green *= bkgd_scale;
+          ping_background->blue *= bkgd_scale;
+
+          if (logging != MagickFalse)
+            {
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+              "    bkgd_scale=%d.",bkgd_scale);
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+              "    ping_background=(%d,%d,%d).",ping_background->red,
+              ping_background->green,ping_background->blue);
+            }
+
           image->background_color.red=
             ScaleShortToQuantum(ping_background->red);
           image->background_color.green=
             ScaleShortToQuantum(ping_background->green);
           image->background_color.blue=
             ScaleShortToQuantum(ping_background->blue);
+
+          if (logging != MagickFalse)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+              "    image->background_color=(%d,%d,%d).",
+              image->background_color.red,
+              image->background_color.green,image->background_color.blue);
         }
     }
 #endif