diff --git a/libpng-manual.txt b/libpng-manual.txt index 240308329..62809ca84 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.5.1rc01 - January 21, 2011 + libpng version 1.5.1beta07 - January 22, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.1rc01 - January 21, 2011 + libpng versions 0.97, January 1998, through 1.5.1beta07 - January 22, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -309,13 +309,15 @@ Customizing libpng. FILE *fp = fopen(file_name, "rb"); if (!fp) { - return (ERROR); + return (ERROR); } + fread(header, 1, number, fp); is_png = !png_sig_cmp(header, 0, number); + if (!is_png) { - return (NOT_PNG); + return (NOT_PNG); } @@ -331,29 +333,32 @@ The structure allocation functions quietly return NULL if they fail to create the structure, so your application should check for that. png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, user_error_fn, user_warning_fn); + if (!png_ptr) - return (ERROR); + return (ERROR); png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { - png_destroy_read_struct(&png_ptr, + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); + return (ERROR); } png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - return (ERROR); + return (ERROR); } If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use +use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use png_create_read_struct_2() instead of png_create_read_struct(): png_structp png_ptr = png_create_read_struct_2 @@ -381,10 +386,10 @@ free any memory. if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - fclose(fp); - return (ERROR); + fclose(fp); + return (ERROR); } If you would rather avoid the complexity of setjmp/longjmp issues, @@ -523,14 +528,17 @@ chunk types. To change this, you can call: 1: ignore; do not keep 2: keep only if safe-to-copy 3: keep even if unsafe-to-copy + You can use these definitions: PNG_HANDLE_CHUNK_AS_DEFAULT 0 PNG_HANDLE_CHUNK_NEVER 1 PNG_HANDLE_CHUNK_IF_SAFE 2 PNG_HANDLE_CHUNK_ALWAYS 3 + chunk_list - list of chunks affected (a byte string, five bytes per chunk, NULL or '\0' if num_chunks is 0) + num_chunks - number of chunks affected; if 0, all unknown chunks are affected. If nonzero, only the chunks in the list are affected @@ -566,8 +574,10 @@ callback function: #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* ignore all unknown chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); + /* also ignore unused known chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, (int)sizeof(unused_chunks)/5); @@ -680,17 +690,22 @@ row_pointers prior to calling png_read_png() with if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) png_error (png_ptr, - "Image is too tall to process in memory"); + "Image is too tall to process in memory"); + if (width > PNG_UINT_32_MAX/pixel_size) png_error (png_ptr, - "Image is too wide to process in memory"); + "Image is too wide to process in memory"); + row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); + height*png_sizeof(png_bytep)); + for (int i=0; i 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + if (PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); When PNG_DEBUG is defined but is zero, the macros aren't defined, but you can still use PNG_DEBUG to control your own debugging: @@ -3180,11 +3355,13 @@ Libpng can support some of these extensions. To enable them, use the png_permit_mng_features() function: feature_set = png_permit_mng_features(png_ptr, mask) + mask is a png_uint_32 containing the bitwise OR of the features you want to enable. These include PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_FILTER_64 PNG_ALL_MNG_FEATURES + feature_set is a png_uint_32 that is the bitwise AND of your mask with the set of MNG features that is supported by the version of libpng that you are using. @@ -3209,7 +3386,7 @@ still alive and well, but they have moved on to other things. The old libpng functions png_read_init(), png_write_init(), png_info_init(), png_read_destroy(), and png_write_destroy() have been moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. +functions will be removed from libpng version 1.4.0. The preferred method of creating and initializing the libpng structures is via the png_create_read_struct(), png_create_write_struct(), and @@ -3445,7 +3622,8 @@ PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support was reenabled, but the function was renamed png_set_quantize() to reflect more accurately what it actually does. At the same time, the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to -PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. +PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED +was renamed to PNG_READ_QUANTIZE_SUPPORTED. We removed the trailing '.' from the warning and error messages. @@ -3472,7 +3650,7 @@ png_memcmp(), png_sprintf, and png_memcpy() macros into a private header file (pngpriv.h) that is not accessible to applications. In png_get_iCCP, the type of "profile" was changed from png_charpp -to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytepp. +to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep. There are changes of form in png.h, including new and changed macros to declare @@ -3587,8 +3765,8 @@ changed. A single set of operating system independent macro definitions is used and operating system specific directives are defined in pnglibconf.h -As part of this the mechanism used to chose procedure call standards on those -systems that allow a choice has been changed. At present this only +As part of this the mechanism used to choose procedure call standards on +those systems that allow a choice has been changed. At present this only affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems running on Intel processors. As before PNGAPI is defined where required to control the exported API functions; however, two new macros, PNGCBAPI @@ -3606,7 +3784,7 @@ necessary to set PNG_API_RULE to 1 should advise the mailing list therefore set PNG_API_RULE to 2 should also contact the mailing list. A new test program, pngvalid, is provided in addition to pngtest. - pngvalid validates the arithmetic accuracy of the gamma correction +pngvalid validates the arithmetic accuracy of the gamma correction calculations and includes a number of validations of the file format. A subset of the full range of tests is run when "make check" is done (in the 'configure' build.) pngvalid also allows total allocated memory @@ -3689,8 +3867,8 @@ unmodified, default, libpng API and thus would probably fail to link. These mechanisms still work in the configure build and in any makefile build that builds pnglibconf.h although the feature selection macros -have changed somewhat as described above. In 1.5.0, however, pngusr.h -is processed once when the exported header file pnglibconf.h is built. +have changed somewhat as described above. In 1.5.0, however, pngusr.h is +processed only once, when the exported header file pnglibconf.h is built. pngconf.h no longer includes pngusr.h, therefore it is ignored after the build of pnglibconf.h and it is never included in an application build. @@ -3745,6 +3923,11 @@ the libpng bug tracker at http://libpng.sourceforge.net +We also accept patches built from the tar or zip distributions, and +simple verbal discriptions of bug fixes, reported either to the +SourceForge bug tracker or to the png-mng-implement at lists.sf.net +mailing list. + XIII. Coding style Our coding style is similar to the "Allman" style, with curly @@ -3855,13 +4038,13 @@ Other rules can be inferred by inspecting the libpng source. XIV. Y2K Compliance in libpng -January 21, 2011 +January 22, 2011 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.5.1rc01 are Y2K compliant. It is my belief that earlier +upward through 1.5.1beta07 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that diff --git a/libpng.3 b/libpng.3 index 77aba88ee..0cca06a35 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "January 21, 2011" +.TH LIBPNG 3 "January 22, 2011" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1beta07 .SH SYNOPSIS \fI\fB @@ -92,75 +92,75 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_bit_depth (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP +\fBpng_uint_32 png_get_bKGD (const_png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP \fI\fB -\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_channels (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP +\fBpng_uint_32 png_get_cHRM (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP +\fBpng_uint_32 png_get_cHRM_fixed (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_chunk_cache_max (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_chunk_cache_max (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_color_type (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_compression_buffer_size (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_compression_type (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_byte png_get_copyright (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_voidp png_get_error_ptr (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_filter_type (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP +\fBpng_uint_32 png_get_gAMA (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP +\fBpng_uint_32 png_get_gAMA_fixed (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP \fI\fB -\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_byte png_get_header_ver (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_byte png_get_header_version (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP +\fBpng_uint_32 png_get_hIST (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_bytepp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP +\fBpng_uint_32 png_get_iCCP (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_bytepp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP \fI\fB @@ -168,11 +168,11 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_image_height (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_image_width (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB @@ -180,7 +180,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_byte png_get_interlace_type (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB @@ -188,109 +188,109 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_byte png_get_libpng_ver (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_alloc_size_t png_get_chunk_malloc_max (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_alloc_size_t png_get_chunk_malloc_max (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_voidp png_get_mem_ptr(const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBint png_get_num_cols (png_structp \fIpng_ptr\fP\fB);\fP +\fBint png_get_num_cols (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBint png_get_num_passes (png_structp \fIpng_ptr\fP\fB);\fP +\fBint png_get_num_passes (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBint png_get_num_rows (png_structp \fIpng_ptr\fP\fB);\fP +\fBint png_get_num_rows (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP +\fBpng_uint_32 png_get_oFFs (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP +\fBpng_uint_32 png_get_pCAL (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP +\fBpng_uint_32 png_get_pHYs (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP \fI\fB -\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBfloat png_get_pixel_aspect_ratio (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_fixed_point png_get_pixel_aspect_ratio_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_fixed_point png_get_pixel_aspect_ratio_fixed (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_pixels_per_meter (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_voidp png_get_progressive_ptr (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP +\fBpng_uint_32 png_get_PLTE (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP \fI\fB -\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr) +\fBpng_byte png_get_rgb_to_gray_status (const_png_structp \fIpng_ptr) -\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_rowbytes (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_bytepp png_get_rows (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP +\fBpng_uint_32 png_get_sBIT (const_png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP \fI\fB -\fBvoid png_get_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, double* \fP\fIwidth\fP\fB, double* \fIheight\fP\fB);\fP +\fBvoid png_get_sCAL (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, double* \fP\fIwidth\fP\fB, double* \fIheight\fP\fB);\fP \fI\fB -\fBvoid png_get_sCAL_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_fixed_pointp \fP\fIwidth\fP\fB, png_fixed_pointp \fIheight\fP\fB);\fP +\fBvoid png_get_sCAL_fixed (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_fixed_pointp \fP\fIwidth\fP\fB, png_fixed_pointp \fIheight\fP\fB);\fP \fI\fB -\fBvoid png_get_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_charpp \fP\fIwidth\fP\fB, \fIpng_charppheight\fP\fB);\fP +\fBvoid png_get_sCAL_s (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_charpp \fP\fIwidth\fP\fB, png_charpp \fIheight\fP\fB);\fP \fI\fB -\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_bytep png_get_signature (const_png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_sPLT (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP +\fBpng_uint_32 png_get_sRGB (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP +\fBpng_uint_32 png_get_text (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP +\fBpng_uint_32 png_get_tIME (const_png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans_alpha\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_color\fP\fB);\fP +\fBpng_uint_32 png_get_tRNS (const_png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans_alpha\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_color\fP\fB);\fP \fI\fB @@ -300,7 +300,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP +\fBpng_uint_32 png_get_uint_31 (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIbuf\fP\fB);\fP \fI\fB @@ -310,67 +310,67 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1rc01 \fI\fB -\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP +\fBpng_uint_32 png_get_unknown_chunks (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP \fI\fB -\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_voidp png_get_user_chunk_ptr (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_user_height_max(const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_voidp png_get_user_transform_ptr (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_user_width_max (const_png_structp \fIpng_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP +\fBpng_uint_32 png_get_valid (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP \fI\fB -\fBfloat png_get_x_offset_inches (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBfloat png_get_x_offset_inches (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_fixed_point png_get_x_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_fixed_point png_get_x_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_int_32 png_get_x_offset_microns (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_int_32 png_get_x_offset_pixels (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_x_pixels_per_meter (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBfloat png_get_y_offset_inches (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBfloat png_get_y_offset_inches (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_fixed_point png_get_y_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_fixed_point png_get_y_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_int_32 png_get_y_offset_microns (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_int_32 png_get_y_offset_pixels (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB -\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBpng_uint_32 png_get_y_pixels_per_meter (const_png_structp \fP\fIpng_ptr\fP\fB, const_png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB @@ -851,7 +851,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.5.1rc01 - January 21, 2011 + libpng version 1.5.1beta07 - January 22, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -862,7 +862,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.1rc01 - January 21, 2011 + libpng versions 0.97, January 1998, through 1.5.1beta07 - January 22, 2011 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -1160,13 +1160,15 @@ Customizing libpng. FILE *fp = fopen(file_name, "rb"); if (!fp) { - return (ERROR); + return (ERROR); } + fread(header, 1, number, fp); is_png = !png_sig_cmp(header, 0, number); + if (!is_png) { - return (NOT_PNG); + return (NOT_PNG); } @@ -1182,29 +1184,32 @@ The structure allocation functions quietly return NULL if they fail to create the structure, so your application should check for that. png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, user_error_fn, user_warning_fn); + if (!png_ptr) - return (ERROR); + return (ERROR); png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { - png_destroy_read_struct(&png_ptr, + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); + return (ERROR); } png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - return (ERROR); + return (ERROR); } If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use +use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use png_create_read_struct_2() instead of png_create_read_struct(): png_structp png_ptr = png_create_read_struct_2 @@ -1232,10 +1237,10 @@ free any memory. if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_read_struct(&png_ptr, &info_ptr, + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - fclose(fp); - return (ERROR); + fclose(fp); + return (ERROR); } If you would rather avoid the complexity of setjmp/longjmp issues, @@ -1374,14 +1379,17 @@ chunk types. To change this, you can call: 1: ignore; do not keep 2: keep only if safe-to-copy 3: keep even if unsafe-to-copy + You can use these definitions: PNG_HANDLE_CHUNK_AS_DEFAULT 0 PNG_HANDLE_CHUNK_NEVER 1 PNG_HANDLE_CHUNK_IF_SAFE 2 PNG_HANDLE_CHUNK_ALWAYS 3 + chunk_list - list of chunks affected (a byte string, five bytes per chunk, NULL or '\0' if num_chunks is 0) + num_chunks - number of chunks affected; if 0, all unknown chunks are affected. If nonzero, only the chunks in the list are affected @@ -1417,8 +1425,10 @@ callback function: #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* ignore all unknown chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); + /* also ignore unused known chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, (int)sizeof(unused_chunks)/5); @@ -1531,17 +1541,22 @@ row_pointers prior to calling png_read_png() with if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) png_error (png_ptr, - "Image is too tall to process in memory"); + "Image is too tall to process in memory"); + if (width > PNG_UINT_32_MAX/pixel_size) png_error (png_ptr, - "Image is too wide to process in memory"); + "Image is too wide to process in memory"); + row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); + height*png_sizeof(png_bytep)); + for (int i=0; i 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + if (PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); When PNG_DEBUG is defined but is zero, the macros aren't defined, but you can still use PNG_DEBUG to control your own debugging: @@ -4031,11 +4206,13 @@ Libpng can support some of these extensions. To enable them, use the png_permit_mng_features() function: feature_set = png_permit_mng_features(png_ptr, mask) + mask is a png_uint_32 containing the bitwise OR of the features you want to enable. These include PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_FILTER_64 PNG_ALL_MNG_FEATURES + feature_set is a png_uint_32 that is the bitwise AND of your mask with the set of MNG features that is supported by the version of libpng that you are using. @@ -4060,7 +4237,7 @@ still alive and well, but they have moved on to other things. The old libpng functions png_read_init(), png_write_init(), png_info_init(), png_read_destroy(), and png_write_destroy() have been moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. +functions will be removed from libpng version 1.4.0. The preferred method of creating and initializing the libpng structures is via the png_create_read_struct(), png_create_write_struct(), and @@ -4296,7 +4473,8 @@ PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support was reenabled, but the function was renamed png_set_quantize() to reflect more accurately what it actually does. At the same time, the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to -PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. +PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED +was renamed to PNG_READ_QUANTIZE_SUPPORTED. We removed the trailing '.' from the warning and error messages. @@ -4323,7 +4501,7 @@ png_memcmp(), png_sprintf, and png_memcpy() macros into a private header file (pngpriv.h) that is not accessible to applications. In png_get_iCCP, the type of "profile" was changed from png_charpp -to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytepp. +to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep. There are changes of form in png.h, including new and changed macros to declare @@ -4438,8 +4616,8 @@ changed. A single set of operating system independent macro definitions is used and operating system specific directives are defined in pnglibconf.h -As part of this the mechanism used to chose procedure call standards on those -systems that allow a choice has been changed. At present this only +As part of this the mechanism used to choose procedure call standards on +those systems that allow a choice has been changed. At present this only affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems running on Intel processors. As before PNGAPI is defined where required to control the exported API functions; however, two new macros, PNGCBAPI @@ -4457,7 +4635,7 @@ necessary to set PNG_API_RULE to 1 should advise the mailing list therefore set PNG_API_RULE to 2 should also contact the mailing list. A new test program, pngvalid, is provided in addition to pngtest. - pngvalid validates the arithmetic accuracy of the gamma correction +pngvalid validates the arithmetic accuracy of the gamma correction calculations and includes a number of validations of the file format. A subset of the full range of tests is run when "make check" is done (in the 'configure' build.) pngvalid also allows total allocated memory @@ -4540,8 +4718,8 @@ unmodified, default, libpng API and thus would probably fail to link. These mechanisms still work in the configure build and in any makefile build that builds pnglibconf.h although the feature selection macros -have changed somewhat as described above. In 1.5.0, however, pngusr.h -is processed once when the exported header file pnglibconf.h is built. +have changed somewhat as described above. In 1.5.0, however, pngusr.h is +processed only once, when the exported header file pnglibconf.h is built. pngconf.h no longer includes pngusr.h, therefore it is ignored after the build of pnglibconf.h and it is never included in an application build. @@ -4596,6 +4774,11 @@ the libpng bug tracker at http://libpng.sourceforge.net +We also accept patches built from the tar or zip distributions, and +simple verbal discriptions of bug fixes, reported either to the +SourceForge bug tracker or to the png-mng-implement at lists.sf.net +mailing list. + .SH XIII. Coding style Our coding style is similar to the "Allman" style, with curly @@ -4706,13 +4889,13 @@ Other rules can be inferred by inspecting the libpng source. .SH XIV. Y2K Compliance in libpng -January 21, 2011 +January 22, 2011 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.5.1rc01 are Y2K compliant. It is my belief that earlier +upward through 1.5.1beta07 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that @@ -4952,7 +5135,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.5.1rc01 - January 21, 2011: +Libpng version 1.5.1beta07 - January 22, 2011: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -4975,7 +5158,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.1rc01, January 21, 2011, are +libpng versions 1.2.6, August 15, 2004, through 1.5.1beta07, January 22, 2011, are Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -5074,7 +5257,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -January 21, 2011 +January 22, 2011 .\" end of man page