fd98e1
From 56103b05af8a9d67ce158eceab9f7c984b38eabb Mon Sep 17 00:00:00 2001
fd98e1
From: Jon Ciesla <limburgher@gmail.com>
fd98e1
Date: Fri, 2 Mar 2012 09:39:36 -0600
fd98e1
Subject: [PATCH 3/3] libpng fix.
fd98e1
fd98e1
---
fd98e1
 input-png.c | 22 ++++++----------------
fd98e1
 1 file changed, 6 insertions(+), 16 deletions(-)
fd98e1
fd98e1
diff --git a/input-png.c b/input-png.c
fd98e1
index 77b96f1..b631f07 100644
fd98e1
--- a/input-png.c
fd98e1
+++ b/input-png.c
fd98e1
@@ -42,7 +42,7 @@ static png_bytep * read_png(png_structp png_ptr, png_infop info_ptr, at_input_op
fd98e1
 
fd98e1
 static void handle_warning(png_structp png, const at_string message) {
fd98e1
         LOG1("PNG warning: %s", message);
fd98e1
-	at_exception_warning((at_exception_type *)png->error_ptr,
fd98e1
+	at_exception_warning((at_exception_type *)png_get_error_ptr(png),
fd98e1
 			     message);
fd98e1
 	/* at_exception_fatal((at_exception_type *)at_png->error_ptr,
fd98e1
 	   "PNG warning"); */
fd98e1
@@ -50,7 +50,7 @@ static void handle_warning(png_structp png, const at_string message) {
fd98e1
 
fd98e1
 static void handle_error(png_structp png, const at_string message) {
fd98e1
 	LOG1("PNG error: %s", message);
fd98e1
-	at_exception_fatal((at_exception_type *)png->error_ptr,
fd98e1
+	at_exception_fatal((at_exception_type *)png_get_error_ptr(png),
fd98e1
 			   message);
fd98e1
 	/* at_exception_fatal((at_exception_type *)at_png->error_ptr,
fd98e1
 	   "PNG error"); */
fd98e1
@@ -157,8 +157,8 @@ read_png(png_structp png_ptr, png_infop info_ptr, at_input_opts_type * opts)
fd98e1
 
fd98e1
 	png_set_strip_16(png_ptr);
fd98e1
 	png_set_packing(png_ptr);
fd98e1
-	if ((png_ptr->bit_depth < 8) ||
fd98e1
-	    (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
fd98e1
+	if ((png_get_bit_depth(png_ptr, info_ptr) < 8) ||
fd98e1
+	    (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) ||
fd98e1
 	    (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
fd98e1
 		png_set_expand(png_ptr);
fd98e1
 
fd98e1
@@ -181,20 +181,10 @@ read_png(png_structp png_ptr, png_infop info_ptr, at_input_opts_type * opts)
fd98e1
 				   PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
fd98e1
 	} else
fd98e1
 		png_set_strip_alpha(png_ptr);
fd98e1
+	png_set_interlace_handling(png_ptr);
fd98e1
 	png_read_update_info(png_ptr, info_ptr);
fd98e1
 
fd98e1
-
fd98e1
-	info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
fd98e1
-							info_ptr->height * sizeof(png_bytep));
fd98e1
-#ifdef PNG_FREE_ME_SUPPORTED
fd98e1
-	info_ptr->free_me |= PNG_FREE_ROWS;
fd98e1
-#endif
fd98e1
-	for (row = 0; row < (int)info_ptr->height; row++)
fd98e1
-		info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
fd98e1
-								    png_get_rowbytes(png_ptr, info_ptr));
fd98e1
-	
fd98e1
-	png_read_image(png_ptr, info_ptr->row_pointers);
fd98e1
-	info_ptr->valid |= PNG_INFO_IDAT;
fd98e1
+	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
fd98e1
 	png_read_end(png_ptr, info_ptr);
fd98e1
 	return png_get_rows(png_ptr, info_ptr);
fd98e1
 }
fd98e1
-- 
fd98e1
1.7.11.2
fd98e1