diff -ur cinepaint/plug-ins/png/png.c cinepaint-png15/plug-ins/png/png.c
--- cinepaint/plug-ins/png/png.c	2006-11-24 15:52:55.000000000 -0500
+++ cinepaint-png15/plug-ins/png/png.c	2013-03-02 03:37:33.304142225 -0500
@@ -405,7 +405,7 @@
   info = (png_infop)calloc(sizeof(png_info), 1);
 #endif /* PNG_LIBPNG_VER > 88 */
 
-  if (setjmp (pp->jmpbuf))
+  if (setjmp (png_jmpbuf(pp)))
   {
     g_message ("%s\nPNG error. File corrupted?", filename);
     return image;
@@ -448,15 +448,15 @@
   */
 
 #ifndef WORDS_BIGENDIAN
-  if(info->bit_depth == 16)
+  if(png_get_bit_depth(pp,info) == 16)
 	  png_set_swap(pp);
 #endif
 
-  if (info->color_type == PNG_COLOR_TYPE_GRAY && info->bit_depth < 8) {
+  if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_GRAY && png_get_bit_depth(pp,info) < 8) {
     png_set_expand(pp);
   }
 
-  if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8) {
+  if (png_get_color_type(pp,info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8) {
     png_set_packing(pp);
   }
 
@@ -464,8 +464,8 @@
   * Expand G+tRNS to GA, RGB+tRNS to RGBA
   */
 
-  if (info->color_type != PNG_COLOR_TYPE_PALETTE &&
-                       (info->valid & PNG_INFO_tRNS)) {
+  if (png_get_color_type(pp,info) != PNG_COLOR_TYPE_PALETTE &&
+                  (png_get_valid(pp,info,PNG_INFO_tRNS) & PNG_INFO_tRNS)) {
     png_set_expand(pp);
   }
 
@@ -482,7 +482,7 @@
 
 #if PNG_LIBPNG_VER > 99
   if (png_get_valid(pp, info, PNG_INFO_tRNS) &&
-      info->color_type == PNG_COLOR_TYPE_PALETTE)
+      png_get_color_type(pp, info) == PNG_COLOR_TYPE_PALETTE)
   {
     png_get_tRNS(pp, info, &alpha_ptr, &num, NULL);
     /* Copy the existing alpha values from the tRNS chunk */
@@ -505,9 +505,9 @@
 
   png_read_update_info(pp, info);
   
-  if(info->bit_depth==16)
+  if(png_get_bit_depth(pp,info)==16)
   {
-	  switch (info->color_type)
+	  switch (png_get_color_type(pp, info))
 	  {
 		  case PNG_COLOR_TYPE_RGB :		/* RGB */
 			  bpp        = 6;
@@ -545,7 +545,7 @@
   }
   else
   {
-	  switch (info->color_type)
+	  switch (png_get_color_type(pp, info))
 	  {
 		  case PNG_COLOR_TYPE_RGB :		/* RGB */
 			  bpp        = 3;
@@ -582,7 +582,7 @@
 	  };
   }
 
-  image = gimp_image_new(info->width, info->height, image_type);
+  image = gimp_image_new(png_get_image_width(pp,info), png_get_image_height(pp,info), image_type);
   if (image == -1)
   {
     g_message("Can't allocate new image\n%s", filename);
@@ -595,7 +595,7 @@
   * Create the "background" layer to hold the image...
   */
 
-  layer = gimp_layer_new(image, _("Background"), info->width, info->height,
+  layer = gimp_layer_new(image, _("Background"), png_get_image_width(pp,info), png_get_image_height(pp,info),
                          layer_type, 100, NORMAL_MODE);
   gimp_image_add_layer(image, layer, 0);
 
@@ -627,20 +627,23 @@
 
   empty= 0; /* by default assume no full transparent palette entries */
 
-  if (info->color_type & PNG_COLOR_MASK_PALETTE) {
+  if (png_get_color_type(pp, info) & PNG_COLOR_MASK_PALETTE) {
+	png_colorp palette;
+	int num_palette;
+	png_get_PLTE(pp, info, &palette, &num_palette);
+
 
 #if PNG_LIBPNG_VER > 99
     if (png_get_valid(pp, info, PNG_INFO_tRNS)) {
       for (empty= 0; empty < 256 && alpha[empty] == 0; ++empty);
         /* Calculates number of fully transparent "empty" entries */
 
-      gimp_image_set_cmap(image, (guchar *) (info->palette + empty),
-                          info->num_palette - empty);
+      gimp_image_set_cmap(image, (guchar *) &palette + empty,num_palette - empty);
     } else {
-      gimp_image_set_cmap(image, (guchar *)info->palette, info->num_palette);
+      gimp_image_set_cmap(image, (guchar *)&palette, num_palette);
     }
 #else
-    gimp_image_set_cmap(image, (guchar *)info->palette, info->num_palette);
+    gimp_image_set_cmap(image, (guchar *)&palette, num_palette);
 #endif /* PNG_LIBPNG_VER > 99 */
 
   }
@@ -659,18 +662,18 @@
   */
 
   tile_height = gimp_tile_height ();
-  pixel       = g_new(guchar, tile_height * info->width * bpp);
+  pixel       = g_new(guchar, tile_height * png_get_image_width(pp,info) * bpp);
   pixels      = g_new(guchar *, tile_height);
 
-  if(info->bit_depth==16)
+  if(png_get_bit_depth(pp,info)==16)
   {
 	  for (i = 0; i < tile_height; i ++)
-		  pixels[i] = pixel + info->width * info->channels * i * 2;
+		  pixels[i] = pixel + png_get_image_width(pp,info) * png_get_channels(pp,info) * i * 2;
   }
   else
   {
 	  for (i = 0; i < tile_height; i ++)
-		  pixels[i] = pixel + info->width * info->channels * i;
+		  pixels[i] = pixel + png_get_image_width(pp,info) * png_get_channels(pp,info) * i;
   }
 
   for (pass = 0; pass < num_passes; pass ++)
@@ -680,11 +683,11 @@
 	   */
 
 	  for (begin = 0, end = tile_height;
-			  begin < info->height;
+			  begin < png_get_image_height(pp,info);
 			  begin += tile_height, end += tile_height)
 	  {
-		  if (end > info->height)
-			  end = info->height;
+		  if (end > png_get_image_height(pp,info))
+			  end = png_get_image_height(pp,info);
 
 		  num = end - begin;
 
@@ -697,21 +700,24 @@
 		  gimp_pixel_rgn_set_rect(&pixel_rgn, pixel, 0, begin,
 				  drawable->width, num);
 
-		  gimp_progress_update(((double)pass + (double)end / (double)info->height) /
+		  gimp_progress_update(((double)pass + (double)end / (double)png_get_image_height(pp,info)) /
 				  (double)num_passes);
 	  };
   };
 
 #if defined(PNG_iCCP_SUPPORTED)
+{
   /* set icc profile */
-  if (info->iccp_proflen > 0) {
-    gimp_image_set_icc_profile_by_mem (image, info->iccp_proflen,
-                                              info->iccp_profile,
-                                              ICC_IMAGE_PROFILE);
+  png_charpp name;
+  int ctype = PNG_COMPRESSION_TYPE_BASE;
+  png_bytepp prof;
+  png_uint_32 proflen;
+  if (png_get_iCCP(pp,info,name,&ctype,prof,&proflen) > 0) {
+    gimp_image_set_icc_profile_by_mem (image, proflen, prof, ICC_IMAGE_PROFILE);
     printf ("%s:%d %s() set embedded profile \"%s\"\n",
-             __FILE__,__LINE__,__func__,
-                                              info->iccp_name);
+             __FILE__,__LINE__,__func__,(const char *)name);
   }
+}
 #endif
 
  /*
@@ -774,6 +780,8 @@
  * 'save_image ()' - Save the specified image to a PNG file.
  */
 
+typedef png_info *png_infop;
+
 static gint
 save_image (gchar  *filename,	        /* I - File to save to */
 	    gint32  image_ID,	        /* I - Image to save */
@@ -794,7 +802,7 @@
   GPixelRgn	pixel_rgn;	/* Pixel region for layer */
   png_structp	pp;		/* PNG read pointer */
   png_infop	info;		/* PNG info pointer */
-  gint		num_colors;	/* Number of colors in colormap */
+  gint		num_colors = 0;	/* Number of colors in colormap */
   gint		offx, offy;	/* Drawable offsets from origin */
   guchar	**pixels,	/* Pixel rows */
 		*fixed,		/* Fixed-up pixel data */
@@ -808,6 +816,7 @@
                 blue;           /* Used for palette background */
   time_t	cutime;         /* Time since epoch */
   struct tm	*gmt;		/* GMT broken down */
+  int bit_depth,color_type;
 
  /*
   * PNG 0.89 and newer have a sane, forwards compatible constructor.
@@ -824,7 +833,7 @@
   info = (png_infop)calloc(sizeof(png_info), 1);
 #endif /* PNG_LIBPNG_VER > 88 */
 
-  if (setjmp (pp->jmpbuf))
+  if (setjmp (png_jmpbuf(pp)))
   {
     g_message ("%s\nPNG error. Couldn't save image", filename);
     return 0;
@@ -863,10 +872,6 @@
 
   png_set_compression_level (pp, pngvals.compression_level);
 
-  info->width          = drawable->width;
-  info->height         = drawable->height;
-  info->interlace_type = pngvals.interlaced;
-
  /*
   * Set color type and remember bytes per pixel count 
   */
@@ -874,71 +879,69 @@
   switch (type)
   {
     case RGB_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_RGB;
-	info->bit_depth      = 8;
+        color_type = PNG_COLOR_TYPE_RGB;
+	bit_depth      = 8;
         bpp              = 3;
         break;
     case RGBA_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-	info->bit_depth      = 8;
+        color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+	bit_depth      = 8;
         bpp              = 4;
         break;
     case GRAY_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_GRAY;
-	info->bit_depth      = 8;
+        color_type = PNG_COLOR_TYPE_GRAY;
+	bit_depth      = 8;
         bpp              = 1;
         break;
     case GRAYA_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
-	info->bit_depth      = 8;
+        color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
+	bit_depth      = 8;
         bpp              = 2;
         break;
     case INDEXED_IMAGE :
 	bpp		 = 1;
-	info->bit_depth      = 8;
-        info->color_type = PNG_COLOR_TYPE_PALETTE;
-	info->valid      |= PNG_INFO_PLTE;
-        info->palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
-        info->num_palette= num_colors;
+	bit_depth      = 8;
+        color_type = PNG_COLOR_TYPE_PALETTE;
+	void *plte = gimp_image_get_cmap(image_ID, &num_colors);
+	png_set_PLTE(pp,info,plte,num_colors);
         break;
     case INDEXEDA_IMAGE :
 	bpp		 = 2;
-	info->bit_depth      = 8;
-	info->color_type = PNG_COLOR_TYPE_PALETTE;
+	bit_depth      = 8;
+	color_type = PNG_COLOR_TYPE_PALETTE;
 	respin_cmap (pp, info, image_ID); /* fix up transparency */
 	break;
     case U16_RGB_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_RGB;
-	info->bit_depth      = 16;
+        color_type = PNG_COLOR_TYPE_RGB;
+	bit_depth      = 16;
         bpp              = 6;
         break;
     case U16_RGBA_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
-	info->bit_depth      = 16;
+        color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+	bit_depth      = 16;
         bpp              = 8;
         break;
     case U16_GRAY_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_GRAY;
-	info->bit_depth      = 16;
+        color_type = PNG_COLOR_TYPE_GRAY;
+	bit_depth      = 16;
         bpp              = 2;
         break;
     case U16_GRAYA_IMAGE :
-        info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
-	info->bit_depth      = 16;
+        color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
+	bit_depth      = 16;
         bpp              = 4;
         break;
-    case U16_INDEXED_IMAGE :
+    case U16_INDEXED_IMAGE :{
 	bpp		 = 2;
-	info->bit_depth      = 16;
-        info->color_type = PNG_COLOR_TYPE_PALETTE;
-	info->valid      |= PNG_INFO_PLTE;
-        info->palette= (png_colorp) gimp_image_get_cmap(image_ID, &num_colors);
-        info->num_palette= num_colors;
+	bit_depth      = 16;
+        color_type = PNG_COLOR_TYPE_PALETTE;
+	void *plte = gimp_image_get_cmap(image_ID, &num_colors);
+	png_set_PLTE(pp,info,plte,num_colors);
         break;
-    case U16_INDEXEDA_IMAGE :
+    }case U16_INDEXEDA_IMAGE :
 	bpp		 = 4;
-	info->bit_depth      = 16;
-	info->color_type = PNG_COLOR_TYPE_PALETTE;
+	bit_depth      = 16;
+	color_type = PNG_COLOR_TYPE_PALETTE;
 	respin_cmap (pp, info, image_ID); /* fix up transparency */
 	break;
     default:
@@ -950,16 +953,21 @@
   * Fix bit depths for (possibly) smaller colormap images
   */
   
-  if (info->valid & PNG_INFO_PLTE) {
-    if (info->num_palette <= 2)
-      info->bit_depth= 1;
-    else if (info->num_palette <= 4)
-      info->bit_depth= 2;
-    else if (info->num_palette <= 16)
-      info->bit_depth= 4;
+  if (png_get_valid(pp,info,PNG_INFO_PLTE) & PNG_INFO_PLTE) {
+    if (num_colors <= 2)
+      bit_depth= 1;
+    else if (num_colors <= 4)
+      bit_depth= 2;
+    else if (num_colors <= 16)
+      bit_depth= 4;
     /* otherwise the default is fine */
   }
 
+  png_set_IHDR(pp,info,drawable->width,drawable->height,
+		bit_depth,color_type,pngvals.interlaced,
+		PNG_COMPRESSION_TYPE_DEFAULT,
+		PNG_FILTER_TYPE_DEFAULT);
+
   // write icc profile
 #if defined(PNG_iCCP_SUPPORTED)
   if (gimp_image_has_icc_profile (image_ID, ICC_IMAGE_PROFILE)) {
@@ -973,7 +981,7 @@
                   0, buffer, size);
     printf ("%s:%d %s() embedd icc profile \"%s\"\n",
              __FILE__,__LINE__,__func__,
-                                              info->iccp_name);
+           gimp_image_get_icc_profile_description (image_ID, ICC_IMAGE_PROFILE));
   }
 #endif
 
@@ -1039,13 +1047,13 @@
   * Convert unpacked pixels to packed if necessary
   */
 
-  if (info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8)
+  if (png_get_color_type(pp, info) == PNG_COLOR_TYPE_PALETTE && png_get_bit_depth(pp,info) < 8)
     png_set_packing(pp);
 
   /* Set swapping for 16 bit per sample images */
   
 #ifndef WORDS_BIGENDIAN
-  if (info->bit_depth == 16)
+  if (png_get_bit_depth(pp,info) == 16)
 	  png_set_swap(pp);
 #endif
   
@@ -1077,7 +1085,7 @@
 	num = end - begin;
 	
 	gimp_pixel_rgn_get_rect (&pixel_rgn, pixel, 0, begin, drawable->width, num);
-        if (info->valid & PNG_INFO_tRNS) {
+        if (png_get_valid(pp,info,PNG_INFO_tRNS) & PNG_INFO_tRNS) {
           for (i = 0; i < num; ++i) {
 	    fixed= pixels[i];
             for (k = 0; k < drawable->width; ++k) {
@@ -1085,7 +1093,7 @@
             }
           }
        /* Forgot this case before, what if there are too many colors? */
-        } else if (info->valid & PNG_INFO_PLTE && bpp == 2) {
+        } else if (png_get_valid(pp,info,PNG_INFO_PLTE) & PNG_INFO_PLTE && bpp == 2) {
           for (i = 0; i < num; ++i) {
 	    fixed= pixels[i];
             for (k = 0; k < drawable->width; ++k) {
@@ -1097,7 +1105,7 @@
 	png_write_rows (pp, pixels, num);
 	
 	gimp_progress_update (((double)pass + (double)end /
-                    (double)info->height) / (double)num_passes);
+                    (double)png_get_image_height(pp,info)) / (double)num_passes);
       };
   };
 
