X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b02c8a11f0e0d284eff32cfde1fcd2a4b2e659d..935789271447807376993f92acf6397e3f1e79a5:/src/png/example.c diff --git a/src/png/example.c b/src/png/example.c index fb1f5ed1d9..08158731a6 100644 --- a/src/png/example.c +++ b/src/png/example.c @@ -1,7 +1,13 @@ #if 0 /* in case someone actually tries to compile this */ -/* example.c - an example of using libpng */ +/* example.c - an example of using libpng + * Last changed in libpng 1.2.1 December 7, 2001. + * This file has been placed in the public domain by the authors. + * Maintained 1998-2007 Glenn Randers-Pehrson + * Maintained 1996, 1997 Andreas Dilger) + * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ /* This is an example of how to use libpng to read and write PNG files. * The file libpng.txt is much more verbose then this. If you have not @@ -194,7 +200,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ /* Expand paletted colors into true RGB triplets */ if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_rgb(png_ptr); + png_set_palette_to_rgb(png_ptr); /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) @@ -490,10 +496,10 @@ row_callback(png_structp png_ptr, png_bytep new_row, * In this function you will receive a pointer to new row data from * libpng called new_row that is to replace a corresponding row (of * the same data format) in a buffer allocated by your application. - * + * * The new row data pointer new_row may be NULL, indicating there is * no new data to be replaced (in cases of interlace loading). - * + * * If new_row is not NULL then you need to call * png_progressive_combine_row() to replace the corresponding row as * shown below: @@ -742,6 +748,9 @@ void write_png(char *file_name /* , ... other image information ... */) png_byte image[height][width*bytes_per_pixel]; png_bytep row_pointers[height]; + if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) + png_error (png_ptr, "Image is too tall to process in memory"); + for (k = 0; k < height; k++) row_pointers[k] = image + k*width*bytes_per_pixel;