From 53f7051b1bfc57011b279e7fb8e351bbdfd411f3 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sat, 1 Sep 2012 13:26:41 -0500 Subject: [PATCH] [libpng] Fixed contrib/examples/png2png.c --- contrib/examples/pngtopng.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contrib/examples/pngtopng.c b/contrib/examples/pngtopng.c index b8e416808..b1b3be677 100644 --- a/contrib/examples/pngtopng.c +++ b/contrib/examples/pngtopng.c @@ -29,13 +29,17 @@ int main(int argc, const char **argv) { png_image image; + /* Only the image structure version number needs to be set. */ memset(&image, 0, sizeof image); + image.version = PNG_IMAGE_VERSION; if (png_image_begin_read_from_file(&image, argv[1])) { png_bytep buffer; - /* Change this to try different formats! */ + /* Change this to try different formats! If you set a colormap format + * then you must also supply a colormap below. + */ image.format = PNG_FORMAT_RGBA; buffer = malloc(PNG_IMAGE_SIZE(image)); @@ -43,10 +47,11 @@ int main(int argc, const char **argv) if (buffer != NULL) { if (png_image_finish_read(&image, NULL/*background*/, buffer, - 0/*row_stride*/)) + 0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */)) { if (png_image_write_to_file(&image, argv[2], - 0/*convert_to_8bit*/, buffer, 0/*row_stride*/)) + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/)) result = 0; else