diff --git a/ANNOUNCE b/ANNOUNCE index b4e44d991..0fdaeb63c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.4.0beta50 - March 9, 2009 +Libpng 1.4.0beta51 - March 21, 2009 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -9,27 +9,27 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - 1.4.0beta50.tar.gz - 1.4.0beta50.tar.bz2 + 1.4.0beta51.tar.gz + 1.4.0beta51.tar.bz2 Source files with LF line endings (for Unix/Linux) without the "configure" script - 1.4.0beta50-no-config.tar.gz - 1.4.0beta50-no-config.tar.bz2 + 1.4.0beta51-no-config.tar.gz + 1.4.0beta51-no-config.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp140b50.zip - lp140b50.tar.bz2 + lp140b51.zip + lp140b51.tar.bz2 Other information: - 1.4.0beta50-README.txt - 1.4.0beta50-KNOWNBUGS.txt - 1.4.0beta50-LICENSE.txt - 1.4.0beta50-Y2K-compliance.txt + 1.4.0beta51-README.txt + 1.4.0beta51-KNOWNBUGS.txt + 1.4.0beta51-LICENSE.txt + 1.4.0beta51-Y2K-compliance.txt Changes since the last public release (1.2.10): @@ -343,7 +343,7 @@ version 1.4.0beta38 [November 22, 2008] Added check for zero-area RGB cHRM triange in png_check_cHRM() and png_check_cHRM_fixed(). -version 1.4.0beta39 [March 9, 2009] +version 1.4.0beta39 [March 21, 2009] Revised png_warning() to write its message on standard output by default when warning_fn is NULL. @@ -392,9 +392,19 @@ version 1.4.0beta49 [February 28, 2009] (bug introduced in libpng-1.2.34/1.4.0beta29). Revised comments in png_set_read_fn() and png_set_write_fn(). -version 1.4.0beta50 [March 9, 2009] +version 1.4.0beta50 [March 21, 2009] Use png_calloc() instead of png_malloc() to allocate big_row_buf when reading an interlaced file, to avoid a possible UMR. + Undid recent revision of PNG_NO_STDIO version of png_write_flush(). Users + having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined + or supply their own flush_fn() replacement. + Revised libpng*.txt and png.h documentation about use of png_write_flush() + and png_set_write_fn(). + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h + +version 1.4.0beta51 [March 21, 2009] + Removed new png_fileno() macro from pngconf.h . version 1.4.0betaN [future] Build shared libraries with -lz and sometimes -lm. diff --git a/CHANGES b/CHANGES index 915636665..d4fda8699 100644 --- a/CHANGES +++ b/CHANGES @@ -2068,9 +2068,19 @@ version 1.4.0beta49 [February 28, 2009] (bug introduced in libpng-1.2.34/1.4.0beta29). Revised comments in png_set_read_fn() and png_set_write_fn(). -version 1.4.0beta50 [March 9, 2009] +version 1.4.0beta50 [March 21, 2009] Use png_calloc() instead of png_malloc() to allocate big_row_buf when reading an interlaced file, to avoid a possible UMR. + Undid revision of PNG_NO_STDIO version of png_write_flush(). Users + having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined + or supply their own flush_fn() replacement. + Revised libpng*.txt and png.h documentation about use of png_write_flush() + and png_set_write_fn(). + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h + +version 1.4.0beta51 [March 21, 2009] + Removed new png_fileno() macro from pngconf.h . version 1.4.0betaN [future] Build shared libraries with -lz and sometimes -lm. diff --git a/INSTALL b/INSTALL index cdb5b43b4..054d0e240 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ -Installing libpng version 1.4.0beta50 - March 9, 2009 +Installing libpng version 1.4.0beta51 - March 21, 2009 On Unix/Linux and similar systems, you can simply type @@ -44,7 +44,7 @@ to have access to the zlib.h and zconf.h include files that correspond to the version of zlib that's installed. You can rename the directories that you downloaded (they -might be called "libpng-1.4.0beta50" or "lpng109" and "zlib-1.2.1" +might be called "libpng-1.4.0beta51" or "lpng109" and "zlib-1.2.1" or "zlib121") so that you have directories called "zlib" and "libpng". Your directory structure should look like this: @@ -95,14 +95,14 @@ include CMakeLists.txt => "cmake" script makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng14.so.14.1.4.0beta50) + gcc, creates libpng14.so.14.1.4.0beta51) makefile.linux => Linux/ELF makefile - (gcc, creates libpng14.so.14.1.4.0beta50) + (gcc, creates libpng14.so.14.1.4.0beta51) makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng14.so.14.1.4.0beta50, + (gcc, creates libpng14.so.14.1.4.0beta51, uses assembler code tuned for Intel MMX platform) makefile.nommx => Linux/ELF makefile - (gcc, creates libpng14.so.14.1.4.0beta50 + (gcc, creates libpng14.so.14.1.4.0beta51 does not use Intel MMX assembler code) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -125,12 +125,12 @@ include makefile.openbsd => OpenBSD makefile makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) makefile.sggcc => Silicon Graphics (gcc, - creates libpng14.so.14.1.4.0beta50) + creates libpng14.so.14.1.4.0beta51) makefile.sunos => Sun makefile makefile.solaris => Solaris 2.X makefile (gcc, - creates libpng14.so.14.1.4.0beta50) + creates libpng14.so.14.1.4.0beta51) makefile.so9 => Solaris 9 makefile (gcc, - creates libpng14.so.14.1.4.0beta50) + creates libpng14.so.14.1.4.0beta51) makefile.32sunu => Sun Ultra 32-bit makefile makefile.64sunu => Sun Ultra 64-bit makefile makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc diff --git a/KNOWNBUG b/KNOWNBUG index 8abe209b1..ba00d2b0f 100644 --- a/KNOWNBUG +++ b/KNOWNBUG @@ -1,5 +1,5 @@ -Known bugs in libpng version 1.4.0beta50 +Known bugs in libpng version 1.4.0beta51 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when reading interlaced PNG files, when assembler code is enabled but running diff --git a/LICENSE b/LICENSE index ab366ec22..0f2e500cd 100644 --- a/LICENSE +++ b/LICENSE @@ -8,7 +8,7 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.2.6, August 15, 2004, through 1.4.0beta50, March 9, 2009, are +libpng versions 1.2.6, August 15, 2004, through 1.4.0beta51, March 21, 2009, 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 @@ -106,4 +106,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -March 9, 2009 +March 21, 2009 diff --git a/Makefile.am b/Makefile.am index 08b4435c2..9329f655b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,7 +86,7 @@ EXTRA_DIST= \ ${srcdir}/contrib/pngsuite/* \ ${srcdir}/contrib/visupng/* \ $(TESTS) \ - example.c libpng-1.4.0beta50.txt pngvcrd.c + example.c libpng-1.4.0beta51.txt pngvcrd.c CLEANFILES= pngout.png libpng14.pc libpng14-config libpng.vers \ libpng.sym diff --git a/Makefile.in b/Makefile.in index 48979a51b..8cf7ac239 100644 --- a/Makefile.in +++ b/Makefile.in @@ -331,7 +331,7 @@ EXTRA_DIST = \ ${srcdir}/contrib/pngsuite/* \ ${srcdir}/contrib/visupng/* \ $(TESTS) \ - example.c libpng-1.4.0beta50.txt pngvcrd.c + example.c libpng-1.4.0beta51.txt pngvcrd.c CLEANFILES = pngout.png libpng14.pc libpng14-config libpng.vers \ libpng.sym diff --git a/README b/README index e70af0116..d3ad9bbf6 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -README for libpng version 1.4.0beta50 - March 9, 2009 (shared library 14.0) +README for libpng version 1.4.0beta51 - March 21, 2009 (shared library 14.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. @@ -184,11 +184,11 @@ Files in this distribution: descrip.mms => VMS makefile for MMS or MMK makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng14.so.14.1.4.0beta50) + gcc, creates libpng14.so.14.1.4.0beta51) makefile.linux => Linux/ELF makefile - (gcc, creates libpng14.so.14.1.4.0beta50) + (gcc, creates libpng14.so.14.1.4.0beta51) makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng14.so.14.1.4.0beta50, + (gcc, creates libpng14.so.14.1.4.0beta51, uses assembler code tuned for Intel MMX platform) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -210,12 +210,12 @@ Files in this distribution: makefile.openbsd => OpenBSD makefile makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) makefile.sggcc => Silicon Graphics - (gcc, creates libpng14.so.14.1.4.0beta50) + (gcc, creates libpng14.so.14.1.4.0beta51) makefile.sunos => Sun makefile makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng14.so.14.1.4.0beta50) + (gcc, creates libpng14.so.14.1.4.0beta51) makefile.so9 => Solaris 9 makefile - (gcc, creates libpng14.so.14.1.4.0beta50) + (gcc, creates libpng14.so.14.1.4.0beta51) makefile.32sunu => Sun Ultra 32-bit makefile makefile.64sunu => Sun Ultra 64-bit makefile makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc diff --git a/configure b/configure index 6b804ac62..af527d94c 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for libpng 1.4.0beta50. +# Generated by GNU Autoconf 2.62 for libpng 1.4.0beta51. # # Report bugs to . # @@ -745,8 +745,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.4.0beta50' -PACKAGE_STRING='libpng 1.4.0beta50' +PACKAGE_VERSION='1.4.0beta51' +PACKAGE_STRING='libpng 1.4.0beta51' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' ac_unique_file="pngget.c" @@ -1484,7 +1484,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libpng 1.4.0beta50 to adapt to many kinds of systems. +\`configure' configures libpng 1.4.0beta51 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1554,7 +1554,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.4.0beta50:";; + short | recursive ) echo "Configuration of libpng 1.4.0beta51:";; esac cat <<\_ACEOF @@ -1661,7 +1661,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.4.0beta50 +libpng configure 1.4.0beta51 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1675,7 +1675,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.4.0beta50, which was +It was created by libpng $as_me 1.4.0beta51, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -2389,7 +2389,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.4.0beta50' + VERSION='1.4.0beta51' cat >>confdefs.h <<_ACEOF @@ -2558,7 +2558,7 @@ fi -PNGLIB_VERSION=1.4.0beta50 +PNGLIB_VERSION=1.4.0beta51 PNGLIB_MAJOR=1 PNGLIB_MINOR=4 PNGLIB_RELEASE=0 @@ -13125,7 +13125,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.4.0beta50, which was +This file was extended by libpng $as_me 1.4.0beta51, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13178,7 +13178,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -libpng config.status 1.4.0beta50 +libpng config.status 1.4.0beta51 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index f4681860c..46c8a5496 100644 --- a/configure.ac +++ b/configure.ac @@ -18,12 +18,12 @@ AC_PREREQ(2.59) dnl Version number stuff here: -AC_INIT([libpng], [1.4.0beta50], [png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng], [1.4.0beta51], [png-mng-implement@lists.sourceforge.net]) AM_INIT_AUTOMAKE dnl stop configure from automagically running automake AM_MAINTAINER_MODE -PNGLIB_VERSION=1.4.0beta50 +PNGLIB_VERSION=1.4.0beta51 PNGLIB_MAJOR=1 PNGLIB_MINOR=4 PNGLIB_RELEASE=0 diff --git a/contrib/pngminim/encoder/pngusr.h b/contrib/pngminim/encoder/pngusr.h index 904673abb..18989d124 100644 --- a/contrib/pngminim/encoder/pngusr.h +++ b/contrib/pngminim/encoder/pngusr.h @@ -51,6 +51,7 @@ #define PNG_NO_WRITE_FILTER #define PNG_NO_WRITE_WEIGHTED_FILTER #define PNG_NO_WRITE_INTERLACING_SUPPORTED +#define PNG_NO_WRITE_FLUSH #define PNG_NO_INFO_IMAGE #define PNG_NO_USER_MEM diff --git a/example.c b/example.c index b93e0f811..ffc8da2ca 100644 --- a/example.c +++ b/example.c @@ -2,7 +2,7 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * This file has been placed in the public domain by the authors. * Maintained 1998-2009 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) @@ -342,11 +342,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ /* The easiest way to read the image: */ png_bytep row_pointers[height]; + /* Clear the pointer array */ + for (row = 0; row < height; row++) + row_pointers[row] = NULL; + for (row = 0; row < height; row++) - { row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } /* Now it's time to read the image. One of these methods is REQUIRED */ #ifdef entire /* Read the entire image in one go */ @@ -597,7 +599,7 @@ void write_png(char *file_name /* , ... other image information ... */) */ if (setjmp(png_jmpbuf(png_ptr))) { - /* If we get here, we had a problem reading the file */ + /* If we get here, we had a problem writing the file */ fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); return (ERROR); @@ -692,7 +694,7 @@ void write_png(char *file_name /* , ... other image information ... */) * write_my_chunk(); * png_write_info(png_ptr, info_ptr); * - * However, given the level of known- and unknown-chunk support in 1.1.0 + * However, given the level of known- and unknown-chunk support in 1.2.0 * and up, this should no longer be necessary. */ @@ -771,9 +773,7 @@ void write_png(char *file_name /* , ... other image information ... */) /* If you are only writing one row at a time, this works */ for (y = 0; y < height; y++) - { png_write_rows(png_ptr, &row_pointers[y], 1); - } } #endif no_entire /* use only one output method */ diff --git a/libpng-1.4.0beta50.txt b/libpng-1.4.0beta51.txt similarity index 94% rename from libpng-1.4.0beta50.txt rename to libpng-1.4.0beta51.txt index ec730aa0f..b974dc77a 100644 --- a/libpng-1.4.0beta50.txt +++ b/libpng-1.4.0beta51.txt @@ -1,13 +1,17 @@ libpng.txt - A description on how to use and modify libpng - libpng version 1.4.0beta50 - March 9, 2009 + libpng version 1.4.0beta51 - March 21, 2009 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2005 Glenn Randers-Pehrson + Copyright (c) 1998-2009 Glenn Randers-Pehrson For conditions of distribution and use, see copyright notice in png.h. - based on: + Based on: + + libpng versions 0.97, January 1998, through 1.4.0beta51 - March 21, 2009 + Updated and distributed by Glenn Randers-Pehrson + Copyright (c) 1998-2008 Glenn Randers-Pehrson libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger @@ -33,6 +37,10 @@ it is heavily commented and should include everything most people will need. We assume that libpng is already installed; see the INSTALL file for instructions on how to install libpng. +For examples of libpng usage, see the files "example.c", "pngtest.c", +and the files in the "contrib" directory, all of which are included in the +libpng distribution. + Libpng was written as a companion to the PNG specification, as a way of reducing the amount of time and effort it takes to support the PNG file format in application programs. @@ -43,12 +51,14 @@ a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at The W3C and ISO documents have identical technical content. The PNG-1.2 specification is available at - +. It is technically equivalent +to the PNG specification (second edition) but has some additional material. The PNG-1.0 specification is available as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks +W3C Recommendation . + +Some additional chunks are described in the special-purpose public chunks documents at . Other information @@ -256,15 +266,19 @@ input stream. You must supply the function png_unknown_chunkp chunk); { /* The unknown chunk structure contains your - chunk data: */ + chunk data, along with similar data for any other + unknown chunks: */ + png_byte name[5]; png_byte *data; png_size_t size; + /* Note that libpng has already taken care of the CRC handling */ - /* put your code here. Return one of the - following: */ + /* put your code here. Search for your chunk in the + unknown chunk structure, process it, and return one + of the following: */ return (-n); /* chunk had an error */ return (0); /* did not recognize */ @@ -284,6 +298,11 @@ you can retrieve with png_get_user_chunk_ptr(png_ptr); +If you call the png_set_read_user_chunk_fn() function, then all unknown +chunks will be saved when read, in case your callback function will need +one or more of them. This behavior can be changed with the +png_set_keep_unknown_chunks() function, described below. + At this point, you can set up a callback function that will be called after each row has been read, which you can use to control a progress meter or the like. It's demonstrated in pngtest.c. @@ -300,18 +319,42 @@ You must supply a function To inform libpng about your function, use png_set_read_status_fn(png_ptr, read_row_callback); + +Width and height limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + Unknown-chunk handling Now you get to set the way the library processes unknown chunks in the input PNG stream. Both known and unknown chunks will be read. Normal behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: +various info_ptr members while unknown chunks will be discarded. This +behavior can be wasteful if your application will never use some known +chunk types. To change this, you can call: png_set_keep_unknown_chunks(png_ptr, keep, chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep + keep - 0: default unknown chunk handling + 1: ignore; do not keep 2: keep only if safe-to-copy 3: keep even if unsafe-to-copy You can use these definitions: @@ -334,6 +377,36 @@ instances of png_set_keep_unknown_chunks(), the final instance will take precedence. The IHDR and IEND chunks should not be named in chunk_list; if they are, libpng will process them normally anyway. +Here is an example of the usage of png_set_keep_unknown_chunks(), +where the private "vpAg" chunk will later be processed by a user chunk +callback function: + + png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + png_byte unused_chunks[]= + { + 104, 73, 83, 84, (png_byte) '\0', /* hIST */ + 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ + 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ + 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ + 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ + 116, 73, 77, 69, (png_byte) '\0', /* tIME */ + }; + #endif + + ... + + #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); + #endif + User limits The PNG specification allows the width and height of an image to be as @@ -395,7 +468,7 @@ you want to do are limited to the following set: PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples (This excludes setting a background color, doing gamma transformation, -and setting filler.) If this is the case, simply do this: +dithering, and setting filler.) If this is the case, simply do this: png_read_png(png_ptr, info_ptr, png_transforms, NULL) @@ -422,14 +495,16 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/sizeof(png_bytep)) + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) png_error (png_ptr, "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"); row_pointers = png_malloc(png_ptr, - height*sizeof(png_bytep)); + height*png_sizeof(png_bytep)); + for (int i=0; i - Copyright (c) 1998-2005 Glenn Randers-Pehrson + Copyright (c) 1998-2009 Glenn Randers-Pehrson For conditions of distribution and use, see copyright notice in png.h. - based on: + Based on: + + libpng versions 0.97, January 1998, through 1.4.0beta51 - March 21, 2009 + Updated and distributed by Glenn Randers-Pehrson + Copyright (c) 1998-2008 Glenn Randers-Pehrson libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger @@ -842,6 +846,10 @@ it is heavily commented and should include everything most people will need. We assume that libpng is already installed; see the INSTALL file for instructions on how to install libpng. +For examples of libpng usage, see the files "example.c", "pngtest.c", +and the files in the "contrib" directory, all of which are included in the +libpng distribution. + Libpng was written as a companion to the PNG specification, as a way of reducing the amount of time and effort it takes to support the PNG file format in application programs. @@ -852,12 +860,14 @@ a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at The W3C and ISO documents have identical technical content. The PNG-1.2 specification is available at - +. It is technically equivalent +to the PNG specification (second edition) but has some additional material. The PNG-1.0 specification is available as RFC 2083 and as a -W3C Recommendation . Some -additional chunks are described in the special-purpose public chunks +W3C Recommendation . + +Some additional chunks are described in the special-purpose public chunks documents at . Other information @@ -1065,15 +1075,19 @@ input stream. You must supply the function png_unknown_chunkp chunk); { /* The unknown chunk structure contains your - chunk data: */ + chunk data, along with similar data for any other + unknown chunks: */ + png_byte name[5]; png_byte *data; png_size_t size; + /* Note that libpng has already taken care of the CRC handling */ - /* put your code here. Return one of the - following: */ + /* put your code here. Search for your chunk in the + unknown chunk structure, process it, and return one + of the following: */ return (-n); /* chunk had an error */ return (0); /* did not recognize */ @@ -1093,6 +1107,11 @@ you can retrieve with png_get_user_chunk_ptr(png_ptr); +If you call the png_set_read_user_chunk_fn() function, then all unknown +chunks will be saved when read, in case your callback function will need +one or more of them. This behavior can be changed with the +png_set_keep_unknown_chunks() function, described below. + At this point, you can set up a callback function that will be called after each row has been read, which you can use to control a progress meter or the like. It's demonstrated in pngtest.c. @@ -1109,18 +1128,42 @@ You must supply a function To inform libpng about your function, use png_set_read_status_fn(png_ptr, read_row_callback); + +.SS Width and height limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + .SS Unknown-chunk handling Now you get to set the way the library processes unknown chunks in the input PNG stream. Both known and unknown chunks will be read. Normal behavior is that known chunks will be parsed into information in -various info_ptr members; unknown chunks will be discarded. To change -this, you can call: +various info_ptr members while unknown chunks will be discarded. This +behavior can be wasteful if your application will never use some known +chunk types. To change this, you can call: png_set_keep_unknown_chunks(png_ptr, keep, chunk_list, num_chunks); - keep - 0: do not handle as unknown - 1: do not keep + keep - 0: default unknown chunk handling + 1: ignore; do not keep 2: keep only if safe-to-copy 3: keep even if unsafe-to-copy You can use these definitions: @@ -1143,6 +1186,36 @@ instances of png_set_keep_unknown_chunks(), the final instance will take precedence. The IHDR and IEND chunks should not be named in chunk_list; if they are, libpng will process them normally anyway. +Here is an example of the usage of png_set_keep_unknown_chunks(), +where the private "vpAg" chunk will later be processed by a user chunk +callback function: + + png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + png_byte unused_chunks[]= + { + 104, 73, 83, 84, (png_byte) '\0', /* hIST */ + 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ + 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ + 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ + 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ + 116, 73, 77, 69, (png_byte) '\0', /* tIME */ + }; + #endif + + ... + + #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); + #endif + .SS User limits The PNG specification allows the width and height of an image to be as @@ -1204,7 +1277,7 @@ you want to do are limited to the following set: PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples (This excludes setting a background color, doing gamma transformation, -and setting filler.) If this is the case, simply do this: +dithering, and setting filler.) If this is the case, simply do this: png_read_png(png_ptr, info_ptr, png_transforms, NULL) @@ -1231,14 +1304,16 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/sizeof(png_bytep)) + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) png_error (png_ptr, "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"); row_pointers = png_malloc(png_ptr, - height*sizeof(png_bytep)); + height*png_sizeof(png_bytep)); + for (int i=0; i\fP diff --git a/png.5 b/png.5 index 6383c61ad..4ad8aa6ef 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "March 9, 2009" +.TH PNG 5 "March 21, 2009" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/png.c b/png.c index d9c8f6fa0..03ae77034 100644 --- a/png.c +++ b/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -13,7 +13,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_4_0beta50 Your_png_h_is_not_version_1_4_0beta50; +typedef version_1_4_0beta51 Your_png_h_is_not_version_1_4_0beta51; /* Version information for C files. This had better match the version * string defined in png.h. */ @@ -641,13 +641,13 @@ png_get_copyright(png_structp png_ptr) #else #ifdef __STDC__ return ((png_charp) PNG_STRING_NEWLINE \ - "libpng version x 1.4.0beta50 - March 9, 2009" PNG_STRING_NEWLINE \ + "libpng version x 1.4.0beta51 - March 21, 2009" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2009 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE); #else - return ((png_charp) "libpng version 1.4.0beta50 - March 9, 2009\ + return ((png_charp) "libpng version 1.4.0beta51 - March 21, 2009\ Copyright (c) 1998-2009 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); diff --git a/png.h b/png.h index a0b7d5109..275525e30 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.4.0beta50 - March 9, 2009 + * libpng version 1.4.0beta51 - March 21, 2009 * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -9,7 +9,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.4.0beta50 - March 9, 2009: Glenn + * libpng versions 0.97, January 1998, through 1.4.0beta51 - March 21, 2009: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -127,7 +127,7 @@ * 1.4.0beta9-14 14 10400 14.so.0.0[.0] * 1.2.13 13 10213 12.so.0.10[.0] * 1.4.0beta15-36 14 10400 14.so.0.0[.0] - * 1.4.0beta37-50 14 10400 14.so.14.0[.0] + * 1.4.0beta37-51 14 10400 14.so.14.0[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -157,7 +157,7 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta50, March 9, 2009, are + * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta51, March 21, 2009, 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: @@ -275,7 +275,7 @@ * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.4.0beta50 are Y2K compliant. It is my belief that earlier + * upward through 1.4.0beta51 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 @@ -331,9 +331,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.4.0beta50" +#define PNG_LIBPNG_VER_STRING "1.4.0beta51" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.4.0beta50 - March 9, 2009\n" + " libpng version 1.4.0beta51 - March 21, 2009\n" #define PNG_LIBPNG_VER_SONUM 14 #define PNG_LIBPNG_VER_DLLNUM 14 @@ -345,7 +345,7 @@ /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ -#define PNG_LIBPNG_VER_BUILD 50 +#define PNG_LIBPNG_VER_BUILD 51 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -1356,7 +1356,7 @@ struct png_struct_def /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef png_structp version_1_4_0beta50; +typedef png_structp version_1_4_0beta51; typedef png_struct FAR * FAR * png_structpp; @@ -1524,7 +1524,8 @@ extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_premultiply_alpha) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_premultiply_alpha) + PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) @@ -1835,6 +1836,11 @@ extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. */ extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); diff --git a/pngconf.h b/pngconf.h index 9432ebf9f..483d1b7ad 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.4.0beta50 - March 9, 2009 + * libpng version 1.4.0beta51 - March 21, 2009 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1339,7 +1339,6 @@ typedef char FAR * FAR * FAR * png_charppp; # define NOCHECK 0 # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_fileno _fileno /* Added to v 1.4.0 */ # define png_strcpy _fstrcpy # define png_strncpy _fstrncpy /* Added to v 1.2.6 */ # define png_strlen _fstrlen @@ -1351,7 +1350,6 @@ typedef char FAR * FAR * FAR * png_charppp; # if defined(_WINDOWS_) /* favor Windows over C runtime fns */ # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_fileno fileno # define png_strcpy lstrcpyA # define png_strncpy lstrcpynA # define png_strlen lstrlenA @@ -1362,7 +1360,6 @@ typedef char FAR * FAR * FAR * png_charppp; # else # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) -# define png_fileno fileno /* Added to v 1.4.0 */ # define png_strcpy strcpy # define png_strncpy strncpy /* Added to v 1.2.6 */ # define png_strlen strlen diff --git a/pngerror.c b/pngerror.c index 4b55c2ce8..f98e1f2c4 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -44,40 +44,19 @@ png_error(png_structp png_ptr, png_const_charp error_message) { if (*error_message == PNG_LITERAL_SHARP) { - /* Strip "#nnnn " from beginning of error message. */ - /* - * 012345678901234567890 - * error_message: #nnnn text\0 - * error_number: nnnn\0 - * msg: : nnnn \0 - * offset points to the first blank after nnnn - * In this example, offset is 5. - */ + /* Strip "#nnnn " from beginning of error message. */ int offset; for (offset = 1; offset<15; offset++) if (error_message[offset] == ' ') break; - /* it is 5 because the loop iterations saw - * offset==1, error_message[1]=="n"; offset++. - * offset==2, error_message[2]=="n"; offset++. - * offset==3, error_message[3]=="n"; offset++. - * offset==4, error_message[4]=="n"; offset++. - * offset==5, error_message[5]==" "; break. - */ if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { int i; - /* Copy the "nnnn" or however many there are, plus the - * blank to the beginning of "msg" string. - */ for (i = 0; i < offset - 1; i++) msg[i] = error_message[i + 1]; - /* In the example, "i" ends up being 5. - */ msg[i - 1] = '\0'; error_message = msg; } - /* msg, and error_message, now contain "nnnn \0". */ else error_message += offset; } @@ -259,16 +238,8 @@ png_default_error(png_structp png_ptr, png_const_charp error_message) #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == PNG_LITERAL_SHARP) - { - /* Strip "#nnnn " from beginning of error message. */ - /* - * 012345678901234567890 - * error_message: #nnnn text\0 - * error_number: nnnn\0 - * offset points to the first blank after nnnn - * In this example, offset is 5, and we want to - * insert a terminating NULL at error_number[4]. - */ + { + /* Strip "#nnnn " from beginning of error message. */ int offset; char error_number[16]; for (offset = 0; offset<15; offset++) @@ -277,21 +248,9 @@ png_default_error(png_structp png_ptr, png_const_charp error_message) if (error_message[offset] == ' ') break; } - /* This is unnecessarily slightly different from above, but - * offset is still 5 because the loop iterations saw - * offset==0, error_message[0]=="#"; error_number[0]="n";offset++. - * offset==1, error_message[1]=="n"; error_number[1]="n";offset++ - * offset==2, error_message[2]=="n"; error_number[2]="n";offset++ - * offset==3, error_message[3]=="n"; error_number[3]="n";offset++ - * offset==4, error_message[4]=="n"; error_number[4]=" ";offset++. - * offset==5, error_message[5]==" "; break. - */ if ((offset > 1) && (offset < 15)) { - /* Replace the " " with a string-terminating NULL */ error_number[offset - 1] = '\0'; - /* GRR: this should be [offset + 1] */ - /* should we update "offset" to point to the beginning of the text? */ fprintf(stderr, "libpng error no. %s: %s", error_number, error_message + offset + 1); fprintf(stderr, PNG_STRING_NEWLINE); diff --git a/pngget.c b/pngget.c index 03b01f8df..306b29266 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngmem.c b/pngmem.c index f11c3e2f5..edc0152d3 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngpread.c b/pngpread.c index e7817a27b..d1806a7e6 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngpriv.h b/pngpriv.h index ec6a5d026..1163e3189 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -1,7 +1,7 @@ /* pngpriv.h - private declarations for use inside libpng * - * libpng version 1.4.0beta50 - March 9, 2009 + * libpng version 1.4.0beta51 - March 21, 2009 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -123,7 +123,8 @@ /* 0x800000L Unused */ #define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ #define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ -#define PNG_PREMULTIPLY_ALPHA 0x4000000L /* Added to libpng-1.4.0 by volker */ +#define PNG_PREMULTIPLY_ALPHA 0x4000000L /* Added to libpng-1.4.0 */ + /* by volker */ /* 0x8000000L unused */ /* 0x10000000L unused */ /* 0x20000000L unused */ @@ -583,17 +584,17 @@ PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, png_bytep row)); #endif -#if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_premultiply_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, png_bytep row, png_uint_32 flags)); #endif +#if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_premultiply_alpha + PNGARG((png_row_infop row_info, png_bytep row)); +#endif + #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); #endif diff --git a/pngread.c b/pngread.c index 8e439326c..42b2e6407 100644 --- a/pngread.c +++ b/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1383,17 +1383,15 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, #else info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, info_ptr->height * png_sizeof(png_bytep)); - png_memset(info_ptr->row_pointers, 0, - info_ptr->height * png_sizeof(png_bytep)); + png_memset(info_ptr->row_pointers, 0, info_ptr->height + * png_sizeof(png_bytep)); #endif #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif for (row = 0; row < (int)info_ptr->height; row++) - { info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } } png_read_image(png_ptr, info_ptr->row_pointers); diff --git a/pngrio.c b/pngrio.c index 14135bdc1..5b4b54aab 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngrtran.c b/pngrtran.c index b13d4771a..9335c9140 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1465,7 +1465,8 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: #if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_PREMULTIPLY_ALPHA) - png_do_read_premultiply_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); + png_do_read_premultiply_alpha(&(png_ptr->row_info), + png_ptr->row_buf + 1); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) diff --git a/pngrutil.c b/pngrutil.c index d332b92c2..e1a41909d 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -3252,11 +3252,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) { png_free(png_ptr, png_ptr->big_row_buf); if (png_ptr->interlaced) - png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, row_bytes+64); + png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, row_bytes + 64); else - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; - png_ptr->old_big_row_buf_size = row_bytes+64; + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64); + png_ptr->row_buf = png_ptr->big_row_buf + 32; + png_ptr->old_big_row_buf_size = row_bytes + 64; } #ifdef PNG_MAX_MALLOC_64K diff --git a/pngset.c b/pngset.c index 7b52f98d9..f6a9c38db 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngtest.c b/pngtest.c index 10f503e37..3038a7cbe 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -318,10 +318,8 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) static void pngtest_flush(png_structp png_ptr) { - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); + /* Do nothing; fflush() is said to be just a waste of energy. */ + png_ptr = png_ptr; /* stifle compiler warning */ } #endif @@ -1613,4 +1611,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_4_0beta50 your_png_h_is_not_version_1_4_0beta50; +typedef version_1_4_0beta51 your_png_h_is_not_version_1_4_0beta51; diff --git a/pngtrans.c b/pngtrans.c index 04a1644b0..c6d0a8418 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwio.c b/pngwio.c index 535a15d40..29cb01067 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -119,8 +119,7 @@ png_default_flush(png_structp png_ptr) png_FILE_p io_ptr; if (png_ptr == NULL) return; io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL && png_fileno(io_ptr) != -1) - fflush(io_ptr); + fflush(io_ptr); } #endif #endif @@ -149,7 +148,10 @@ png_default_flush(png_structp png_ptr) PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time, output_flush_fn will be ignored, although it must be supplied for compatibility. May be NULL, in which case - libpng's default function will be used. */ + libpng's default function will be used, if + PNG_WRITE_FLUSH_SUPPORTED is defined. This is not + a good idea if io_ptr does not point to a standard + *FILE structure. */ void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) diff --git a/pngwrite.c b/pngwrite.c index 9078ee152..f5ce49348 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwtran.c b/pngwtran.c index 59c8ae015..6b4419639 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngwutil.c b/pngwutil.c index e3aabc09e..ad9f29b9f 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.4.0 [March 9, 2009] + * Last changed in libpng 1.4.0 [March 21, 2009] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 499ef5643..46d70b535 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -178,7 +178,7 @@ configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in # SET UP LINKS set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 0.${PNGLIB_RELEASE}.1.4.0beta50 +# VERSION 0.${PNGLIB_RELEASE}.1.4.0beta51 VERSION 0.${PNGLIB_RELEASE}.0 SOVERSION 0 CLEAN_DIRECT_OUTPUT 1) diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in index 83e917931..6da2168e5 100755 --- a/scripts/libpng-config-head.in +++ b/scripts/libpng-config-head.in @@ -8,7 +8,7 @@ # Modeled after libxml-config. -version=1.4.0beta50 +version=1.4.0beta51 prefix="" libdir="" libs="" diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in index cb9b3b38e..4f4d1c41f 100644 --- a/scripts/libpng.pc.in +++ b/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng14 Name: libpng Description: Loads and saves PNG files -Version: 1.4.0beta50 +Version: 1.4.0beta51 Libs: -L${libdir} -lpng14 Cflags: -I${includedir} diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu index b5db70cda..498b4fb98 100644 --- a/scripts/makefile.32sunu +++ b/scripts/makefile.32sunu @@ -8,7 +8,7 @@ # Library name: LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu index f548e905d..919b528c4 100644 --- a/scripts/makefile.64sunu +++ b/scripts/makefile.64sunu @@ -8,7 +8,7 @@ # Library name: LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.aix b/scripts/makefile.aix index a26961def..085b3354f 100644 --- a/scripts/makefile.aix +++ b/scripts/makefile.aix @@ -20,7 +20,7 @@ LN_SF = ln -f -s LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) prefix=/usr/local diff --git a/scripts/makefile.beos b/scripts/makefile.beos index 6023a3deb..5d227ff8c 100644 --- a/scripts/makefile.beos +++ b/scripts/makefile.beos @@ -8,7 +8,7 @@ # Library name: LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin index 53c756ec7..19aab83e4 100644 --- a/scripts/makefile.cygwin +++ b/scripts/makefile.cygwin @@ -65,7 +65,7 @@ CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ LIBNAME = libpng14 PNGMAJ = 14 CYGDLL = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) SHAREDLIB=cygpng$(CYGDLL).dll diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin index 7f23b2ef0..3fc9ef604 100644 --- a/scripts/makefile.darwin +++ b/scripts/makefile.darwin @@ -19,7 +19,7 @@ ZLIBINC=../zlib # Library name: LIBNAME = libpng14 PNGMAJ = 12 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.dec b/scripts/makefile.dec index 73cdea69d..23294865b 100644 --- a/scripts/makefile.dec +++ b/scripts/makefile.dec @@ -5,7 +5,7 @@ # Library name: PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng14 diff --git a/scripts/makefile.elf b/scripts/makefile.elf index 09e47686d..b43b1e94b 100644 --- a/scripts/makefile.elf +++ b/scripts/makefile.elf @@ -12,7 +12,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx index 8e8821b51..4917ffdcb 100644 --- a/scripts/makefile.gcmmx +++ b/scripts/makefile.gcmmx @@ -16,7 +16,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.hp64 b/scripts/makefile.hp64 index e13fe577e..4add23d91 100644 --- a/scripts/makefile.hp64 +++ b/scripts/makefile.hp64 @@ -18,7 +18,7 @@ ZLIBINC=/opt/zlib/include # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc index c7f9655b7..67ae91a16 100644 --- a/scripts/makefile.hpgcc +++ b/scripts/makefile.hpgcc @@ -8,7 +8,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux index 805bbe1c1..8a49a6f92 100644 --- a/scripts/makefile.hpux +++ b/scripts/makefile.hpux @@ -18,7 +18,7 @@ ZLIBINC=/opt/zlib/include # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.linux b/scripts/makefile.linux index 3e56cd04f..b5ff13eed 100644 --- a/scripts/makefile.linux +++ b/scripts/makefile.linux @@ -6,7 +6,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.mingw b/scripts/makefile.mingw index 95b5e422a..29d9ca235 100644 --- a/scripts/makefile.mingw +++ b/scripts/makefile.mingw @@ -81,7 +81,7 @@ CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ LIBNAME = libpng14 PNGMAJ = 14 MINGDLL = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) SHAREDLIB=libpng$(MINGDLL).dll diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd index 977d8ada4..e8fa81d99 100644 --- a/scripts/makefile.ne12bsd +++ b/scripts/makefile.ne12bsd @@ -14,7 +14,7 @@ INCSDIR=${LOCALBASE}/include/libpng14 LIB= png14 SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.4.0beta50 +SHLIB_MINOR= 1.4.0beta51 SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngwtran.c pngmem.c pngerror.c pngpread.c diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd index e7a70a396..1e0b07f2a 100644 --- a/scripts/makefile.netbsd +++ b/scripts/makefile.netbsd @@ -13,7 +13,7 @@ INCSDIR=${LOCALBASE}/include/libpng LIB= png SHLIB_MAJOR= 3 -SHLIB_MINOR= 1.4.0beta50 +SHLIB_MINOR= 1.4.0beta51 SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngwtran.c pngmem.c pngerror.c pngpread.c diff --git a/scripts/makefile.nommx b/scripts/makefile.nommx index 8c4f5cb53..b654fdd5f 100644 --- a/scripts/makefile.nommx +++ b/scripts/makefile.nommx @@ -16,7 +16,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd index b74e2b110..7d6446f14 100644 --- a/scripts/makefile.openbsd +++ b/scripts/makefile.openbsd @@ -8,7 +8,7 @@ LIBDIR= ${PREFIX}/lib MANDIR= ${PREFIX}/man/cat SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.4.0beta50 +SHLIB_MINOR= 1.4.0beta51 LIB= png SRCS= png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \ diff --git a/scripts/makefile.sco b/scripts/makefile.sco index 45c449a26..04e478d61 100644 --- a/scripts/makefile.sco +++ b/scripts/makefile.sco @@ -9,7 +9,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc index fcbec7d71..4c17c7def 100644 --- a/scripts/makefile.sggcc +++ b/scripts/makefile.sggcc @@ -6,7 +6,7 @@ # Library name: LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi index 210e09d7f..4734325e1 100644 --- a/scripts/makefile.sgi +++ b/scripts/makefile.sgi @@ -6,7 +6,7 @@ # Library name: LIBNAME=libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/makefile.so9 b/scripts/makefile.so9 index cd451c848..62b9584b9 100644 --- a/scripts/makefile.so9 +++ b/scripts/makefile.so9 @@ -8,7 +8,7 @@ # Library name: PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng14 diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris index 9d0f190be..9734eb773 100644 --- a/scripts/makefile.solaris +++ b/scripts/makefile.solaris @@ -8,7 +8,7 @@ # Library name: LIBNAME = libpng14 PNGMAJ = 14 -PNGMIN = 1.4.0beta50 +PNGMIN = 1.4.0beta51 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/scripts/pngos2.def b/scripts/pngos2.def index beafa26b2..bdc2e40d3 100644 --- a/scripts/pngos2.def +++ b/scripts/pngos2.def @@ -2,7 +2,7 @@ ; PNG.LIB module definition file for OS/2 ;---------------------------------------- -; Version 1.4.0beta50 +; Version 1.4.0beta51 LIBRARY PNG DESCRIPTION "PNG image compression library for OS/2" diff --git a/scripts/pngwin.def b/scripts/pngwin.def index 7fa083c7e..953a68ad8 100644 --- a/scripts/pngwin.def +++ b/scripts/pngwin.def @@ -5,7 +5,7 @@ LIBRARY EXPORTS -;Version 1.4.0beta50 +;Version 1.4.0beta51 png_build_grayscale_palette png_chunk_error png_chunk_warning