]> granicus.if.org Git - imagemagick/commitdiff
Fixed various problems with the PNG encoder, mainly loss of transparency.
authorglennrp <glennrp@git.imagemagick.org>
Wed, 17 Nov 2010 14:40:15 +0000 (14:40 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Wed, 17 Nov 2010 14:40:15 +0000 (14:40 +0000)
ChangeLog
coders/png.c

index 1a728e4970b280f9d24d698a2d159a3d3e85b257..e88403624ab4d0390dd14550163fcab0b3869c77 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-11-17  6.6.5-9 Glenn Randers-Pehrson <glennrp@image...>
+  * Many of the problems with the PNG encoder have been fixed (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=16487).
+
 2010-11-14  6.6.5-9 Cristy  <quetzlzacatenango@image...>
   * The splice option no longer throws spurious "pixels are not authentic"
     exceptions.
@@ -11,9 +15,6 @@
     preservation of images which only vary horizontally (or vertically)" under
     no-op. New blur = 0.9812505644269356.
 
-2010-10-29  6.6.5-9 Glenn Randers-Pehrson <glennrp@image...>
-  * Revised PNG encoder to avoid emitting some spurious warnings.
-
 2010-11-08  6.6.5-8 Nicolas Robidoux <nicolas.robidoux@gmai...>
   * Missing logical operator in tiff.c.
 
index 0dc80a1929a13af63665728d03924063f2db9b7b..c8e37e2c6268507cffd07b7c732d7874d2b93d01 100644 (file)
@@ -345,7 +345,6 @@ typedef struct _MngInfo
     need_fram,
     object_id,
     old_framing_mode,
-    optimize,
     saved_bkgd_index;
 
   int
@@ -7054,6 +7053,39 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
   if (image->colorspace != RGBColorspace)
     (void) TransformImageColorspace(image,RGBColorspace);
 
+  /*
+    Sometimes we get PseudoClass images whose RGB values don't match
+    the colors in the colormap.  This code syncs the RGB values.
+  */
+  if (image->taint && image->storage_class == PseudoClass)
+     (void) SyncImage(image);
+
+#ifdef PNG_BUILD_PALETTE
+  
+  if (((mng_info->write_png_colortype-1) == PNG_COLOR_TYPE_PALETTE) ||
+      (mng_info->write_png_colortype == 0 && image->depth <= 8))
+    {
+      /*
+        Sometimes we get DirectClass images that have 256 colors or fewer.
+        This code will convert them to PseudoClass and build a colormap.
+      */
+      if (image->storage_class != PseudoClass)
+        {
+          image->colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
+          if (image->colors <= 256)
+            {
+              image->colors=0;
+
+              if (image->matte != MagickFalse)
+                (void) SetImageType(image,PaletteMatteType);
+
+              else
+                (void) SetImageType(image,PaletteType);
+            }
+        }
+    }
+#endif
+
   mng_info->IsPalette=image->storage_class == PseudoClass &&
     image_colors <= 256 && !IsOpaqueImage(image,&image->exception);
 
@@ -9925,56 +9957,6 @@ static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image)
       }
     }
 
-  /*
-    Sometimes we get PseudoClass images whose RGB values don't match
-    the colors in the colormap.  This code syncs the RGB values.
-  */
-  {
-    Image
-      *p;
-
-    for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
-    {
-      if (p->taint && p->storage_class == PseudoClass)
-         (void) SyncImage(p);
-
-      if (mng_info->adjoin == MagickFalse)
-        break;
-    }
-  }
-
-#ifdef PNG_BUILD_PALETTE
-  if (!(mng_info->write_png24 || mng_info->write_png32))
-    {
-      /*
-        Sometimes we get DirectClass images that have 256 colors or fewer.
-        This code will convert them to PseudoClass and build a colormap.
-      */
-      Image
-        *p;
-
-      for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
-      {
-        if (p->storage_class != PseudoClass)
-          {
-            p->colors=GetNumberColors(p,(FILE *) NULL,&p->exception);
-            if (p->colors <= 256)
-              {
-                p->colors=0;
-
-                if (p->matte != MagickFalse)
-                  (void) SetImageType(p,PaletteMatteType);
-
-                else
-                  (void) SetImageType(p,PaletteType);
-              }
-          }
-        if (mng_info->adjoin == MagickFalse)
-          break;
-      }
-    }
-#endif
-
   use_global_plte=MagickFalse;
   all_images_are_gray=MagickFalse;
 #ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED