diff -ru4NwbB libpng-1.2.35/Makefile.am libpng-1.4.0beta60/Makefile.am --- libpng-1.2.35/Makefile.am 2009-02-14 15:59:41.743264853 -0600 +++ libpng-1.4.0beta60/Makefile.am 2009-05-18 16:58:35.065394699 -0500 @@ -15,49 +15,49 @@ # test programs - run on make check, make distcheck check_PROGRAMS= pngtest pngtest_SOURCES = pngtest.c -pngtest_LDADD = libpng12.la +pngtest_LDADD = libpng14.la TESTS = test-pngtest.sh TESTS_ENVIRONMENT= srcdir=$(srcdir) # man pages dist_man_MANS= libpng.3 libpngpf.3 png.5 # generate the -config scripts if required -binconfigs= libpng12-config -EXTRA_SCRIPTS= libpng-config libpng12-config +binconfigs= libpng14-config +EXTRA_SCRIPTS= libpng-config libpng14-config bin_SCRIPTS= @binconfigs@ # rules to build libpng, only build the old library on request -lib_LTLIBRARIES=libpng12.la @compatlib@ +lib_LTLIBRARIES=libpng14.la @compatlib@ EXTRA_LTLIBRARIES= libpng.la -libpng12_la_SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ +libpng14_la_SOURCES = 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 \ png.h pngconf.h -libpng_la_SOURCES = $(libpng12_la_SOURCES) +libpng_la_SOURCES = $(libpng14_la_SOURCES) libpng_la_CPPFLAGS = @LIBPNG_DEFINES@ -libpng12_la_CPPFLAGS = @LIBPNG_DEFINES@ +libpng14_la_CPPFLAGS = @LIBPNG_DEFINES@ # MAJOR UPGRADE: the version-number settings below must be changed. -libpng12_la_LDFLAGS = -no-undefined -export-dynamic \ - -version-number 0:@PNGLIB_RELEASE@:0 +libpng14_la_LDFLAGS = -no-undefined -export-dynamic \ + -version-number 14:@PNGLIB_RELEASE@:14 # -rpath is needed as automake doesn't know the directory libpng_la_LDFLAGS = -rpath '$(libdir)' -no-undefined -export-dynamic \ - -version-number 3:@PNGLIB_RELEASE@:0 + -version-number 14:@PNGLIB_RELEASE@:14 if HAVE_LD_VERSION_SCRIPT # Versioned symbols and restricted exports - libpng12_la_LDFLAGS += -Wl,--version-script=libpng.vers - libpng12_la_DEPENDENCIES = libpng.vers + libpng14_la_LDFLAGS += -Wl,--version-script=libpng.vers + libpng14_la_DEPENDENCIES = libpng.vers else # Only restricted exports when possible - libpng12_la_LDFLAGS += -export-symbols libpng.sym - libpng12_la_DEPENDENCIES = libpng.sym + libpng14_la_LDFLAGS += -export-symbols libpng.sym + libpng14_la_DEPENDENCIES = libpng.sym endif -libpng_la_DEPENDENCIES = $(libpng12_la_DEPENDENCIES) +libpng_la_DEPENDENCIES = $(libpng14_la_DEPENDENCIES) # Avoid depending upon Character Ranges. AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' @@ -67,9 +67,9 @@ # pkg-config stuff, note that libpng.pc is always required in order # to get the correct library pkgconfigdir = @pkgconfigdir@ -pkgconfig_DATA = libpng12.pc +pkgconfig_DATA = libpng14.pc #extra source distribution files. EXTRA_DIST= \ ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \ @@ -87,9 +87,9 @@ ${srcdir}/contrib/visupng/* \ $(TESTS) \ example.c libpng-1.4.0beta60.txt pngvcrd.c -CLEANFILES= pngout.png libpng12.pc libpng12-config libpng.vers \ +CLEANFILES= pngout.png libpng14.pc libpng14-config libpng.vers \ libpng.sym MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ config.sub configure depcomp install-sh ltmain.sh missing @@ -121,13 +121,14 @@ # install the .../include headers as links to the new ones install-data-hook: cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h - cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h pngconf.h + cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \ + pngconf.h cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc -# do evil things to libpng to cause libpng12 to be used +# do evil things to libpng to cause libpng14 to be used install-exec-hook: cd $(DESTDIR)$(bindir); rm -f libpng-config cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config @set -x;\ diff -ru4NwbB libpng-1.2.35/configure.ac libpng-1.4.0beta60/configure.ac --- libpng-1.2.35/configure.ac 2009-02-14 15:59:41.749216452 -0600 +++ libpng-1.4.0beta60/configure.ac 2009-05-18 16:58:35.070632434 -0500 @@ -24,9 +24,9 @@ AM_MAINTAINER_MODE PNGLIB_VERSION=1.4.0beta60 PNGLIB_MAJOR=1 -PNGLIB_MINOR=2 +PNGLIB_MINOR=4 PNGLIB_RELEASE=%RELEASE% dnl End of version number stuff @@ -59,20 +59,10 @@ AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) ) AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed])) LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG -AC_MSG_CHECKING( - [if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE]) -AC_TRY_COMPILE( - [#include "$srcdir/pnggccrd.c"], - [return 0;], - AC_MSG_RESULT(yes) - LIBPNG_NO_MMX="", - AC_MSG_RESULT(no) - LIBPNG_NO_MMX=-DPNG_NO_MMX_CODE) -LIBPNG_DEFINES=$LIBPNG_DEFINES\ $LIBPNG_NO_MMX +LIBPNG_DEFINES=$LIBPNG_DEFINES AC_SUBST(LIBPNG_DEFINES) -AC_SUBST(LIBPNG_NO_MMX) AC_MSG_CHECKING([if libraries can be versioned]) GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` if test "$GLD"; then diff -ru4NwbB libpng-1.2.35/contrib/gregbook/Makefile.sgi libpng-1.4.0beta60/contrib/gregbook/Makefile.sgi --- libpng-1.2.35/contrib/gregbook/Makefile.sgi 2009-02-14 15:59:26.741756172 -0600 +++ libpng-1.4.0beta60/contrib/gregbook/Makefile.sgi 2009-05-18 16:58:20.771107412 -0500 @@ -22,11 +22,11 @@ # macros -------------------------------------------------------------------- -PNGINC = -I/usr/local/include/libpng12 -PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng +PNGINC = -I/usr/local/include/libpng%NN% +PNGLIB = -L/usr/local/lib -lpng%NN% # dynamically linked against libpng +#PNGLIB = /usr/local/lib/libpng%NN%.a # statically linked against libpng # or: #PNGINC = -I../.. #PNGLIB = -L../.. -lpng #PNGLIB = ../../libpng.a diff -ru4NwbB libpng-1.2.35/contrib/gregbook/Makefile.unx libpng-1.4.0beta60/contrib/gregbook/Makefile.unx --- libpng-1.2.35/contrib/gregbook/Makefile.unx 2009-02-14 15:59:26.750518099 -0600 +++ libpng-1.4.0beta60/contrib/gregbook/Makefile.unx 2009-05-18 16:58:20.780349957 -0500 @@ -25,16 +25,16 @@ # macros -------------------------------------------------------------------- #PNGDIR = /usr/local/lib -#PNGINC = -I/usr/local/include/libpng12 -#PNGLIBd = -L$(PNGDIR) -lpng12 # dynamically linked, installed libpng -#PNGLIBs = $(PNGDIR)/libpng12.a # statically linked, installed libpng +#PNGINC = -I/usr/local/include/libpng%NN% +#PNGLIBd = -L$(PNGDIR) -lpng%NN% # dynamically linked, installed libpng +#PNGLIBs = $(PNGDIR)/libpng%NN%.a # statically linked, installed libpng # or: PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds #PNGDIR = ../libpng PNGINC = -I$(PNGDIR) -PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng12 # dynamically linked +PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng%NN% # dynamically linked PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng ZDIR = /usr/local/lib #ZDIR = /usr/lib64 diff -ru4NwbB libpng-1.2.35/contrib/gregbook/readpng.c libpng-1.4.0beta60/contrib/gregbook/readpng.c --- libpng-1.2.35/contrib/gregbook/readpng.c 2009-02-14 15:59:26.786454752 -0600 +++ libpng-1.4.0beta60/contrib/gregbook/readpng.c 2009-05-18 16:58:20.820149482 -0500 @@ -92,9 +92,9 @@ /* first do a quick check that the file really is a PNG image; could * have used slightly more general png_sig_cmp() function instead */ fread(sig, 1, 8, infile); - if (!png_check_sig(sig, 8)) + if (png_sig_cmp(sig, 0, 8)) return 1; /* bad signature */ /* could pass pointers to user-defined error handlers instead of NULLs: */ diff -ru4NwbB libpng-1.2.35/contrib/gregbook/readpng2.c libpng-1.4.0beta60/contrib/gregbook/readpng2.c --- libpng-1.2.35/contrib/gregbook/readpng2.c 2009-02-14 15:59:26.806474387 -0600 +++ libpng-1.4.0beta60/contrib/gregbook/readpng2.c 2009-05-18 16:58:20.842144053 -0500 @@ -158,9 +158,9 @@ int readpng2_check_sig(uch *sig, int num) { - return png_check_sig(sig, num); + return (!png_sig_cmp(sig, 0, num)); } diff -ru4NwbB libpng-1.2.35/contrib/pngminim/decoder/gather.sh libpng-1.4.0beta60/contrib/pngminim/decoder/gather.sh --- libpng-1.2.35/contrib/pngminim/decoder/gather.sh 2007-12-07 12:22:01.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/decoder/gather.sh 2009-04-13 10:40:06.656290000 -0500 @@ -1,8 +1,8 @@ cp ../../pngminus/png2pnm.c pngm2pnm.c cp ../../../*.h . cp ../../../*.c . -rm example.c pnggccrd.c pngvcrd.c pngtest.c pngpread.c +rm example.c pnggccrd.c pngvcrd.c pngtest.c pngpread.c pngw*.c # change the following 2 lines if zlib is somewhere else cp ../../../../zlib/*.h . cp ../../../../zlib/*.c . rm minigzip.c example.c compress.c deflate.c diff -ru4NwbB libpng-1.2.35/contrib/pngminim/decoder/pngusr.h libpng-1.4.0beta60/contrib/pngminim/decoder/pngusr.h --- libpng-1.2.35/contrib/pngminim/decoder/pngusr.h 2007-08-19 22:30:16.000000000 -0500 +++ libpng-1.4.0beta60/contrib/pngminim/decoder/pngusr.h 2009-05-18 14:26:02.270270000 -0500 @@ -6,8 +6,12 @@ #ifndef MINRDPNGCONF_H #define MINRDPNGCONF_H +#ifdef NJET + /* No 16-bit support beyond reading with strip_16 */ +#endif + #define PNG_NO_GLOBAL_ARRAYS #define PNG_NO_WARNINGS #define png_warning(s1,s2) "" @@ -39,8 +43,9 @@ #define PNG_NO_READ_pHYs #define PNG_NO_READ_sBIT #define PNG_NO_READ_sCAL #define PNG_NO_READ_sPLT +#define PNG_NO_READ_sRGB #define PNG_NO_READ_TEXT #define PNG_NO_READ_tIME #define PNG_NO_READ_UNKNOWN_CHUNKS #define PNG_NO_READ_USER_CHUNKS diff -ru4NwbB libpng-1.2.35/contrib/pngminim/encoder/gather.sh libpng-1.4.0beta60/contrib/pngminim/encoder/gather.sh --- libpng-1.2.35/contrib/pngminim/encoder/gather.sh 2007-12-07 12:22:16.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/encoder/gather.sh 2009-04-13 10:40:16.994507000 -0500 @@ -1,8 +1,8 @@ cp ../../pngminus/pnm2png.c pnm2pngm.c cp ../../../*.h . cp ../../../*.c . -rm example.c pnggccrd.c pngvcrd.c pngtest.c pngr*.c +rm example.c pnggccrd.c pngvcrd.c pngtest.c pngr*.c pngpread.c # Change the next 2 lines if zlib is somewhere else. cp ../../../../zlib/*.h . cp ../../../../zlib/*.c . rm inf*.[ch] diff -ru4NwbB libpng-1.2.35/contrib/pngminim/encoder/pngusr.h libpng-1.4.0beta60/contrib/pngminim/encoder/pngusr.h --- libpng-1.2.35/contrib/pngminim/encoder/pngusr.h 2007-08-27 23:31:31.000000000 -0500 +++ libpng-1.4.0beta60/contrib/pngminim/encoder/pngusr.h 2009-05-18 14:31:05.548005000 -0500 @@ -32,17 +32,17 @@ #define PNG_NO_WRITE_USER_TRANSFORM #define PNG_NO_WRITE_bKGD #define PNG_NO_WRITE_cHRM #define PNG_NO_WRITE_gAMA -#define PNG_NO_WRITE_sRGB #define PNG_NO_WRITE_hIST #define PNG_NO_WRITE_iCCP #define PNG_NO_WRITE_oFFs #define PNG_NO_WRITE_pCAL #define PNG_NO_WRITE_pHYs #define PNG_NO_WRITE_sBIT #define PNG_NO_WRITE_sCAL #define PNG_NO_WRITE_sPLT +#define PNG_NO_WRITE_sRGB #define PNG_NO_WRITE_TEXT #define PNG_NO_WRITE_tIME #define PNG_NO_WRITE_UNKNOWN_CHUNKS #define PNG_NO_WRITE_USER_CHUNKS @@ -50,8 +50,9 @@ #define PNG_NO_WRITE_OPT_PLTE #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 #define PNG_NO_FIXED_POINT_SUPPORTED diff -ru4NwbB libpng-1.2.35/contrib/pngminim/preader/README libpng-1.4.0beta60/contrib/pngminim/preader/README --- libpng-1.2.35/contrib/pngminim/preader/README 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/preader/README 2009-05-18 15:17:13.823085000 -0500 @@ -0,0 +1,10 @@ +This demonstrates the use of PNG_USER_CONFIG and pngusr.h + +To build a minimal read-only progressive decoder with X display, run +gather.sh to collect needed files from gregbook, libpng, and zlib + +Edit makefile.std if required, to find your X library and include files, +then + + make -f makefile.std + diff -ru4NwbB libpng-1.2.35/contrib/pngminim/preader/gather.sh libpng-1.4.0beta60/contrib/pngminim/preader/gather.sh --- libpng-1.2.35/contrib/pngminim/preader/gather.sh 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/preader/gather.sh 2009-05-18 12:42:38.841511000 -0500 @@ -0,0 +1,9 @@ +cp ../../gregbook/rpng2-x.c ../../gregbook/readpng2.[ch] . +cp ../../gregbook/COPYING ../../gregbook/LICENSE . +cp ../../../*.h . +cp ../../../*.c . +rm example.c pnggccrd.c pngvcrd.c pngtest.c pngw*.c +# change the following 2 lines if zlib is somewhere else +cp ../../../../zlib/*.h . +cp ../../../../zlib/*.c . +rm minigzip.c example.c compress.c deflate.c diff -ru4NwbB libpng-1.2.35/contrib/pngminim/preader/makefile.std libpng-1.4.0beta60/contrib/pngminim/preader/makefile.std --- libpng-1.2.35/contrib/pngminim/preader/makefile.std 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/preader/makefile.std 2009-05-18 14:21:08.274009000 -0500 @@ -0,0 +1,60 @@ +# Makefile for PngMinus (rpng2) +# Linux / Unix + +#CC=cc +CC=gcc +LD=$(CC) + +RM=rm -f + +#XINC = -I/usr/include # old-style, stock X distributions +#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX) + +#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) +#XLIB = -L/usr/openwin/lib -lX11 + +XINC = -I/usr/X11R6/include # new X distributions (X.org, etc.) +XLIB = -L/usr/X11R6/lib -lX11 +#XLIB = -L/usr/X11R6/lib64 -lX11 # e.g., Red Hat on AMD64 + +#XINC = -I/usr/local/include # FreeBSD +#XLIB = -L/usr/local/lib -lX11 + +#LIBS = $(XLIB) +LIBS = $(XLIB) -lm #platforms that need libm + +CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \ + -DdeflateParams\(a,b,c\)=Z_OK -I. $(XINC) -O1 + +C=.c +O=.o +L=.a +E= + +ZOBJS = adler32$(O) crc32$(O) gzio$(O) \ + infback$(O) inffast$(O) inflate$(O) inftrees$(O) \ + trees$(O) uncompr$(O) zutil$(O) + +OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ + pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \ + pngset$(O) pngtrans$(O) $(ZOBJS) + +# implicit make rules ------------------------------------------------------- + +.c$(O): png.h pngconf.h readpng2.h pngusr.h zlib.h + $(CC) -c $(CFLAGS) $< + +# dependencies + +all: rpng2-x$(E) + +rpng2-x$(E): $(OBJS) + $(LD) -o rpng2-x$(E) $(OBJS) $(LIBS) + strip rpng2-x$(E) + +clean: + $(RM) rpng2-x$(O) + $(RM) rpng2-x$(E) + $(RM) $(OBJS) + +# End of makefile for rpng2-x diff -ru4NwbB libpng-1.2.35/contrib/pngminim/preader/pngusr.h libpng-1.4.0beta60/contrib/pngminim/preader/pngusr.h --- libpng-1.2.35/contrib/pngminim/preader/pngusr.h 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/contrib/pngminim/preader/pngusr.h 2009-05-18 14:31:56.558134000 -0500 @@ -0,0 +1,62 @@ +/* minrdpngconf.h: headers to make a minimal png-read-only library + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 2007 Glenn Randers-Pehrson + * Derived from pngcrush.h, Copyright 1998-2007, Glenn Randers-Pehrson + */ + +#ifndef MINRDPNGCONF_H +#define MINRDPNGCONF_H + +#define PNG_NO_GLOBAL_ARRAYS + +#define PNG_NO_WARNINGS +#define png_warning(s1,s2) "" +#define png_chunk_warning(s1,s2) "" +#define PNG_NO_ERROR_TEXT +#define png_error(s1,s2) png_err(s1) +#define png_chunk_error(s1,s2) png_err(s1) + +#define PNG_NO_ASSEMBLER_CODE +#define PNG_NO_OPTIMIZED_CODE +#define PNG_NO_READ_DITHER +#define PNG_NO_READ_INVERT +#define PNG_NO_READ_SHIFT +#define PNG_NO_READ_PACK +#define PNG_NO_READ_PACKSWAP +#define PNG_NO_READ_FILLER +#define PNG_NO_READ_SWAP_ALPHA +#define PNG_NO_READ_INVERT_ALPHA +#define PNG_NO_READ_RGB_TO_GRAY +#define PNG_NO_READ_USER_TRANSFORM +#define PNG_NO_READ_cHRM +#define PNG_NO_READ_hIST +#define PNG_NO_READ_iCCP +#define PNG_NO_READ_pCAL +#define PNG_NO_READ_pHYs +#define PNG_NO_READ_sBIT +#define PNG_NO_READ_sCAL +#define PNG_NO_READ_sPLT +#define PNG_NO_READ_TEXT +#define PNG_NO_READ_tIME +#define PNG_NO_READ_UNKNOWN_CHUNKS +#define PNG_NO_READ_USER_CHUNKS +#define PNG_NO_READ_EMPTY_PLTE +#define PNG_NO_READ_OPT_PLTE +#define PNG_NO_READ_STRIP_ALPHA +#define PNG_NO_READ_oFFs +#define PNG_NO_WARN_UNINITIALIZED_ROW + +#define PNG_NO_WRITE_SUPPORTED + +#define PNG_NO_INFO_IMAGE +#define PNG_NO_USER_MEM +#define PNG_NO_FIXED_POINT_SUPPORTED +#define PNG_NO_MNG_FEATURES +#define PNG_NO_USER_TRANSFORM_PTR +#define PNG_NO_HANDLE_AS_UNKNOWN +#define PNG_NO_CONSOLE_IO +#define PNG_NO_ZALLOC_ZERO +#define PNG_NO_ERROR_NUMBERS +#define PNG_NO_EASY_ACCESS + +#endif /* MINRDPNGCONF_H */ diff -ru4NwbB libpng-1.2.35/example.c libpng-1.4.0beta60/example.c --- libpng-1.2.35/example.c 2009-02-14 15:59:26.552153830 -0600 +++ libpng-1.4.0beta60/example.c 2009-05-18 16:58:20.570210517 -0500 @@ -1,9 +1,9 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.2.35 [May 18, 2009] + * Last changed in libpng 1.4.0 [May 18, 2009] * This file has been placed in the public domain by the authors. * Maintained 1998-2009 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -119,9 +120,9 @@ info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); - png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL); + png_destroy_read_struct(&png_ptr, NULL, NULL); return (ERROR); } /* Set error handling if you are using the setjmp/longjmp method (this is @@ -131,9 +132,9 @@ if (setjmp(png_jmpbuf(png_ptr))) { /* Free all of the memory associated with the png_ptr and info_ptr */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); /* If we get here, we had a problem reading the file */ return (ERROR); } @@ -162,9 +163,10 @@ * dithering, filling, setting background, and doing gamma * adjustment), then you can read the entire image (including * pixels) into the info structure with this call: */ - png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); + png_read_png(png_ptr, info_ptr, png_transforms, NULL); + #else /* OK, you're doing it the hard way, with the lower-level functions */ /* The call to png_read_info() gives us all of the information from the @@ -172,17 +174,17 @@ */ png_read_info(png_ptr, info_ptr); png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, - &interlace_type, int_p_NULL, int_p_NULL); + &interlace_type, NULL, NULL); /* Set up the data transformations you want. Note that these are all * optional. Only call them if you want/need them. Many of the * transformations only work on specific types of images, and many * are mutually exclusive. */ - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + /* Tell libpng to strip 16 bit/color files down to 8 bits/color */ png_set_strip_16(png_ptr); /* Strip alpha bytes from the input data without combining with the * background (not recommended). @@ -227,12 +229,13 @@ else png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ + /* Some suggestions as to how to get a screen gamma value + * + * Note that screen gamma is the display_exponent, which includes + * the CRT_exponent and any correction for viewing conditions + */ if (/* We have a user-defined screen gamma value */) { screen_gamma = user-defined screen_gamma; } @@ -243,9 +246,9 @@ } /* If we don't have another value */ else { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly + screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly lit room */ screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ } @@ -282,9 +285,9 @@ /* An array of colors to which the image should be dithered */ png_color std_color_cube[MAX_SCREEN_COLORS]; png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, - MAX_SCREEN_COLORS, png_uint_16p_NULL, 0); + MAX_SCREEN_COLORS, NULL, 0); } /* This reduces the image to the palette supplied in the file */ else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) { @@ -296,31 +299,31 @@ max_screen_colors, histogram, 0); } } - /* invert monochrome files to have 0 as white and 1 as black */ + /* Invert monochrome files to have 0 as white and 1 as black */ png_set_invert_mono(png_ptr); /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: */ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) { - png_color_8p sig_bit; + png_color_8p sig_bit_p; - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); + png_get_sBIT(png_ptr, info_ptr, &sig_bit_p); + png_set_shift(png_ptr, sig_bit_p); } - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (color_type & PNG_COLOR_MASK_COLOR) png_set_bgr(png_ptr); - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ png_set_swap_alpha(png_ptr); - /* swap bytes of 16 bit files to least significant byte first */ + /* Swap bytes of 16 bit files to least significant byte first */ png_set_swap(png_ptr); /* Add filler (or alpha) byte (before/after each RGB triplet) */ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); @@ -361,46 +364,45 @@ { #ifdef single /* Read the image a single row at a time */ for (y = 0; y < height; y++) { - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1); + png_read_rows(png_ptr, &row_pointers[y], NULL, 1); } #else no_single /* Read the image several rows at a time */ for (y = 0; y < height; y += number_of_rows) { #ifdef sparkle /* Read the image using the "sparkle" effect. */ - png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, + png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows); #else no_sparkle /* Read the image using the "rectangle" effect */ - png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], + png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows); #endif no_sparkle /* use only one of these two methods */ } - /* if you want to display the image after every pass, do - so here */ + /* if you want to display the image after every pass, do so here */ #endif no_single /* use only one of these two methods */ } #endif no_entire /* use only one of these two methods */ - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); #endif hilevel /* At this point you have read the entire image */ - /* clean up after the read, and free any memory allocated - REQUIRED */ - png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); + /* Clean up after the read, and free any memory allocated - REQUIRED */ + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - /* close the file */ + /* Close the file */ fclose(fp); /* that's it */ return (OK); } -/* progressively read a file */ +/* Progressively read a file */ int initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) { @@ -422,15 +424,15 @@ *info_ptr = png_create_info_struct(png_ptr); if (*info_ptr == NULL) { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } if (setjmp(png_jmpbuf((*png_ptr)))) { - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } /* This one's new. You will need to provide all three @@ -457,15 +459,15 @@ { if (setjmp(png_jmpbuf((*png_ptr)))) { /* Free the png_ptr and info_ptr memory on error */ - png_destroy_read_struct(png_ptr, info_ptr, png_infopp_NULL); + png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } /* This one's new also. Simply give it chunks of data as * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. + * On segmented machines, don't give it any more than 64K. * The library seems to run fine with sizes of 4K, although * you can give it much less if necessary (I assume you can * give it chunks of 1 byte, but I haven't tried with less * than 256 bytes yet). When this function returns, you may @@ -477,9 +479,9 @@ } info_callback(png_structp png_ptr, png_infop info) { -/* do any setup here, including setting any of the transformations + /* Do any setup here, including setting any of the transformations * mentioned in the Reading PNG files section. For now, you _must_ * call either png_start_read_image() or png_read_update_info() * after all the transformations are set (even if you don't set * any). You may start getting rows before png_process_data() @@ -498,9 +500,9 @@ * In this function you will receive a pointer to new row data from * libpng called new_row that is to replace a corresponding row (of * the same data format) in a buffer allocated by your application. * - * The new row data pointer new_row may be NULL, indicating there is + * The new row data pointer "new_row" may be NULL, indicating there is * no new data to be replaced (in cases of interlace loading). * * If new_row is not NULL then you need to call * png_progressive_combine_row() to replace the corresponding row as @@ -545,9 +548,9 @@ } end_callback(png_structp png_ptr, png_infop info) { -/* this function is called when the whole image has been read, + /* This function is called when the whole image has been read, * including any chunks after the image (up to and including * the IEND). You will usually have the same info chunk as you * had in the header, although some data may have been added * to the comments and time fields. @@ -556,17 +559,17 @@ * marks the image as finished. */ } -/* write a png file */ +/* Write a png file */ void write_png(char *file_name /* , ... other image information ... */) { FILE *fp; png_structp png_ptr; png_infop info_ptr; png_colorp palette; - /* open the file */ + /* Open the file */ fp = fopen(file_name, "wb"); if (fp == NULL) return (ERROR); @@ -589,18 +592,18 @@ info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); - png_destroy_write_struct(&png_ptr, png_infopp_NULL); + png_destroy_write_struct(&png_ptr, NULL); return (ERROR); } /* Set error handling. REQUIRED if you aren't supplying your own * error handling functions in the png_create_write_struct() call. */ 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); } @@ -605,25 +608,29 @@ return (ERROR); } /* One of the following I/O initialization functions is REQUIRED */ + #ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ + /* Set up the output control if you are using standard C streams */ png_init_io(png_ptr, fp); + #else no_streams /* I/O initialization method 2 */ /* If you are using replacement write functions, instead of calling - * png_init_io() here you would call */ + * png_init_io() here you would call + */ png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, user_IO_flush_function); /* where user_io_ptr is a structure you want available to the callbacks */ #endif no_streams /* only use one initialization method */ #ifdef hilevel /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many + * image info living in the structure. You could "|" many * PNG_TRANSFORM flags into the png_transforms integer here. */ - png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); + png_write_png(png_ptr, info_ptr, png_transforms, NULL); + #else /* This is the hard way */ /* Set the image information here. Width and height are up to 2^31, @@ -636,27 +643,29 @@ */ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - /* set the palette if there is one. REQUIRED for indexed-color images */ + /* Set the palette if there is one. REQUIRED for indexed-color images */ palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - /* ... set palette colors ... */ + /* ... Set palette colors ... */ png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ + * the palette that you malloced. Wait until you are about to destroy + * the png structure. + */ - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ + /* Optional significant bit (sBIT) chunk */ + png_color_8 sig_bit; + /* If we are dealing with a grayscale image then */ sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ + /* Otherwise, if we are dealing with a color image then */ sig_bit.red = true_red_bit_depth; sig_bit.green = true_green_bit_depth; sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ + /* If the image has an alpha channel then */ sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); + png_set_sBIT(png_ptr, info_ptr, &sig_bit); /* Optional gamma chunk is strongly suggested if you have any guess * as to the correct gamma of the image. @@ -679,11 +688,14 @@ text_ptr[2].lang = NULL; #endif png_set_text(png_ptr, info_ptr, text_ptr, 3); - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ + /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ + + /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored + * on read and, if your application chooses to write them, they must + * be written in accordance with the sRGB profile + */ /* Write the file header information. REQUIRED */ png_write_info(png_ptr, info_ptr); @@ -693,9 +705,9 @@ * png_write_info_before_PLTE(write_ptr, write_info_ptr); * 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. */ /* Once we write out the header, the compression type on the text @@ -703,41 +715,41 @@ * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again * at the end. */ - /* set up the transformations you want. Note that these are + /* Set up the transformations you want. Note that these are * all optional. Only call them if you want them. */ - /* invert monochrome pixels */ + /* Invert monochrome pixels */ png_set_invert_mono(png_ptr); /* Shift the pixels up to a legal bit depth and fill in * as appropriate to correctly scale the image. */ png_set_shift(png_ptr, &sig_bit); - /* pack pixels into bytes */ + /* Pack pixels into bytes */ png_set_packing(png_ptr); - /* swap location of alpha bytes from ARGB to RGBA */ + /* Swap location of alpha bytes from ARGB to RGBA */ png_set_swap_alpha(png_ptr); /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels). The second parameter is not used. */ png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - /* flip BGR pixels to RGB */ + /* Flip BGR pixels to RGB */ png_set_bgr(png_ptr); - /* swap bytes of 16-bit files to most significant byte first */ + /* Swap bytes of 16-bit files to most significant byte first */ png_set_swap(png_ptr); - /* swap bits of 1, 2, 4 bit packed pixel formats */ + /* Swap bits of 1, 2, 4 bit packed pixel formats */ png_set_packswap(png_ptr); - /* turn on interlace handling if you are not using png_write_image() */ + /* Turn on interlace handling if you are not using png_write_image() */ if (interlacing) number_passes = png_set_interlace_handling(png_ptr); else number_passes = 1; @@ -756,14 +768,16 @@ for (k = 0; k < height; k++) row_pointers[k] = image + k*width*bytes_per_pixel; /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ + +#ifdef entire /* Write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); /* the other way to write the image - deal with interlacing */ -#else no_entire /* write out the image data by one or more scanlines */ +#else no_entire /* Write out the image data by one or more scanlines */ + /* The number of passes is either 1 for non-interlaced images, * or 7 for interlaced images. */ for (pass = 0; pass < number_passes; pass++) @@ -774,12 +788,12 @@ /* 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 */ +#endif no_entire /* Use only one output method */ /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public + * as well. Shouldn't be necessary in 1.2.0 and up as all the public * chunks are supported and you can use png_set_unknown_chunks() to * register unknown chunks into the info structure to be written out. */ @@ -787,28 +801,35 @@ png_write_end(png_ptr, info_ptr); #endif hilevel /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ + * as recommended in versions 1.0.5m and earlier of this example; if + * libpng mallocs info_ptr->palette, libpng will free it). If you + * allocated it with malloc() instead of png_malloc(), use free() instead + * of png_free(). + */ png_free(png_ptr, palette); palette = NULL; /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ + * png_set_something(), such as a hist or trans array, free it here, + * when you can be sure that libpng is through with it. + */ png_free(png_ptr, trans); trans = NULL; + /* Whenever you use png_free() it is a good idea to set the pointer to + * NULL in case your application inadvertently tries to png_free() it + * again. When png_free() sees a NULL it returns without action, thus + * avoiding the double-free security problem. + */ - /* clean up after the write, and free any memory allocated */ + /* Clean up after the write, and free any memory allocated */ png_destroy_write_struct(&png_ptr, &info_ptr); - /* close the file */ + /* Close the file */ fclose(fp); - /* that's it */ + /* That's it */ return (OK); } #endif /* if 0 */ diff -ru4NwbB libpng-1.2.35/png.c libpng-1.4.0beta60/png.c --- libpng-1.2.35/png.c 2009-02-14 15:59:26.559242943 -0600 +++ libpng-1.4.0beta60/png.c 2009-05-18 16:58:20.577209505 -0500 @@ -1,17 +1,17 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #define PNG_NO_EXTERN #include "png.h" +#include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ typedef version_%_VER_% Your_png_h_is_not_version_%_VER_%; @@ -91,12 +91,13 @@ #ifdef PNG_READ_SUPPORTED void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_debug(1, "in png_set_sig_bytes"); if (num_bytes > 8) - png_error(png_ptr, "Too many bytes for PNG signature."); + png_error(png_ptr, "Too many bytes for PNG signature"); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); } @@ -125,71 +126,38 @@ return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); } -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* (Obsolete) function to check signature bytes. It does not allow one - * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG. - */ -int PNGAPI -png_check_sig(png_bytep sig, int num) -{ - return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); -} -#endif #endif /* PNG_READ_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Function to allocate memory for zlib and clear it to 0. */ -#ifdef PNG_1_0_X -voidpf PNGAPI -#else voidpf /* private */ -#endif png_zalloc(voidpf png_ptr, uInt items, uInt size) { png_voidp ptr; png_structp p=(png_structp)png_ptr; png_uint_32 save_flags=p->flags; - png_uint_32 num_bytes; + png_alloc_size_t num_bytes; - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); if (items > PNG_UINT_32_MAX/size) { png_warning (p, "Potential overflow in png_zalloc()"); return (NULL); } - num_bytes = (png_uint_32)items * size; + num_bytes = (png_alloc_size_t)items * size; p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); p->flags=save_flags; -#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) - if (ptr == NULL) - return ((voidpf)ptr); - - if (num_bytes > (png_uint_32)0x8000L) - { - png_memset(ptr, 0, (png_size_t)0x8000L); - png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, - (png_size_t)(num_bytes - (png_uint_32)0x8000L)); - } - else - { - png_memset(ptr, 0, (png_size_t)num_bytes); - } -#endif return ((voidpf)ptr); } /* function to free memory for zlib */ -#ifdef PNG_1_0_X -void PNGAPI -#else void /* private */ -#endif png_zfree(voidpf png_ptr, voidpf ptr) { png_free((png_structp)png_ptr, (png_voidp)ptr); } @@ -240,9 +208,10 @@ { png_infop info_ptr; png_debug(1, "in png_create_info_struct"); - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, png_ptr->malloc_fn, png_ptr->mem_ptr); #else @@ -262,9 +231,10 @@ void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { png_infop info_ptr = NULL; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_debug(1, "in png_destroy_info_struct"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; @@ -286,24 +256,16 @@ /* Initialize the info structure. This is now an internal function (0.89) * and applications using it are urged to use png_create_info_struct() * instead. */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#undef png_info_init -void PNGAPI -png_info_init(png_infop info_ptr) -{ - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} -#endif void PNGAPI png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) { png_infop info_ptr = *ptr_ptr; - if (info_ptr == NULL) return; + if (info_ptr == NULL) + return; png_debug(1, "in png_info_init_3"); if (png_sizeof(png_info) > png_info_struct_size) @@ -330,9 +292,9 @@ else if (freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; else png_warning(png_ptr, - "Unknown freer parameter in png_data_freer."); + "Unknown freer parameter in png_data_freer"); } #endif void PNGAPI @@ -568,12 +530,10 @@ int row; for (row = 0; row < (int)info_ptr->height; row++) { png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; } png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; } info_ptr->valid &= ~PNG_INFO_IDAT; } #endif @@ -600,9 +560,8 @@ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; png_ptr->num_chunk_list = 0; } #endif @@ -616,9 +575,10 @@ */ png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr) { - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); return (png_ptr->io_ptr); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) @@ -632,9 +592,10 @@ void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp) { png_debug(1, "in png_init_io"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->io_ptr = (png_voidp)fp; } #endif @@ -648,26 +609,16 @@ static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); if (png_ptr->time_buffer == NULL) { png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* png_sizeof(char))); } -#if defined(_WIN32_WCE) - { - wchar_t time_buf[29]; - wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), - ptime->day % 32, short_months[(ptime->month - 1) % 12], - ptime->year, ptime->hour % 24, ptime->minute % 60, - ptime->second % 61); - WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, - NULL, NULL); - } -#else #ifdef USE_FAR_KEYWORD { char near_time_buf[29]; png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000", @@ -682,9 +633,8 @@ ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); #endif -#endif /* _WIN32_WCE */ return ((png_charp)png_ptr->time_buffer); } #endif /* PNG_TIME_RFC1123_SUPPORTED */ @@ -693,12 +643,25 @@ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.4.0beta60 - May 18, 2009\n\ - Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\ - Copyright (c) 1996-1997 Andreas Dilger\n\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); +#ifdef PNG_STRING_COPYRIGHT + return PNG_STRING_COPYRIGHT +#else +#ifdef __STDC__ + return ((png_charp) PNG_STRING_NEWLINE \ + "libpng version x 1.4.0beta60 - May 18, 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.0beta60 - May 18, 2009\ + Copyright (c) 1998-2009 Glenn Randers-Pehrson\ + Copyright (c) 1996-1997 Andreas Dilger\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); +#endif +#endif } /* The following return the library version as a short string in the * format 1.0.0 through 99.99.99zz. To get the version of *.h files @@ -728,13 +691,17 @@ png_get_header_version(png_structp png_ptr) { /* Returns longer string containing both version and date */ png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ +#ifdef __STDC__ return ((png_charp) PNG_HEADER_VERSION_STRING #ifndef PNG_READ_SUPPORTED " (NO READ SUPPORT)" #endif - "\n"); + PNG_STRING_NEWLINE); +#else + return ((png_charp) PNG_HEADER_VERSION_STRING); +#endif } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED @@ -757,9 +724,10 @@ /* This function, added to libpng-1.0.6g, is untested. */ int PNGAPI png_reset_zstream(png_structp png_ptr) { - if (png_ptr == NULL) return Z_STREAM_ERROR; + if (png_ptr == NULL) + return Z_STREAM_ERROR; return (inflateReset(&png_ptr->zstream)); } #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ @@ -771,19 +739,8 @@ return((png_uint_32) PNG_LIBPNG_VER); } -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if !defined(PNG_1_0_X) -/* this function was added to libpng 1.2.0 */ -int PNGAPI -png_mmx_support(void) -{ - /* obsolete, to be removed from libpng-1.4.0 */ - return -1; -} -#endif /* PNG_1_0_X */ -#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_SIZE_T /* Added at libpng version 1.2.6 */ @@ -799,21 +756,22 @@ /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ #if defined(PNG_cHRM_SUPPORTED) #if !defined(PNG_NO_CHECK_cHRM) -/* - Multiply two 32-bit numbers, V1 and V2, using 32-bit - arithmetic, to produce a 64 bit result in the HI/LO words. - A B - x C D - ------ - AD || BD -AC || CB || 0 - - where A and B are the high and low 16-bit words of V1, - C and D are the 16-bit words of V2, AD is the product of - A and D, and X || Y is (X << 16) + Y. +/* + * Multiply two 32-bit numbers, V1 and V2, using 32-bit + * arithmetic, to produce a 64 bit result in the HI/LO words. + * + * A B + * x C D + * ------ + * AD || BD + * AC || CB || 0 + * + * where A and B are the high and low 16-bit words of V1, + * C and D are the 16-bit words of V2, AD is the product of + * A and D, and X || Y is (X << 16) + Y. */ void png_64bit_product (long v1, long v2, unsigned long *hi_product, unsigned long *lo_product) diff -ru4NwbB libpng-1.2.35/png.h libpng-1.4.0beta60/png.h --- libpng-1.2.35/png.h 2009-02-14 15:59:26.535979077 -0600 +++ libpng-1.4.0beta60/png.h 2009-05-18 16:58:20.547107863 -0500 @@ -101,128 +102,33 @@ * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 + * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 + * 1.0.18 10 10018 12.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10beta1-7 13 10210 12.so.0.10[.0] + * 1.2.10rc1-2 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * 1.2.17beta1-2 13 10217 12.so.0.17[.0] - * 1.0.25rc1 10 10025 10.so.0.25[.0] - * 1.2.17rc1-3 13 10217 12.so.0.17[.0] - * 1.0.25 10 10025 10.so.0.25[.0] - * 1.2.17 13 10217 12.so.0.17[.0] - * 1.0.26 10 10026 10.so.0.26[.0] - * 1.2.18 13 10218 12.so.0.18[.0] - * 1.2.19beta1-31 13 10219 12.so.0.19[.0] - * 1.0.27rc1-6 10 10027 10.so.0.27[.0] - * 1.2.19rc1-6 13 10219 12.so.0.19[.0] - * 1.0.27 10 10027 10.so.0.27[.0] - * 1.2.19 13 10219 12.so.0.19[.0] - * 1.2.20beta01-04 13 10220 12.so.0.20[.0] - * 1.0.28rc1-6 10 10028 10.so.0.28[.0] - * 1.2.20rc1-6 13 10220 12.so.0.20[.0] - * 1.0.28 10 10028 10.so.0.28[.0] - * 1.2.20 13 10220 12.so.0.20[.0] - * 1.2.21beta1-2 13 10221 12.so.0.21[.0] - * 1.2.21rc1-3 13 10221 12.so.0.21[.0] - * 1.0.29 10 10029 10.so.0.29[.0] - * 1.2.21 13 10221 12.so.0.21[.0] - * 1.2.22beta1-4 13 10222 12.so.0.22[.0] - * 1.0.30rc1 10 10030 10.so.0.30[.0] - * 1.2.22rc1 13 10222 12.so.0.22[.0] - * 1.0.30 10 10030 10.so.0.30[.0] - * 1.2.22 13 10222 12.so.0.22[.0] - * 1.2.23beta01-05 13 10223 12.so.0.23[.0] - * 1.2.23rc01 13 10223 12.so.0.23[.0] - * 1.2.23 13 10223 12.so.0.23[.0] - * 1.2.24beta01-02 13 10224 12.so.0.24[.0] - * 1.2.24rc01 13 10224 12.so.0.24[.0] - * 1.2.24 13 10224 12.so.0.24[.0] - * 1.2.25beta01-06 13 10225 12.so.0.25[.0] - * 1.2.25rc01-02 13 10225 12.so.0.25[.0] - * 1.0.31 10 10031 10.so.0.31[.0] - * 1.2.25 13 10225 12.so.0.25[.0] - * 1.2.26beta01-06 13 10226 12.so.0.26[.0] - * 1.2.26rc01 13 10226 12.so.0.26[.0] - * 1.2.26 13 10226 12.so.0.26[.0] - * 1.0.32 10 10032 10.so.0.32[.0] - * 1.2.27beta01-06 13 10227 12.so.0.27[.0] - * 1.2.27rc01 13 10227 12.so.0.27[.0] - * 1.0.33 10 10033 10.so.0.33[.0] - * 1.2.27 13 10227 12.so.0.27[.0] - * 1.0.34 10 10034 10.so.0.34[.0] - * 1.2.28 13 10228 12.so.0.28[.0] - * 1.2.29beta01-03 13 10229 12.so.0.29[.0] - * 1.2.29rc01 13 10229 12.so.0.29[.0] - * 1.0.35 10 10035 10.so.0.35[.0] - * 1.2.29 13 10229 12.so.0.29[.0] - * 1.0.37 10 10037 10.so.0.37[.0] - * 1.2.30beta01-04 13 10230 12.so.0.30[.0] - * 1.0.38rc01-08 10 10038 10.so.0.38[.0] - * 1.2.30rc01-08 13 10230 12.so.0.30[.0] - * 1.0.38 10 10038 10.so.0.38[.0] - * 1.2.30 13 10230 12.so.0.30[.0] - * 1.0.39rc01-03 10 10039 10.so.0.39[.0] - * 1.2.31rc01-03 13 10231 12.so.0.31[.0] - * 1.0.39 10 10039 10.so.0.39[.0] - * 1.2.31 13 10231 12.so.0.31[.0] - * 1.2.32beta01-02 13 10232 12.so.0.32[.0] - * 1.0.40rc01 10 10040 10.so.0.40[.0] - * 1.2.32rc01 13 10232 12.so.0.32[.0] - * 1.0.40 10 10040 10.so.0.40[.0] - * 1.2.32 13 10232 12.so.0.32[.0] - * 1.2.33beta01-02 13 10233 12.so.0.33[.0] - * 1.2.33rc01-02 13 10233 12.so.0.33[.0] - * 1.0.41rc01 10 10041 10.so.0.41[.0] - * 1.2.33 13 10233 12.so.0.33[.0] - * 1.0.41 10 10041 10.so.0.41[.0] - * 1.2.34beta01-07 13 10234 12.so.0.34[.0] - * 1.0.42rc01 10 10042 10.so.0.42[.0] - * 1.2.34rc01 13 10234 12.so.0.34[.0] - * 1.0.42 10 10042 10.so.0.42[.0] - * 1.2.34 13 10234 12.so.0.34[.0] - * 1.2.35beta01-03 13 10235 12.so.0.35[.0] - * 1.0.43rc01-02 10 10043 10.so.0.43[.0] - * 1.2.35rc01-02 13 10235 12.so.0.35[.0] - * 1.0.43 10 10043 10.so.0.43[.0] - * 1.2.35 13 10235 12.so.0.35[.0] + * 1.4.0beta1-5 14 10400 14.so.0.0[.0] + * 1.2.11beta1-4 13 10210 12.so.0.10[.0] + * 1.4.0beta7-8 14 10400 14.so.0.0[.0] + * 1.2.11 13 10211 12.so.0.10[.0] + * 1.2.12 13 10212 12.so.0.10[.0] + * 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-60 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 * used for changes in backward compatibility, as it is intended. The @@ -230,9 +136,9 @@ * for applications, is an unsigned integer of the form xyyzz corresponding * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcNN". + * release number plus "betaNN" or "rcN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. @@ -251,9 +157,9 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * * libpng versions 1.2.6, August 15, 2004, through 1.4.0beta60, May 18, 2009, are - * Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and 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: * * Cosmin Truta @@ -362,9 +268,9 @@ /* * Y2K compliance in libpng: * ========================= * - * May 18, 2009 + * July 1, 2008 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * @@ -455,22 +361,26 @@ PNG_LIBPNG_BUILD_SPECIAL */ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE %BUILDTYPE% +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER %VER_NUM% /* %MAJOR%.%MINOR%.%RELEASE% */ +#define PNG_LIBPNG_VER 10400 /* 1.4.0 */ #ifndef PNG_VERSION_INFO_ONLY /* include the compression library's header */ #include "zlib.h" #endif +#ifdef AIX +#define jmpbuf __jmpbuf +#endif + /* include all user configurable info, including optional assembler routines */ #include "pngconf.h" /* @@ -510,65 +420,34 @@ * library functions, while the third has the internal library functions, * which applications aren't expected to use directly. */ -#ifndef PNG_NO_TYPECAST_NULL -#define int_p_NULL (int *)NULL -#define png_bytep_NULL (png_bytep)NULL -#define png_bytepp_NULL (png_bytepp)NULL -#define png_doublep_NULL (png_doublep)NULL -#define png_error_ptr_NULL (png_error_ptr)NULL -#define png_flush_ptr_NULL (png_flush_ptr)NULL -#define png_free_ptr_NULL (png_free_ptr)NULL -#define png_infopp_NULL (png_infopp)NULL -#define png_malloc_ptr_NULL (png_malloc_ptr)NULL -#define png_read_status_ptr_NULL (png_read_status_ptr)NULL -#define png_rw_ptr_NULL (png_rw_ptr)NULL -#define png_structp_NULL (png_structp)NULL -#define png_uint_16p_NULL (png_uint_16p)NULL -#define png_voidp_NULL (png_voidp)NULL -#define png_write_status_ptr_NULL (png_write_status_ptr)NULL -#else -#define int_p_NULL NULL -#define png_bytep_NULL NULL -#define png_bytepp_NULL NULL -#define png_doublep_NULL NULL -#define png_error_ptr_NULL NULL -#define png_flush_ptr_NULL NULL -#define png_free_ptr_NULL NULL -#define png_infopp_NULL NULL -#define png_malloc_ptr_NULL NULL -#define png_read_status_ptr_NULL NULL -#define png_rw_ptr_NULL NULL -#define png_structp_NULL NULL -#define png_uint_16p_NULL NULL -#define png_voidp_NULL NULL -#define png_write_status_ptr_NULL NULL -#endif - /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* Version information for C files, stored in png.c. This had better match * the version above. */ #ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18]; +PNG_EXPORT_VAR (const char) png_libpng_ver[18]; /* need room for 99.99.99beta99z */ #else #define png_libpng_ver png_get_header_ver(NULL) #endif #ifdef PNG_USE_GLOBAL_ARRAYS /* This was removed in version 1.0.5c */ /* Structures to facilitate easy interlacing. See png.c for more details */ -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7]; -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; +#ifdef PNG_USE_PNGGCCRD +PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; +#endif /* This isn't currently used. If you need it, see png.c for more details. -PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; */ #endif #endif /* PNG_NO_EXTERN */ @@ -703,12 +582,11 @@ * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually * know about their semantics. */ -#define PNG_CHUNK_NAME_LENGTH 5 typedef struct png_unknown_chunk_t { - png_byte name[PNG_CHUNK_NAME_LENGTH]; + png_byte name[5]; png_byte *data; png_size_t size; /* libpng-using applications should NOT directly modify this byte. */ @@ -763,9 +641,9 @@ /* the following are necessary for every PNG file */ png_uint_32 width; /* width of image in pixels (from IHDR) */ png_uint_32 height; /* height of image in pixels (from IHDR) */ png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ + png_size_t rowbytes; /* bytes needed to hold an untransformed row */ png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ @@ -843,9 +721,9 @@ * single color specified that should be treated as fully transparent. * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. */ png_bytep trans; /* transparent values for paletted image */ - png_color_16 trans_values; /* transparent color for non-palette image */ + png_color_16 trans_color; /* transparent color for non-palette image */ #endif #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) /* The bKGD chunk gives the suggested image background color if the @@ -1002,12 +880,8 @@ /* Maximum positive integer used in PNG is (2^31)-1 */ #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) #define PNG_UINT_32_MAX ((png_uint_32)(-1)) #define PNG_SIZE_MAX ((png_size_t)(-1)) -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ -#define PNG_MAX_UINT PNG_UINT_31_MAX -#endif /* These describe the color_type field in png_info. */ /* color type masks */ #define PNG_COLOR_MASK_PALETTE 1 @@ -1102,9 +976,9 @@ */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ + png_size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ @@ -1163,19 +1037,19 @@ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ /* Added to libpng-1.2.34 */ -#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* WRITE only */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_alloc_size_t)); typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); /* The structure that holds the information to read and write PNG files. * The only people who need to care about what is inside of this are the @@ -1230,20 +1104,18 @@ png_uint_32 width; /* width of image in pixels */ png_uint_32 height; /* height of image in pixels */ png_uint_32 num_rows; /* number of rows in current pass */ png_uint_32 usr_width; /* width of row at start of write */ - png_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_size_t rowbytes; /* size of row in bytes */ + png_size_t irowbytes; /* size of current interlaced row in bytes */ png_uint_32 iwidth; /* width of current interlaced row in pixels */ png_uint_32 row_number; /* current row in interlace pass */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */ -#ifndef PNG_NO_WRITE_FILTER png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */ png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ -#endif png_row_info row_info; /* used for transformation routines */ png_uint_32 idat_size; /* current IDAT size for read */ png_uint_32 crc; /* current chunk CRC value */ @@ -1316,9 +1188,9 @@ #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) png_bytep trans; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values for non-paletted files */ + png_color_16 trans_color; /* transparent color for non-paletted files */ #endif png_read_status_ptr read_row_fn; /* called after each row is decoded */ png_write_status_ptr write_row_fn; /* called after each row is encoded */ @@ -1343,9 +1215,10 @@ png_size_t current_text_size; /* current size of text input data */ png_size_t current_text_left; /* how much text left to read in input */ png_charp current_text; /* current text chunk buffer */ png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_TEXT_SUPPORTED */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) /* for the Borland special 64K segment handler */ @@ -1408,13 +1281,9 @@ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) /* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ #endif /* New member added in libpng-1.0.7 */ #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) @@ -1425,23 +1294,14 @@ #if defined(PNG_MNG_FEATURES_SUPPORTED) png_byte filter_type; #endif -#if defined(PNG_1_0_X) /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ +#if (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) png_uint_32 row_buf_size; #endif /* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ #ifdef PNG_USER_MEM_SUPPORTED png_voidp mem_ptr; /* user supplied struct for mem functions */ @@ -1466,8 +1326,13 @@ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_uint_32 user_width_max; png_uint_32 user_height_max; + /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown + * chunks that can be stored (0x7fffffff means unlimited). + + */ + png_uint_32 user_chunk_cache_max; #endif /* New member added in libpng-1.0.25 and 1.2.17 */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) @@ -1480,8 +1345,12 @@ /* New member added in libpng-1.2.30 */ png_charp chunkdata; /* buffer for reading chunk data */ +/* New member added in libpng-1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED + png_uint_32 io_state; +#endif }; /* This triggers a compiler error in png.c, if png.c and png.h @@ -1516,9 +1385,9 @@ /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); +#define png_check_sig(sig,n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ extern PNG_EXPORT(png_structp,png_create_read_struct) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, @@ -1529,15 +1398,15 @@ PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)); #ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) +extern PNG_EXPORT(png_size_t,png_get_compression_buffer_size) PNGARG((png_structp png_ptr)); #endif #ifdef PNG_WRITE_SUPPORTED extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); + PNGARG((png_structp png_ptr, png_size_t size)); #endif /* Reset the compression stream */ extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); @@ -1553,8 +1422,11 @@ png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); #endif +/* Write the PNG file signature. */ +extern PNG_EXPORT(void,png_write_sig) PNGARG((png_structp png_ptr)); + /* Write a PNG chunk - size, type, (optional) data, CRC. */ extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length)); @@ -1572,16 +1444,8 @@ /* Allocate and initialize the info structure */ extern PNG_EXPORT(png_infop,png_create_info_struct) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif - extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, png_size_t png_info_struct_size)); /* Writes all the PNG information before the image. */ @@ -1600,10 +1464,8 @@ extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) PNGARG((png_structp png_ptr, png_timep ptime)); #endif -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ #if defined(PNG_WRITE_tIME_SUPPORTED) /* convert from a struct tm to png_time */ extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, struct tm FAR * ttime)); @@ -1611,23 +1473,16 @@ /* convert from time_t to png_time. Uses gmtime() */ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, time_t ttime)); #endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ #if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ @@ -1667,20 +1522,23 @@ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) 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)); +#endif + #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ #define PNG_FILLER_BEFORE 0 #define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, png_uint_32 filler, int flags)); -#endif #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ @@ -1746,17 +1604,8 @@ double screen_gamma, double default_file_gamma)); #endif #endif -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif -#endif #if defined(PNG_WRITE_FLUSH_SUPPORTED) /* Set how many lines between output flushes - 0 for no flushing */ extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); @@ -1986,8 +1835,13 @@ /* Replace the default data output functions with a user supplied one(s). * 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)); @@ -2066,30 +1920,22 @@ png_bytep old_row, png_bytep new_row)); #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); + png_alloc_size_t size)); +/* Added at libpng version 1.4.0 */ +#ifdef PNG_CALLOC_SUPPORTED +extern PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr, + png_alloc_size_t size)); +#endif -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else /* Added at libpng version 1.2.4 */ extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif + png_alloc_size_t size)); -/* frees a pointer allocated by png_malloc() */ +/* Frees a pointer allocated by png_malloc() */ extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - /* Free data that was allocated internally */ extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); #ifdef PNG_FREE_ME_SUPPORTED @@ -2118,48 +1964,47 @@ #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); + png_alloc_size_t size)); extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, png_voidp ptr)); #endif -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - #if defined(USE_FAR_KEYWORD) /* memory model conversion function */ extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, int check)); #endif /* USE_FAR_KEYWORD */ -#ifndef PNG_NO_ERROR_TEXT /* Fatal error in PNG image of libpng - can't continue */ extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, png_const_charp error_message)); /* The same, but the chunk name is prepended to the error string. */ extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, png_const_charp error_message)); -#else -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); -#endif -#ifndef PNG_NO_WARNINGS /* Non-fatal error in libpng. Can continue, but may have a problem. */ extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, png_const_charp warning_message)); -#ifdef PNG_READ_SUPPORTED /* Non-fatal error in libpng, chunk name is prepended to message. */ extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, png_const_charp warning_message)); -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_NO_WARNINGS */ + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Benign error in libpng. Can continue, but may have a problem. + * User can choose whether to handle as a fatal error or as a warning. */ +extern PNG_EXPORT(void,png_benign_error) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* Same, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_benign_error) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +extern PNG_EXPORT(void,png_set_benign_errors) PNGARG((png_structp + png_ptr, int allowed)); +#endif /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or @@ -2176,9 +2021,9 @@ extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +extern PNG_EXPORT(png_size_t,png_get_rowbytes) PNGARG((png_structp png_ptr, png_infop info_ptr)); #if defined(PNG_INFO_IMAGE_SUPPORTED) /* Returns row_pointers, which is an array of pointers to scanlines that was @@ -2450,15 +2295,15 @@ #if defined(PNG_tRNS_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); + png_color_16p *trans_color)); #endif #if defined(PNG_tRNS_SUPPORTED) extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); + png_color_16p trans_color)); #endif #if defined(PNG_tRNS_SUPPORTED) #endif @@ -2555,13 +2400,14 @@ #else /* PNG_DEBUG_FILE || !_MSC_VER */ #ifndef PNG_DEBUG_FILE #define PNG_DEBUG_FILE stderr #endif /* PNG_DEBUG_FILE */ + #if (PNG_DEBUG > 1) -#ifndef png_debug /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on * non-ISO compilers */ #ifdef __STDC__ +# ifndef png_debug #define png_debug(l,m) \ { \ int num_tabs=l; \ fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ @@ -2586,35 +2432,42 @@ #endif #else /* __STDC __ */ #ifndef png_debug #define png_debug(l,m) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format); + fprintf(PNG_DEBUG_FILE,format); \ + } #endif #ifndef png_debug1 #define png_debug1(l,m,p1) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1); + fprintf(PNG_DEBUG_FILE,format,p1); \ + } #endif #ifndef png_debug2 #define png_debug2(l,m,p1,p2) \ + { \ int num_tabs=l; \ char format[256]; \ snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1,p2); + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } #endif #endif /* __STDC __ */ #endif /* (PNG_DEBUG > 1) */ + #endif /* _MSC_VER */ #endif /* (PNG_DEBUG > 0) */ #endif /* PNG_DEBUG */ #ifndef png_debug @@ -2626,8 +2479,12 @@ #ifndef png_debug2 #define png_debug2(l, m, p1, p2) #endif +#if 0 +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); +#endif + extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); @@ -2642,94 +2499,70 @@ #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp png_ptr, png_uint_32 strip_mode)); #endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ +/* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp png_ptr)); +/* Added in libpng-1.4.0 */ +extern PNG_EXPORT(void,png_set_chunk_cache_max) PNGARG((png_structp + png_ptr, png_uint_32 user_chunk_cache_max)); +extern PNG_EXPORT(png_uint_32,png_get_chunk_cache_max) + PNGARG((png_structp png_ptr)); #endif +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +PNG_EXPORT(png_uint_32,png_get_pixels_per_inch) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXPORT(png_uint_32,png_get_x_pixels_per_inch) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXPORT(png_uint_32,png_get_y_pixels_per_inch) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXPORT(float,png_get_x_offset_inches) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXPORT(float,png_get_y_offset_inches) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_pHYs_SUPPORTED) +PNG_EXPORT(png_uint_32,png_get_pHYs_dpi) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* Added in libpng-1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_io_state) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(png_bytep,png_get_io_chunk_name) + PNGARG((png_structp png_ptr)); + +/* The flags returned by png_get_io_state() are the following: */ +#define PNG_IO_NONE 0x0000 /* no I/O at this moment */ +#define PNG_IO_READING 0x0001 /* currently reading */ +#define PNG_IO_WRITING 0x0002 /* currently writing */ +#define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ +#define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ +#define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ +#define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ +#define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ +#define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ +#endif /* ?PNG_IO_STATE_SUPPORTED */ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED @@ -2772,25 +2605,36 @@ (png_uint_32)32767) / (png_uint_32)65535L) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +#ifdef PNG_USE_READ_MACROS +/* Inline macros to do direct reads of bytes from the input buffer. + * The png_get_int_32() routine assumes we are using two's complement + * format for negative values, which is almost certainly true. + */ +/* We could make special-case BIG_ENDIAN macros that do direct reads here */ +# define png_get_uint_32(buf) \ + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) +# define png_get_uint_16(buf) \ + (((png_uint_32)(*(buf)) << 8) + \ + ((png_uint_32)(*((buf) + 1)))) +#if defined(PNG_GET_INT_32_SUPPORTED) +# define png_get_int_32(buf) \ + (((png_int_32)(*(buf)) << 24) + \ + ((png_int_32)(*((buf) + 1)) << 16) + \ + ((png_int_32)(*((buf) + 2)) << 8) + \ + ((png_int_32)(*((buf) + 3)))) +#endif #else extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); +#if defined(PNG_GET_INT_32_SUPPORTED) extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ +#endif +#endif extern PNG_EXPORT(png_uint_32,png_get_uint_31) PNGARG((png_structp png_ptr, png_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ @@ -2810,853 +2654,18 @@ /* No png_save_int_16 -- may be added if there's a real need for it. */ /* ************************************************************************* */ -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - - -/* Various modes of operation, that are visible to applications because - * they are used for unknown chunk location. +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. */ #define PNG_HAVE_IHDR 0x01 #define PNG_HAVE_PLTE 0x02 #define PNG_HAVE_IDAT 0x04 #define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ #define PNG_HAVE_IEND 0x10 - -#if defined(PNG_INTERNAL) - -/* More modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ #define PNG_HAVE_gAMA 0x20 #define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; -#else -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_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_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Read the chunk header (length + type name) */ -PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); - -/* Added at libpng version 1.2.34 */ -#if defined(PNG_cHRM_SUPPORTED) -PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ #ifdef __cplusplus } #endif diff -ru4NwbB libpng-1.2.35/pngconf.h libpng-1.4.0beta60/pngconf.h --- libpng-1.2.35/pngconf.h 2009-02-14 15:59:26.544632620 -0600 +++ libpng-1.4.0beta60/pngconf.h 2009-05-18 16:58:20.555672713 -0500 @@ -16,11 +16,24 @@ #ifndef PNGCONF_H #define PNGCONF_H -#define PNG_1_2_X +#ifndef PNG_NO_LIMITS_H +#include +#endif + +/* Added at libpng-1.2.9 */ + +/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ +#ifdef PNG_CONFIGURE_LIBPNG +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#endif /* + * Added at libpng-1.2.8 + * * PNG_USER_CONFIG has to be defined on the compiler command line. This * includes the resource compiler for Windows DLL configurations. */ #ifdef PNG_USER_CONFIG @@ -29,18 +42,14 @@ # endif #include "pngusr.h" #endif -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +/* Added at libpng-1.4.0beta49 for testing */ +#ifndef PNG_NO_CALLOC +# define PNG_CALLOC_SUPPORTED #endif /* - * Added at libpng-1.2.8 - * * If you create a private DLL you need to define in "pngusr.h" the followings: * #define PNG_USER_PRIVATEBUILD * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." @@ -74,16 +83,8 @@ #ifndef PNG_VERSION_INFO_ONLY /* End of material added to libpng-1.2.8 */ -/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble - Restored at libpng-1.2.21 */ -#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \ - !defined(PNG_WARN_UNINITIALIZED_ROW) -# define PNG_WARN_UNINITIALIZED_ROW 1 -#endif -/* End of material added at libpng-1.2.19/1.2.21 */ - /* This is the size of the compression buffer, and thus the size of * an IDAT chunk. Make this whatever size you feel is best for your * machine. One of these will be allocated per png_struct. When this * is full, it writes the data to the disk, and does some other @@ -111,11 +112,22 @@ #ifndef PNG_NO_WRITE_SUPPORTED # define PNG_WRITE_SUPPORTED #endif +/* Enabled in 1.4.0. */ +#ifdef PNG_ALLOW_BENIGN_ERRORS +# define png_benign_error png_warning +# define png_chunk_benign_error png_chunk_warning +#else +# ifndef PNG_BENIGN_ERRORS_SUPPORTED +# define png_benign_error png_error +# define png_chunk_benign_error png_chunk_error +# endif +#endif + /* Enabled by default in 1.2.0. You can disable this if you don't need to support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +#if !defined(PNG_NO_MNG_FEATURES) # ifndef PNG_MNG_FEATURES_SUPPORTED # define PNG_MNG_FEATURES_SUPPORTED # endif #endif @@ -232,10 +244,8 @@ #if defined(_WIN32_WCE) # include /* Console I/O functions are not supported on WindowsCE */ # define PNG_NO_CONSOLE_IO - /* abort() may not be supported on some/all Windows CE platforms */ -# define PNG_ABORT() exit(-1) # ifdef PNG_DEBUG # undef PNG_DEBUG # endif #endif @@ -257,13 +267,10 @@ # include # endif # endif # else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ # include # endif -# endif /* This macro protects us against machines that don't have function * prototypes (ie K&R style headers). If your compiler does not handle * function prototypes, define this macro and use the included ansi2knr. @@ -278,11 +285,8 @@ #else #ifdef _NO_PROTO # define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif #else # define PNGARG(arglist) arglist #endif /* _NO_PROTO */ @@ -313,10 +316,17 @@ #ifdef PNG_SETJMP_SUPPORTED /* This is an attempt to force a single setjmp behaviour on Linux. If * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + * + * You can bypass this test if you know that your application uses exactly + * the same setjmp.h that was included when libpng was built. Only define + * PNG_SKIP_SETJMP_CHECK while building your application, prior to the + * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK + * while building a separate libpng library for general use. */ +# ifndef PNG_SKIP_SETJMP_CHECK # ifdef __linux__ # ifdef _BSD_SOURCE # define PNG_SAVE_BSD_SOURCE # undef _BSD_SOURCE @@ -324,21 +334,23 @@ # ifdef _SETJMP_H /* If you encounter a compiler error here, see the explanation * near the end of INSTALL. */ - __pngconf.h__ already includes setjmp.h; + __pngconf.h__ in libpng already includes setjmp.h; __dont__ include it again.; # endif # endif /* __linux__ */ +# endif /* PNG_SKIP_SETJMP_CHECK */ /* include setjmp.h for error handling */ # include # ifdef __linux__ # ifdef PNG_SAVE_BSD_SOURCE -# ifndef _BSD_SOURCE -# define _BSD_SOURCE +# ifdef _BSD_SOURCE +# undef _BSD_SOURCE # endif +# define _BSD_SOURCE # undef PNG_SAVE_BSD_SOURCE # endif # endif /* __linux__ */ #endif /* PNG_SETJMP_SUPPORTED */ @@ -349,61 +361,8 @@ # include #endif /* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include -# include -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include -#endif /* This controls how fine the dithering gets. As this allocates * a largish chunk of memory (32K), those who are not as concerned * with dithering quality can decrease some or all of these. @@ -435,10 +394,8 @@ #ifndef PNG_GAMMA_THRESHOLD # define PNG_GAMMA_THRESHOLD 0.05 #endif -#endif /* PNG_INTERNAL */ - /* The following uses const char * instead of char * for error * and warning message functions, so some compilers won't complain. * If you do not want to use const, define PNG_NO_CONST here. */ @@ -478,23 +435,11 @@ /* The size of the png_text structure changed in libpng-1.0.6 when * iTXt support was added. iTXt support was turned off by default through * libpng-1.2.x, to support old apps that malloc the png_text structure * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. + * was turned on by default in libpng-1.4.0. */ -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt -# endif -#endif - #if !defined(PNG_NO_iTXt_SUPPORTED) # if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) # define PNG_READ_iTXt # endif @@ -570,11 +515,13 @@ # endif # ifndef PNG_NO_READ_INVERT # define PNG_READ_INVERT_SUPPORTED # endif +#if 0 /* removed from libpng-1.4.0 */ # ifndef PNG_NO_READ_DITHER # define PNG_READ_DITHER_SUPPORTED # endif +#endif /* 0 */ # ifndef PNG_NO_READ_BACKGROUND # define PNG_READ_BACKGROUND_SUPPORTED # endif # ifndef PNG_NO_READ_16_TO_8 @@ -594,8 +541,11 @@ # endif # ifndef PNG_NO_READ_INVERT_ALPHA # define PNG_READ_INVERT_ALPHA_SUPPORTED # endif +# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA +# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED +# endif # ifndef PNG_NO_READ_STRIP_ALPHA # define PNG_READ_STRIP_ALPHA_SUPPORTED # endif # ifndef PNG_NO_READ_USER_TRANSFORM @@ -606,26 +556,25 @@ # endif #endif /* PNG_READ_TRANSFORMS_SUPPORTED */ #if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ # define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ #endif /* about interlacing capability! You'll */ /* still have interlacing unless you change the following line: */ -#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ #ifndef PNG_NO_READ_COMPOSITE_NODIV # ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ # define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ # endif #endif -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED +#if !defined(PNG_NO_GET_INT_32) || defined(PNG_READ_oFFS_SUPPORTED) || \ + defined(PNG_READ_pCAL_SUPPORTED) +# ifndef PNG_GET_INT_32_SUPPORTED +# define PNG_GET_INT_32_SUPPORTED #endif #endif #endif /* PNG_READ_SUPPORTED */ @@ -686,22 +635,18 @@ #ifndef PNG_NO_WRITE_FLUSH # define PNG_WRITE_FLUSH_SUPPORTED #endif -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#if !defined(PNG_NO_SAVE_INT_32) || defined(PNG_WRITE_oFFS_SUPPORTED) || \ + defined(PNG_WRITE_pCAL_SUPPORTED) +# ifndef PNG_SAVE_INT_32_SUPPORTED +# define PNG_SAVE_INT_32_SUPPORTED #endif #endif #endif /* PNG_WRITE_SUPPORTED */ -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ +#define PNG_NO_ERROR_NUMBERS #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) # ifndef PNG_NO_USER_TRANSFORM_PTR @@ -732,66 +677,20 @@ #if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) # define PNG_EASY_ACCESS_SUPPORTED #endif -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * and removed from version 1.2.20. The following will be removed - * from libpng-1.4.0 -*/ - -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) -# ifndef PNG_OPTIMIZED_CODE_SUPPORTED -# define PNG_OPTIMIZED_CODE_SUPPORTED -# endif -#endif - -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif - -# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) - /* work around 64-bit gcc compiler bugs in gcc-3.x */ -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if defined(__APPLE__) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif - -#endif -/* end of obsolete code to be removed from libpng-1.4.0 */ - -#if !defined(PNG_1_0_X) #if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) # define PNG_USER_MEM_SUPPORTED #endif -#endif /* PNG_1_0_X */ /* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) #ifndef PNG_SET_USER_LIMITS_SUPPORTED #if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) # define PNG_SET_USER_LIMITS_SUPPORTED #endif #endif -#endif /* PNG_1_0_X */ -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter +/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGs no matter * how large, set these limits to 0x7fffffffL */ #ifndef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L @@ -799,10 +698,27 @@ #ifndef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L #endif +/* Added at libpng-1.4.0 */ +#ifndef PNG_USER_CHUNK_CACHE_MAX +# define PNG_USER_CHUNK_CACHE_MAX 0x7ffffffLL +#endif + +/* Added at libpng-1.4.0 */ +#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED) +# define PNG_IO_STATE_SUPPORTED +#endif -/* Added at libpng-1.2.34 and 1.4.0 */ +#ifndef PNG_LITERAL_SHARP +# define PNG_LITERAL_SHARP 0x23 +#endif +#ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET +# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b +#endif +#ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET +# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d +#endif #ifndef PNG_STRING_NEWLINE #define PNG_STRING_NEWLINE "\n" #endif @@ -824,18 +740,17 @@ # define PNG_READ_BIG_ENDIAN_SUPPORTED #endif */ +#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +# define PNG_USE_READ_MACROS +#endif + /* Buggy compilers (e.g., gcc 2.7.2.2) need this */ /* #define PNG_NO_POINTER_INDEXING */ -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ /* Any chunks you are not interested in, you can undef here. The * ones that allocate memory may be expecially important (hIST, * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info @@ -1116,30 +1031,31 @@ * common platforms. The typedefs should be at least as large as the * numbers suggest (a png_uint_32 must be at least 32 bits long), but they * don't have to be exactly that size. Some compilers dislike passing * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. + * unsigned int for png_uint_16. */ +#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL) +typedef unsigned int png_uint_32; +typedef int png_int_32; +#else typedef unsigned long png_uint_32; typedef long png_int_32; +#endif typedef unsigned short png_uint_16; typedef short png_int_16; typedef unsigned char png_byte; -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof(x)) +#ifdef PNG_NO_SIZE_T + typedef unsigned int png_size_t; #else typedef size_t png_size_t; -# define png_sizeof(x) sizeof(x) #endif +#define png_sizeof(x) sizeof(x) /* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides + * pngpriv.h header. Needs modification for other compilers besides * MSC. Model independent support declares all arrays and pointers to be * large using the far keyword. The zlib version used must also support * model independent data. As of version zlib 1.0.4, the necessary changes * have been made in zlib. The USE_FAR_KEYWORD define triggers other @@ -1238,20 +1154,8 @@ /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char FAR * FAR * FAR * png_charppp; -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - /* * Define PNG_BUILD_DLL if the module being built is a Windows * LIBPNG DLL. * @@ -1300,10 +1204,9 @@ * They are no longer used in libpng itself, since version 1.0.5c, * but might be required for some pre-1.0.5c applications. */ #if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || \ - (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) # define PNG_USE_LOCAL_ARRAYS # else # define PNG_USE_GLOBAL_ARRAYS # endif @@ -1417,37 +1320,62 @@ # define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type # endif #endif -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. +/* Users may want to use these so they are not private. Any library + * functions that are passed far data must be model-independent. */ -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - #ifdef PNG_SETJMP_SUPPORTED # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) #endif -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* memory model/platform independent fns */ +#ifndef PNG_ABORT +# ifdef _WINDOWS_ +# define PNG_ABORT() ExitProcess(0) +# else +# define PNG_ABORT() abort() +# endif +#endif + +#if defined(USE_FAR_KEYWORD) /* use this to make far-to-near assignments */ # define CHECK 1 # 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_snprintf _fsnprintf /* Added to v 1.2.19 */ +# define png_strcpy _fstrcpy +# define png_strncpy _fstrncpy /* Added to v 1.2.6 */ # define png_strlen _fstrlen # define png_memcmp _fmemcmp /* SJT: added */ # define png_memcpy _fmemcpy # define png_memset _fmemset -#else /* use the usual functions */ +# define png_sprintf sprintf +#else +# if defined(_WINDOWS_) /* favor Windows over C runtime fns */ # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy lstrcpyA +# define png_strncpy lstrcpynA +# define png_strlen lstrlenA +# define png_memcmp memcmp +# define png_memcpy CopyMemory +# define png_memset memset +# define png_sprintf wsprintfA +# else +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strncpy strncpy /* Added to v 1.2.6 */ +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +# define png_sprintf sprintf # ifndef PNG_NO_SNPRINTF # ifdef _MSC_VER # define png_snprintf _snprintf /* Added to v 1.2.19 */ # define png_snprintf2 _snprintf @@ -1467,14 +1395,42 @@ # define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) # define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) # endif -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset #endif -/* End of memory model independent support */ +#endif + +/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, + * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32 + * to png_alloc_size_t are not necessary; in fact, it is recommended + * not to use them at all so that the compiler can complain when something + * turns out to be problematic. + * Casts in the other direction (from png_alloc_size_t to png_size_t or + * png_uint_32) should be explicitly applied; however, we do not expect + * to encounter practical situations that require such conversions. + */ +#if defined(__TURBOC__) && !defined(__FLAT__) +# define png_mem_alloc farmalloc +# define png_mem_free farfree + typedef unsigned long png_alloc_size_t; +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) +# define png_mem_alloc(s) halloc(s, 1) +# define png_mem_free hfree + typedef unsigned long png_alloc_size_t; +# else +# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) +# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s) +# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p) + typedef DWORD png_alloc_size_t; +# else +# define png_mem_alloc malloc +# define png_mem_free free + typedef png_size_t png_alloc_size_t; +# endif +# endif +#endif +/* End of memory model/platform independent support */ /* Just a little check that someone hasn't tried to define something * contradictory. */ diff -ru4NwbB libpng-1.2.35/pngerror.c libpng-1.4.0beta60/pngerror.c --- libpng-1.2.35/pngerror.c 2009-02-14 15:59:26.564665362 -0600 +++ libpng-1.4.0beta60/pngerror.c 2009-05-18 16:58:20.582829473 -0500 @@ -1,10 +1,10 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) * * This file provides a location for all error handling. Users who @@ -12,11 +12,11 @@ * and use png_set_error_fn() to use those functions. See the instructions * at each function. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" static void /* PRIVATE */ png_default_error PNGARG((png_structp png_ptr, png_const_charp error_message)); @@ -41,9 +41,9 @@ { if (png_ptr->flags& (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) { - if (*error_message == '#') + if (*error_message == PNG_LITERAL_SHARP) { /* Strip "#nnnn " from beginning of error message. */ int offset; for (offset = 1; offset<15; offset++) @@ -108,9 +108,9 @@ if (png_ptr->flags& (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) #endif { - if (*warning_message == '#') + if (*warning_message == PNG_LITERAL_SHARP) { for (offset = 1; offset < 15; offset++) if (warning_message[offset] == ' ') break; @@ -123,8 +123,18 @@ png_default_warning(png_ptr, warning_message + offset); } #endif /* PNG_NO_WARNINGS */ +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_benign_error(png_structp png_ptr, png_const_charp error_message) +{ + if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); +} +#endif /* These utilities are used internally to build an error message that relates * to the current chunk. The chunk name comes from png_ptr->chunk_name, * this is used to prefix the message. The message is limited in length @@ -150,12 +160,12 @@ { int c = png_ptr->chunk_name[iin++]; if (isnonalpha(c)) { - buffer[iout++] = '['; + buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; buffer[iout++] = png_digit[(c & 0xf0) >> 4]; buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = ']'; + buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; } else { buffer[iout++] = (png_byte)c; @@ -203,8 +213,20 @@ } } #endif /* PNG_NO_WARNINGS */ +#ifdef PNG_READ_SUPPORTED +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +void PNGAPI +png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message) +{ + if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) + png_chunk_warning(png_ptr, error_message); + else + png_chunk_error(png_ptr, error_message); +} +#endif +#endif /* PNG_READ_SUPPORTED */ /* This is the default error handling function. Note that replacements for * this function MUST NOT RETURN, or the program will likely crash. This * function is used by default, or if the program supplies NULL for the @@ -214,11 +236,11 @@ 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 == '#') + if (*error_message == PNG_LITERAL_SHARP) { - /* Strip "#nnnn " from beginning of warning message. */ + /* Strip "#nnnn " from beginning of error message. */ int offset; char error_number[16]; for (offset = 0; offset<15; offset++) { @@ -228,17 +250,25 @@ } if ((offset > 1) && (offset < 15)) { error_number[offset - 1] = '\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message + offset + 1); + fprintf(stderr, "libpng error no. %s: %s", + error_number, error_message + offset + 1); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset); + { + fprintf(stderr, "libpng error: %s, offset=%d", + error_message, offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else #endif - fprintf(stderr, "libpng error: %s\n", error_message); + { + fprintf(stderr, "libpng error: %s", error_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #endif #ifdef PNG_SETJMP_SUPPORTED if (png_ptr) @@ -271,9 +301,9 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message) { #ifndef PNG_NO_CONSOLE_IO # ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == '#') + if (*warning_message == PNG_LITERAL_SHARP) { int offset; char warning_number[16]; for (offset = 0; offset < 15; offset++) @@ -284,17 +314,25 @@ } if ((offset > 1) && (offset < 15)) { warning_number[offset + 1] = '\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message + offset); + fprintf(stderr, "libpng warning no. %s: %s", + warning_number, warning_message + offset); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", + warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else # endif - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #else warning_message = warning_message; /* make compiler happy */ #endif png_ptr = png_ptr; /* make compiler happy */ diff -ru4NwbB libpng-1.2.35/pnggccrd.c libpng-1.4.0beta60/pnggccrd.c --- libpng-1.2.35/pnggccrd.c 2009-02-14 15:59:26.569580693 -0600 +++ libpng-1.4.0beta60/pnggccrd.c 2009-05-18 16:58:20.584163360 -0500 @@ -1,103 +0,0 @@ -/* pnggccrd.c was removed from libpng-1.2.20. */ - -/* This code snippet is for use by configure's compilation test. */ - -#if (!defined _MSC_VER) && \ - defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ - defined(PNG_MMX_CODE_SUPPORTED) - -int PNGAPI png_dummy_mmx_support(void); - -static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested - -int PNGAPI -png_dummy_mmx_support(void) __attribute__((noinline)); - -int PNGAPI -png_dummy_mmx_support(void) -{ - int result; -#if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck - __asm__ __volatile__ ( -#if defined(__x86_64__) - "pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction - "pushq %%rcx \n\t" // so does rcx... - "pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux) - "pushfq \n\t" // save Eflag to stack - "popq %%rax \n\t" // get Eflag from stack into rax - "movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushq %%rax \n\t" // save modified Eflag back to stack - "popfq \n\t" // restore modified value to Eflag reg - "pushfq \n\t" // save Eflag to stack - "popq %%rax \n\t" // get Eflag from stack - "pushq %%rcx \n\t" // save original Eflag to stack - "popfq \n\t" // restore original Eflag -#else - "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction - "pushl %%ecx \n\t" // so does ecx... - "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack into eax - "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx - "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) - "pushl %%eax \n\t" // save modified Eflag back to stack - "popfl \n\t" // restore modified value to Eflag reg - "pushfl \n\t" // save Eflag to stack - "popl %%eax \n\t" // get Eflag from stack - "pushl %%ecx \n\t" // save original Eflag to stack - "popfl \n\t" // restore original Eflag -#endif - "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag - "jz 0f \n\t" // if same, CPUID instr. is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero -// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) - "cpuid \n\t" // get the CPU identification info - "cmpl $1, %%eax \n\t" // make sure eax return non-zero value - "jl 0f \n\t" // if eax is zero, MMX is not supported - - "xorl %%eax, %%eax \n\t" // set eax to zero and... - "incl %%eax \n\t" // ...increment eax to 1. This pair is - // faster than the instruction "mov eax, 1" - "cpuid \n\t" // get the CPU identification info again - "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) - "cmpl $0, %%edx \n\t" // 0 = MMX not supported - "jz 0f \n\t" // non-zero = yes, MMX IS supported - - "movl $1, %%eax \n\t" // set return value to 1 - "jmp 1f \n\t" // DONE: have MMX support - - "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions - "movl $0, %%eax \n\t" // set return value to 0 - "1: \n\t" // .RETURN: target label for jump instructions -#if defined(__x86_64__) - "popq %%rdx \n\t" // restore rdx - "popq %%rcx \n\t" // restore rcx - "popq %%rbx \n\t" // restore rbx -#else - "popl %%edx \n\t" // restore edx - "popl %%ecx \n\t" // restore ecx - "popl %%ebx \n\t" // restore ebx -#endif - -// "ret \n\t" // DONE: no MMX support - // (fall through to standard C "ret") - - : "=a" (result) // output list - - : // any variables used on input (none) - - // no clobber list -// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually -// , "memory" // if write to a variable gcc thought was in a reg -// , "cc" // "condition codes" (flag bits) - ); - _mmx_supported = result; -#else - _mmx_supported = 0; -#endif /* PNG_MMX_CODE_SUPPORTED */ - - return _mmx_supported; -} -#endif diff -ru4NwbB libpng-1.2.35/pngget.c libpng-1.4.0beta60/pngget.c --- libpng-1.2.35/pngget.c 2009-02-14 15:59:26.576381841 -0600 +++ libpng-1.4.0beta60/pngget.c 2009-05-18 16:58:20.594039293 -0500 @@ -1,17 +1,17 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) { @@ -20,9 +21,9 @@ else return(0); } -png_uint_32 PNGAPI +png_size_t PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->rowbytes); @@ -41,76 +44,69 @@ } #endif #ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ +/* Easy access to info, added in libpng-0.99 */ png_uint_32 PNGAPI png_get_image_width(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->width; - } + return (0); } png_uint_32 PNGAPI png_get_image_height(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->height; - } + return (0); } png_byte PNGAPI png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->bit_depth; - } + return (0); } png_byte PNGAPI png_get_color_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->color_type; - } + return (0); } png_byte PNGAPI png_get_filter_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->filter_type; - } + return (0); } png_byte PNGAPI png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->interlace_type; - } + return (0); } png_byte PNGAPI png_get_compression_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->compression_type; - } + return (0); } png_uint_32 PNGAPI @@ -549,23 +564,30 @@ *height = info_ptr->height; *bit_depth = info_ptr->bit_depth; if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) png_error(png_ptr, "Invalid bit depth"); + *color_type = info_ptr->color_type; + if (info_ptr->color_type > 6) png_error(png_ptr, "Invalid color type"); + if (compression_type != NULL) *compression_type = info_ptr->compression_type; + if (filter_type != NULL) *filter_type = info_ptr->filter_type; + if (interlace_type != NULL) *interlace_type = info_ptr->interlace_type; - /* check for potential overflow of rowbytes */ + /* Check for potential overflow of rowbytes */ if (*width == 0 || *width > PNG_UINT_31_MAX) png_error(png_ptr, "Invalid image width"); + if (*height == 0 || *height > PNG_UINT_31_MAX) png_error(png_ptr, "Invalid image height"); + if (info_ptr->width > (PNG_UINT_32_MAX >> 3) /* 8-byte RGBA pixels */ - 64 /* bigrowbuf hack */ - 1 /* filter byte */ @@ -572,10 +594,11 @@ - 7*8 /* rounding of width to multiple of 8 pixels */ - 8) /* extra max_pixel_depth pad */ { png_warning(png_ptr, - "Width too large for libpng to process image data."); + "Width too large for libpng to process image data"); } + return (1); } return (0); } @@ -759,9 +788,9 @@ #if defined(PNG_tRNS_SUPPORTED) png_uint_32 PNGAPI png_get_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep *trans, int *num_trans, png_color_16p *trans_values) + png_bytep *trans, int *num_trans, png_color_16p *trans_color) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { @@ -772,18 +801,20 @@ { *trans = info_ptr->trans; retval |= PNG_INFO_tRNS; } - if (trans_values != NULL) - *trans_values = &(info_ptr->trans_values); + + if (trans_color != NULL) + *trans_color = &(info_ptr->trans_color); } else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ { - if (trans_values != NULL) + if (trans_color != NULL) { - *trans_values = &(info_ptr->trans_values); + *trans_color = &(info_ptr->trans_color); retval |= PNG_INFO_tRNS; } + if (trans != NULL) *trans = NULL; } if (num_trans != NULL) @@ -826,75 +857,48 @@ } #endif #ifdef PNG_WRITE_SUPPORTED -png_uint_32 PNGAPI +png_size_t PNGAPI png_get_compression_buffer_size(png_structp png_ptr) { - return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); + return (png_ptr ? png_ptr->zbuf_size : 0L); } #endif -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -#ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ -png_uint_32 PNGAPI -png_get_asm_flags (png_structp png_ptr) -{ - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0L: 0L); -} -/* this function was added to libpng 1.2.0 and should exist by default */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +/* These functions were added to libpng 1.2.6 */ png_uint_32 PNGAPI -png_get_asm_flagmask (int flag_select) +png_get_user_width_max (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - flag_select=flag_select; - return 0L; + return (png_ptr? png_ptr->user_width_max : 0); } - - /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ png_uint_32 PNGAPI -png_get_mmx_flagmask (int flag_select, int *compilerID) -{ - /* obsolete, to be removed from libpng-1.4.0 */ - flag_select=flag_select; - *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ - return 0L; -} - -/* this function was added to libpng 1.2.0 */ -png_byte PNGAPI -png_get_mmx_bitdepth_threshold (png_structp png_ptr) +png_get_user_height_max (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0: 0); + return (png_ptr? png_ptr->user_height_max : 0); } - -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.4.0 */ png_uint_32 PNGAPI -png_get_mmx_rowbytes_threshold (png_structp png_ptr) +png_get_chunk_cache_max (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ - return (png_ptr? 0L: 0L); + return (png_ptr? png_ptr->user_chunk_cache_max? 0x7fffffffL : + png_ptr->user_chunk_cache_max - 1 : 0); } -#endif /* ?PNG_1_0_X */ -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ +#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* These functions were added to libpng 1.2.6 */ +#ifdef PNG_IO_STATE_SUPPORTED png_uint_32 PNGAPI -png_get_user_width_max (png_structp png_ptr) +png_get_io_state (png_structp png_ptr) { - return (png_ptr? png_ptr->user_width_max : 0); + return png_ptr->io_state; } -png_uint_32 PNGAPI -png_get_user_height_max (png_structp png_ptr) + +png_bytep PNGAPI +png_get_io_chunk_name (png_structp png_ptr) { - return (png_ptr? png_ptr->user_height_max : 0); + return png_ptr->chunk_name; } -#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - +#endif /* ?PNG_IO_STATE_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff -ru4NwbB libpng-1.2.35/pngmem.c libpng-1.4.0beta60/pngmem.c --- libpng-1.2.35/pngmem.c 2009-02-14 15:59:26.582630808 -0600 +++ libpng-1.4.0beta60/pngmem.c 2009-05-18 16:58:20.600187124 -0500 @@ -1,10 +1,10 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) * * This file provides a location for all memory allocation. Users who @@ -13,11 +13,11 @@ * png_create_read_struct_2() and png_create_write_struct_2() to * identify the replacement functions. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) /* if you change this, be sure to change the one in png.h also */ @@ -27,9 +27,9 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); + return (png_create_struct_2(type, NULL, NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ png_voidp /* PRIVATE */ @@ -66,9 +66,9 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); + png_destroy_struct_2(struct_ptr, NULL, NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ @@ -110,11 +110,23 @@ * since on some systems a png_size_t is a 16-bit quantity, and as a * result, we would be truncating potentially larger memory requests * (which should cause a fatal error) and introducing major problems. */ +#ifdef PNG_CALLOC_SUPPORTED +png_voidp PNGAPI +png_calloc(png_structp png_ptr, png_alloc_size_t size) +{ + png_voidp ret; + + ret = (png_malloc(png_ptr, size)); + if (ret != NULL) + png_memset(ret,0,(png_size_t)size); + return (ret); +} +#endif png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) +png_malloc(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; if (png_ptr == NULL || size == 0) @@ -125,14 +137,14 @@ ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory!"); + png_error(png_ptr, "Out of memory"); return (ret); } png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) +png_malloc_default(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -186,11 +198,11 @@ if (table == NULL) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ + png_error(png_ptr, "Out Of Memory"); /* Note "O" and "M" */ else - png_warning(png_ptr, "Out Of Memory."); + png_warning(png_ptr, "Out Of Memory"); #endif return (NULL); } @@ -214,11 +226,11 @@ if (png_ptr->offset_table_ptr == NULL) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ + png_error(png_ptr, "Out Of memory"); /* Note "O" and "M" */ else - png_warning(png_ptr, "Out Of memory."); + png_warning(png_ptr, "Out Of memory"); #endif return (NULL); } @@ -243,11 +255,11 @@ if (png_ptr->offset_table_count >= png_ptr->offset_table_number) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ + png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */ else - png_warning(png_ptr, "Out of Memory."); + png_warning(png_ptr, "Out of Memory"); #endif return (NULL); } @@ -259,21 +271,21 @@ #ifndef PNG_USER_MEM_SUPPORTED if (ret == NULL) { if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ + png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */ else - png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ + png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */ } #endif return (ret); } /* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ - + * configuration, png_ptr is not used, but is passed in case it + * is needed. If ptr is NULL, return without taking any action. + */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) @@ -284,17 +296,19 @@ { (*(png_ptr->free_fn))(png_ptr, ptr); return; } - else png_free_default(png_ptr, ptr); + else + png_free_default(png_ptr, ptr); } void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ - if (png_ptr == NULL || ptr == NULL) return; + if (png_ptr == NULL || ptr == NULL) + return; if (png_ptr->offset_table != NULL) { int i; @@ -331,9 +345,9 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); + return (png_create_struct_2(type, NULL, NULL)); } /* Allocate memory for a png_struct or a png_info. The malloc and memset can be replaced by a single call to calloc() if this is thought @@ -385,9 +399,9 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); + png_destroy_struct_2(struct_ptr, NULL, NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ @@ -419,15 +433,27 @@ } } /* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + */ png_voidp PNGAPI -png_malloc(png_structp png_ptr, png_uint_32 size) +png_calloc(png_structp png_ptr, png_alloc_size_t size) +{ + png_voidp ret; + + ret = (png_malloc(png_ptr, size)); + if (ret != NULL) + png_memset(ret,0,(png_size_t)size); + return (ret); +} + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; #ifdef PNG_USER_MEM_SUPPORTED @@ -438,14 +464,14 @@ ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) - png_error(png_ptr, "Out of Memory!"); + png_error(png_ptr, "Out of Memory"); return (ret); } png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_uint_32 size) +png_malloc_default(png_structp png_ptr, png_alloc_size_t size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -492,9 +518,10 @@ return (ret); } /* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ + * without taking any action. + */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) @@ -505,9 +532,10 @@ { (*(png_ptr->free_fn))(png_ptr, ptr); return; } - else png_free_default(png_ptr, ptr); + else + png_free_default(png_ptr, ptr); } void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr) { @@ -528,57 +556,28 @@ } #endif /* Not Borland DOS special memory handler */ -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else /* This function was added at libpng version 1.2.3. The png_malloc_warn() * function will set up png_malloc() to issue a png_warning and return NULL * instead of issuing a png_error, if it fails to allocate the requested * memory. */ png_voidp PNGAPI -png_malloc_warn(png_structp png_ptr, png_uint_32 size) +png_malloc_warn(png_structp png_ptr, png_alloc_size_t size) { png_voidp ptr; png_uint_32 save_flags; - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); save_flags = png_ptr->flags; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); png_ptr->flags=save_flags; return(ptr); } -#endif - -png_voidp PNGAPI -png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, - png_uint_32 length) -{ - png_size_t size; - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr, "Overflow in png_memcpy_check."); - - return(png_memcpy (s1, s2, size)); -} - -png_voidp PNGAPI -png_memset_check (png_structp png_ptr, png_voidp s1, int value, - png_uint_32 length) -{ - png_size_t size; - - size = (png_size_t)length; - if ((png_uint_32)size != length) - png_error(png_ptr, "Overflow in png_memset_check."); - - return (png_memset (s1, value, size)); - -} #ifdef PNG_USER_MEM_SUPPORTED /* This function is called when the application wants to use another method * of allocating and freeing memory. @@ -601,9 +600,10 @@ */ png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr) { - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff -ru4NwbB libpng-1.2.35/pngpread.c libpng-1.4.0beta60/pngpread.c --- libpng-1.2.35/pngpread.c 2009-02-14 15:59:26.590680586 -0600 +++ libpng-1.4.0beta60/pngpread.c 2009-05-18 16:58:20.608564255 -0500 @@ -1,17 +1,17 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.32 [September 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #include "png.h" #ifdef PNG_PROGRESSIVE_READ_SUPPORTED +#include "pngpriv.h" /* push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 @@ -26,9 +26,11 @@ void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size) { - if (png_ptr == NULL || info_ptr == NULL) return; + if (png_ptr == NULL || info_ptr == NULL) + return; + png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) { @@ -41,9 +43,11 @@ */ void /* PRIVATE */ png_process_some_data(png_structp png_ptr, png_infop info_ptr) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; + switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: { @@ -293,9 +318,9 @@ if (png_ptr->push_length == 0) return; if (png_ptr->mode & PNG_AFTER_IDAT) - png_error(png_ptr, "Too many IDAT's found"); + png_benign_error(png_ptr, "Too many IDATs found"); } png_ptr->idat_size = png_ptr->push_length; png_ptr->mode |= PNG_HAVE_IDAT; @@ -564,9 +624,11 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; + ptr = buffer; if (png_ptr->save_buffer_size) { png_size_t save_size; @@ -628,12 +691,13 @@ (png_ptr->current_buffer_size + 256)) { png_error(png_ptr, "Potential overflow of save_buffer"); } + new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, - (png_uint_32)new_max); + (png_size_t)new_max); png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } @@ -755,9 +823,9 @@ { int ret; if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) - png_error(png_ptr, "Extra compression data"); + png_benign_error(png_ptr, "Extra compression data"); png_ptr->zstream.next_in = buffer; png_ptr->zstream.avail_in = (uInt)buffer_length; for (;;) @@ -767,9 +835,10 @@ { if (ret == Z_STREAM_END) { if (png_ptr->zstream.avail_in) - png_error(png_ptr, "Extra compressed data"); + png_benign_error(png_ptr, "Extra compressed data"); + if (!(png_ptr->zstream.avail_out)) { png_push_process_row(png_ptr); } @@ -821,10 +892,9 @@ png_read_filter_row(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->prev_row + 1, (int)(png_ptr->row_buf[0])); - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); + png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1); if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); @@ -852,12 +923,13 @@ if (png_ptr->pass == 2) /* pass 1 might be empty */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { @@ -860,19 +932,22 @@ if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 6 && png_ptr->height <= 4) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } + case 1: { int i; for (i = 0; i < 8 && png_ptr->pass == 1; i++) @@ -883,17 +959,20 @@ if (png_ptr->pass == 2) /* skip top 4 generated rows */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 2: { int i; + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); @@ -897,13 +976,15 @@ { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + if (png_ptr->pass == 4) /* pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { @@ -906,17 +987,20 @@ if (png_ptr->pass == 4) /* pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 3: { int i; + for (i = 0; i < 4 && png_ptr->pass == 3; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); @@ -924,17 +1009,20 @@ if (png_ptr->pass == 4) /* skip top two generated rows */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } + break; } + case 4: { int i; + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); @@ -938,23 +1026,28 @@ { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + if (png_ptr->pass == 6) /* pass 5 might be empty */ { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } + case 5: { int i; + for (i = 0; i < 2 && png_ptr->pass == 5; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); @@ -958,13 +1051,15 @@ { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + if (png_ptr->pass == 6) /* skip top generated row */ { - png_push_have_row(png_ptr, png_bytep_NULL); + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } + break; } case 6: { @@ -969,11 +1064,13 @@ case 6: { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); + if (png_ptr->pass != 6) break; - png_push_have_row(png_ptr, png_bytep_NULL); + + png_push_have_row(png_ptr, NULL); png_read_push_finish_row(png_ptr); } } } @@ -988,20 +1085,20 @@ void /* PRIVATE */ png_read_push_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h @@ -1012,12 +1109,13 @@ png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; +#if defined(PNG_READ_INTERLACING_SUPPORTED) if (png_ptr->interlaced) { png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, + png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { png_ptr->pass++; @@ -1048,8 +1147,9 @@ png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } +#endif /* PNG_READ_INTERLACING_SUPPORTED */ } #if defined(PNG_READ_tEXt_SUPPORTED) void /* PRIVATE */ @@ -1073,9 +1173,9 @@ } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length + 1)); + (png_size_t)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; @@ -1125,9 +1227,9 @@ if (text < key + png_ptr->current_text_size) text++; text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; @@ -1141,9 +1243,9 @@ png_free(png_ptr, text_ptr); png_ptr->current_text = NULL; if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); + png_warning(png_ptr, "Insufficient memory to store text chunk"); } } #endif @@ -1171,9 +1273,9 @@ } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length + 1)); + (png_size_t)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; @@ -1262,15 +1366,19 @@ { if (text == NULL) { text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size + (png_ptr->zbuf_size - png_ptr->zstream.avail_out + key_size + 1)); + png_memcpy(text + key_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_memcpy(text, key, key_size); + text_size = key_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; } else { @@ -1277,14 +1385,17 @@ png_charp tmp; tmp = text; text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size + (png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); + png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; *(text + text_size) = '\0'; } if (ret != Z_STREAM_END) @@ -1318,9 +1429,9 @@ key = text; text += key_size; text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; @@ -1333,9 +1444,9 @@ png_free(png_ptr, key); png_free(png_ptr, text_ptr); if (ret) - png_warning(png_ptr, "Insufficient memory to store text chunk."); + png_warning(png_ptr, "Insufficient memory to store text chunk"); } } #endif @@ -1361,9 +1472,9 @@ } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length + 1)); + (png_size_t)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; @@ -1434,9 +1549,10 @@ if (text < key + png_ptr->current_text_size) text++; text_ptr = (png_textp)png_malloc(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); + text_ptr->compression = comp_flag + 2; text_ptr->key = key; text_ptr->lang = lang; text_ptr->lang_key = lang_key; @@ -1449,9 +1565,9 @@ png_ptr->current_text = NULL; png_free(png_ptr, text_ptr); if (ret) - png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); + png_warning(png_ptr, "Insufficient memory to store iTXt chunk"); } } #endif @@ -1497,16 +1613,19 @@ png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1] = '\0'; png_ptr->unknown_chunk.size = (png_size_t)length; + if (length == 0) png_ptr->unknown_chunk.data = NULL; + else { png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, - (png_uint_32)length); + (png_size_t)length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } + #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) if (png_ptr->read_user_chunk_fn != NULL) { /* callback to user unknown chunk handler */ @@ -1566,9 +1689,11 @@ #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST int FARDATA png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; #endif - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; + if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); } @@ -1576,9 +1701,11 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->info_fn = info_fn; png_ptr->row_fn = row_fn; png_ptr->end_fn = end_fn; @@ -1587,8 +1714,10 @@ png_voidp PNGAPI png_get_progressive_ptr(png_structp png_ptr) { - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); + return png_ptr->io_ptr; } #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff -ru4NwbB libpng-1.2.35/pngpriv.h libpng-1.4.0beta60/pngpriv.h --- libpng-1.2.35/pngpriv.h 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/pngpriv.h 2009-05-18 16:58:20.563110619 -0500 @@ -0,0 +1,857 @@ + +/* pngpriv.h - private declarations for use inside libpng + * + * libpng version 1.4.0beta60 - May 18, 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) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* The symbols declared in this file (including the functions declared + * as PNG_EXTERN) are PRIVATE. They are not part of the libpng public + * interface, and are not recommended for use by regular applications. + * Some of them may become public in the future; others may stay private, + * change in an incompatible way, or even disappear. + * Although the libpng users are not forbidden to include this header, + * they should be well aware of the issues that may arise from doing so. + */ + +#ifndef PNGPRIV_H +#define PNGPRIV_H + +#ifndef PNG_VERSION_INFO_ONLY + +#include + +/* The functions exported by PNG_EXTERN are internal functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it + * is possible to have run-time registry of chunk-handling functions, + * some of these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ + defined(_WIN32) || defined(__WIN32__) +# include /* defines _WINDOWS_ macro */ +/* I have no idea why is this necessary... */ +# if defined(_MSC_VER) +# include +# endif +#endif + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + /* 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 */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L +#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ +#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ +#define PNG_FLAG_BENIGN_ERRORS_WARN 0x800000L /* Added to libpng-1.4.0 */ + /* 0x1000000L unused */ + /* 0x2000000L unused */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ + (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + ideal-delta..ideal+delta. Each argument is evaluated twice. + "ideal" and "delta" should be constants, normally simple + integers, "value" a variable. Added to libpng-1.2.6 JB */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#if 0 +#define png_sig png_sig_bytes(NULL) +#endif +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_sTER const png_byte png_sTER[5] = {115, 84, 69, 82, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* These functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* Function to allocate memory for zlib. PNGAPI is disallowed. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib. PNGAPI is disallowed. */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, png_size_t prefix_length, + png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_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 + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_color, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_color, png_color_16p background)); +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +/* Added at libpng version 1.4.0 */ +#if defined(PNG_cHRM_SUPPORTED) +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +#endif /* PNGPRIV_H */ diff -ru4NwbB libpng-1.2.35/pngread.c libpng-1.4.0beta60/pngread.c --- libpng-1.2.35/pngread.c 2009-02-27 17:49:09.184770384 -0600 +++ libpng-1.4.0beta60/pngread.c 2009-05-18 16:58:20.616962578 -0500 @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.35 [February 14, 2009] + * Last changed in libpng 1.4.0 [May 18, 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) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -10,11 +10,12 @@ * This file contains routines that an application calls directly to * read a PNG file or stream. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) +#include "pngpriv.h" + /* Create a PNG structure for reading, and allocate any memory needed. */ png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, @@ -22,9 +23,9 @@ { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); + warn_fn, NULL, NULL, NULL)); } /* Alternate create PNG structure for reading, and allocate any memory needed. */ png_structp PNGAPI @@ -37,8 +38,9 @@ #ifdef PNG_SETJMP_SUPPORTED volatile #endif png_structp png_ptr; + int png_cleanup_needed = 0; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD jmp_buf jmpbuf; @@ -49,9 +51,9 @@ png_debug(1, "in png_create_read_struct"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); + malloc_fn, mem_ptr); #else png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); #endif if (png_ptr == NULL) @@ -63,27 +65,17 @@ png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif #ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then + encounter a png_error() will longjmp here. Since the jmpbuf is + then meaningless we abort instead of returning. */ #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else if (setjmp(png_ptr->jmpbuf)) #endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf = NULL; -#ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, - (png_free_ptr)free_fn, (png_voidp)mem_ptr); -#else - png_destroy_struct((png_voidp)png_ptr); -#endif - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); -#endif + PNG_ABORT(); #endif #ifdef PNG_USER_MEM_SUPPORTED png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); @@ -131,189 +123,66 @@ #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags = 0; #endif - png_error(png_ptr, + png_warning(png_ptr, "Incompatible libpng version in application and library"); + + png_cleanup_needed = 1; } } + if (!png_cleanup_needed) + { /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); + png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr, + png_ptr->zbuf_size); + if (png_ptr->zbuf == NULL) + png_cleanup_needed = 1; + } png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; png_ptr->zstream.opaque = (voidpf)png_ptr; + if (!png_cleanup_needed) + { switch (inflateInit(&png_ptr->zstream)) { case Z_OK: /* Do nothing */ break; case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; - default: png_error(png_ptr, "Unknown zlib error"); + case Z_STREAM_ERROR: png_warning(png_ptr, "zlib memory error"); + png_cleanup_needed = 1; break; + case Z_VERSION_ERROR: png_warning(png_ptr, "zlib version error"); + png_cleanup_needed = 1; break; + default: png_warning(png_ptr, "Unknown zlib error"); + png_cleanup_needed = 1; } - - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); } -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Initialize PNG structure for reading, and allocate any memory needed. - This interface is deprecated in favour of the png_create_read_struct(), - and it will disappear as of libpng-1.3.0. */ -#undef png_read_init -void PNGAPI -png_read_init(png_structp png_ptr) -{ - /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if (png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if (png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn = NULL; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if (png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn = NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags = 0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if (png_sizeof(png_info) > png_info_size) - { - png_ptr->error_fn = NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags = 0; -#endif - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - png_structp png_ptr=*ptr_ptr; - - if (png_ptr == NULL) return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) + if (png_cleanup_needed) { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + /* Clean up PNG structure and deallocate any memory. */ + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else - png_ptr->warning_fn = NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_read_init_3"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); + png_destroy_struct((png_voidp)png_ptr); #endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; + return (NULL); } - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof(png_struct)); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); -#endif + png_set_read_fn(png_ptr, NULL, NULL); - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - png_ptr->zstream.zalloc = png_zalloc; - png_ptr->zstream.zfree = png_zfree; - png_ptr->zstream.opaque = (voidpf)png_ptr; - - switch (inflateInit(&png_ptr->zstream)) - { - case Z_OK: /* Do nothing */ break; - case Z_MEM_ERROR: - case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; - case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; - default: png_error(png_ptr, "Unknown zlib error"); + return (png_ptr); } - png_ptr->zstream.next_out = png_ptr->zbuf; - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; - - png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); -} #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. This has been * changed in v0.90 to allow reading a file that already has the magic @@ -325,16 +194,21 @@ */ void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr) { - if (png_ptr == NULL || info_ptr == NULL) return; + if (png_ptr == NULL || info_ptr == NULL) + return; png_debug(1, "in png_read_info"); /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { png_size_t num_checked = png_ptr->sig_bytes, num_to_check = 8 - num_checked; +#ifdef PNG_IO_STATE_SUPPORTED + png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE; +#endif + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); png_ptr->sig_bytes = 8; if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) @@ -533,9 +407,10 @@ void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_read_update_info"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); else png_warning(png_ptr, @@ -552,9 +427,10 @@ void PNGAPI png_start_read_image(png_structp png_ptr) { png_debug(1, "in png_start_read_image"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ @@ -569,43 +445,44 @@ 0xff}; PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; #endif int ret; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_debug2(1, "in png_read_row (row %lu, pass %d)", - png_ptr->row_number, png_ptr->pass); + (unsigned long) png_ptr->row_number, png_ptr->pass); if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) { /* check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); #endif } #if defined(PNG_READ_INTERLACING_SUPPORTED) @@ -714,9 +591,9 @@ if (ret == Z_STREAM_END) { if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || png_ptr->idat_size) - png_error(png_ptr, "Extra compressed data"); + png_benign_error(png_ptr, "Extra compressed data"); png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } @@ -738,10 +615,9 @@ png_read_filter_row(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->prev_row + 1, (int)(png_ptr->row_buf[0])); - png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, - png_ptr->rowbytes + 1); + png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1); #if defined(PNG_MNG_FEATURES_SUPPORTED) if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) @@ -761,10 +637,10 @@ (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) /* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + * png_do_read_interlace(&(png_ptr->row_info), + * png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); */ png_do_read_interlace(png_ptr); if (dsp_row != NULL) @@ -822,9 +698,10 @@ png_bytepp rp; png_bytepp dp; png_debug(1, "in png_read_rows"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; rp = row; dp = display_row; if (rp != NULL && dp != NULL) for (i = 0; i < num_rows; i++) @@ -837,16 +714,16 @@ else if (rp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, png_bytep_NULL); + png_read_row(png_ptr, rptr, NULL); rp++; } else if (dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; - png_read_row(png_ptr, png_bytep_NULL, dptr); + png_read_row(png_ptr, NULL, dptr); dp++; } } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ @@ -871,16 +748,17 @@ int pass, j; png_bytepp rp; png_debug(1, "in png_read_image"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; #ifdef PNG_READ_INTERLACING_SUPPORTED pass = png_set_interlace_handling(png_ptr); #else if (png_ptr->interlaced) png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled."); + "Cannot read interlaced image -- interlace handler disabled"); pass = 1; #endif @@ -891,9 +769,9 @@ { rp = image; for (i = 0; i < image_height; i++) { - png_read_row(png_ptr, *rp, png_bytep_NULL); + png_read_row(png_ptr, *rp, NULL); rp++; } } } @@ -907,9 +785,10 @@ void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_read_end"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do { @@ -982,9 +861,9 @@ { if (!png_memcmp(chunk_name, png_IDAT, 4)) { if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); + png_benign_error(png_ptr, "Too many IDATs found"); } png_handle_unknown(png_ptr, info_ptr, length); if (!png_memcmp(chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; @@ -995,9 +874,9 @@ /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. */ if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - png_error(png_ptr, "Too many IDAT's found"); + png_benign_error(png_ptr, "Too many IDATs found"); png_crc_finish(png_ptr, length); } else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); @@ -1295,9 +1174,10 @@ void PNGAPI png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->read_row_fn = read_row_fn; } @@ -1309,9 +1189,10 @@ voidp params) { int row; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) /* invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) @@ -1327,9 +1208,9 @@ /* -------------- image transformations start here ------------------- */ #if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color + /* Tell libpng to strip 16 bit/color files down to 8 bits per color. */ if (transforms & PNG_TRANSFORM_STRIP_16) png_set_strip_16(png_ptr); #endif @@ -1431,24 +1312,29 @@ png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); #endif if (info_ptr->row_pointers == NULL) { +#ifdef PNG_CALLOC_SUPPORTED + info_ptr->row_pointers = (png_bytepp)png_calloc(png_ptr, + info_ptr->height * png_sizeof(png_bytep)); +#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)); +#endif #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif - png_memset(info_ptr->row_pointers, 0, info_ptr->height - * png_sizeof(png_bytep)); 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); info_ptr->valid |= PNG_INFO_IDAT; - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); transforms = transforms; /* quiet compiler warnings */ params = params; diff -ru4NwbB libpng-1.2.35/pngrio.c libpng-1.4.0beta60/pngrio.c --- libpng-1.2.35/pngrio.c 2009-02-27 17:51:17.104471248 -0600 +++ libpng-1.4.0beta60/pngrio.c 2009-05-18 16:58:20.622221505 -0500 @@ -1,10 +1,10 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.36 [May 18, 2009] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) * * This file provides a location for all input. Users who need @@ -14,17 +14,18 @@ * function, but rather write a replacement function and then make * libpng use it at run time with png_set_read_fn(...). */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) +#include "pngpriv.h" /* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more then 64K on a 16 bit machine. + */ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_debug1(4, "reading %d bytes", (int)length); @@ -35,34 +36,30 @@ } #if !defined(PNG_NO_STDIO) /* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else - check = (png_size_t)fread(data, (png_size_t)1, length, - (png_FILE_p)png_ptr->io_ptr); -#endif + check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); if (check != length) png_error(png_ptr, "Read Error"); } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -71,24 +68,20 @@ static void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - int check; + png_size_t check; png_byte *n_data; png_FILE_p io_ptr; - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; /* Check if data really is near. If so, use usual code. */ n_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)n_data == data) { -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else check = fread(n_data, 1, length, io_ptr); -#endif } else { png_byte buf[NEAR_BUF_SIZE]; @@ -97,14 +90,9 @@ remaining = length; do { read = MIN(NEAR_BUF_SIZE, remaining); -#if defined(_WIN32_WCE) - if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) - err = 0; -#else - err = fread(buf, (png_size_t)1, read, io_ptr); -#endif + err = fread(buf, 1, read, io_ptr); png_memcpy(data, buf, read); /* copy far buffer to near buffer */ if (err != read) break; else @@ -120,25 +108,29 @@ #endif #endif /* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ + * for libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png input data structure + * io_ptr - pointer to user supplied structure containing info about + * the input functions. May be NULL. + * read_data_fn - pointer to a new input function that takes as its + * arguments a pointer to a png_struct, a pointer to + * a location where input data can be stored, and a 32-bit + * unsigned int that is the number of bytes to be read. + * To exit and output any fatal error messages the new write + * function should call png_error(png_ptr, "Error msg"). + * May be NULL, in which case libpng's default function will + * be used. + */ void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->io_ptr = io_ptr; #if !defined(PNG_NO_STDIO) if (read_data_fn != NULL) @@ -155,9 +147,9 @@ png_ptr->write_data_fn = NULL; png_warning(png_ptr, "It's an error to set both read_data_fn and write_data_fn in the "); png_warning(png_ptr, - "same structure. Resetting write_data_fn to NULL."); + "same structure. Resetting write_data_fn to NULL"); } #if defined(PNG_WRITE_FLUSH_SUPPORTED) png_ptr->output_flush_fn = NULL; diff -ru4NwbB libpng-1.2.35/pngrtran.c libpng-1.4.0beta60/pngrtran.c --- libpng-1.2.35/pngrtran.c 2009-02-27 17:51:00.108616289 -0600 +++ libpng-1.4.0beta60/pngrtran.c 2009-05-18 16:58:20.636855417 -0500 @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.35 [February 14, 2009] + * Last changed in libpng 1.4.0 [May 18, 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) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -12,19 +12,20 @@ * Transformations that are used in both reading and writing are * in pngtrans.c. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) +#include "pngpriv.h" /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) { png_debug(1, "in png_set_crc_action"); /* Tell libpng how we react to CRC errors in critical chunks */ - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; switch (crit_action) { case PNG_CRC_NO_CHANGE: /* leave setting as is */ break; @@ -36,12 +39,14 @@ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; + case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ png_warning(png_ptr, - "Can't discard critical data on CRC error."); + "Can't discard critical data on CRC error"); case PNG_CRC_ERROR_QUIT: /* error/quit */ + case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; break; @@ -80,9 +90,10 @@ png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma) { png_debug(1, "in png_set_background"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); return; @@ -97,14 +108,15 @@ } #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ +/* Strip 16 bit depth files to 8 bit depth */ void PNGAPI png_set_strip_16(png_structp png_ptr) { png_debug(1, "in png_set_strip_16"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_16_TO_8; } #endif @@ -112,13 +124,29 @@ void PNGAPI png_set_strip_alpha(png_structp png_ptr) { png_debug(1, "in png_set_strip_alpha"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; } #endif +#if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) +void PNGAPI +png_set_premultiply_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_premultiply_alpha"); + if(png_ptr == NULL) + return; + png_ptr->transformations |= + (PNG_PREMULTIPLY_ALPHA | PNG_EXPAND_tRNS); + png_ptr->transformations |= + PNG_EXPAND; /* This shouldn't be necessary */ + png_ptr->flags &= ~PNG_FLAG_ROW_INIT; +} +#endif + #if defined(PNG_READ_DITHER_SUPPORTED) /* Dither file to 8 bit. Supply a palette, the current number * of elements in the palette, the maximum number of elements * allowed, and a histogram if possible. If the current number @@ -142,9 +170,10 @@ int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither) { png_debug(1, "in png_set_dither"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_DITHER; if (!full_dither) { @@ -160,9 +189,10 @@ { if (histogram != NULL) { /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ + * Perhaps not the best solution, but good enough. + */ int i; /* initialize an array to sort colors */ @@ -173,12 +203,13 @@ for (i = 0; i < num_palette; i++) png_ptr->dither_sort[i] = (png_byte)i; /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ + * bubble sort, and running it until we have sorted + * out enough colors. Note that we don't care about + * sorting all the colors, just finding which are + * least used. + */ for (i = num_palette - 1; i >= maximum_colors; i--) { int done; /* to stop early if the list is pre-sorted */ @@ -201,15 +232,16 @@ if (done) break; } - /* swap the palette around, and set up a table, if necessary */ + /* Swap the palette around, and set up a table, if necessary */ if (full_dither) { int j = num_palette; - /* put all the useful colors within the max, but don't - move the others */ + /* Put all the useful colors within the max, but don't + * move the others. + */ for (i = 0; i < maximum_colors; i++) { if ((int)png_ptr->dither_sort[i] >= maximum_colors) { @@ -223,13 +255,14 @@ else { int j = num_palette; - /* move all the used colors inside the max limit, and - develop a translation table */ + /* Move all the used colors inside the max limit, and + * develop a translation table. + */ for (i = 0; i < maximum_colors; i++) { - /* only move the colors we need to */ + /* Only move the colors we need to */ if ((int)png_ptr->dither_sort[i] >= maximum_colors) { png_color tmp_color; @@ -239,22 +272,22 @@ tmp_color = palette[j]; palette[j] = palette[i]; palette[i] = tmp_color; - /* indicate where the color went */ + /* Indicate where the color went */ png_ptr->dither_index[j] = (png_byte)i; png_ptr->dither_index[i] = (png_byte)j; } } - /* find closest color for those colors we are not using */ + /* Find closest color for those colors we are not using */ for (i = 0; i < num_palette; i++) { if ((int)png_ptr->dither_index[i] >= maximum_colors) { int min_d, k, min_k, d_index; - /* find the closest color to one we threw out */ + /* Find the closest color to one we threw out */ d_index = png_ptr->dither_index[i]; min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); for (k = 1, min_k = 0; k < maximum_colors; k++) { @@ -267,9 +300,9 @@ min_d = d; min_k = k; } } - /* point to closest color */ + /* Point to closest color */ png_ptr->dither_index[i] = (png_byte)min_k; } } } @@ -278,14 +311,14 @@ } else { /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] + * we need to go through a median cut routine, but those + * don't always behave themselves with only a few colors + * as input. So we will just find the closest two colors, + * and throw out one of them (chosen somewhat randomly). + * [We don't understand this at all, so if someone wants to + * work on improving it, be our guest - AED, GRP] */ int i; int max_d; int num_new_palette; @@ -293,34 +326,39 @@ png_dsortpp hash; t = NULL; - /* initialize palette index arrays */ + /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof(png_byte))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof(png_byte))); - /* initialize the sort array */ + /* Initialize the sort array */ for (i = 0; i < num_palette; i++) { png_ptr->index_to_palette[i] = (png_byte)i; png_ptr->palette_to_index[i] = (png_byte)i; } +#ifdef PNG_CALLOC_SUPPORTED + hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * + png_sizeof(png_dsortp))); +#else hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * png_sizeof(png_dsortp))); png_memset(hash, 0, 769 * png_sizeof(png_dsortp)); +#endif num_new_palette = num_palette; - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. + /* Initial wild guess at how far apart the farthest pixel + * pair we will be eliminating will be. Larger + * numbers mean more areas will be allocated, Smaller + * numbers run the risk of not saving enough data, and + * having to do this all over again. + * + * I have not done extensive checking on this number. */ max_d = 96; while (num_new_palette > maximum_colors) @@ -455,13 +493,17 @@ int num_green = (1 << PNG_DITHER_GREEN_BITS); int num_blue = (1 << PNG_DITHER_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->palette_lookup = (png_bytep )png_calloc(png_ptr, + (png_uint_32)(num_entries * png_sizeof(png_byte))); +#else png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); - png_memset(png_ptr->palette_lookup, 0, num_entries * png_sizeof(png_byte)); +#endif distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); @@ -524,9 +566,10 @@ void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) { png_debug(1, "in png_set_gamma"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) png_ptr->transformations |= PNG_GAMMA; @@ -543,9 +586,10 @@ void PNGAPI png_set_expand(png_structp png_ptr) { png_debug(1, "in png_set_expand"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -570,36 +614,25 @@ void PNGAPI png_set_palette_to_rgb(png_structp png_ptr) { png_debug(1, "in png_set_palette_to_rgb"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } -#if !defined(PNG_1_0_X) /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) { png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_EXPAND; png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } -#endif -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -/* Deprecated as of libpng-1.2.9 */ -void PNGAPI -png_set_gray_1_2_4_to_8(png_structp png_ptr) -{ - png_debug(1, "in png_set_gray_1_2_4_to_8"); - if (png_ptr == NULL) return; - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif /* Expand tRNS chunks to alpha channels. */ void PNGAPI @@ -632,9 +665,10 @@ double green) { int red_fixed = (int)((float)red*100000.0 + 0.5); int green_fixed = (int)((float)green*100000.0 + 0.5); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); } #endif @@ -642,9 +676,10 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green) { png_debug(1, "in png_set_rgb_to_gray"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; switch(error_action) { case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; break; @@ -657,9 +694,9 @@ png_ptr->transformations |= PNG_EXPAND; #else { png_warning(png_ptr, - "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); png_ptr->transformations &= ~PNG_RGB_TO_GRAY; } #endif { @@ -695,9 +732,10 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn) { png_debug(1, "in png_set_read_user_transform_fn"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif @@ -715,11 +753,8 @@ void /* PRIVATE */ png_init_read_transformations(png_structp png_ptr) { png_debug(1, "in png_init_read_transformations"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (png_ptr != NULL) -#endif { #if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ || defined(PNG_READ_GAMMA_SUPPORTED) int color_type = png_ptr->color_type; @@ -728,10 +763,11 @@ #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or + * for gray --> RGB case + * + * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or * RGB_ALPHA (in which case need_expand is superfluous anyway), the * background color might actually be gray yet not be flagged as such. * This is not a problem for the current code, which uses * PNG_BACKGROUND_IS_GRAY only to decide when to do the @@ -756,22 +792,23 @@ (png_ptr->transformations & PNG_EXPAND)) { if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ { - /* expand background and tRNS chunks */ + /* Expand background and tRNS chunks */ switch (png_ptr->bit_depth) { case 1: png_ptr->background.gray *= (png_uint_16)0xff; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { - png_ptr->trans_values.gray *= (png_uint_16)0xff; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + png_ptr->trans_color.gray *= (png_uint_16)0xff; + png_ptr->trans_color.red = png_ptr->trans_color.green + = png_ptr->trans_color.blue = png_ptr->trans_color.gray; } break; + case 2: png_ptr->background.gray *= (png_uint_16)0x55; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; @@ -776,13 +813,14 @@ png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { - png_ptr->trans_values.gray *= (png_uint_16)0x55; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + png_ptr->trans_color.gray *= (png_uint_16)0x55; + png_ptr->trans_color.red = png_ptr->trans_color.green + = png_ptr->trans_color.blue = png_ptr->trans_color.gray; } break; + case 4: png_ptr->background.gray *= (png_uint_16)0x11; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; @@ -787,14 +825,16 @@ png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { - png_ptr->trans_values.gray *= (png_uint_16)0x11; - png_ptr->trans_values.red = png_ptr->trans_values.green - = png_ptr->trans_values.blue = png_ptr->trans_values.gray; + png_ptr->trans_color.gray *= (png_uint_16)0x11; + png_ptr->trans_color.red = png_ptr->trans_color.green + = png_ptr->trans_color.blue = png_ptr->trans_color.gray; } break; + case 8: + case 16: png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; break; @@ -815,10 +855,11 @@ #if defined(PNG_READ_EXPAND_SUPPORTED) if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) #endif { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ + /* Invert the alpha channel (in tRNS) unless the pixels are + * going to be expanded, in which case leave it for later + */ int i, istop; istop=(int)png_ptr->num_trans; for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); @@ -858,10 +899,9 @@ if (png_ptr->transformations & PNG_BACKGROUND) { if (color_type == PNG_COLOR_TYPE_PALETTE) { - /* could skip if no transparency and - */ + /* Could skip if no transparency */ png_color back, back_1; png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; @@ -1228,13 +1272,11 @@ ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; - /* if adding a true alpha channel not just filler */ -#if !defined(PNG_1_0_X) + /* If adding a true alpha channel not just filler */ if (png_ptr->transformations & PNG_ADD_ALPHA) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#endif } #endif #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ @@ -1283,9 +1325,10 @@ #ifdef PNG_WARN_UNINITIALIZED_ROW if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) /* Application has failed to call either png_read_start_image() * or png_read_update_info() after setting transforms that expand - * pixels. This check added to libpng-1.2.19 */ + * pixels. This check added to libpng-1.2.19 + */ #if (PNG_WARN_UNINITIALIZED_ROW==1) png_error(png_ptr, "Uninitialized row"); #else png_warning(png_ptr, "Uninitialized row"); @@ -1304,9 +1347,9 @@ { if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values)); + &(png_ptr->trans_color)); else png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, NULL); } @@ -1336,52 +1379,59 @@ } } #endif -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. +/* From Andreas Dilger e-mail to png-implement, 26 March 1998: + * + * In most cases, the "simple transparency" should be done prior to doing + * gray-to-RGB, or you will have to test 3x as many bytes to check if a + * pixel is transparent. You would also need to make sure that the + * transparency information is upgraded to RGB. + * + * To summarize, the current flow is: + * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + * with background "in place" if transparent, + * convert to RGB if necessary + * - Gray + alpha -> composite with gray background and remove alpha bytes, + * convert to RGB if necessary + * + * To support RGB backgrounds for gray images we need: + * - Gray + simple transparency -> convert to RGB + simple transparency, + * compare 3 or 6 bytes and composite with + * background "in place" if transparent + * (3x compare/pixel compared to doing + * composite with gray bkgrnd) + * - Gray + alpha -> convert to RGB + alpha, composite with background and + * remove alpha bytes (3x float + * operations/pixel compared with composite + * on gray background) + * + * Greg's change will do this. The reason it wasn't done before is for + * performance, as this increases the per-pixel operations. If we would check + * in advance if the background was gray or RGB, and position the gray-to-RGB + * transform appropriately, then it would save a lot of work/time. */ #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ + /* If gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons + */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if (png_ptr->transformations & PNG_16_TO_8) + png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + #if defined(PNG_READ_BACKGROUND_SUPPORTED) if ((png_ptr->transformations & PNG_BACKGROUND) && ((png_ptr->num_trans != 0 ) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, - &(png_ptr->trans_values), &(png_ptr->background) + &(png_ptr->trans_color), &(png_ptr->background) #if defined(PNG_READ_GAMMA_SUPPORTED) , &(png_ptr->background_1), png_ptr->gamma_table, png_ptr->gamma_from_1, png_ptr->gamma_to_1, png_ptr->gamma_16_table, @@ -1403,13 +1453,8 @@ png_ptr->gamma_table, png_ptr->gamma_16_table, png_ptr->gamma_shift); #endif -#if defined(PNG_READ_16_TO_8_SUPPORTED) - if (png_ptr->transformations & PNG_16_TO_8) - png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); -#endif - #if defined(PNG_READ_DITHER_SUPPORTED) if (png_ptr->transformations & PNG_DITHER) { png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, @@ -1445,9 +1490,9 @@ png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ + /* If gray -> RGB, do so now only if we did not do so above */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif @@ -1457,8 +1502,14 @@ png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, (png_uint_32)png_ptr->filler, png_ptr->flags); #endif +#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); +#endif + #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_ALPHA) png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif @@ -1512,13 +1563,9 @@ void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_unpack"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth < 8) -#else if (row_info->bit_depth < 8) -#endif { png_uint_32 i; png_uint_32 row_width=row_info->width; @@ -1603,11 +1652,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { png_debug(1, "in png_do_unshift"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && sig_bits != NULL && -#endif row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift[4]; int channels = 0; @@ -1703,18 +1752,14 @@ } #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ +/* Chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ png_do_chop(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_chop"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && row_info->bit_depth == 16) -#else if (row_info->bit_depth == 16) -#endif { png_bytep sp = row; png_bytep dp = row; png_uint_32 i; @@ -1727,16 +1772,19 @@ * value, rather than a simple low-byte truncation. * * What the ideal calculation should be: * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L; + * (png_uint_32)(*(sp + 1))) * 255 + 127) + * / (png_uint_32)65535L; * * GRR: no, I think this is what it really should be: * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L; + * (png_uint_32)(*(sp + 1))) + 128L) + * / (png_uint_32)257L; * * GRR: here's the exact calculation with shifts: - * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L; + * temp = (((png_uint_32)(*sp) << 8) | + * (png_uint_32)(*(sp + 1))) + 128L; * *dp = (temp - (temp >> 8)) >> 8; * * Approximate calculation with shift/add instead of multiply/divide: * *dp = ((((png_uint_32)(*sp) << 8) | @@ -1762,11 +1810,8 @@ void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_swap_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { @@ -1854,11 +1899,8 @@ void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_invert_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { @@ -1947,8 +1989,86 @@ } } #endif +#if defined(PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_read_premultiply_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_premultiply_alpha"); + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This premultiplies the pixels with the alpha channel in RGBA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_16 a = 0; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + a = *(--sp); --dp; + + *(--dp) = (*(--sp) * a) / 255; + *(--dp) = (*(--sp) * a) / 255; + *(--dp) = (*(--sp) * a) / 255; + } + } + /* This premultiplies the pixels with the alpha channel in RRGGBBAA */ + else + { + png_uint_16p sp = (png_uint_16p)(row + row_info->rowbytes); + png_uint_16p dp = sp; + png_uint_32 a = 0; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + a = *(--sp); --dp; + *(--dp) = (png_uint_16) ((*(--sp) * a) / 65535); + *(--dp) = (png_uint_16) ((*(--sp) * a) / 65535); + *(--dp) = (png_uint_16) ((*(--sp) * a) / 65535); + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This premultiplies the pixels with the alpha channel in GA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_16 a = 0; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + a = *(--sp); --dp; + *(--dp) = (*(--sp) * a) / 255; + } + } + /* This premultiplies the pixels with the alpha channel in GGAA */ + else + { + png_uint_16p sp = (png_uint_16p) (row + row_info->rowbytes); + png_uint_16p dp = sp; + png_uint_32 a = 0; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + a = *(--sp); --dp; + *(--dp) = (png_uint_16) ((*(--sp) * a) / 65535); + } + } + } + } +} +#endif + #if defined(PNG_READ_FILLER_SUPPORTED) /* Add filler channel if we have RGB color */ void /* PRIVATE */ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -1961,11 +2081,8 @@ png_byte lo_filler = (png_byte)(filler & 0xff); png_debug(1, "in png_do_read_filler"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { @@ -2133,11 +2250,8 @@ png_uint_32 row_width = row_info->width; png_debug(1, "in png_do_gray_to_rgb"); if (row_info->bit_depth >= 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif !(row_info->color_type & PNG_COLOR_MASK_COLOR)) { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { @@ -2239,11 +2353,8 @@ int rgb_error = 0; png_debug(1, "in png_do_rgb_to_gray"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; @@ -2511,198 +2626,17 @@ palette[i].blue = (png_byte)v; } } -/* This function is currently unused. Do we really need it? */ -#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) -void /* PRIVATE */ -png_correct_palette(png_structp png_ptr, png_colorp palette, - int num_palette) -{ - png_debug(1, "in png_correct_palette"); -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) - { - png_color back, back_1; - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - double g; - - g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); - - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || - fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) - { - back.red = png_ptr->background.red; - back.green = png_ptr->background.green; - back.blue = png_ptr->background.blue; - } - else - { - back.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - g = 1.0 / png_ptr->background_gamma; - - back_1.red = - (png_byte)(pow((double)png_ptr->background.red/255, g) * - 255.0 + 0.5); - back_1.green = - (png_byte)(pow((double)png_ptr->background.green/255, g) * - 255.0 + 0.5); - back_1.blue = - (png_byte)(pow((double)png_ptr->background.blue/255, g) * - 255.0 + 0.5); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_uint_32 i; - - for (i = 0; i < (png_uint_32)num_palette; i++) - { - if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) - { - palette[i] = back; - } - else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) - { - png_byte v, w; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; - png_composite(w, v, png_ptr->trans[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; - png_composite(w, v, png_ptr->trans[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; - png_composite(w, v, png_ptr->trans[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - else - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (palette[i].red == (png_byte)png_ptr->trans_values.gray) - { - palette[i] = back; - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - } - } - else -#endif -#if defined(PNG_READ_GAMMA_SUPPORTED) - if (png_ptr->transformations & PNG_GAMMA) - { - int i; - - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - else -#endif -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) - if (png_ptr->transformations & PNG_BACKGROUND) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_color back; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < (int)png_ptr->num_trans; i++) - { - if (png_ptr->trans[i] == 0) - { - palette[i].red = back.red; - palette[i].green = back.green; - palette[i].blue = back.blue; - } - else if (png_ptr->trans[i] != 0xff) - { - png_composite(palette[i].red, png_ptr->palette[i].red, - png_ptr->trans[i], back.red); - png_composite(palette[i].green, png_ptr->palette[i].green, - png_ptr->trans[i], back.green); - png_composite(palette[i].blue, png_ptr->palette[i].blue, - png_ptr->trans[i], back.blue); - } - } - } - else /* assume grayscale palette (what else could it be?) */ - { - int i; - - for (i = 0; i < num_palette; i++) - { - if (i == (png_byte)png_ptr->trans_values.gray) - { - palette[i].red = (png_byte)png_ptr->background.red; - palette[i].green = (png_byte)png_ptr->background.green; - palette[i].blue = (png_byte)png_ptr->background.blue; - } - } - } - } -#endif -} -#endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. */ void /* PRIVATE */ png_do_background(png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background + png_color_16p trans_color, png_color_16p background #if defined(PNG_READ_GAMMA_SUPPORTED) , png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, @@ -2716,13 +2650,10 @@ int shift; png_debug(1, "in png_do_background"); if (background != NULL && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || - (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) + (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_color))) { switch (row_info->color_type) { case PNG_COLOR_TYPE_GRAY: @@ -2735,9 +2666,9 @@ shift = 7; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x01) - == trans_values->gray) + == trans_color->gray) { *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } @@ -2760,9 +2692,9 @@ shift = 6; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) + == trans_color->gray) { *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } @@ -2790,9 +2722,9 @@ shift = 6; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) - == trans_values->gray) + == trans_color->gray) { *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } @@ -2816,9 +2749,9 @@ shift = 4; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) + == trans_color->gray) { *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } @@ -2846,9 +2779,9 @@ shift = 4; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) - == trans_values->gray) + == trans_color->gray) { *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } @@ -2870,9 +2804,9 @@ { sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == trans_values->gray) + if (*sp == trans_color->gray) { *sp = (png_byte)background->gray; } else @@ -2886,9 +2820,9 @@ { sp = row; for (i = 0; i < row_width; i++, sp++) { - if (*sp == trans_values->gray) + if (*sp == trans_color->gray) { *sp = (png_byte)background->gray; } } @@ -2905,11 +2840,11 @@ { png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) + if (v == trans_color->gray) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *sp = (png_byte)((background->gray >> 8) & 0xff); *(sp + 1) = (png_byte)(background->gray & 0xff); } else @@ -2928,9 +2863,9 @@ { png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - if (v == trans_values->gray) + if (v == trans_color->gray) { *sp = (png_byte)((background->gray >> 8) & 0xff); *(sp + 1) = (png_byte)(background->gray & 0xff); } @@ -2950,11 +2886,11 @@ { sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) + if (*sp == trans_color->red && + *(sp + 1) == trans_color->green && + *(sp + 2) == trans_color->blue) { *sp = (png_byte)background->red; *(sp + 1) = (png_byte)background->green; *(sp + 2) = (png_byte)background->blue; @@ -2972,11 +2908,11 @@ { sp = row; for (i = 0; i < row_width; i++, sp += 3) { - if (*sp == trans_values->red && - *(sp + 1) == trans_values->green && - *(sp + 2) == trans_values->blue) + if (*sp == trans_color->red && + *(sp + 1) == trans_color->green && + *(sp + 2) == trans_color->blue) { *sp = (png_byte)background->red; *(sp + 1) = (png_byte)background->green; *(sp + 2) = (png_byte)background->blue; @@ -2994,12 +2930,12 @@ { png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) + if (r == trans_color->red && g == trans_color->green && + b == trans_color->blue) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *sp = (png_byte)((background->red >> 8) & 0xff); *(sp + 1) = (png_byte)(background->red & 0xff); *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); *(sp + 3) = (png_byte)(background->green & 0xff); @@ -3029,10 +2965,10 @@ png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); - if (r == trans_values->red && g == trans_values->green && - b == trans_values->blue) + if (r == trans_color->red && g == trans_color->green && + b == trans_color->blue) { *sp = (png_byte)((background->red >> 8) & 0xff); *(sp + 1) = (png_byte)(background->red & 0xff); *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); @@ -3064,9 +3001,9 @@ *dp = gamma_table[*sp]; } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)background->gray; } else { @@ -3131,9 +3068,9 @@ #else else #endif { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -3208,9 +3146,9 @@ *(dp + 2) = gamma_table[*(sp + 2)]; } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)background->red; *(dp + 1) = (png_byte)background->green; *(dp + 2) = (png_byte)background->blue; } @@ -3289,9 +3227,9 @@ *(dp + 5) = (png_byte)(v & 0xff); } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)((background->red >> 8) & 0xff); *(dp + 1) = (png_byte)(background->red & 0xff); *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); *(dp + 3) = (png_byte)(background->green & 0xff); @@ -3398,11 +3336,8 @@ png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_gamma"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif ((row_info->bit_depth <= 8 && gamma_table != NULL) || (row_info->bit_depth == 16 && gamma_16_table != NULL))) { switch (row_info->color_type) @@ -3580,11 +3521,8 @@ png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand_palette"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->color_type == PNG_COLOR_TYPE_PALETTE) { if (row_info->bit_depth < 8) { @@ -3722,11 +3663,8 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); @@ -3928,11 +3871,8 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_dither"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup && row_info->bit_depth == 8) { @@ -3944,14 +3884,14 @@ r = *sp++; g = *sp++; b = *sp++; - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); + /* This looks real messy, but the compiler will reduce + * it down to a reasonable formula. For example, with + * 5 bits per color, we get: + * p = (((r >> 3) & 0x1f) << 10) | + * (((g >> 3) & 0x1f) << 5) | + * ((b >> 3) & 0x1f); */ p = (((r >> (8 - PNG_DITHER_RED_BITS)) & ((1 << PNG_DITHER_RED_BITS) - 1)) << (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | @@ -4122,18 +4068,22 @@ g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); else g = 1.0; +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->gamma_16_table = (png_uint_16pp)png_calloc(png_ptr, + (png_uint_32)(num * png_sizeof(png_uint_16p))); +#else png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p))); + png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); +#endif if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) { double fin, fout; png_uint_32 last, max; - png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); - for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof(png_uint_16))); @@ -4184,12 +4135,16 @@ { g = 1.0 / (png_ptr->gamma); +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->gamma_16_to_1 = (png_uint_16pp)png_calloc(png_ptr, + (png_uint_32)(num * png_sizeof(png_uint_16p ))); +#else png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p ))); - png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p)); +#endif for (i = 0; i < num; i++) { png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, @@ -4206,16 +4161,21 @@ } if (png_ptr->screen_gamma > 0.000001) g = 1.0 / png_ptr->screen_gamma; + else g = png_ptr->gamma; /* probably doing rgb_to_gray */ +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->gamma_16_from_1 = (png_uint_16pp)png_calloc(png_ptr, + (png_uint_32)(num * png_sizeof(png_uint_16p))); +#else png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof(png_uint_16p))); - png_memset(png_ptr->gamma_16_from_1, 0, num * png_sizeof(png_uint_16p)); +#endif for (i = 0; i < num; i++) { png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, @@ -4244,11 +4205,8 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_intrapixel"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; diff -ru4NwbB libpng-1.2.35/pngrutil.c libpng-1.4.0beta60/pngrutil.c --- libpng-1.2.35/pngrutil.c 2009-02-14 15:59:26.630905530 -0600 +++ libpng-1.4.0beta60/pngrutil.c 2009-05-18 16:58:20.649704226 -0500 @@ -1,68 +1,31 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) * * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) +#include "pngpriv.h" -#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500) -# define WIN32_WCE_OLD -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -# if defined(WIN32_WCE_OLD) -/* strtod() function is not supported on WindowsCE */ -__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) -{ - double result = 0; - int len; - wchar_t *str, *end; - - len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t)); - if ( NULL != str ) - { - MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); - result = wcstod(str, &end); - len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); - png_free(png_ptr, str); - } - return result; -} -# else # define png_strtod(p,a,b) strtod(a,b) -# endif -#endif - png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf) { -#ifdef PNG_READ_BIG_ENDIAN_SUPPORTED png_uint_32 i = png_get_uint_32(buf); -#else - /* Avoid an extra function call by inlining the result. */ - png_uint_32 i = ((png_uint_32)(*buf) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - (png_uint_32)(*(buf + 3)); -#endif if (i > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range."); + png_error(png_ptr, "PNG unsigned integer out of range"); return (i); } -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +#ifndef PNG_USE_READ_MACROS /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ png_uint_32 PNGAPI png_get_uint_32(png_bytep buf) { @@ -75,9 +38,10 @@ } /* Grab a signed 32-bit integer from a buffer in big-endian format. The * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ + * assumed that the machine format for signed integers is the same. + */ png_int_32 PNGAPI png_get_int_32(png_bytep buf) { png_int_32 i = ((png_int_32)(*buf) << 24) + @@ -96,9 +60,9 @@ (png_uint_16)(*(buf + 1))); return (i); } -#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ +#endif /* PNG_USE_READ_MACROS */ /* Read the chunk header (length + type name). * Put the type name into png_ptr->chunk_name, and return the length. */ @@ -107,41 +71,57 @@ { png_byte buf[8]; png_uint_32 length; - /* read the length and the chunk name */ +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk header is being read. + * PNG_IO_CHUNK_HDR requires a single I/O call. + */ + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR; +#endif + + /* Read the length and the chunk name */ png_read_data(png_ptr, buf, 8); length = png_get_uint_31(png_ptr, buf); - /* put the chunk name into png_ptr->chunk_name */ + /* Put the chunk name into png_ptr->chunk_name */ png_memcpy(png_ptr->chunk_name, buf + 4, 4); png_debug2(0, "Reading %s chunk, length = %lu", png_ptr->chunk_name, length); - /* reset the crc and run it over the chunk name */ + /* Reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); png_calculate_crc(png_ptr, png_ptr->chunk_name, 4); - /* check to see if chunk name is valid */ + /* Check to see if chunk name is valid */ png_check_chunk_name(png_ptr, png_ptr->chunk_name); +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that chunk data will (possibly) be read. + * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. + */ + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; +#endif + return length; } /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_read_data(png_ptr, buf, length); png_calculate_crc(png_ptr, buf, length); } /* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ + * are reading a ancillary or critical chunk, and how the program has set + * things up, we may calculate the CRC on the data and print a message. + * Returns '1' if there was a CRC error, '0' otherwise. + */ int /* PRIVATE */ png_crc_finish(png_structp png_ptr, png_uint_32 skip) { png_size_t i; @@ -166,18 +146,20 @@ png_chunk_warning(png_ptr, "CRC error"); } else { - png_chunk_error(png_ptr, "CRC error"); + png_chunk_benign_error(png_ptr, "CRC error"); + return (0); } return (1); } return (0); } /* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ + * the data it has read thus far. + */ int /* PRIVATE */ png_crc_error(png_structp png_ptr) { png_byte crc_bytes[4]; @@ -195,8 +177,14 @@ if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } +#ifdef PNG_IO_STATE_SUPPORTED + /* inform the I/O callback that the chunk CRC is being read */ + /* PNG_IO_CHUNK_CRC requires the I/O to be done at once */ + png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC; +#endif + png_read_data(png_ptr, crc_bytes, 4); if (need_crc) { @@ -282,9 +270,9 @@ { png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; png_error(png_ptr, - "Not enough memory to decompress chunk."); + "Not enough memory to decompress chunk"); } png_memcpy(text + prefix_size, png_ptr->zbuf, text_size - prefix_size); png_memcpy(text, png_ptr->chunkdata, prefix_size); @@ -295,17 +283,17 @@ png_charp tmp; tmp = text; text = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(text_size + + (png_size_t)(text_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); if (text == NULL) { png_free(png_ptr, tmp); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; png_error(png_ptr, - "Not enough memory to decompress chunk.."); + "Not enough memory to decompress chunk"); } png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); png_memcpy(text + text_size, png_ptr->zbuf, @@ -323,9 +311,9 @@ } } if (ret != Z_STREAM_END) { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) +#if !defined(PNG_NO_STDIO) char umsg[52]; if (ret == Z_BUF_ERROR) png_snprintf(umsg, 52, @@ -351,9 +342,9 @@ if (text == NULL) { png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; - png_error(png_ptr, "Not enough memory for text."); + png_error(png_ptr, "Not enough memory for text"); } png_memcpy(text, png_ptr->chunkdata, prefix_size); } *(text + text_size) = 0x00; @@ -367,9 +358,9 @@ *newlength=text_size; } else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) +#if !defined(PNG_NO_STDIO) char umsg[50]; png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type); png_warning(png_ptr, umsg); @@ -382,9 +373,9 @@ } } #endif -/* read and check the IDHR chunk */ +/* Read and check the IDHR chunk */ void /* PRIVATE */ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[13]; @@ -396,9 +387,9 @@ if (png_ptr->mode & PNG_HAVE_IHDR) png_error(png_ptr, "Out of place IHDR"); - /* check the length */ + /* Check the length */ if (length != 13) png_error(png_ptr, "Invalid IHDR chunk"); png_ptr->mode |= PNG_HAVE_IHDR; @@ -413,9 +404,9 @@ compression_type = buf[10]; filter_type = buf[11]; interlace_type = buf[12]; - /* set internal variables */ + /* Set internal variables */ png_ptr->width = width; png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; @@ -424,9 +415,9 @@ png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; - /* find number of channels */ + /* Find number of channels */ switch (png_ptr->color_type) { case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_PALETTE: @@ -442,9 +436,9 @@ png_ptr->channels = 4; break; } - /* set up other useful info */ + /* Set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); @@ -453,9 +447,9 @@ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } -/* read and check the palette */ +/* Read and check the palette */ void /* PRIVATE */ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_color palette[PNG_MAX_PALETTE_LENGTH]; @@ -533,11 +530,12 @@ } #endif /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ + * whatever the normal CRC configuration tells us. However, if we + * have an RGB image, the PLTE can be considered ancillary, so + * we will act as though it is. + */ #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { @@ -553,9 +551,9 @@ if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) { - png_chunk_error(png_ptr, "CRC error"); + png_chunk_benign_error(png_ptr, "CRC error"); } else { png_chunk_warning(png_ptr, "CRC error"); @@ -1090,9 +1088,9 @@ if (profile_size > profile_length) { png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; - png_warning(png_ptr, "Ignoring truncated iCCP profile."); + png_warning(png_ptr, "Ignoring truncated iCCP profile"); return; } png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata, @@ -1117,8 +1115,25 @@ png_size_t slength; png_debug(1, "in png_handle_sPLT"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for sPLT"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sPLT"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1282,9 +1297,9 @@ } png_crc_read(png_ptr, buf, 2); png_ptr->num_trans = 1; - png_ptr->trans_values.gray = png_get_uint_16(buf); + png_ptr->trans_color.gray = png_get_uint_16(buf); } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { png_byte buf[6]; @@ -1296,11 +1311,11 @@ return; } png_crc_read(png_ptr, buf, (png_size_t)length); png_ptr->num_trans = 1; - png_ptr->trans_values.red = png_get_uint_16(buf); - png_ptr->trans_values.green = png_get_uint_16(buf + 2); - png_ptr->trans_values.blue = png_get_uint_16(buf + 4); + png_ptr->trans_color.red = png_get_uint_16(buf); + png_ptr->trans_color.green = png_get_uint_16(buf + 2); + png_ptr->trans_color.blue = png_get_uint_16(buf + 4); } else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (!(png_ptr->mode & PNG_HAVE_PLTE)) @@ -1337,9 +1352,9 @@ return; } png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_values)); + &(png_ptr->trans_color)); } #endif #if defined(PNG_READ_bKGD_SUPPORTED) @@ -1605,9 +1620,9 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) { - png_warning(png_ptr, "No memory for pCAL purpose."); + png_warning(png_ptr, "No memory for pCAL purpose"); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); @@ -1666,14 +1681,14 @@ /* Empty loop to move past the units string. */ ; png_debug(3, "Allocating pCAL parameters array"); params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)(nparams * png_sizeof(png_charp))) ; + (png_size_t)(nparams * png_sizeof(png_charp))); if (params == NULL) { png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; - png_warning(png_ptr, "No memory for pCAL params."); + png_warning(png_ptr, "No memory for pCAL params"); return; } /* Get pointers to the start of each parameter string. */ @@ -1774,9 +1789,9 @@ { png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); return; } - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); + png_memcpy(swidth, ep, png_strlen(ep)); #endif #endif for (ep = png_ptr->chunkdata; *ep; ep++) @@ -1809,9 +1824,9 @@ { png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); return; } - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); + png_memcpy(sheight, ep, png_strlen(ep)); #endif #endif if (png_ptr->chunkdata + slength < ep @@ -1904,8 +1919,24 @@ int ret; png_debug(1, "in png_handle_tEXt"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for tEXt"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tEXt"); @@ -1925,9 +1956,9 @@ png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) { - png_warning(png_ptr, "No memory to process text chunk."); + png_warning(png_ptr, "No memory to process text chunk"); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); @@ -1949,12 +1980,12 @@ if (text != key + slength) text++; text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); if (text_ptr == NULL) { - png_warning(png_ptr, "Not enough memory to process text chunk."); + png_warning(png_ptr, "Not enough memory to process text chunk"); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } @@ -1973,9 +2004,9 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; png_free(png_ptr, text_ptr); if (ret) - png_warning(png_ptr, "Insufficient memory to process text chunk."); + png_warning(png_ptr, "Insufficient memory to process text chunk"); } #endif #if defined(PNG_READ_zTXt_SUPPORTED) @@ -1990,8 +2021,24 @@ png_size_t slength, prefix_len, data_len; png_debug(1, "in png_handle_zTXt"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for zTXt"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before zTXt"); @@ -2012,9 +2059,9 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) { - png_warning(png_ptr, "Out of memory processing zTXt chunk."); + png_warning(png_ptr, "Out of memory processing zTXt chunk"); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); @@ -2053,12 +2100,12 @@ png_decompress_chunk(png_ptr, comp_type, (png_size_t)length, prefix_len, &data_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); if (text_ptr == NULL) { - png_warning(png_ptr, "Not enough memory to process zTXt chunk."); + png_warning(png_ptr, "Not enough memory to process zTXt chunk"); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } @@ -2077,9 +2124,9 @@ png_free(png_ptr, text_ptr); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; if (ret) - png_error(png_ptr, "Insufficient memory to store zTXt chunk."); + png_error(png_ptr, "Insufficient memory to store zTXt chunk"); } #endif #if defined(PNG_READ_iTXt_SUPPORTED) @@ -2095,8 +2142,24 @@ png_size_t slength, prefix_len, data_len; png_debug(1, "in png_handle_iTXt"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for iTXt"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iTXt"); @@ -2117,9 +2180,9 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) { - png_warning(png_ptr, "No memory to process iTXt chunk."); + png_warning(png_ptr, "No memory to process iTXt chunk"); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); @@ -2184,12 +2247,12 @@ (size_t)length, prefix_len, &data_len); else data_len = png_strlen(png_ptr->chunkdata + prefix_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); + png_sizeof(png_text)); if (text_ptr == NULL) { - png_warning(png_ptr, "Not enough memory to process iTXt chunk."); + png_warning(png_ptr, "Not enough memory to process iTXt chunk"); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } @@ -2206,9 +2269,9 @@ png_free(png_ptr, text_ptr); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; if (ret) - png_error(png_ptr, "Insufficient memory to store iTXt chunk."); + png_error(png_ptr, "Insufficient memory to store iTXt chunk"); } #endif /* This function is called when we haven't found a handler for a @@ -2222,8 +2285,24 @@ png_uint_32 skip = 0; png_debug(1, "in png_handle_unknown"); +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_cache_max != 0) + { + if (png_ptr->user_chunk_cache_max == 1) + { + png_crc_finish(png_ptr, length); + return; + } + if (--png_ptr->user_chunk_cache_max == 1) + { + png_warning(png_ptr, "No space in chunk cache for unknown chunk"); + png_crc_finish(png_ptr, length); + return; + } + } +#endif if (png_ptr->mode & PNG_HAVE_IDAT) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -2886,8 +2965,9 @@ break; } } +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED void /* PRIVATE */ png_read_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -2916,9 +2996,9 @@ #ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - png_memset_check(png_ptr, png_ptr->prev_row, 0, + png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { png_ptr->pass++; @@ -3000,9 +3080,9 @@ "Decompression Error"); if (!(png_ptr->zstream.avail_out)) { - png_warning(png_ptr, "Extra compressed data."); + png_warning(png_ptr, "Extra compressed data"); png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } @@ -3017,8 +3097,9 @@ inflateReset(&png_ptr->zstream); png_ptr->mode |= PNG_AFTER_IDAT; } +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ void /* PRIVATE */ png_read_start_row(png_structp png_ptr) { @@ -3186,8 +3267,11 @@ if (row_bytes + 64 > png_ptr->old_big_row_buf_size) { 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); + 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; } @@ -3196,9 +3280,9 @@ if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory."); + png_error(png_ptr, "Row has too many bytes to allocate in memory"); if (png_ptr->rowbytes+1 > png_ptr->old_prev_row_size) { png_free(png_ptr, png_ptr->prev_row); @@ -3206,9 +3290,9 @@ png_ptr->rowbytes + 1)); png_ptr->old_prev_row_size = png_ptr->rowbytes+1; } - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_debug1(3, "width = %lu,", png_ptr->width); png_debug1(3, "height = %lu,", png_ptr->height); png_debug1(3, "iwidth = %lu,", png_ptr->iwidth); diff -ru4NwbB libpng-1.2.35/pngset.c libpng-1.4.0beta60/pngset.c --- libpng-1.2.35/pngset.c 2009-02-27 17:50:44.248728306 -0600 +++ libpng-1.4.0beta60/pngset.c 2009-05-18 16:58:20.657865516 -0500 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.35 [February 14, 2009] + * Last changed in libpng 1.4.0 [May 18, 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) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -12,11 +12,11 @@ * into the info struct for writing into the file. This abstracts the * info struct and allows us to change the structure in the future. */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" #if defined(PNG_bKGD_SUPPORTED) void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) @@ -107,63 +107,63 @@ #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) { - double gamma; + double png_gamma; png_debug1(1, "in %s storage function", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; /* Check for overflow */ if (file_gamma > 21474.83) { png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; + png_gamma=21474.83; } else - gamma = file_gamma; - info_ptr->gamma = (float)gamma; + png_gamma = file_gamma; + info_ptr->gamma = (float)png_gamma; #ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); + info_ptr->int_gamma = (int)(png_gamma*100000.+.5); #endif info_ptr->valid |= PNG_INFO_gAMA; - if (gamma == 0.0) + if (png_gamma == 0.0) png_warning(png_ptr, "Setting gamma=0"); } #endif void PNGAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point int_gamma) { - png_fixed_point gamma; + png_fixed_point png_gamma; png_debug1(1, "in %s storage function", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) { png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; + png_gamma=PNG_UINT_31_MAX; } else { if (int_gamma < 0) { png_warning(png_ptr, "Setting negative gamma to zero"); - gamma = 0; + png_gamma = 0; } else - gamma = int_gamma; + png_gamma = int_gamma; } #ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); + info_ptr->gamma = (float)(png_gamma/100000.); #endif #ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; + info_ptr->int_gamma = png_gamma; #endif info_ptr->valid |= PNG_INFO_gAMA; - if (gamma == 0) + if (png_gamma == 0) png_warning(png_ptr, "Setting gamma=0"); } #endif @@ -179,22 +179,23 @@ if (info_ptr->num_palette == 0 || info_ptr->num_palette > PNG_MAX_PALETTE_LENGTH) { png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); + "Invalid palette size, hIST allocation skipped"); return; } #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); #endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ + /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in + * version 1.2.1 + */ png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); + PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)); if (png_ptr->hist == NULL) { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); + png_warning(png_ptr, "Insufficient memory for hIST chunk data"); return; } for (i = 0; i < info_ptr->num_palette; i++) @@ -312,9 +313,9 @@ - 64 /* bigrowbuf hack */ - 1 /* filter byte */ - 7*8 /* rounding of width to multiple of 8 pixels */ - 8) /* extra max_pixel_depth pad */ - info_ptr->rowbytes = (png_size_t)0; + info_ptr->rowbytes = 0; else info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); } @@ -339,9 +340,9 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) { - png_uint_32 length; + png_size_t length; int i; png_debug1(1, "in %s storage function", "pCAL"); if (png_ptr == NULL || info_ptr == NULL) @@ -352,12 +353,12 @@ (unsigned long)length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); + png_warning(png_ptr, "Insufficient memory for pCAL purpose"); return; } - png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); + png_memcpy(info_ptr->pcal_purpose, purpose, length); png_debug(3, "storing X0, X1, type, and nparams in info"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; @@ -369,25 +370,21 @@ (unsigned long)length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL units."); + png_warning(png_ptr, "Insufficient memory for pCAL units"); return; } - png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); + png_memcpy(info_ptr->pcal_units, units, length); info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, - (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); + (png_size_t)((nparams + 1) * png_sizeof(png_charp))); if (info_ptr->pcal_params == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL params."); + png_warning(png_ptr, "Insufficient memory for pCAL params"); return; } -#ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_PCAL; -#endif - png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); for (i = 0; i < nparams; i++) { @@ -396,15 +393,18 @@ (unsigned long)length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_params[i] == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); + png_warning(png_ptr, "Insufficient memory for pCAL parameter"); return; } - png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); + png_memcpy(info_ptr->pcal_params[i], params[i], length); } info_ptr->valid |= PNG_INFO_pCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PCAL; +#endif } #endif #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) @@ -428,9 +428,9 @@ void PNGAPI png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, int unit, png_charp swidth, png_charp sheight) { - png_uint_32 length; + png_size_t length; png_debug1(1, "in %s storage function", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -443,12 +443,12 @@ info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { png_warning(png_ptr, - "Memory allocation failed while processing sCAL."); + "Memory allocation failed while processing sCAL"); return; } - png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); + png_memcpy(info_ptr->scal_s_width, swidth, length); length = png_strlen(sheight) + 1; png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)length); @@ -457,12 +457,12 @@ { png_free (png_ptr, info_ptr->scal_s_width); info_ptr->scal_s_width = NULL; png_warning(png_ptr, - "Memory allocation failed while processing sCAL."); + "Memory allocation failed while processing sCAL"); return; } - png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); + png_memcpy(info_ptr->scal_s_height, sheight, length); info_ptr->valid |= PNG_INFO_sCAL; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SCAL; #endif @@ -516,14 +516,20 @@ png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); #endif /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ + * of num_palette entries, in case of an invalid PNG file that has + * too-large sample values. + */ +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->palette = (png_colorp)png_calloc(png_ptr, + PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); +#else png_ptr->palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); +#endif png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -657,18 +663,18 @@ length = png_strlen(name)+1; new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length); if (new_iccp_name == NULL) { - png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); + png_warning(png_ptr, "Insufficient memory to process iCCP chunk"); return; } png_memcpy(new_iccp_name, name, length); new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); if (new_iccp_profile == NULL) { png_free (png_ptr, new_iccp_name); png_warning(png_ptr, - "Insufficient memory to process iCCP profile."); + "Insufficient memory to process iCCP profile"); return; } png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); @@ -723,9 +729,9 @@ old_max = info_ptr->max_text; info_ptr->max_text = info_ptr->num_text + num_text + 8; old_text = info_ptr->text; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); + (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) { png_free(png_ptr, old_text); return(1); @@ -738,9 +744,9 @@ { info_ptr->max_text = num_text + 8; info_ptr->num_text = 0; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); + (png_size_t)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) return(1); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TEXT; @@ -779,9 +785,9 @@ lang_key_len = 0; } #else { - png_warning(png_ptr, "iTXt chunk not supported."); + png_warning(png_ptr, "iTXt chunk not supported"); continue; } #endif @@ -801,19 +807,18 @@ textp->compression = text_ptr[i].compression; } textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32) + (png_size_t) (key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) return(1); png_debug2(2, "Allocated %lu bytes at %x in png_set_text", - (png_uint_32) + (unsigned long)(png_uint_32) (key_len + lang_len + lang_key_len + text_length + 4), (int)textp->key); - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); + png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); *(textp->key + key_len) = '\0'; #ifdef PNG_iTXt_SUPPORTED if (text_ptr[i].compression > 0) { @@ -876,9 +881,9 @@ #if defined(PNG_tRNS_SUPPORTED) void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans, int num_trans, png_color_16p trans_values) + png_bytep trans, int num_trans, png_color_16p trans_color) { png_debug1(1, "in %s storage function", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -896,25 +901,25 @@ #endif /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - (png_uint_32)PNG_MAX_PALETTE_LENGTH); + (png_size_t)PNG_MAX_PALETTE_LENGTH); if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); } - if (trans_values != NULL) + if (trans_color != NULL) { int sample_max = (1 << info_ptr->bit_depth); if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - (int)trans_values->gray > sample_max) || + (int)trans_color->gray > sample_max) || (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - ((int)trans_values->red > sample_max || - (int)trans_values->green > sample_max || - (int)trans_values->blue > sample_max))) + ((int)trans_color->red > sample_max || + (int)trans_color->green > sample_max || + (int)trans_color->blue > sample_max))) png_warning(png_ptr, "tRNS chunk has out-of-range samples for bit_depth"); - png_memcpy(&(info_ptr->trans_values), trans_values, + png_memcpy(&(info_ptr->trans_color), trans_color, png_sizeof(png_color_16)); if (num_trans == 0) num_trans = 1; } @@ -951,12 +956,12 @@ return; np = (png_sPLT_tp)png_malloc_warn(png_ptr, (info_ptr->splt_palettes_num + nentries) * - (png_uint_32)png_sizeof(png_sPLT_t)); + (png_size_t)png_sizeof(png_sPLT_t)); if (np == NULL) { - png_warning(png_ptr, "No memory for sPLT palettes."); + png_warning(png_ptr, "No memory for sPLT palettes"); return; } png_memcpy(np, info_ptr->splt_palettes, @@ -971,18 +975,18 @@ png_sPLT_tp from = entries + i; png_uint_32 length; length = png_strlen(from->name) + 1; - to->name = (png_charp)png_malloc_warn(png_ptr, length); + to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length); if (to->name == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); continue; } png_memcpy(to->name, from->name, length); to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, - (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); + (png_size_t)(from->nentries * png_sizeof(png_sPLT_entry))); if (to->entries == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); @@ -1016,21 +1020,20 @@ if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) return; np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) * + (png_size_t)((info_ptr->unknown_chunks_num + num_unknowns) * png_sizeof(png_unknown_chunk))); if (np == NULL) { png_warning(png_ptr, - "Out of memory while processing unknown chunk."); + "Out of memory while processing unknown chunk"); return; } png_memcpy(np, info_ptr->unknown_chunks, info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; for (i = 0; i < num_unknowns; i++) { png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; @@ -1048,13 +1051,13 @@ to->data=NULL; else { to->data = (png_bytep)png_malloc_warn(png_ptr, - (png_uint_32)from->size); + (png_size_t)from->size); if (to->data == NULL) { png_warning(png_ptr, - "Out of memory while processing unknown chunk."); + "Out of memory while processing unknown chunk"); to->size = 0; } else png_memcpy(to->data, from->data, from->size); @@ -1076,25 +1079,8 @@ info_ptr->unknown_chunks[chunk].location = (png_byte)location; } #endif -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -void PNGAPI -png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) -{ - /* This function is deprecated in favor of png_permit_mng_features() - and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED."); - if (png_ptr == NULL) - return; - png_ptr->mng_features_permitted = (png_byte) - ((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) | - ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); -} -#endif -#endif #if defined(PNG_MNG_FEATURES_SUPPORTED) png_uint_32 PNGAPI png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) @@ -1133,9 +1119,9 @@ if (chunk_list == NULL) return; old_num_chunks = png_ptr->num_chunk_list; new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32) + (png_size_t) (5*(num_chunks + old_num_chunks))); if (png_ptr->chunk_list != NULL) { png_memcpy(new_list, png_ptr->chunk_list, @@ -1187,14 +1173,14 @@ #ifdef PNG_WRITE_SUPPORTED void PNGAPI png_set_compression_buffer_size(png_structp png_ptr, - png_uint_32 size) + png_size_t size) { if (png_ptr == NULL) return; png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf_size = (png_size_t)size; + png_ptr->zbuf_size = size; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } @@ -1207,34 +1193,8 @@ info_ptr->valid &= ~mask; } -#ifndef PNG_1_0_X -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* function was added to libpng 1.2.0 and should always exist by default */ -void PNGAPI -png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) -{ -/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ - if (png_ptr != NULL) - png_ptr->asm_flags = 0; - asm_flags = asm_flags; /* Quiet the compiler */ -} - -/* this function was added to libpng 1.2.0 */ -void PNGAPI -png_set_mmx_thresholds (png_structp png_ptr, - png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold) -{ -/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ - if (png_ptr == NULL) - return; - /* Quiet the compiler */ - mmx_bitdepth_threshold = mmx_bitdepth_threshold; - mmx_rowbytes_threshold = mmx_rowbytes_threshold; -} -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED /* this function was added to libpng 1.2.6 */ void PNGAPI @@ -1244,12 +1204,37 @@ /* Images with dimensions larger than these limits will be * rejected by png_set_IHDR(). To accept any PNG datastream * regardless of dimensions, set both limits to 0x7ffffffL. */ - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->user_width_max = user_width_max; png_ptr->user_height_max = user_height_max; } +/* this function was added to libpng 1.4.0 */ +void PNGAPI +png_set_chunk_cache_max (png_structp png_ptr, + png_uint_32 user_chunk_cache_max) +{ + if (png_ptr == NULL) + return; + png_ptr->user_chunk_cache_max = user_chunk_cache_max; + if (user_chunk_cache_max == 0x7fffffffL) /* Unlimited */ + png_ptr->user_chunk_cache_max = 0; + else + png_ptr->user_chunk_cache_max = user_chunk_cache_max + 1; +} #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -#endif /* ?PNG_1_0_X */ + +#if defined(PNG_BENIGN_ERRORS_SUPPORTED) +void PNGAPI +png_set_benign_errors(png_structp png_ptr, int allowed) +{ + png_debug(1, "in png_set_benign_errors"); + if (allowed) + png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; + else + png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN; +} +#endif /* PNG_BENIGN_ERRORS_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff -ru4NwbB libpng-1.2.35/pngtest.c libpng-1.4.0beta60/pngtest.c --- libpng-1.2.35/pngtest.c 2009-02-14 15:59:26.647524575 -0600 +++ libpng-1.4.0beta60/pngtest.c 2009-05-18 16:58:20.666353774 -0500 @@ -1,10 +1,10 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.2.32 [September 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) * * This program reads in a PNG image, writes it out again, and then @@ -28,37 +28,17 @@ * of files at once by typing "pngtest -m file1.png file2.png ..." */ #include "png.h" +#include "pngpriv.h" -#if defined(_WIN32_WCE) -# if _WIN32_WCE < 211 - __error__ (f|w)printf functions are not supported on old WindowsCE.; -# endif -# include -# include -# define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check, NULL)) check = 0 -# define WRITEFILE(file, data, length, check)) \ - if (WriteFile(file, data, length, &check, NULL)) check = 0 -# define FCLOSE(file) CloseHandle(file) -#else # include # include -# define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data, (png_size_t)1, length, file) -# define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data, (png_size_t)1, length, file) # define FCLOSE(file) fclose(file) -#endif #if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else typedef FILE * png_FILE_p; # endif -#endif /* Makes pngtest verbose so we can find problems (needs to be before png.h) */ #ifndef PNG_DEBUG # define PNG_DEBUG 0 @@ -114,19 +94,14 @@ static int status_dots_requested = 0; static int status_dots = 1; void -#ifdef PNG_1_0_X -PNGAPI -#endif read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); void -#ifdef PNG_1_0_X -PNGAPI -#endif read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) + return; if (status_pass != pass) { fprintf(stdout, "\n Pass %d: ", pass); status_pass = pass; @@ -141,37 +116,27 @@ fprintf(stdout, "r"); } void -#ifdef PNG_1_0_X -PNGAPI -#endif write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); void -#ifdef PNG_1_0_X -PNGAPI -#endif write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) + return; fprintf(stdout, "w"); } #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) /* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ + * but merely examine the row filters. We set this to 256 rather than + * 5 in case illegal filter values are present.) + */ static png_uint_32 filters_used[256]; void -#ifdef PNG_1_0_X -PNGAPI -#endif count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); void -#ifdef PNG_1_0_X -PNGAPI -#endif count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) { if (png_ptr != NULL && row_info != NULL) ++filters_used[*(data - 1)]; @@ -179,21 +144,16 @@ #endif #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) /* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ + * but merely count the zero samples) + */ static png_uint_32 zero_samples; void -#ifdef PNG_1_0_X -PNGAPI -#endif count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); void -#ifdef PNG_1_0_X -PNGAPI -#endif count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) { png_bytep dp = data; if (png_ptr == NULL)return; @@ -217,35 +176,39 @@ for (n = 0, nstop=row_info->width; nbit_depth == 1) { - if (((*dp << pos++ ) & 0x80) == 0) zero_samples++; + if (((*dp << pos++ ) & 0x80) == 0) + zero_samples++; if (pos == 8) { pos = 0; dp++; } } if (row_info->bit_depth == 2) { - if (((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; + if (((*dp << (pos+=2)) & 0xc0) == 0) + zero_samples++; if (pos == 8) { pos = 0; dp++; } } if (row_info->bit_depth == 4) { - if (((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; + if (((*dp << (pos+=4)) & 0xf0) == 0) + zero_samples++; if (pos == 8) { pos = 0; dp++; } } if (row_info->bit_depth == 8) - if (*dp++ == 0) zero_samples++; + if (*dp++ == 0) + zero_samples++; if (row_info->bit_depth == 16) { if ((*dp | *(dp+1)) == 0) zero_samples++; dp+=2; @@ -263,9 +226,10 @@ { for (channel = 0; channel < color_channels; channel++) { if (row_info->bit_depth == 8) - if (*dp++ == 0) zero_samples++; + if (*dp++ == 0) + zero_samples++; if (row_info->bit_depth == 16) { if ((*dp | *(dp+1)) == 0) zero_samples++; dp+=2; @@ -273,9 +237,10 @@ } if (row_info->color_type > 3) { dp++; - if (row_info->bit_depth == 16)dp++; + if (row_info->bit_depth == 16) + dp++; } } } } @@ -284,14 +249,15 @@ static int wrote_question = 0; #if defined(PNG_NO_STDIO) /* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ +/* These copies of the default read/write functions come from pngrio.c and + * pngwio.c. They allow "don't include stdio" testing of the library. + * This is the function that does the actual reading of data. If you are + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD static void pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) @@ -300,17 +266,17 @@ /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ - READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); + check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); if (check != length) { png_error(png_ptr, "Read Error!"); } } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -319,18 +285,18 @@ static void pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - int check; + png_size_t check; png_byte *n_data; png_FILE_p io_ptr; /* Check if data really is near. If so, use usual code. */ n_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)n_data == data) { - READFILE(io_ptr, n_data, length, check); + check = fread(n_data, 1, length, io_ptr); } else { png_byte buf[NEAR_BUF_SIZE]; @@ -339,9 +305,9 @@ remaining = length; do { read = MIN(NEAR_BUF_SIZE, remaining); - READFILE(io_ptr, buf, 1, err); + err = fread(buf, 1, 1, io_ptr); png_memcpy(data, buf, read); /* copy far buffer to near buffer */ if (err != read) break; else @@ -351,45 +317,40 @@ } while (remaining != 0); } if (check != length) - { png_error(png_ptr, "read Error"); } -} #endif /* USE_FAR_KEYWORD */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) static void pngtest_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif + /* Do nothing; fflush() is said to be just a waste of energy. */ + png_ptr = png_ptr; /* stifle compiler warning */ } #endif /* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD static void pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_uint_32 check; + png_size_t check; - WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check); + check = fwrite(data, 1, length, (png_FILE_p)png_ptr->io_ptr); if (check != length) { png_error(png_ptr, "Write Error"); } } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -398,18 +359,18 @@ static void pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_uint_32 check; + png_size_t check; png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ png_FILE_p io_ptr; /* Check if data really is near. If so, use usual code. */ near_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)near_data == data) { - WRITEFILE(io_ptr, near_data, length, check); + check = fwrite(near_data, 1, length, io_ptr); } else { png_byte buf[NEAR_BUF_SIZE]; @@ -419,9 +380,9 @@ do { written = MIN(NEAR_BUF_SIZE, remaining); png_memcpy(buf, data, written); /* copy far buffer to near buffer */ - WRITEFILE(io_ptr, buf, written, err); + err = fwrite(buf, 1, written, io_ptr); if (err != written) break; else check += err; @@ -460,27 +421,29 @@ pngtest_error(png_structp png_ptr, png_const_charp message) { pngtest_warning(png_ptr, message); /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ + * actually OK in this case. + */ } #endif /* PNG_NO_STDIO */ /* END of code to validate stdio-free compilation */ /* START of code to validate memory allocation and deallocation */ #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG /* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + * + * This piece of code can be compiled to validate max 64K allocations + * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. + */ typedef struct memory_information { - png_uint_32 size; + png_alloc_size_t size; png_voidp pointer; struct memory_information FAR *next; } memory_information; typedef memory_information FAR *memory_infop; @@ -490,17 +453,19 @@ static int maximum_allocation = 0; static int total_allocation = 0; static int num_allocations = 0; -png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size)); +png_voidp png_debug_malloc + PNGARG((png_structp png_ptr, png_alloc_size_t size)); void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); png_voidp -png_debug_malloc(png_structp png_ptr, png_uint_32 size) +png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) { /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ + * png_debug_malloc directly, with png_ptr == NULL which is OK + */ if (size == 0) return (NULL); @@ -510,26 +475,25 @@ /* Disable malloc_fn and free_fn */ memory_infop pinfo; png_set_mem_fn(png_ptr, NULL, NULL, NULL); pinfo = (memory_infop)png_malloc(png_ptr, - (png_uint_32)png_sizeof(*pinfo)); + png_sizeof(*pinfo)); pinfo->size = size; current_allocation += size; total_allocation += size; num_allocations ++; if (current_allocation > maximum_allocation) maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); + pinfo->pointer = png_malloc(png_ptr, size); /* Restore malloc_fn and free_fn */ png_set_mem_fn(png_ptr, - png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, - (png_free_ptr)png_debug_free); + NULL, png_debug_malloc, png_debug_free); if (size != 0 && pinfo->pointer == NULL) { current_allocation -= size; total_allocation -= size; png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc."); + "out of memory in pngtest->png_debug_malloc"); } pinfo->next = pinformation; pinformation = pinfo; /* Make sure the caller isn't assuming zeroed memory. */ @@ -595,9 +559,9 @@ /* Demonstration of user chunk support of the sTER and vpAg chunks */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* (sTER is a public chunk not yet understood by libpng. vpAg is a private +/* (sTER is a public chunk not yet known by libpng. vpAg is a private chunk used in ImageMagick to store "virtual page" size). */ static png_uint_32 user_chunk_data[4]; @@ -610,16 +574,16 @@ static int read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) { png_uint_32 - *user_chunk_data; - - /* Return one of the following: */ - /* return (-n); chunk had an error */ - /* return (0); did not recognize */ - /* return (n); success */ + *my_user_chunk_data; - /* The unknown chunk structure contains the chunk data: + /* Return one of the following: + * return (-n); chunk had an error + * return (0); did not recognize + * return (n); success + * + * The unknown chunk structure contains the chunk data: * png_byte name[5]; * png_byte *data; * png_size_t size; * @@ -633,12 +597,13 @@ if (chunk->size != 1) return (-1); /* Error return */ if (chunk->data[0] != 0 && chunk->data[0] != 1) return (-1); /* Invalid mode */ - user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); - user_chunk_data[0]=chunk->data[0]+1; + my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + my_user_chunk_data[0]=chunk->data[0]+1; return (1); } + if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ return (0); /* Did not recognize */ @@ -646,13 +611,13 @@ if (chunk->size != 9) return (-1); /* Error return */ - user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); - user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data); - user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4); - user_chunk_data[3]=(png_uint_32)chunk->data[8]; + my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data); + my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4); + my_user_chunk_data[3]=(png_uint_32)chunk->data[8]; return (1); } @@ -686,32 +651,19 @@ jmp_buf jmpbuf; #endif #endif -#if defined(_WIN32_WCE) - TCHAR path[MAX_PATH]; -#endif char inbuf[256], outbuf[256]; row_buf = NULL; -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else if ((fpin = fopen(inname, "rb")) == NULL) -#endif { fprintf(STDERR, "Could not find input file %s\n", inname); return (1); } -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE) -#else if ((fpout = fopen(outname, "wb")) == NULL) -#endif { fprintf(STDERR, "Could not open output file %s\n", outname); FCLOSE(fpin); return (1); @@ -719,15 +671,14 @@ png_debug(0, "Allocating read and write structures"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG read_ptr = - png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, + png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL, + NULL, NULL, NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else read_ptr = - png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); + png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); #endif #if defined(PNG_NO_STDIO) png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); @@ -744,15 +695,13 @@ #endif #ifdef PNG_WRITE_SUPPORTED #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG write_ptr = - png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, - (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); + png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, + NULL, NULL, NULL, png_debug_malloc, png_debug_free); #else write_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, - png_error_ptr_NULL, png_error_ptr_NULL); + png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); #endif #if defined(PNG_NO_STDIO) png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); @@ -840,11 +789,11 @@ } else { #ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL); + png_set_write_status_fn(write_ptr, NULL); #endif - png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL); + png_set_read_status_fn(read_ptr, NULL); } #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) { @@ -863,16 +812,16 @@ # ifndef PNG_HANDLE_CHUNK_ALWAYS # define PNG_HANDLE_CHUNK_ALWAYS 3 # endif png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - png_bytep_NULL, 0); + NULL, 0); #endif #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) # ifndef PNG_HANDLE_CHUNK_IF_SAFE # define PNG_HANDLE_CHUNK_IF_SAFE 2 # endif png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, - png_bytep_NULL, 0); + NULL, 0); #endif png_debug(0, "Reading info struct"); png_read_info(read_ptr, read_info_ptr); @@ -909,12 +858,10 @@ { png_fixed_point gamma; if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); } - } #endif #else /* Use floating point versions */ #if defined(PNG_FLOATING_POINT_SUPPORTED) #if defined(PNG_cHRM_SUPPORTED) @@ -933,12 +880,10 @@ { double gamma; if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { png_set_gAMA(write_ptr, write_info_ptr, gamma); } - } #endif #endif /* floating point */ #endif /* fixed point */ #if defined(PNG_iCCP_SUPPORTED) @@ -960,22 +905,18 @@ { int intent; if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { png_set_sRGB(write_ptr, write_info_ptr, intent); } - } #endif { png_colorp palette; int num_palette; if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); } - } #if defined(PNG_bKGD_SUPPORTED) { png_color_16p background; @@ -989,12 +930,10 @@ { png_uint_16p hist; if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { png_set_hIST(write_ptr, write_info_ptr, hist); } - } #endif #if defined(PNG_oFFs_SUPPORTED) { png_int_32 offset_x, offset_y; @@ -1027,22 +966,18 @@ png_uint_32 res_x, res_y; int unit_type; if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); } - } #endif #if defined(PNG_sBIT_SUPPORTED) { png_color_8p sig_bit; if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { png_set_sBIT(write_ptr, write_info_ptr, sig_bit); } - } #endif #if defined(PNG_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED { @@ -1090,10 +1025,11 @@ { png_set_tIME(write_ptr, write_info_ptr, mod_time); #if defined(PNG_TIME_RFC1123_SUPPORTED) /* we have to use png_memcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ + * pointed to by png_convert_to_rfc1123() gets free'ed before + * we use it. + */ png_memcpy(tIME_string, png_convert_to_rfc1123(read_ptr, mod_time), png_sizeof(tIME_string)); tIME_string[png_sizeof(tIME_string) - 1] = '\0'; @@ -1105,23 +1041,23 @@ #if defined(PNG_tRNS_SUPPORTED) { png_bytep trans; int num_trans; - png_color_16p trans_values; + png_color_16p trans_color; if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans, - &trans_values)) + &trans_color)) { int sample_max = (1 << read_info_ptr->bit_depth); /* libpng doesn't reject a tRNS chunk with out-of-range samples */ if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - (int)trans_values->gray > sample_max) || + (int)trans_color->gray > sample_max) || (read_info_ptr->color_type == PNG_COLOR_TYPE_RGB && - ((int)trans_values->red > sample_max || - (int)trans_values->green > sample_max || - (int)trans_values->blue > sample_max)))) + ((int)trans_color->red > sample_max || + (int)trans_color->green > sample_max || + (int)trans_color->blue > sample_max)))) png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); + trans_color); } } #endif #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) @@ -1134,10 +1070,11 @@ png_size_t i; png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, num_unknowns); /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ + * generated locations in write_info_ptr are wrong because we + * haven't written anything yet. + */ for (i = 0; i < (png_size_t)num_unknowns; i++) png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, unknowns[i].location); } @@ -1147,9 +1084,9 @@ #ifdef PNG_WRITE_SUPPORTED png_debug(0, "Writing info struct"); /* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); + * png_write_info_before_PLTE(write_ptr, write_info_ptr); */ png_write_info(write_ptr, write_info_ptr); #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) @@ -1160,9 +1097,9 @@ unsigned char ster_chunk_data[1]; if (verbose) - fprintf(STDERR, "stereo mode = %lu\n", + fprintf(STDERR, "\n stereo mode = %lu\n", (unsigned long)(user_chunk_data[0] - 1)); ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1); png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1); } @@ -1221,9 +1158,9 @@ png_get_rowbytes(read_ptr, read_info_ptr)); png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf, png_get_rowbytes(read_ptr, read_info_ptr)); #endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); + png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1); #ifdef PNG_WRITE_SUPPORTED #ifdef PNGTEST_TIMING t_stop = (float)clock(); @@ -1299,10 +1236,11 @@ png_size_t i; png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, num_unknowns); /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ + * generated locations in write_end_info_ptr are wrong because we + * haven't written the end_info yet. + */ for (i = 0; i < (png_size_t)num_unknowns; i++) png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, unknowns[i].location); } @@ -1317,9 +1255,9 @@ { png_uint_32 iwidth, iheight; iwidth = png_get_image_width(write_ptr, write_info_ptr); iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", + fprintf(STDERR, "\n Image width = %lu, height = %lu\n", (unsigned long)iwidth, (unsigned long)iheight); } #endif @@ -1342,25 +1280,15 @@ FCLOSE(fpin); FCLOSE(fpout); png_debug(0, "Opening files for comparison"); -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); - if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else if ((fpin = fopen(inname, "rb")) == NULL) -#endif { fprintf(STDERR, "Could not find file %s\n", inname); return (1); } -#if defined(_WIN32_WCE) - MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH); - if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) -#else if ((fpout = fopen(outname, "rb")) == NULL) -#endif { fprintf(STDERR, "Could not find file %s\n", outname); FCLOSE(fpin); return (1); @@ -1369,10 +1297,10 @@ for (;;) { png_size_t num_in, num_out; - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); + num_in = fread(inbuf, 1, 1, fpin); + num_out = fread(outbuf, 1, 1, fpout); if (num_in != num_out) { fprintf(STDERR, "\nFiles %s and %s are of a different size\n", @@ -1438,9 +1366,9 @@ { int multiple = 0; int ierror = 0; - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); fprintf(STDERR, "%s", png_get_copyright(NULL)); /* Show the version of libpng used in building the library */ fprintf(STDERR, " library (%lu):%s", @@ -1452,11 +1380,12 @@ fprintf(STDERR, " sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n", (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ + * not sure this matters, but it is nice to know, the first of these + * tests should be impossible because of the way the macros are set + * in pngconf.h + */ #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); #endif /* I think the following can happen. */ @@ -1526,9 +1455,9 @@ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) int k; #endif int kerror; - fprintf(STDERR, "Testing %s:", argv[i]); + fprintf(STDERR, "\n Testing %s:", argv[i]); kerror = test_one_file(argv[i], outname); if (kerror == 0) { #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) @@ -1596,9 +1525,9 @@ #endif if (i == 1) status_dots_requested = 1; else if (verbose == 0)status_dots_requested = 0; if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:", inname); + fprintf(STDERR, "\n Testing %s:", inname); kerror = test_one_file(inname, outname); if (kerror == 0) { if (verbose == 1 || i == 2) @@ -1627,9 +1556,9 @@ } else { if (verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:", inname); + fprintf(STDERR, "\n Testing %s:", inname); fprintf(STDERR, " FAIL\n"); ierror += kerror; } #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG diff -ru4NwbB libpng-1.2.35/pngtrans.c libpng-1.4.0beta60/pngtrans.c --- libpng-1.2.35/pngtrans.c 2009-02-14 15:59:26.654103109 -0600 +++ libpng-1.4.0beta60/pngtrans.c 2009-05-18 16:58:20.672799794 -0500 @@ -1,25 +1,26 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #include "png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) +#include "pngpriv.h" #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ +/* Turn on BGR-to-RGB mapping */ void PNGAPI png_set_bgr(png_structp png_ptr) { png_debug(1, "in png_set_bgr"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_BGR; } #endif @@ -28,9 +29,10 @@ void PNGAPI png_set_swap(png_structp png_ptr) { png_debug(1, "in png_set_swap"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } #endif @@ -40,9 +42,10 @@ void PNGAPI png_set_packing(png_structp png_ptr) { png_debug(1, "in png_set_packing"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; png_ptr->usr_bit_depth = 8; @@ -55,9 +58,10 @@ void PNGAPI png_set_packswap(png_structp png_ptr) { png_debug(1, "in png_set_packswap"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } #endif @@ -66,9 +70,10 @@ void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits) { png_debug(1, "in png_set_shift"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } #endif @@ -98,9 +103,10 @@ void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { png_debug(1, "in png_set_filler"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_FILLER; png_ptr->filler = (png_byte)filler; if (filler_loc == PNG_FILLER_AFTER) png_ptr->flags |= PNG_FLAG_FILLER_AFTER; @@ -125,19 +131,18 @@ png_ptr->usr_channels = 2; } } -#if !defined(PNG_1_0_X) /* Added to libpng-1.2.7 */ void PNGAPI png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { png_debug(1, "in png_set_add_alpha"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_set_filler(png_ptr, filler, filler_loc); png_ptr->transformations |= PNG_ADD_ALPHA; } -#endif #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ @@ -145,9 +150,10 @@ void PNGAPI png_set_swap_alpha(png_structp png_ptr) { png_debug(1, "in png_set_swap_alpha"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif @@ -156,9 +162,10 @@ void PNGAPI png_set_invert_alpha(png_structp png_ptr) { png_debug(1, "in png_set_invert_alpha"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif @@ -166,9 +173,10 @@ void PNGAPI png_set_invert_mono(png_structp png_ptr) { png_debug(1, "in png_set_invert_mono"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_INVERT_MONO; } /* invert monochrome grayscale data */ @@ -178,12 +186,8 @@ png_debug(1, "in png_do_invert"); /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row == NULL || row_info == NULL) - return; -#endif if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_bytep rp = row; png_uint_32 i; @@ -231,11 +235,8 @@ png_do_swap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_swap"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; @@ -356,17 +357,14 @@ 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF }; -/* swaps pixel packing order within bytes */ +/* Swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_packswap"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->bit_depth < 8) { png_bytep rp, end, table; @@ -388,16 +386,13 @@ #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ +/* Remove filler or alpha byte(s) */ void /* PRIVATE */ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { png_debug(1, "in png_do_strip_filler"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { png_bytep sp=row; png_bytep dp=row; png_uint_32 row_width=row_info->width; @@ -546,17 +541,14 @@ } #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ +/* Swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_bgr"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) @@ -630,9 +622,10 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { png_debug(1, "in png_set_user_transform_info"); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; @@ -651,9 +644,10 @@ */ png_voidp PNGAPI png_get_user_transform_ptr(png_structp png_ptr) { - if (png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) return ((png_voidp)png_ptr->user_transform_ptr); #else return (NULL); diff -ru4NwbB libpng-1.2.35/pngvcrd.c libpng-1.4.0beta60/pngvcrd.c --- libpng-1.2.35/pngvcrd.c 2009-02-14 15:59:26.658772901 -0600 +++ libpng-1.4.0beta60/pngvcrd.c 2009-05-18 16:58:20.673997205 -0500 @@ -1 +0,0 @@ -/* pnggvrd.c was removed from libpng-1.2.20. */ diff -ru4NwbB libpng-1.2.35/pngwio.c libpng-1.4.0beta60/pngwio.c --- libpng-1.2.35/pngwio.c 2009-02-27 17:50:49.640399946 -0600 +++ libpng-1.4.0beta60/pngwio.c 2009-05-18 16:58:20.682016337 -0500 @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.35 [February 14, 2009] + * Last changed in libpng 1.4.0 [May 18, 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) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,17 +14,18 @@ * functions, but rather write replacement functions and then change * them at run time with png_set_write_fn(...). */ -#define PNG_INTERNAL #include "png.h" #ifdef PNG_WRITE_SUPPORTED +#include "pngpriv.h" /* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ + * writes to a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered writes. This should never be asked + * to write more than 64K on a 16 bit machine. + */ void /* PRIVATE */ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { @@ -35,31 +36,27 @@ } #if !defined(PNG_NO_STDIO) /* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD void PNGAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_uint_32 check; if (png_ptr == NULL) return; -#if defined(_WIN32_WCE) - if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) - check = 0; -#else check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); -#endif if (check != length) png_error(png_ptr, "Write Error"); } #else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. +/* This is the model-independent version. Since the standard I/O library + * can't handle far buffers in the medium and small models, we have to copy + * the data. */ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) @@ -76,14 +73,9 @@ near_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)near_data == data) { -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) - check = 0; -#else check = fwrite(near_data, 1, length, io_ptr); -#endif } else { png_byte buf[NEAR_BUF_SIZE]; @@ -93,18 +85,15 @@ do { written = MIN(NEAR_BUF_SIZE, remaining); png_memcpy(buf, data, written); /* copy far buffer to near buffer */ -#if defined(_WIN32_WCE) - if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) - err = 0; -#else err = fwrite(buf, 1, written, io_ptr); -#endif if (err != written) break; + else check += err; + data += written; remaining -= written; } while (remaining != 0); @@ -116,10 +105,11 @@ #endif #endif /* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ + * to disk). After png_flush is called, there should be no data pending + * writing in any buffers. + */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) void /* PRIVATE */ png_flush(png_structp png_ptr) { @@ -130,48 +120,53 @@ #if !defined(PNG_NO_STDIO) void PNGAPI png_default_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) png_FILE_p io_ptr; -#endif - if (png_ptr == NULL) return; -#if !defined(_WIN32_WCE) + if (png_ptr == NULL) + return; io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL && fileno(io_ptr) != -1) fflush(io_ptr); -#endif } #endif #endif /* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ + * libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png output data structure + * io_ptr - pointer to user supplied structure containing info about + * the output functions. May be NULL. + * write_data_fn - pointer to a new output function that takes as its + * arguments a pointer to a png_struct, a pointer to + * data to be written, and a 32-bit unsigned int that is + * the number of bytes to be written. The new write + * function should call png_error(png_ptr, "Error msg") + * to exit and output any fatal error messages. May be + * NULL, in which case libpng's default function will + * be used. + * flush_data_fn - pointer to a new flush function that takes as its + * arguments a pointer to a png_struct. After a call to + * the flush function, there should be no data in any buffers + * or pending transmission. If the output method doesn't do + * any buffering of ouput, a function prototype must still be + * supplied although it doesn't have to do anything. If + * 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, 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) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->io_ptr = io_ptr; #if !defined(PNG_NO_STDIO) if (write_data_fn != NULL) @@ -199,9 +196,9 @@ png_ptr->read_data_fn = NULL; png_warning(png_ptr, "Attempted to set both read_data_fn and write_data_fn in"); png_warning(png_ptr, - "the same structure. Resetting read_data_fn to NULL."); + "the same structure. Resetting read_data_fn to NULL"); } } #if defined(USE_FAR_KEYWORD) diff -ru4NwbB libpng-1.2.35/pngwrite.c libpng-1.4.0beta60/pngwrite.c --- libpng-1.2.35/pngwrite.c 2009-02-14 15:59:26.671733647 -0600 +++ libpng-1.4.0beta60/pngwrite.c 2009-05-18 16:58:20.690078120 -0500 @@ -1,18 +1,18 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ /* get internal access to png.h */ -#define PNG_INTERNAL #include "png.h" #ifdef PNG_WRITE_SUPPORTED +#include "pngpriv.h" /* Writes all the PNG information. This is the suggested way to use the * library. If you have a new chunk to add, make a function to write it, * and put it in the correct location here. If you want the chunk written @@ -46,10 +46,11 @@ info_ptr->interlace_type); #else 0); #endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ + /* The rest of these check to see if the valid field has the appropriate + * flag set, and if it does, writes the chunk. + */ #if defined(PNG_WRITE_gAMA_SUPPORTED) if (info_ptr->valid & PNG_INFO_gAMA) { # ifdef PNG_FLOATING_POINT_SUPPORTED @@ -155,9 +156,9 @@ for (j=0; j<(int)info_ptr->num_trans; j++) info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); } #endif - png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), + png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_color), info_ptr->num_trans, info_ptr->color_type); } #endif #if defined(PNG_WRITE_bKGD_SUPPORTED) @@ -178,40 +179,47 @@ png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, info_ptr->pcal_units, info_ptr->pcal_params); #endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) + +#if defined(PNG_sCAL_SUPPORTED) if (info_ptr->valid & PNG_INFO_sCAL) +#if defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else +#else /* !FLOATING_POINT */ #ifdef PNG_FIXED_POINT_SUPPORTED png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_s_width, info_ptr->scal_s_height); -#else +#endif /* FIXED_POINT */ +#endif /* FLOATING_POINT */ +#else /* !WRITE_sCAL */ png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif + "png_write_sCAL not supported; sCAL chunk not written"); +#endif /* WRITE_sCAL */ +#endif /* sCAL */ + #if defined(PNG_WRITE_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif +#endif /* pHYs */ + #if defined(PNG_WRITE_tIME_SUPPORTED) if (info_ptr->valid & PNG_INFO_tIME) { png_write_tIME(png_ptr, &(info_ptr->mod_time)); png_ptr->mode |= PNG_WROTE_tIME; } -#endif +#endif /* tIME */ + #if defined(PNG_WRITE_sPLT_SUPPORTED) if (info_ptr->valid & PNG_INFO_sPLT) for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif +#endif /* sPLT */ + #if defined(PNG_WRITE_TEXT_SUPPORTED) /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { @@ -254,16 +262,18 @@ /* write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; #else + /* Can't get here */ png_warning(png_ptr, "Unable to write uncompressed text"); #endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } } -#endif +#endif /* tEXt */ + #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; @@ -395,21 +405,17 @@ png_write_IEND(png_ptr); /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, * and restored again in libpng-1.2.30, may cause some applications that * do not set png_ptr->output_flush_fn to crash. If your application - * experiences a problem, please try building libpng with - * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to - * png-mng-implement at lists.sf.net . This kludge will be removed - * from libpng-1.4.0. + * experiences a problem, please report the event to + * png-mng-implement at lists.sf.net . */ -#if defined(PNG_WRITE_FLUSH_SUPPORTED) && \ - defined(PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED) +#if defined(PNG_WRITE_FLUSH_SUPPORTED) png_flush(png_ptr); #endif } #if defined(PNG_WRITE_tIME_SUPPORTED) -#if !defined(_WIN32_WCE) /* "time.h" functions are not supported on WindowsCE */ void PNGAPI png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) { @@ -431,18 +437,18 @@ tbuf = gmtime(&ttime); png_convert_from_struct_tm(ptime, tbuf); } #endif -#endif + /* Initialize png_ptr structure, and allocate any memory needed */ png_structp PNGAPI png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); + warn_fn, NULL, NULL, NULL)); } /* Alternate initialize png_ptr structure, and allocate any memory needed */ png_structp PNGAPI @@ -450,8 +456,9 @@ png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ + int png_cleanup_needed = 0; #ifdef PNG_SETJMP_SUPPORTED volatile #endif png_structp png_ptr; @@ -477,22 +484,17 @@ png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif #ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then + encounter a png_error() will longjmp here. Since the jmpbuf is + then meaningless we abort instead of returning. */ #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else if (setjmp(png_ptr->jmpbuf)) #endif - { - png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; - png_destroy_struct(png_ptr); - return (NULL); - } -#ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); -#endif + PNG_ABORT(); #endif #ifdef PNG_USER_MEM_SUPPORTED png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); @@ -536,172 +538,48 @@ #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif - png_error(png_ptr, + png_warning(png_ptr, "Incompatible libpng version in application and library"); + png_cleanup_needed = 1; } } /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* Applications that neglect to set up their own setjmp() and then encounter - a png_error() will longjmp here. Since the jmpbuf is then meaningless we - abort instead of returning. */ -#ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) - PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); -#else - if (setjmp(png_ptr->jmpbuf)) - PNG_ABORT(); -#endif -#endif - return (png_ptr); -} - -/* Initialize png_ptr structure, and allocate any memory needed */ -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* Deprecated. */ -#undef png_write_init -void PNGAPI -png_write_init(png_structp png_ptr) + if (!png_cleanup_needed) { - /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0); -} - -void PNGAPI -png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size, png_size_t png_info_size) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if (png_ptr == NULL) return; -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if (png_sizeof(png_struct) > png_struct_size || - png_sizeof(png_info) > png_info_size) - { - char msg[80]; - png_ptr->warning_fn=NULL; - if (user_png_ver) - { - png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", - user_png_ver); - png_warning(png_ptr, msg); - } - png_snprintf(msg, 80, - "Application is running with png.c from libpng-%.20s", - png_libpng_ver); - png_warning(png_ptr, msg); - } -#endif - if (png_sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The png struct allocated by the application for writing is too small."); + png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr, + png_ptr->zbuf_size); + if (png_ptr->zbuf == NULL) + png_cleanup_needed = 1; } - if (png_sizeof(png_info) > png_info_size) + if (png_cleanup_needed) { - png_ptr->error_fn=NULL; -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; -#endif - png_error(png_ptr, - "The info struct allocated by the application for writing is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} -#endif /* PNG_1_0_X || PNG_1_2_X */ - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ -#endif - - int i = 0; - - if (png_ptr == NULL) - return; - - do - { - if (user_png_ver[i] != png_libpng_ver[i]) - { -#ifdef PNG_LEGACY_SUPPORTED - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + /* Clean up PNG structure and deallocate any memory. */ + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else - png_ptr->warning_fn=NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; -#endif - } - } while (png_libpng_ver[i++]); - - png_debug(1, "in png_write_init_3"); - -#ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); + png_destroy_struct((png_voidp)png_ptr); #endif - - if (png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; + return (NULL); } - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof(png_struct)); - - /* added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - png_ptr->user_width_max=PNG_USER_WIDTH_MAX; - png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); -#endif - - png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, - png_flush_ptr_NULL); - - /* initialize zbuf - compression buffer */ - png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); + png_set_write_fn(png_ptr, NULL, NULL, NULL); #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, png_doublep_NULL, png_doublep_NULL); + 1, NULL, NULL); #endif + + return (png_ptr); } + /* Write a few rows of image data. If the image is interlaced, * either you will have to write the 7 sub images, or, if you * have called png_set_interlace_handling(), you will have to * "write" the image seven times. @@ -740,9 +618,10 @@ png_debug(1, "in png_write_image"); #if defined(PNG_WRITE_INTERLACING_SUPPORTED) /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ + * this will set pass to 1 + */ num_pass = png_set_interlace_handling(png_ptr); #else num_pass = 1; #endif @@ -771,38 +650,38 @@ { /* make sure we wrote the header info */ if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) png_error(png_ptr, - "png_write_info was never called before png_write_row."); + "png_write_info was never called before png_write_row"); /* check for transforms that have been set but were defined out */ #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined"); #endif #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined"); #endif png_write_start_row(png_ptr); } @@ -884,28 +763,27 @@ png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth); png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ - png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, - png_ptr->row_info.rowbytes); + png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes); #if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ + /* Handle interlacing */ if (png_ptr->interlaced && png_ptr->pass < 6 && (png_ptr->transformations & PNG_INTERLACE)) { png_do_write_interlace(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ + /* This should always get caught above, but still ... */ if (!(png_ptr->row_info.width)) { png_write_finish_row(png_ptr); return; } } #endif - /* handle other transformations */ + /* Handle other transformations */ if (png_ptr->transformations) png_do_write_transformations(png_ptr); #if defined(PNG_MNG_FEATURES_SUPPORTED) @@ -998,9 +876,9 @@ png_flush(png_ptr); } #endif /* PNG_WRITE_FLUSH_SUPPORTED */ -/* free all memory used by the write */ +/* Free all memory used by the write */ void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) { png_structp png_ptr = NULL; @@ -1040,9 +918,8 @@ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; png_ptr->num_chunk_list = 0; } #endif } @@ -1111,9 +988,9 @@ png_free(png_ptr, png_ptr->inv_filter_costs); #endif #ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ + /* Reset structure */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); #endif error_fn = png_ptr->error_fn; @@ -1467,9 +1344,9 @@ { if (png_ptr == NULL || info_ptr == NULL) return; #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ + /* Invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) png_set_invert_alpha(png_ptr); #endif @@ -1478,9 +1355,9 @@ /* ------ these transformations don't touch the info structure ------- */ #if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ + /* Invert monochrome pixels */ if (transforms & PNG_TRANSFORM_INVERT_MONO) png_set_invert_mono(png_ptr); #endif @@ -1493,15 +1370,15 @@ png_set_shift(png_ptr, &info_ptr->sig_bit); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ + /* Pack pixels into bytes */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ + /* Swap location of alpha bytes from ARGB to RGBA */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif @@ -1513,28 +1390,28 @@ png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); #endif #if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ + /* Flip BGR pixels to RGB */ if (transforms & PNG_TRANSFORM_BGR) png_set_bgr(png_ptr); #endif #if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ + /* Swap bytes of 16-bit files to most significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) png_set_swap(png_ptr); #endif #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ + /* Swap bits of 1, 2, 4 bit packed pixel formats */ if (transforms & PNG_TRANSFORM_PACKSWAP) png_set_packswap(png_ptr); #endif /* ----------------------- end of transformations ------------------- */ - /* write the bits */ + /* Write the bits */ if (info_ptr->valid & PNG_INFO_IDAT) png_write_image(png_ptr, info_ptr->row_pointers); /* It is REQUIRED to call this to finish writing the rest of the file */ diff -ru4NwbB libpng-1.2.35/pngwtran.c libpng-1.4.0beta60/pngwtran.c --- libpng-1.2.35/pngwtran.c 2009-02-14 15:59:26.677940055 -0600 +++ libpng-1.4.0beta60/pngwtran.c 2009-05-18 16:58:20.696350730 -0500 @@ -1,17 +1,17 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.2.9 April 14, 2006 + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #include "png.h" #ifdef PNG_WRITE_SUPPORTED +#include "pngpriv.h" /* Transform the data according to the user's wishes. The order of * transformations is significant. */ @@ -87,11 +87,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { png_debug(1, "in png_do_pack"); if (row_info->bit_depth == 8 && -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif row_info->channels == 1) { switch ((int)bit_depth) { @@ -212,13 +209,9 @@ void /* PRIVATE */ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { png_debug(1, "in png_do_shift"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && -#else if ( -#endif row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; int channels = 0; @@ -336,11 +329,8 @@ void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_swap_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { /* This converts from ARGB to RGBA */ @@ -424,11 +414,8 @@ void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_invert_alpha"); -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL) -#endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { /* This inverts the alpha channel in RGBA */ @@ -515,11 +502,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_intrapixel"); if ( -#if defined(PNG_USELESS_TESTS_SUPPORTED) - row != NULL && row_info != NULL && -#endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; diff -ru4NwbB libpng-1.2.35/pngwutil.c libpng-1.4.0beta60/pngwutil.c --- libpng-1.2.35/pngwutil.c 2009-02-14 15:59:26.688440709 -0600 +++ libpng-1.4.0beta60/pngwutil.c 2009-05-18 16:58:20.707050669 -0500 @@ -1,17 +1,17 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.34 [December 18, 2008] + * Last changed in libpng 1.4.0 [May 18, 2009] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * 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.) */ -#define PNG_INTERNAL #include "png.h" #ifdef PNG_WRITE_SUPPORTED +#include "pngpriv.h" /* Place a 32-bit number into a buffer in PNG byte order. We work * with unsigned numbers for convenience, although one supported * ancillary chunk uses signed (two's complement) numbers. @@ -24,8 +24,9 @@ buf[2] = (png_byte)((i >> 8) & 0xff); buf[3] = (png_byte)(i & 0xff); } +#if defined(PNG_SAVE_INT_32_SUPPORTED) /* The png_save_int_32 function assumes integers are stored in two's * complement format. If this isn't the case, then this routine needs to * be modified to write data in two's complement format. */ @@ -36,8 +37,9 @@ buf[1] = (png_byte)((i >> 16) & 0xff); buf[2] = (png_byte)((i >> 8) & 0xff); buf[3] = (png_byte)(i & 0xff); } +#endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. @@ -54,14 +56,19 @@ * being embedded into another stream and doesn't need its own signature, * we should call png_set_sig_bytes() to tell libpng how many of the * bytes have already been written. */ -void /* PRIVATE */ +void PNGAPI png_write_sig(png_structp png_ptr) { png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ +#ifdef PNG_IO_STATE_SUPPORTED + /* inform the I/O callback that the signature is being written */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; +#endif + + /* Write the rest of the 8 byte signature */ png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], (png_size_t)(8 - png_ptr->sig_bytes)); if (png_ptr->sig_bytes < 3) png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; @@ -79,9 +86,10 @@ void PNGAPI png_write_chunk(png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length) { - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); png_write_chunk_data(png_ptr, data, (png_size_t)length); png_write_chunk_end(png_ptr); } @@ -95,21 +103,36 @@ png_uint_32 length) { png_byte buf[8]; +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk header is being written. + * PNG_IO_CHUNK_HDR requires a single I/O call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; +#endif + png_debug2(0, "Writing %s chunk, length = %lu", chunk_name, (unsigned long)length); - if (png_ptr == NULL) return; + if (png_ptr == NULL) + return; - /* write the length and the chunk name */ + /* Write the length and the chunk name */ png_save_uint_32(buf, length); png_memcpy(buf + 4, chunk_name, 4); png_write_data(png_ptr, buf, (png_size_t)8); - /* put the chunk name into png_ptr->chunk_name */ + /* Put the chunk name into png_ptr->chunk_name */ png_memcpy(png_ptr->chunk_name, chunk_name, 4); - /* reset the crc and run it over the chunk name */ + /* Reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); + png_calculate_crc(png_ptr, chunk_name, 4); + +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that chunk data will (possibly) be written. + * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; +#endif } /* Write the data of a PNG chunk started with png_write_chunk_start(). * Note that multiple calls to this function are allowed, and that the @@ -118,14 +141,15 @@ */ void PNGAPI png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) { - /* write the data, and run the CRC over it */ - if (png_ptr == NULL) return; + /* Write the data, and run the CRC over it */ + if (png_ptr == NULL) + return; if (data != NULL && length > 0) { png_write_data(png_ptr, data, length); - /* update the CRC after writing the data, + /* Update the CRC after writing the data, * in case that the user I/O routine alters it. */ png_calculate_crc(png_ptr, data, length); } @@ -138,17 +162,23 @@ png_byte buf[4]; if (png_ptr == NULL) return; - /* write the crc in a single operation */ +#ifdef PNG_IO_STATE_SUPPORTED + /* Inform the I/O callback that the chunk CRC is being written. + * PNG_IO_CHUNK_CRC requires a single I/O function call. + */ + png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; +#endif + + /* Write the crc in a single operation */ png_save_uint_32(buf, png_ptr->crc); png_write_data(png_ptr, buf, (png_size_t)4); } #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a +/* This pair of functions encapsulates the operation of (a) compressing a * text string, and (b) issuing it later as a series of chunk data writes. * The compression_state structure is shared context for these functions * set up by the caller in order to make the whole mess thread-safe. */ @@ -175,9 +205,9 @@ comp->output_ptr = NULL; comp->input = NULL; comp->input_len = 0; - /* we may just want to pass the text right through */ + /* We may just want to pass the text right through */ if (compression == PNG_TEXT_COMPRESSION_NONE) { comp->input = text; comp->input_len = text_len; @@ -185,9 +215,9 @@ } if (compression >= PNG_TEXT_COMPRESSION_LAST) { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) +#if !defined(PNG_NO_STDIO) char msg[50]; png_snprintf(msg, 50, "Unknown compression type %d", compression); png_warning(png_ptr, msg); #else @@ -209,15 +239,15 @@ * data, or if the input string is incredibly large (although this * wouldn't cause a failure, just a slowdown due to swapping). */ - /* set up the compression buffers */ + /* Set up the compression buffers */ png_ptr->zstream.avail_in = (uInt)text_len; png_ptr->zstream.next_in = (Bytef *)text; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - /* this is the same compression loop as in png_write_row() */ + /* This is the same compression loop as in png_write_row() */ do { /* compress the data */ ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); @@ -228,12 +258,12 @@ png_error(png_ptr, png_ptr->zstream.msg); else png_error(png_ptr, "zlib error"); } - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { - /* make sure the output array has room */ + /* Make sure the output array has room */ if (comp->num_output_ptr >= comp->max_output_ptr) { int old_max; @@ -244,47 +274,47 @@ png_charpp old_ptr; old_ptr = comp->output_ptr; comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32) + (png_alloc_size_t) (comp->max_output_ptr * png_sizeof(png_charpp))); png_memcpy(comp->output_ptr, old_ptr, old_max * png_sizeof(png_charp)); png_free(png_ptr, old_ptr); } else comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32) + (png_alloc_size_t) (comp->max_output_ptr * png_sizeof(png_charp))); } - /* save the data */ + /* Save the data */ comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); + (png_alloc_size_t)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); comp->num_output_ptr++; /* and reset the buffer */ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_out = png_ptr->zbuf; } - /* continue until we don't have any more to compress */ + /* Continue until we don't have any more to compress */ } while (png_ptr->zstream.avail_in); - /* finish the compression */ + /* Finish the compression */ do { - /* tell zlib we are finished */ + /* Tell zlib we are finished */ ret = deflate(&png_ptr->zstream, Z_FINISH); if (ret == Z_OK) { - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { - /* check to make sure our output array has room */ + /* Check to make sure our output array has room */ if (comp->num_output_ptr >= comp->max_output_ptr) { int old_max; @@ -296,24 +326,24 @@ old_ptr = comp->output_ptr; /* This could be optimized to realloc() */ comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * + (png_alloc_size_t)(comp->max_output_ptr * png_sizeof(png_charp))); png_memcpy(comp->output_ptr, old_ptr, old_max * png_sizeof(png_charp)); png_free(png_ptr, old_ptr); } else comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * + (png_alloc_size_t)(comp->max_output_ptr * png_sizeof(png_charp))); } - /* save off the data */ + /* Save the data */ comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, - (png_uint_32)png_ptr->zbuf_size); + (png_alloc_size_t)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); comp->num_output_ptr++; @@ -323,17 +353,17 @@ } } else if (ret != Z_STREAM_END) { - /* we got an error */ + /* We got an error */ if (png_ptr->zstream.msg != NULL) png_error(png_ptr, png_ptr->zstream.msg); else png_error(png_ptr, "zlib error"); } } while (ret != Z_STREAM_END); - /* text length is number of buffers plus last buffer */ + /* Text length is number of buffers plus last buffer */ text_len = png_ptr->zbuf_size * comp->num_output_ptr; if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; @@ -345,33 +375,31 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) { int i; - /* handle the no-compression case */ + /* Handle the no-compression case */ if (comp->input) { png_write_chunk_data(png_ptr, (png_bytep)comp->input, (png_size_t)comp->input_len); return; } - /* write saved output buffers, if any */ + /* Write saved output buffers, if any */ for (i = 0; i < comp->num_output_ptr; i++) { png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i], (png_size_t)png_ptr->zbuf_size); png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; } if (comp->max_output_ptr != 0) png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ + /* Write anything left in zbuf */ if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) png_write_chunk_data(png_ptr, png_ptr->zbuf, (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - /* reset zlib for another zTXt/iTXt or image data */ + /* Reset zlib for another zTXt/iTXt or image data */ deflateReset(&png_ptr->zstream); png_ptr->zstream.data_type = Z_BINARY; } #endif @@ -475,9 +503,9 @@ #else interlace_type=PNG_INTERLACE_NONE; #endif - /* save off the relevent information */ + /* Save the relevent information */ png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; #if defined(PNG_MNG_FEATURES_SUPPORTED) @@ -493,21 +521,21 @@ png_ptr->usr_width = png_ptr->width; png_ptr->usr_bit_depth = png_ptr->bit_depth; png_ptr->usr_channels = png_ptr->channels; - /* pack the header information into the buffer */ + /* Pack the header information into the buffer */ png_save_uint_32(buf, width); png_save_uint_32(buf + 4, height); buf[8] = (png_byte)bit_depth; buf[9] = (png_byte)color_type; buf[10] = (png_byte)compression_type; buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; - /* write the chunk */ + /* Write the chunk */ png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - /* initialize zlib with PNG info */ + /* Initialize zlib with PNG info */ png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; png_ptr->zstream.opaque = (voidpf)png_ptr; if (!(png_ptr->do_filter)) @@ -554,9 +582,9 @@ png_ptr->mode = PNG_HAVE_IHDR; } -/* write the palette. We are careful not to trust png_color to be in the +/* Write the palette. We are careful not to trust png_color to be in the * correct order for PNG, so people can redefine it to any convenient * structure. */ void /* PRIVATE */ @@ -621,9 +649,9 @@ png_write_chunk_end(png_ptr); png_ptr->mode |= PNG_HAVE_PLTE; } -/* write an IDAT chunk */ +/* Write an IDAT chunk */ void /* PRIVATE */ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -638,11 +666,13 @@ { unsigned int z_cmf = data[0]; /* zlib compression method and flags */ if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ + /* Avoid memory underflows and multiplication overflows. + * + * The conditions below are practically always satisfied; + * however, they still must be checked. + */ if (length >= 2 && png_ptr->height < 16384 && png_ptr->width < 16384) { png_uint_32 uncompressed_idat_size = png_ptr->height * @@ -673,23 +703,23 @@ png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); png_ptr->mode |= PNG_HAVE_IDAT; } -/* write an IEND chunk */ +/* Write an IEND chunk */ void /* PRIVATE */ png_write_IEND(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_IEND; #endif png_debug(1, "in png_write_IEND"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, + png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } #if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ +/* Write a gAMA chunk */ #ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ png_write_gAMA(png_structp png_ptr, double file_gamma) { @@ -723,9 +753,9 @@ #endif #endif #if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ +/* Write a sRGB chunk */ void /* PRIVATE */ png_write_sRGB(png_structp png_ptr, int srgb_intent) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -742,9 +772,9 @@ } #endif #if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ +/* Write an iCCP chunk */ void /* PRIVATE */ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, png_charp profile, int profile_len) { @@ -784,8 +814,9 @@ if (profile_len < embedded_profile_len) { png_warning(png_ptr, "Embedded profile length too large in iCCP chunk"); + png_free(png_ptr, new_name); return; } if (profile_len > embedded_profile_len) @@ -814,9 +845,9 @@ } #endif #if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ +/* Write a sPLT chunk */ void /* PRIVATE */ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -824,28 +855,27 @@ #endif png_size_t name_len; png_charp new_name; png_byte entrybuf[10]; - int entry_size = (spalette->depth == 8 ? 6 : 10); - int palette_size = entry_size * spalette->nentries; + png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); + png_size_t palette_size = entry_size * spalette->nentries; png_sPLT_entryp ep; #ifdef PNG_NO_POINTER_INDEXING int i; #endif png_debug(1, "in png_write_sPLT"); - if ((name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) + if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0) return; - /* make sure we include the NULL after the name */ + /* Make sure we include the NULL after the name */ png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, (png_uint_32)(name_len + 2 + palette_size)); png_write_chunk_data(png_ptr, (png_bytep)new_name, (png_size_t)(name_len + 1)); png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1); - /* loop through each palette entry, writing appropriately */ + /* Loop through each palette entry, writing appropriately */ #ifndef PNG_NO_POINTER_INDEXING for (ep = spalette->entries; epentries + spalette->nentries; ep++) { if (spalette->depth == 8) @@ -906,9 +936,9 @@ png_byte buf[4]; png_size_t size; png_debug(1, "in png_write_sBIT"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ + /* Make sure we don't depend upon the order of PNG_COLOR_8 */ if (color_type & PNG_COLOR_MASK_COLOR) { png_byte maxbits; @@ -1038,9 +1068,9 @@ #endif #endif #if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ +/* Write the tRNS chunk */ void /* PRIVATE */ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, int num_trans, int color_type) { @@ -1094,9 +1124,9 @@ } #endif #if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ +/* Write the background chunk */ void /* PRIVATE */ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -1147,9 +1177,9 @@ } #endif #if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ +/* Write the histogram */ void /* PRIVATE */ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -1221,9 +1251,9 @@ { if ((png_byte)*kp < 0x20 || ((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1)) { -#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) +#if !defined(PNG_NO_STDIO) char msg[40]; png_snprintf(msg, 40, "invalid keyword character 0x%02X", (png_byte)*kp); @@ -1293,9 +1323,8 @@ if (key_len == 0) { png_free(png_ptr, *new_key); - *new_key=NULL; png_warning(png_ptr, "Zero length keyword"); } if (key_len > 79) @@ -1309,9 +1338,9 @@ } #endif #if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ +/* Write a tEXt chunk */ void /* PRIVATE */ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len) { @@ -1349,9 +1378,9 @@ } #endif #if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ +/* Write a compressed text chunk */ void /* PRIVATE */ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len, int compression) { @@ -1385,33 +1414,33 @@ } text_len = png_strlen(text); - /* compute the compressed data; do it now for the length */ + /* Compute the compressed data; do it now for the length */ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp); - /* write start of chunk */ + /* Write start of chunk */ png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)(key_len+text_len + 2)); - /* write key */ + /* Write key */ png_write_chunk_data(png_ptr, (png_bytep)new_key, (png_size_t)(key_len + 1)); png_free(png_ptr, new_key); buf[0] = (png_byte)compression; - /* write compression */ + /* Write compression */ png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ + /* Write the compressed data */ png_write_compressed_data_out(png_ptr, &comp); - /* close the chunk */ + /* Close the chunk */ png_write_chunk_end(png_ptr); } #endif #if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ +/* Write an iTXt chunk */ void /* PRIVATE */ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, png_charp lang, png_charp lang_key, png_charp text) { @@ -1450,14 +1479,14 @@ text_len = 0; else text_len = png_strlen(text); - /* compute the compressed data; do it now for the length */ + /* Compute the compressed data; do it now for the length */ text_len = png_text_compress(png_ptr, text, text_len, compression-2, &comp); - /* make sure we include the compression flag, the compression byte, + /* Make sure we include the compression flag, the compression byte, * and the NULs after the key, lang, and lang_key parts */ png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, (png_uint_32)( @@ -1466,24 +1495,23 @@ + lang_len + lang_key_len + text_len)); - /* - * We leave it to the application to meet PNG-1.0 requirements on the + /* We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ png_write_chunk_data(png_ptr, (png_bytep)new_key, (png_size_t)(key_len + 1)); - /* set the compression flag */ + /* Set the compression flag */ if (compression == PNG_ITXT_COMPRESSION_NONE || \ compression == PNG_TEXT_COMPRESSION_NONE) cbuf[0] = 0; else /* compression == PNG_ITXT_COMPRESSION_zTXt */ cbuf[0] = 1; - /* set the compression method */ + /* Set the compression method */ cbuf[1] = 0; png_write_chunk_data(png_ptr, cbuf, (png_size_t)2); cbuf[0] = 0; @@ -1499,9 +1527,9 @@ } #endif #if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ +/* Write the oFFs chunk */ void /* PRIVATE */ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type) { @@ -1521,9 +1549,9 @@ png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); } #endif #if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ +/* Write the pCAL chunk (described in the PNG extensions document) */ void /* PRIVATE */ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) { @@ -1546,9 +1574,9 @@ png_debug1(3, "pCAL units length = %d", (int)units_len); total_len = purpose_len + units_len + 10; params_len = (png_uint_32p)png_malloc(png_ptr, - (png_uint_32)(nparams * png_sizeof(png_uint_32))); + (png_alloc_size_t)(nparams * png_sizeof(png_uint_32))); /* Find the length of each parameter, making sure we don't count the null terminator for the last parameter. */ for (i = 0; i < nparams; i++) @@ -1583,9 +1611,9 @@ } #endif #if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ +/* Write the sCAL chunk */ #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) void /* PRIVATE */ png_write_sCAL(png_structp png_ptr, int unit, double width, double height) { @@ -1597,29 +1625,12 @@ png_debug(1, "in png_write_sCAL"); buf[0] = (char)unit; -#if defined(_WIN32_WCE) -/* sprintf() function is not supported on WindowsCE */ - { - wchar_t wc_buf[32]; - size_t wc_len; - swprintf(wc_buf, TEXT("%12.12e"), width); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL); - total_len = wc_len + 2; - swprintf(wc_buf, TEXT("%12.12e"), height); - wc_len = wcslen(wc_buf); - WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len, - NULL, NULL); - total_len += wc_len; - } -#else png_snprintf(buf + 1, 63, "%12.12e", width); total_len = 1 + png_strlen(buf + 1) + 1; png_snprintf(buf + total_len, 64-total_len, "%12.12e", height); total_len += png_strlen(buf + total_len); -#endif png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); } @@ -1657,9 +1668,9 @@ #endif #endif #if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ +/* Write the pHYs chunk */ void /* PRIVATE */ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int unit_type) @@ -1712,26 +1723,26 @@ png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); } #endif -/* initializes the row writing capability of libpng */ +/* Initializes the row writing capability of libpng */ void /* PRIVATE */ png_write_start_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif #endif @@ -1740,55 +1751,60 @@ png_debug(1, "in png_write_start_row"); buf_size = (png_size_t)(PNG_ROWBYTES( png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1); - /* set up row buffer */ + /* Set up row buffer */ png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, - (png_uint_32)buf_size); + (png_alloc_size_t)buf_size); png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; #ifndef PNG_NO_WRITE_FILTER - /* set up filtering buffer, if using this filter */ + /* Set up filtering buffer, if using this filter */ if (png_ptr->do_filter & PNG_FILTER_SUB) { png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_ptr->rowbytes + 1)); + (png_alloc_size_t)(png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } /* We only need to keep the previous row if we are using one of these. */ if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { /* set up previous row buffer */ +#ifdef PNG_CALLOC_SUPPORTED + png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, + (png_alloc_size_t)buf_size); +#else png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); png_memset(png_ptr->prev_row, 0, buf_size); +#endif if (png_ptr->do_filter & PNG_FILTER_UP) { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_ptr->rowbytes + 1)); + (png_size_t)(png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } if (png_ptr->do_filter & PNG_FILTER_AVG) { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_ptr->rowbytes + 1)); + (png_alloc_size_t)(png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } if (png_ptr->do_filter & PNG_FILTER_PAETH) { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(png_ptr->rowbytes + 1)); + (png_size_t)(png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } } #endif /* PNG_NO_WRITE_FILTER */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ + /* If interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) { @@ -1818,20 +1834,20 @@ png_write_finish_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif #endif @@ -1840,14 +1856,14 @@ png_debug(1, "in png_write_finish_row"); /* next row */ png_ptr->row_number++; - /* see if we are done */ + /* See if we are done */ if (png_ptr->row_number < png_ptr->num_rows) return; #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ + /* If interlaced, go to next pass */ if (png_ptr->interlaced) { png_ptr->row_number = 0; if (png_ptr->transformations & PNG_INTERLACE) @@ -1855,9 +1871,9 @@ png_ptr->pass++; } else { - /* loop until we find a non-zero width or height pass */ + /* Loop until we find a non-zero width or height pass */ do { png_ptr->pass++; if (png_ptr->pass >= 7) @@ -1875,9 +1891,9 @@ } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); } - /* reset the row above the image for the next pass */ + /* Reset the row above the image for the next pass */ if (png_ptr->pass < 7) { if (png_ptr->prev_row != NULL) png_memset(png_ptr->prev_row, 0, @@ -1887,18 +1903,18 @@ } } #endif - /* if we get here, we've just written the last row, so we need + /* If we get here, we've just written the last row, so we need to flush the compressor */ do { - /* tell the compressor we are done */ + /* Tell the compressor we are done */ ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ + /* Check for an error */ if (ret == Z_OK) { - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); png_ptr->zstream.next_out = png_ptr->zbuf; @@ -1913,9 +1929,9 @@ png_error(png_ptr, "zlib error"); } } while (ret != Z_STREAM_END); - /* write any extra space */ + /* Write any extra space */ if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) { png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); @@ -1936,26 +1952,22 @@ void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif png_debug(1, "in png_do_write_interlace"); - /* we don't have to do anything on the last pass (6) */ -#if defined(PNG_USELESS_TESTS_SUPPORTED) - if (row != NULL && row_info != NULL && pass < 6) -#else + /* We don't have to do anything on the last pass (6) */ if (pass < 6) -#endif { - /* each pixel depth is handled separately */ + /* Each pixel depth is handled separately */ switch (row_info->pixel_depth) { case 1: { @@ -2064,29 +2076,29 @@ png_uint_32 i; png_uint_32 row_width = row_info->width; png_size_t pixel_bytes; - /* start at the beginning */ + /* Start at the beginning */ dp = row; - /* find out how many bytes each pixel takes up */ + /* Find out how many bytes each pixel takes up */ pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that + /* Loop through the row, only looking at the pixels that matter */ for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { - /* find out where the original pixel is */ + /* Find out where the original pixel is */ sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ + /* Move the pixel */ if (dp != sp) png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ + /* Next pixel */ dp += pixel_bytes; } break; } } - /* set new row width */ + /* Set new row width */ row_info->width = (row_info->width + png_pass_inc[pass] - 1 - png_pass_start[pass]) / png_pass_inc[pass]; @@ -2204,11 +2216,11 @@ #endif mins = sum; } - /* sub filter */ + /* Sub filter */ if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ + /* It's the only filter so no testing is needed */ { png_bytep rp, lp, dp; png_uint_32 i; for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; @@ -2321,9 +2333,9 @@ best_row = png_ptr->sub_row; } } - /* up filter */ + /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { png_bytep rp, dp, pp; png_uint_32 i; @@ -2424,9 +2436,9 @@ best_row = png_ptr->up_row; } } - /* avg filter */ + /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { png_bytep rp, dp, pp, lp; png_uint_32 i; @@ -2727,40 +2739,40 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) { png_debug(1, "in png_write_filtered_row"); png_debug1(2, "filter = %d", filtered_row[0]); - /* set up the zlib input buffer */ + /* Set up the zlib input buffer */ png_ptr->zstream.next_in = filtered_row; png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ + /* Repeat until we have compressed all the data */ do { - int ret; /* return of zlib */ + int ret; /* Return of zlib */ - /* compress the data */ + /* Compress the data */ ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ + /* Check for compression errors */ if (ret != Z_OK) { if (png_ptr->zstream.msg != NULL) png_error(png_ptr, png_ptr->zstream.msg); else png_error(png_ptr, "zlib error"); } - /* see if it is time to write another IDAT */ + /* See if it is time to write another IDAT */ if (!(png_ptr->zstream.avail_out)) { - /* write the IDAT and reset the zlib output buffer */ + /* Write the IDAT and reset the zlib output buffer */ png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } - /* repeat until all data has been compressed */ + /* Repeat until all data has been compressed */ } while (png_ptr->zstream.avail_in); - /* swap the current and previous rows */ + /* Swap the current and previous rows */ if (png_ptr->prev_row != NULL) { png_bytep tptr; @@ -2768,9 +2780,9 @@ png_ptr->prev_row = png_ptr->row_buf; png_ptr->row_buf = tptr; } - /* finish row - updates counters and flushes zlib if last row */ + /* Finish row - updates counters and flushes zlib if last row */ png_write_finish_row(png_ptr); #if defined(PNG_WRITE_FLUSH_SUPPORTED) png_ptr->flush_rows++; diff -ru4NwbB libpng-1.2.35/projects/visualc6/README.txt libpng-1.4.0beta60/projects/visualc6/README.txt --- libpng-1.2.35/projects/visualc6/README.txt 2009-02-14 15:59:28.223020487 -0600 +++ libpng-1.4.0beta60/projects/visualc6/README.txt 2009-05-18 16:58:22.540674593 -0500 @@ -30,13 +30,13 @@ This project builds the libpng binaries as follows: -* Win32_DLL_Release\libpng13.dll DLL build -* Win32_DLL_Debug\libpng13d.dll DLL build (debug version) -* Win32_DLL_ASM_Release\libpng13.dll DLL build using ASM code -* Win32_DLL_ASM_Debug\libpng13d.dll DLL build using ASM (debug version) -* Win32_DLL_VB\libpng13vb.dll DLL build for Visual Basic, using stdcall +* Win32_DLL_Release\libpng14.dll DLL build +* Win32_DLL_Debug\libpng14d.dll DLL build (debug version) +* Win32_DLL_ASM_Release\libpng14.dll DLL build using ASM code +* Win32_DLL_ASM_Debug\libpng14d.dll DLL build using ASM (debug version) +* Win32_DLL_VB\libpng14vb.dll DLL build for Visual Basic, using stdcall * Win32_LIB_Release\libpng.lib static build * Win32_LIB_Debug\libpngd.lib static build (debug version) * Win32_LIB_ASM_Release\libpng.lib static build using ASM code * Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) diff -ru4NwbB libpng-1.2.35/projects/visualc6/libpng.dsp libpng-1.4.0beta60/projects/visualc6/libpng.dsp --- libpng-1.2.35/projects/visualc6/libpng.dsp 2009-02-14 15:59:28.233298002 -0600 +++ libpng-1.4.0beta60/projects/visualc6/libpng.dsp 2009-05-18 16:58:22.550858072 -0500 @@ -49,9 +49,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "PNG_NO_MMX_CODE" /D "ZLIB_DLL" /D "_CRT_SECURE_NO_WARNINGS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -62,9 +62,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_Release\libpng14.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" !ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" # PROP BASE Use_MFC 0 @@ -80,9 +80,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "PNG_NO_MMX_CODE" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -93,9 +93,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" +# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\libpng14d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" !ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" # PROP BASE Use_MFC 0 @@ -111,9 +111,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -124,9 +124,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng13.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release" +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\libpng14.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release" !ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" # PROP BASE Use_MFC 0 @@ -142,9 +142,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -155,9 +155,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng13d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug" +# ADD LINK32 zlib1d.lib /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\libpng14d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug" !ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" # PROP BASE Use_MFC 0 @@ -173,9 +173,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -186,12 +186,12 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /dll /machine:I386 -# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng13vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" +# ADD LINK32 zlib1.lib /nologo /dll /machine:I386 /out:"Win32_DLL_VB\libpng14vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" # Begin Special Build Tool OutDir=.\Win32_DLL_VB -TargetName=libpng13vb +TargetName=libpng14vb SOURCE="$(InputPath)" PostBuild_Cmds=echo Deleting $(targetname) import library and export file (Not required for VB projects) del $(outdir)\$(targetname).lib del $(outdir)\$(targetname).exp # End Special Build Tool @@ -209,9 +209,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "PNG_NO_MMX_CODE" /D "WIN32" /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" @@ -236,9 +236,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "PNG_NO_MMX_CODE" /D PNG_DEBUG=1 /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -263,9 +263,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" @@ -290,9 +290,9 @@ # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -364,9 +364,44 @@ SOURCE=..\..\pngtrans.c # End Source File # Begin Source File -SOURCE=..\..\scripts\pngw32.def +SOURCE=..\..\pngvcrd.c + +!IF "$(CFG)" == "libpng - Win32 DLL Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug" + +!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" + +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release" + +!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\..\scripts\pngwin.def !IF "$(CFG)" == "libpng - Win32 DLL Release" !ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" @@ -425,15 +460,19 @@ # Begin Source File SOURCE=..\..\pngconf.h # End Source File +# Begin Source File + +SOURCE=..\..\pngpriv.h +# End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File -SOURCE=..\..\scripts\pngw32.rc +SOURCE=..\..\scripts\pngwin.rc !IF "$(CFG)" == "libpng - Win32 DLL Release" !ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" diff -ru4NwbB libpng-1.2.35/projects/visualc6/pngtest.dsp libpng-1.4.0beta60/projects/visualc6/pngtest.dsp --- libpng-1.2.35/projects/visualc6/pngtest.dsp 2009-02-14 15:59:28.252953603 -0600 +++ libpng-1.4.0beta60/projects/visualc6/pngtest.dsp 2009-05-18 16:58:22.560562850 -0500 @@ -57,9 +57,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_DLL_Release\libpng14.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Release\zlib1.lib /nologo /subsystem:console /machine:I386 # Begin Special Build Tool OutDir=.\Win32_DLL_Release SOURCE="$(InputPath)" PostBuild_Desc=[Run Test] @@ -89,9 +89,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_DLL_Debug\libpng14d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # Begin Special Build Tool OutDir=.\Win32_DLL_Debug SOURCE="$(InputPath)" PostBuild_Desc=[Run Test] @@ -121,9 +121,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_DLL_ASM_Release\libpng13.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Win32_DLL_ASM_Release\libpng14.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Release\zlib1.lib /nologo /subsystem:console /machine:I386 # Begin Special Build Tool OutDir=.\Win32_DLL_ASM_Release SOURCE="$(InputPath)" PostBuild_Desc=[Run Test] @@ -153,9 +153,9 @@ # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_DLL_ASM_Debug\libpng13d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Win32_DLL_ASM_Debug\libpng14d.lib ..\..\..\zlib\projects\visualc6\Win32_DLL_ASM_Debug\zlib1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # Begin Special Build Tool OutDir=.\Win32_DLL_ASM_Debug SOURCE="$(InputPath)" PostBuild_Desc=[Run Test] diff -ru4NwbB libpng-1.2.35/projects/visualc71/PRJ0041.mak libpng-1.4.0beta60/projects/visualc71/PRJ0041.mak --- libpng-1.2.35/projects/visualc71/PRJ0041.mak 2004-11-29 03:16:32.000000000 -0600 +++ libpng-1.4.0beta60/projects/visualc71/PRJ0041.mak 2006-08-15 14:08:14.000000000 -0500 @@ -1,6 +1,6 @@ # Prevent "Cannot find missing dependency..." warnings while compiling -# pngw32.rc (PRJ0041). +# pngwin.rc (PRJ0041). all: $(IntDir)\alloc.h \ $(IntDir)\fp.h \ $(IntDir)\m68881.h \ diff -ru4NwbB libpng-1.2.35/projects/visualc71/libpng.vcproj libpng-1.4.0beta60/projects/visualc71/libpng.vcproj --- libpng-1.2.35/projects/visualc71/libpng.vcproj 2007-09-02 19:16:28.000000000 -0500 +++ libpng-1.4.0beta60/projects/visualc71/libpng.vcproj 2006-08-15 14:10:31.000000000 -0500 @@ -17,9 +17,9 @@ + ModuleDefinitionFile="..\..\scripts\pngwin.def"/> @@ -42,9 +42,9 @@ @@ -65,9 +65,9 @@ @@ -113,9 +113,9 @@ + ModuleDefinitionFile="..\..\scripts\pngwin.def"/> @@ -139,9 +139,9 @@ Name="VCPreLinkEventTool"/> @@ -162,9 +162,9 @@ @@ -211,9 +211,9 @@ @@ -259,9 +259,9 @@ + RelativePath="..\..\pngvcrd.c"> + + + + + + + + + + + + + + + + + + + + RelativePath="..\..\scripts\pngwin.rc"> $@ $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) @@ -175,9 +166,9 @@ pngtest.pic.o: pngtest.c $(CC) $(CFLAGS) -c $< -o $@ -pngtest.o: pngtest.c +pngtest.o: pngtest.c png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) -c $< -o $@ test: test-static test-shared @@ -275,25 +266,25 @@ .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c +png.o png.pic.o: png.h pngconf.h pngpriv.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h pngpread.c -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c +pngtest.o: png.h pngconf.h pngpriv.h pngtest.c +pngtest-stat.o: png.h pngconf.h pngpriv.h pngtest.c diff -ru4NwbB libpng-1.2.35/scripts/makefile.darwin libpng-1.4.0beta60/scripts/makefile.darwin --- libpng-1.2.35/scripts/makefile.darwin 2009-02-14 15:59:28.011524301 -0600 +++ libpng-1.4.0beta60/scripts/makefile.darwin 2009-05-18 16:58:22.324118180 -0500 @@ -17,9 +17,9 @@ ZLIBINC=../zlib # Library name: LIBNAME = libpng%N% -PNGMAJ = 12 +PNGMAJ = %N% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -37,9 +37,9 @@ LN_SF=ln -sf RANLIB=ranlib RM_F=/bin/rm -f -# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE +# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops LDFLAGS=-L. -L$(ZLIBLIB) -lpng%N% -lz INCPATH=$(prefix)/include @@ -214,21 +214,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.dec libpng-1.4.0beta60/scripts/makefile.dec --- libpng-1.2.35/scripts/makefile.dec 2009-02-14 15:59:28.021114317 -0600 +++ libpng-1.4.0beta60/scripts/makefile.dec 2009-05-18 16:58:22.333777841 -0500 @@ -3,9 +3,9 @@ # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h # Library name: -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng%N% @@ -194,21 +194,21 @@ libpng.pc # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.dj2 libpng-1.4.0beta60/scripts/makefile.dj2 --- libpng-1.2.35/scripts/makefile.dj2 2002-04-19 18:53:16.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.dj2 2009-05-02 07:08:26.556046000 -0500 @@ -1,6 +1,6 @@ # DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h # where make install will put libpng.a and png.h @@ -35,21 +35,21 @@ rm -f *.o libpng.a pngtest pngout.png # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.elf libpng-1.4.0beta60/scripts/makefile.elf --- libpng-1.2.35/scripts/makefile.elf 2009-02-14 15:59:28.031106285 -0600 +++ libpng-1.4.0beta60/scripts/makefile.elf 2009-05-18 16:58:22.343710139 -0500 @@ -11,9 +11,9 @@ # * versioned symbols # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -256,21 +256,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.freebsd libpng-1.4.0beta60/scripts/makefile.freebsd --- libpng-1.2.35/scripts/makefile.freebsd 2007-06-20 17:10:26.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.freebsd 2009-05-18 16:58:22.085577942 -0500 @@ -1,10 +1,10 @@ # makefile for libpng under FreeBSD -# Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov +# Copyright (C) 2002, 2007, 2009 Glenn Randers-Pehrson and Andrey A. Chernov # For conditions of distribution and use, see copyright notice in png.h PREFIX?= /usr/local -SHLIB_VER?= 5 +SHLIB_VER?= %SONUM% LIB= png SHLIB_MAJOR= ${SHLIB_VER} SHLIB_MINOR= 0 @@ -13,9 +13,9 @@ # where make install puts libpng.a and png.h DESTDIR= ${PREFIX} LIBDIR= /lib -INCS= png.h pngconf.h +INCS= png.h pngconf.h pngpriv.h INCSDIR= /include/libpng INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk MAN= libpng.3 libpngpf.3 png.5 MANDIR= /man/man @@ -24,11 +24,8 @@ LDADD+= -lm -lz DPADD+= ${LIBM} ${LIBZ} CFLAGS+= -I. -.if (${MACHINE_ARCH} != "i386") -CFLAGS+= -DPNG_NO_MMX_CODE -.endif SRCS= 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 -ru4NwbB libpng-1.2.35/scripts/makefile.gcc libpng-1.4.0beta60/scripts/makefile.gcc --- libpng-1.2.35/scripts/makefile.gcc 2008-08-02 07:20:59.850809000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.gcc 2009-05-02 07:46:38.672645000 -0500 @@ -60,21 +60,21 @@ clean: $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h +pngerror$(O): png.h pngconf.h pngpriv.h +pngget$(O): png.h pngconf.h pngpriv.h +pngmem$(O): png.h pngconf.h pngpriv.h +pngpread$(O): png.h pngconf.h pngpriv.h +pngread$(O): png.h pngconf.h pngpriv.h +pngrio$(O): png.h pngconf.h pngpriv.h +pngrtran$(O): png.h pngconf.h pngpriv.h +pngrutil$(O): png.h pngconf.h pngpriv.h +pngset$(O): png.h pngconf.h pngpriv.h +pngtrans$(O): png.h pngconf.h pngpriv.h +pngwio$(O): png.h pngconf.h pngpriv.h +pngwrite$(O): png.h pngconf.h pngpriv.h +pngwtran$(O): png.h pngconf.h pngpriv.h +pngwutil$(O): png.h pngconf.h pngpriv.h +pngtest$(O): png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.gcmmx libpng-1.4.0beta60/scripts/makefile.gcmmx --- libpng-1.2.35/scripts/makefile.gcmmx 2009-02-14 15:59:28.041236003 -0600 +++ libpng-1.4.0beta60/scripts/makefile.gcmmx 1969-12-31 18:00:00.000000000 -0600 @@ -1,271 +0,0 @@ -# makefile for libpng.a and libpng%N%.so on Linux ELF with gcc using MMX -# assembler code -# Copyright 2002, 2006, 2008 Greg Roelofs and Glenn Randers-Pehrson -# Copyright 1998-2001 Greg Roelofs -# Copyright 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. - -# NOTE: When testing MMX performance on a multitasking system, make sure -# there are no floating-point programs (e.g., SETI@Home) running in -# the background! Context switches between MMX and FPU are expensive. - -# Library name: -LIBNAME = libpng%N% -PNGMAJ = 0 -PNGMIN = 1.4.0beta60 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.%OLDNUM% -OLDSOVER=libpng.so.%OLDNUM%.$(PNGMIN) - -# Utilities: -CC = gcc -LD = $(CC) -AR_RC = ar rc -LN_SF = ln -sf -MKDIR_P = mkdir -p -RANLIB = ranlib -RM_F = /bin/rm -f - -# where "make install" puts libpng%N%.a, libpng%N%.so*, -# libpng%N%/png.h and libpng%N%/pngconf.h -# Prefix must be a full pathname. -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located. -#ZLIBLIB=/usr/local/lib -#ZLIBINC=/usr/local/include -ZLIBLIB=../zlib -ZLIBINC=../zlib - -ALIGN= -# for i386: -#ALIGN=-malign-loops=2 -malign-functions=2 - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion - -# for pgcc version 2.95.1, -O3 is buggy; don't use it. - -# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety -### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ - $(ALIGN) -funroll-loops \ - -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 -### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ -# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer -### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ -# -m486 -malign-double -ffast-math \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer - -LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm -LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm - - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ - -e s!@exec_prefix@!$(exec_prefix)! \ - -e s!@libdir@!$(LIBPATH)! \ - -e s!@includedir@!$(INCPATH)! \ - -e s!-lpng%N%!-lpng%N%\ -lz\ -lm! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_THREAD_UNSAFE_OK \"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ - echo libs=\"-lpng%N% -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ - -o $(LIBSOVER) \ - $(OBJSDLL) - -$(OLDSOVER): $(OBJSDLL) - $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \ - -o $(OLDSOVER) \ - $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -pngtest-static: pngtest.o libpng.a - $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) - -test: pngtest pngtest-static - @echo "" - @echo " Running pngtest dynamically linked with $(LIBSO):" - @echo "" - ./pngtest - @echo "" - @echo " Running pngtest statically linked with libpng.a:" - @echo "" - ./pngtest-static - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ - $(LN_SF) $(LIBSOMAJ) $(LIBSO)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c diff -ru4NwbB libpng-1.2.35/scripts/makefile.hp64 libpng-1.4.0beta60/scripts/makefile.hp64 --- libpng-1.2.35/scripts/makefile.hp64 2009-02-14 15:59:28.050927484 -0600 +++ libpng-1.4.0beta60/scripts/makefile.hp64 2009-05-18 16:58:22.353445405 -0500 @@ -1,6 +1,6 @@ # makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002 Glenn Randers-Pehrson +# Copyright (C) 1999-2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42 # contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard # For conditions of distribution and use, see copyright notice in png.h @@ -16,9 +16,9 @@ # SHAREDLIB=libz.sl # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -216,20 +216,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h + +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.hpgcc libpng-1.4.0beta60/scripts/makefile.hpgcc --- libpng-1.2.35/scripts/makefile.hpgcc 2009-02-14 15:59:28.060641515 -0600 +++ libpng-1.4.0beta60/scripts/makefile.hpgcc 2009-05-18 16:58:22.363351577 -0500 @@ -6,9 +6,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -225,21 +225,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.hpux libpng-1.4.0beta60/scripts/makefile.hpux --- libpng-1.2.35/scripts/makefile.hpux 2009-02-14 15:59:28.070333928 -0600 +++ libpng-1.4.0beta60/scripts/makefile.hpux 2009-05-18 16:58:22.374801166 -0500 @@ -16,9 +16,9 @@ # SHAREDLIB=libz.sl # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -44,9 +44,9 @@ LIBPATH=$(exec_prefix)/lib MANPATH=$(prefix)/man BINPATH=$(exec_prefix)/bin -CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 -DPNG_NO_MMX_CODE +CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 # Caution: be sure you have built zlib with the same CFLAGS. CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm @@ -213,20 +213,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h + +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.ibmc libpng-1.4.0beta60/scripts/makefile.ibmc --- libpng-1.2.35/scripts/makefile.ibmc 2001-06-11 08:06:30.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.ibmc 2009-05-02 05:47:47.873563000 -0500 @@ -1,6 +1,7 @@ # Makefile for libpng (static) # IBM C version 3.x for Win32 and OS/2 +# Copyright (C) 2006 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta # For conditions of distribution and use, see copyright notice in png.h # Notes: # Derived from makefile.std @@ -52,20 +53,21 @@ $(RM) libpng$(A) $(RM) pngtest$(E) $(RM) pngout.png -png$(O): png.h pngconf.h -pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h -pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h -pngrtran$(O): png.h pngconf.h -pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h -pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h -pngwrite$(O): png.h pngconf.h -pngwtran$(O): png.h pngconf.h -pngwutil$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h +pngerror$(O): png.h pngconf.h pngpriv.h +pngget$(O): png.h pngconf.h pngpriv.h +pngmem$(O): png.h pngconf.h pngpriv.h +pngpread$(O): png.h pngconf.h pngpriv.h +pngread$(O): png.h pngconf.h pngpriv.h +pngrio$(O): png.h pngconf.h pngpriv.h +pngrtran$(O): png.h pngconf.h pngpriv.h +pngrutil$(O): png.h pngconf.h pngpriv.h +pngset$(O): png.h pngconf.h pngpriv.h +pngtrans$(O): png.h pngconf.h pngpriv.h +pngwio$(O): png.h pngconf.h pngpriv.h +pngwrite$(O): png.h pngconf.h pngpriv.h +pngwtran$(O): png.h pngconf.h pngpriv.h +pngwutil$(O): png.h pngconf.h pngpriv.h + +pngtest$(O): png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.intel libpng-1.4.0beta60/scripts/makefile.intel --- libpng-1.2.35/scripts/makefile.intel 2007-09-01 09:31:06.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.intel 2009-05-02 07:55:41.452054000 -0500 @@ -1,13 +1,15 @@ # Makefile for libpng # Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later +# Copyright (C) 2006 Glenn Randers-Pehrson # Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is # copyright 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h # To use, do "nmake /f scripts\makefile.intel" +# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- # Where the zlib library and include files are located ZLIBLIB=..\zlib ZLIBINC=..\zlib @@ -39,54 +40,51 @@ pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) all: test -png$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - -pngset$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngget$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngread$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngpread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrtran$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrutil$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngerror$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngmem$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrio$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtrans$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwrite$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwtran$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) libpng.lib: $(OBJS) if exist libpng.lib del libpng.lib @@ -94,8 +92,11 @@ pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib +pngtest$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + test: pngtest.exe pngtest.exe diff -ru4NwbB libpng-1.2.35/scripts/makefile.knr libpng-1.4.0beta60/scripts/makefile.knr --- libpng-1.2.35/scripts/makefile.knr 2006-02-25 06:37:26.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.knr 2009-05-02 07:07:23.659665000 -0500 @@ -1,6 +1,6 @@ # makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # For conditions of distribution and use, see copyright notice in png.h # This makefile requires the file ansi2knr.c, which you can get @@ -57,9 +57,9 @@ test: pngtest ./pngtest -install: libpng.a +install: libpng.a png.h pngconf.h -@mkdir $(DESTDIR)$(INCPATH) -@mkdir $(DESTDIR)$(INCPATH)/libpng -@mkdir $(DESTDIR)$(LIBPATH) -@rm -f $(DESTDIR)$(INCPATH)/png.h @@ -80,20 +80,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h + pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.linux libpng-1.4.0beta60/scripts/makefile.linux --- libpng-1.2.35/scripts/makefile.linux 2009-02-14 15:59:28.080004256 -0600 +++ libpng-1.4.0beta60/scripts/makefile.linux 2009-05-18 16:58:22.386603769 -0500 @@ -5,9 +5,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -47,9 +47,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm @@ -230,21 +230,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.mingw libpng-1.4.0beta60/scripts/makefile.mingw --- libpng-1.2.35/scripts/makefile.mingw 2009-02-14 15:59:28.090396724 -0600 +++ libpng-1.4.0beta60/scripts/makefile.mingw 2009-05-18 16:58:22.398875676 -0500 @@ -57,23 +57,14 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -### if you don't need thread safety, but want the asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ -# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### if you need thread safety and want (minimal) asm accel -#CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ -# -W -Wall -O $(ALIGN) -funroll-loops \ -# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 -### Normal (non-asm) compilation CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ + -W -Wall -O3 $(ALIGN) -funroll-loops \ -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% MINGDLL = %N% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) @@ -156,9 +147,9 @@ $(STATLIB): $(OBJS) $(AR) rc $@ $(OBJS) $(RANLIB) $@ -$(SHAREDDEF): scripts/pngw32.def +$(SHAREDDEF): scripts/pngwin.def cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ sed -e 's/\([^;]*\);/;/' > $@ $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) @@ -266,24 +257,21 @@ .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h png.c -pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c -pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c -pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c -pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c -pngset.o pngset.pic.o: png.h pngconf.h pngset.c -pngget.o pngget.pic.o: png.h pngconf.h pngget.c -pngread.o pngread.pic.o: png.h pngconf.h pngread.c -pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c -pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c -pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c -pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c -pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c -pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c -pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c - -pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c - - +png.o png.pic.o: png.h pngconf.h pngpriv.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h pngpread.c +pngtest.o pngtest.pic.o: png.h pngconf.h pngpriv.h pngtest.c diff -ru4NwbB libpng-1.2.35/scripts/makefile.mips libpng-1.4.0beta60/scripts/makefile.mips --- libpng-1.2.35/scripts/makefile.mips 2006-02-25 06:37:32.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.mips 2009-05-02 05:30:00.631520000 -0500 @@ -64,20 +64,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngpread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h + pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.msc libpng-1.4.0beta60/scripts/makefile.msc --- libpng-1.2.35/scripts/makefile.msc 2001-01-05 18:24:59.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.msc 2009-05-02 06:57:59.382276000 -0500 @@ -1,6 +1,7 @@ # makefile for libpng # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. +# Copyright (C) 2006, 2009 Glenn Randers-Pehrson # For conditions of distribution and use, see copyright notice in png.h # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # -------- Microsoft C 5.1 and later, does not use assembler code -------- @@ -21,62 +22,62 @@ OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) all: libpng.lib -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngset$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngget$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngpread$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrtran$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrutil$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngerror$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngmem$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtrans$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) del libpng.lib lib libpng $(OBJS1); lib libpng $(OBJS2); lib libpng $(OBJS3); +pngtest$(O): png.h pngconf.h pngpriv.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; test: pngtest.exe diff -ru4NwbB libpng-1.2.35/scripts/makefile.ne12bsd libpng-1.4.0beta60/scripts/makefile.ne12bsd --- libpng-1.2.35/scripts/makefile.ne12bsd 2009-02-14 15:59:28.099015609 -0600 +++ libpng-1.4.0beta60/scripts/makefile.ne12bsd 2009-05-18 16:58:22.409225646 -0500 @@ -1,9 +1,9 @@ # makefile for libpng for NetBSD for the standard # make obj && make depend && make && make test # make includes && make install # Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson +# Copyright (C) 2007, 2009 Glenn Randers-Pehrson # For conditions of distribution and use, see copyright notice in png.h # You should also run makefile.netbsd @@ -11,9 +11,9 @@ LIBDIR= ${LOCALBASE}/lib MANDIR= ${LOCALBASE}/man INCSDIR=${LOCALBASE}/include/libpng%N% -LIB= png12 +LIB= png%N% SHLIB_MAJOR= 0 SHLIB_MINOR= 1.4.0beta60 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ @@ -22,14 +22,12 @@ MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} -# something like this for mmx assembler, but it core dumps for me at the moment +# We should be able to do something like this instead of the manual +# uncommenting, but it core dumps for me at the moment: # .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK # MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE # .endif CLEANFILES+=pngtest.o pngtest diff -ru4NwbB libpng-1.2.35/scripts/makefile.netbsd libpng-1.4.0beta60/scripts/makefile.netbsd --- libpng-1.2.35/scripts/makefile.netbsd 2009-02-14 15:59:28.107535222 -0600 +++ libpng-1.4.0beta60/scripts/makefile.netbsd 2009-05-18 16:58:22.419316350 -0500 @@ -1,9 +1,9 @@ # makefile for libpng for NetBSD for the standard # make obj && make depend && make && make test # make includes && make install # Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson +# Copyright (C) 2007, 2009 Glenn Randers-Pehrson # For conditions of distribution and use, see copyright notice in png.h # You should also run makefile.ne0bsd @@ -22,14 +22,12 @@ MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} -# something like this for mmx assembler, but it core dumps for me at the moment +# We should be able to do something like this instead of the manual +# uncommenting, but it core dumps for me at the moment: # .if ${MACHINE_ARCH} == "i386" -# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK # MKLINT= no -# .else - CPPFLAGS+=-DPNG_NO_MMX_CODE # .endif CLEANFILES+=pngtest.o pngtest diff -ru4NwbB libpng-1.2.35/scripts/makefile.nommx libpng-1.4.0beta60/scripts/makefile.nommx --- libpng-1.2.35/scripts/makefile.nommx 2009-02-14 15:59:28.117117151 -0600 +++ libpng-1.4.0beta60/scripts/makefile.nommx 2009-05-18 16:58:22.430587119 -0500 @@ -5,9 +5,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -47,9 +47,9 @@ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm @@ -97,14 +97,13 @@ -e s!@libdir@!$(LIBPATH)! \ -e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \ -e s!-lpng%N%!-lpng%N%\ -lz\ -lm! \ - -e s!Cflags: !Cflags:\ -DPNG_NO_MMX_CODE!> libpng.pc libpng-config: ( cat scripts/libpng-config-head.in; \ echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \ + echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \ echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ echo libs=\"-lpng%N% -lz -lm\"; \ cat scripts/libpng-config-body.in ) > libpng-config @@ -232,21 +231,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h pngpread.c -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h pngtest.c diff -ru4NwbB libpng-1.2.35/scripts/makefile.openbsd libpng-1.4.0beta60/scripts/makefile.openbsd --- libpng-1.2.35/scripts/makefile.openbsd 2009-02-14 15:59:28.125971910 -0600 +++ libpng-1.4.0beta60/scripts/makefile.openbsd 2009-05-18 16:58:22.440945626 -0500 @@ -17,9 +17,9 @@ HDRS= png.h pngconf.h CFLAGS+= -W -Wall -CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE +CPPFLAGS+= -I${.CURDIR} NOPROFILE= Yes CLEANFILES+= pngtest.o pngtest diff -ru4NwbB libpng-1.2.35/scripts/makefile.os2 libpng-1.4.0beta60/scripts/makefile.os2 --- libpng-1.2.35/scripts/makefile.os2 2008-08-02 07:23:02.526620000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.os2 2009-05-01 17:52:56.404059000 -0500 @@ -49,21 +49,21 @@ rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h pngtest.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.sco libpng-1.4.0beta60/scripts/makefile.sco --- libpng-1.2.35/scripts/makefile.sco 2009-02-14 15:59:28.135670135 -0600 +++ libpng-1.4.0beta60/scripts/makefile.sco 2009-05-18 16:58:22.452500682 -0500 @@ -7,9 +7,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -37,9 +37,9 @@ #ZLIBINC=/usr/local/include ZLIBLIB=../zlib ZLIBINC=../zlib -CFLAGS= -dy -belf -I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE +CFLAGS= -dy -belf -I$(ZLIBINC) -O3 LDFLAGS=-L. -L$(ZLIBLIB) -lpng%N% -lz -lm INCPATH=$(prefix)/include/libpng LIBPATH=$(exec_prefix)/lib @@ -209,21 +209,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.sggcc libpng-1.4.0beta60/scripts/makefile.sggcc --- libpng-1.2.35/scripts/makefile.sggcc 2009-02-14 15:59:28.145298633 -0600 +++ libpng-1.4.0beta60/scripts/makefile.sggcc 2009-05-18 16:58:22.464297944 -0500 @@ -4,9 +4,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME=libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -43,9 +43,9 @@ # See "man abi". zlib must be built with the same ABI. ABI= WARNMORE= # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -fPIC -mabi=n32 -DPNG_NO_MMX_CODE +CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -fPIC -mabi=n32 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ -set_version sgi$(PNGMAJ).0 LDLEGACY=cc $(ABI) -shared -soname $(OLDSOMAJ) \ @@ -96,9 +96,9 @@ ( cat scripts/libpng-config-head.in; \ echo prefix=\"$(prefix)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo ccopts=\"$(ABI)\"; \ - echo cppflags=\"-DPNG_NO_MMX_CODE\"; \ + echo cppflags=\"\"; \ echo ldopts=\"$(ABI)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \ echo libdir=\"$(LIBPATH)\"; \ echo libs=\"-lpng%N% -lz -lm\"; \ @@ -211,32 +211,30 @@ -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` ./pngtesti pngtest.png clean: - $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations + $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc \ + so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* $(OLDSOVER) DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.sgi libpng-1.4.0beta60/scripts/makefile.sgi --- libpng-1.2.35/scripts/makefile.sgi 2009-02-14 15:59:28.154801559 -0600 +++ libpng-1.4.0beta60/scripts/makefile.sgi 2009-05-18 16:58:22.475919902 -0500 @@ -4,9 +4,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME=libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -44,10 +44,10 @@ ABI= WARNMORE=-fullwarn # Note: -KPIC is the default anyhow -#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_NO_MMX_CODE # -g -DPNG_DEBUG=5 -CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_NO_MMX_CODE +#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC # -g -DPNG_DEBUG=5 +CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng%N% -lz -lm LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ -set_version sgi$(PNGMAJ).0 @@ -98,9 +98,8 @@ libpng-config: ( cat scripts/libpng-config-head.in; \ echo prefix=\"$(prefix)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_NO_MMX_CODE\"; \ echo ccopts=\"$(ABI)\"; \ echo ldopts=\"$(ABI)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \ echo libdir=\"$(LIBPATH)\"; \ @@ -225,21 +224,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.so9 libpng-1.4.0beta60/scripts/makefile.so9 --- libpng-1.2.35/scripts/makefile.so9 2009-02-14 15:59:28.164717538 -0600 +++ libpng-1.4.0beta60/scripts/makefile.so9 2009-05-18 16:58:22.485909483 -0500 @@ -6,9 +6,9 @@ # Copyright (C) 1996-1997 Andreas Dilger # For conditions of distribution and use, see copyright notice in png.h # Library name: -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng%N% @@ -231,21 +231,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.solaris libpng-1.4.0beta60/scripts/makefile.solaris --- libpng-1.2.35/scripts/makefile.solaris 2009-02-14 15:59:28.174438948 -0600 +++ libpng-1.4.0beta60/scripts/makefile.solaris 2009-05-18 16:58:22.497538183 -0500 @@ -6,9 +6,9 @@ # For conditions of distribution and use, see copyright notice in png.h # Library name: LIBNAME = libpng%N% -PNGMAJ = 0 +PNGMAJ = %SONUM% PNGMIN = 1.4.0beta60 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -43,9 +43,8 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion CFLAGS=-I$(ZLIBINC) -W -Wall -O \ - -DPNG_NO_MMX_CODE; \ # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng%N% -lz -lm INCPATH=$(prefix)/include @@ -95,9 +94,9 @@ libpng-config: ( cat scripts/libpng-config-head.in; \ echo prefix=\"$(prefix)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\"-DPNG_NO_MMX_CODE\"; \ + echo cppflags=\"\"; \ echo L_opts=\"-L$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \ echo libs=\"-lpng%N% -lz -lm\"; \ cat scripts/libpng-config-body.in ) > libpng-config @@ -229,21 +228,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h pngpriv.h +pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h +pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h +pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h +pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h +pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h +pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h +pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h +pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pngpriv.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.solaris-x86 libpng-1.4.0beta60/scripts/makefile.solaris-x86 --- libpng-1.2.35/scripts/makefile.solaris-x86 2009-02-14 15:59:28.184101925 -0600 +++ libpng-1.4.0beta60/scripts/makefile.solaris-x86 1969-12-31 18:00:00.000000000 -0600 @@ -1,248 +0,0 @@ -# makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson -# Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 1998 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h - -# Library name: -LIBNAME = libpng%N% -PNGMAJ = 0 -PNGMIN = 1.4.0beta60 -PNGVER = $(PNGMAJ).$(PNGMIN) - -# Shared library names: -LIBSO=$(LIBNAME).so -LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) -LIBSOVER=$(LIBNAME).so.$(PNGVER) -OLDSO=libpng.so -OLDSOMAJ=libpng.so.%OLDNUM% -OLDSOVER=libpng.so.%OLDNUM%.$(PNGMIN) - -# Utilities: -AR_RC=ar rc -CC=gcc -MKDIR_P=mkdir -p -LN_SF=ln -f -s -RANLIB=echo -RM_F=/bin/rm -f - -# Where make install puts libpng.a, libpng%N%.so*, and png.h -prefix=/usr/local -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -# Changing these to ../zlib poses a security risk. If you want -# to have zlib in an adjacent directory, specify the full path instead of "..". -#ZLIBLIB=../zlib -#ZLIBINC=../zlib - -ZLIBLIB=/usr/local/lib -ZLIBINC=/usr/local/include - -WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ - -Wmissing-declarations -Wtraditional -Wcast-align \ - -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -W -Wall -O \ - # $(WARNMORE) -g -DPNG_DEBUG=5 -LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng%N% -lz -lm - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib -MANPATH=$(prefix)/man -BINPATH=$(exec_prefix)/bin - -# override DESTDIR= on the make install command line to easily support -# installing into a temporary location. Example: -# -# make install DESTDIR=/tmp/build/libpng -# -# If you're going to install into a temporary location -# via DESTDIR, $(DESTDIR)$(prefix) must already exist before -# you execute make install. -DESTDIR= - -DB=$(DESTDIR)$(BINPATH) -DI=$(DESTDIR)$(INCPATH) -DL=$(DESTDIR)$(LIBPATH) -DM=$(DESTDIR)$(MANPATH) - -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ - pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ - pngwtran.o pngmem.o pngerror.o pngpread.o - -OBJSDLL = $(OBJS:.o=.pic.o) - -.SUFFIXES: .c .o .pic.o - -.c.pic.o: - $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c - -all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config - -libpng.a: $(OBJS) - $(AR_RC) $@ $(OBJS) - $(RANLIB) $@ - -libpng.pc: - cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ - -e s!@exec_prefix@!$(exec_prefix)! \ - -e s!@libdir@!$(LIBPATH)! \ - -e s!@includedir@!$(INCPATH)! \ - -e s!-lpng%N%!-lpng%N%\ -lz\ -lm! > libpng.pc - -libpng-config: - ( cat scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo cppflags=\""; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo R_opts=\"-R$(LIBPATH)\"; \ - echo libs=\"-lpng%N% -lz -lm\"; \ - cat scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -$(LIBSO): $(LIBSOMAJ) - $(LN_SF) $(LIBSOMAJ) $(LIBSO) - -$(LIBSOMAJ): $(LIBSOVER) - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) - -$(LIBSOVER): $(OBJSDLL) - @case "`type ld`" in *ucb*) \ - echo; \ - echo '## WARNING:'; \ - echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \ - echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \ - echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \ - echo '## The environment variable LD_LIBRARY_PATH should not be set'; \ - echo '## at all. If it is, things are likely to break because of'; \ - echo '## the libucb dependency that is created.'; \ - echo; \ - ;; \ - esac - $(LD) -G -h $(LIBSOMAJ) \ - -o $(LIBSOVER) $(OBJSDLL) - -$(OLDSOVER): $(OBJS) - $(LD) -G -h $(OLDSOMAJ) \ - -o $(OLDSOVER) $(OBJSDLL) - -pngtest: pngtest.o $(LIBSO) - $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) - -test: pngtest - ./pngtest - -install-headers: png.h pngconf.h - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - cp png.h pngconf.h $(DI)/$(LIBNAME) - chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h - -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h - -@$(RM_F) $(DI)/libpng - (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) - -install-static: install-headers libpng.a - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - cp libpng.a $(DL)/$(LIBNAME).a - chmod 644 $(DL)/$(LIBNAME).a - -@$(RM_F) $(DL)/libpng.a - (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) - -install-shared: install-headers $(LIBSOVER) libpng.pc \ - $(OLDSOVER) - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO) - -@$(RM_F) $(DL)/$(LIBSOMAJ) - -@$(RM_F) $(DL)/$(OLDSO) - -@$(RM_F) $(DL)/$(OLDSOMAJ) - -@$(RM_F) $(DL)/$(OLDSOVER)* - cp $(LIBSOVER) $(DL) - cp $(OLDSOVER) $(DL) - chmod 755 $(DL)/$(LIBSOVER) - chmod 755 $(DL)/$(OLDSOVER) - (cd $(DL); \ - $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ - $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSO); \ - $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)) - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc - -@$(RM_F) $(DL)/pkgconfig/libpng.pc - cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) - -install-man: libpng.3 libpngpf.3 png.5 - -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi - -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi - -@$(RM_F) $(DM)/man3/libpng.3 - -@$(RM_F) $(DM)/man3/libpngpf.3 - cp libpng.3 $(DM)/man3 - cp libpngpf.3 $(DM)/man3 - -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi - -@$(RM_F) $(DM)/man5/png.5 - cp png.5 $(DM)/man5 - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@$(RM_F) $(DB)/libpng-config - -@$(RM_F) $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) - -install: install-static install-shared install-man install-config - -# If you installed in $(DESTDIR), test-installed won't work until you -# move the library to its final location. Use test-dd to test it -# before then. - -test-dd: - echo - echo Testing installed dynamic shared library in $(DL). - $(CC) -I$(DI) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(DL) -L$(ZLIBLIB) -R$(ZLIBLIB) -R$(DL) - ./pngtestd pngtest.png - -test-installed: - echo - echo Testing installed dynamic shared library. - $(CC) -I$(ZLIBINC) \ - `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ - -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` \ - -L$(ZLIBLIB) -R$(ZLIBLIB) - ./pngtesti pngtest.png - -clean: - $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ - libpng-config $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - libpng.pc - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.std libpng-1.4.0beta60/scripts/makefile.std --- libpng-1.2.35/scripts/makefile.std 2006-03-06 11:06:28.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.std 2009-05-01 17:53:10.713419000 -0500 @@ -72,21 +72,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.sunos libpng-1.4.0beta60/scripts/makefile.sunos --- libpng-1.2.35/scripts/makefile.sunos 2006-03-08 12:34:28.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.sunos 2009-05-02 05:30:48.324095000 -0500 @@ -77,21 +77,21 @@ chmod a-w *.[ch35] $(DOCS) scripts/* # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o: png.h pngconf.h -pngerror.o: png.h pngconf.h -pngrio.o: png.h pngconf.h -pngwio.o: png.h pngconf.h -pngmem.o: png.h pngconf.h -pngset.o: png.h pngconf.h -pngget.o: png.h pngconf.h -pngread.o: png.h pngconf.h -pngrtran.o: png.h pngconf.h -pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h -pngtrans.o: png.h pngconf.h -pngwrite.o: png.h pngconf.h -pngwtran.o: png.h pngconf.h -pngwutil.o: png.h pngconf.h -pngpread.o: png.h pngconf.h +png.o: png.h pngconf.h pngpriv.h +pngerror.o: png.h pngconf.h pngpriv.h +pngrio.o: png.h pngconf.h pngpriv.h +pngwio.o: png.h pngconf.h pngpriv.h +pngmem.o: png.h pngconf.h pngpriv.h +pngset.o: png.h pngconf.h pngpriv.h +pngget.o: png.h pngconf.h pngpriv.h +pngread.o: png.h pngconf.h pngpriv.h +pngrtran.o: png.h pngconf.h pngpriv.h +pngrutil.o: png.h pngconf.h pngpriv.h +pngtrans.o: png.h pngconf.h pngpriv.h +pngwrite.o: png.h pngconf.h pngpriv.h +pngwtran.o: png.h pngconf.h pngpriv.h +pngwutil.o: png.h pngconf.h pngpriv.h +pngpread.o: png.h pngconf.h pngpriv.h +pngtest.o: png.h pngconf.h diff -ru4NwbB libpng-1.2.35/scripts/makefile.tc3 libpng-1.4.0beta60/scripts/makefile.tc3 --- libpng-1.2.35/scripts/makefile.tc3 2001-01-05 18:26:07.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.tc3 2009-05-01 17:27:02.721362000 -0500 @@ -29,54 +29,54 @@ test: pngtest$(E) pngtest$(E) -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngset$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngget$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngpread$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngrtran$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngrutil$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngerror$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngmem$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngrio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngtrans$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngwrite$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngwtran$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c libpng$(MODEL).lib: $(OBJS1) $(OBJS2) $(OBJS3) $(LIB) libpng$(MODEL) +$(OBJSL1) diff -ru4NwbB libpng-1.2.35/scripts/makefile.vcawin32 libpng-1.4.0beta60/scripts/makefile.vcawin32 --- libpng-1.2.35/scripts/makefile.vcawin32 2007-09-01 09:32:54.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.vcawin32 2009-05-18 16:58:22.190892534 -0500 @@ -1,18 +1,18 @@ # makefile for libpng +# Copyright (C) 2006,2009 Glenn Randers-Pehrson # Copyright (C) 1998 Tim Wegner # For conditions of distribution and use, see copyright notice in png.h # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # To use, do "nmake /f scripts\makefile.vcawin32" -# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- -# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. +# -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- # Compiler, linker, librarian, and other tools CC = cl LD = link AR = lib -CFLAGS = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib +CFLAGS = -nologo -MD -O2 -W3 -I..\zlib LDFLAGS = -nologo ARFLAGS = -nologo RM = del @@ -30,60 +30,60 @@ # Targets all: libpng.lib -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngset$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngget$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngpread$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrtran$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrutil$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngerror$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngmem$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtrans$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) libpng.lib: $(OBJS) -$(RM) $@ $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) +pngtest$(O): png.h pngconf.h pngpriv.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest$(O) libpng.lib $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) test: pngtest.exe diff -ru4NwbB libpng-1.2.35/scripts/makefile.vcwin32 libpng-1.4.0beta60/scripts/makefile.vcwin32 --- libpng-1.2.35/scripts/makefile.vcwin32 2007-06-19 14:08:25.000000000 -0500 +++ libpng-1.4.0beta60/scripts/makefile.vcwin32 2009-05-18 16:58:22.199175273 -0500 @@ -1,18 +1,18 @@ # makefile for libpng # Copyright (C) 1998 Tim Wegner +# Copyright (C) 2006,2009 Glenn Randers-Pehrson # For conditions of distribution and use, see copyright notice in png.h # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # To use, do "nmake /f scripts\makefile.vcwin32" # -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- -# If you want to use assembler (MMX) code, use makefile.vcawin32 instead. # Compiler, linker, librarian, and other tools CC = cl LD = link AR = lib -CFLAGS = -nologo -DPNG_NO_MMX_CODE -MD -O2 -W3 -I..\zlib +CFLAGS = -nologo -MD -O2 -W3 -I..\zlib LDFLAGS = -nologo ARFLAGS = -nologo RM = del @@ -30,60 +30,60 @@ # Targets all: libpng.lib -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngset$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngget$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngpread$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrtran$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrutil$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngerror$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngmem$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngrio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtrans$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwrite$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngwtran$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) libpng.lib: $(OBJS) -$(RM) $@ $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) +pngtest$(O): png.h pngconf.h pngpriv.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest$(O) libpng.lib $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) test: pngtest.exe diff -ru4NwbB libpng-1.2.35/scripts/makefile.watcom libpng-1.4.0beta60/scripts/makefile.watcom --- libpng-1.2.35/scripts/makefile.watcom 2001-01-05 18:26:23.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makefile.watcom 2009-05-01 17:28:10.537871000 -0500 @@ -45,54 +45,54 @@ all: test -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngset$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngget$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngread$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngpread$(O): png.h pngconf.h +pngpread$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrtran$(O): png.h pngconf.h +pngrtran$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrutil$(O): png.h pngconf.h +pngrutil$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngerror$(O): png.h pngconf.h +pngerror$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngmem$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngrio$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtrans$(O): png.h pngconf.h +pngtrans$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwrite$(O): png.h pngconf.h +pngwrite$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwtran$(O): png.h pngconf.h +pngwtran$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngwutil$(O): png.h pngconf.h +pngwutil$(O): png.h pngconf.h pngpriv.h $(CC) $(CFLAGS) $*.c $(ERRFILE) libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) wlib -b -c -n -q libpng.lib $(OBJS1) diff -ru4NwbB libpng-1.2.35/scripts/makevms.com libpng-1.4.0beta60/scripts/makevms.com --- libpng-1.2.35/scripts/makevms.com 2001-01-12 13:12:19.000000000 -0600 +++ libpng-1.4.0beta60/scripts/makevms.com 2009-05-02 05:26:40.174862000 -0500 @@ -53,39 +53,37 @@ $ if make.eqs."" $ then $ dele pngtest.obj;* $ CALL MAKE png.OBJ "cc ''CCOPT' png" - - png.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h + png.c png.h pngconf.h pngpriv.h $ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - - pngset.c png.h pngconf.h + pngset.c png.h pngconf.h pngpriv.h $ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - - pngget.c png.h pngconf.h + pngget.c png.h pngconf.h pngpriv.h $ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - - pngread.c png.h pngconf.h + pngread.c png.h pngconf.h pngpriv.h $ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h + pngpread.c png.h pngconf.h pngpriv.h $ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - - pngrtran.c png.h pngconf.h + pngrtran.c png.h pngconf.h pngpriv.h $ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - - pngrutil.c png.h pngconf.h + pngrutil.c png.h pngconf.h pngpriv.h $ CALL MAKE pngerror.OBJ "cc ''CCOPT' pngerror" - - pngerror.c png.h pngconf.h + pngerror.c png.h pngconf.h pngpriv.h $ CALL MAKE pngmem.OBJ "cc ''CCOPT' pngmem" - - pngmem.c png.h pngconf.h + pngmem.c png.h pngconf.h pngpriv.h $ CALL MAKE pngrio.OBJ "cc ''CCOPT' pngrio" - - pngrio.c png.h pngconf.h + pngrio.c png.h pngconf.h pngpriv.h $ CALL MAKE pngwio.OBJ "cc ''CCOPT' pngwio" - - pngwio.c png.h pngconf.h + pngwio.c png.h pngconf.h pngpriv.h $ CALL MAKE pngtrans.OBJ "cc ''CCOPT' pngtrans" - - pngtrans.c png.h pngconf.h + pngtrans.c png.h pngconf.h pngpriv.h $ CALL MAKE pngwrite.OBJ "cc ''CCOPT' pngwrite" - - pngwrite.c png.h pngconf.h + pngwrite.c png.h pngconf.h pngpriv.h $ CALL MAKE pngwtran.OBJ "cc ''CCOPT' pngwtran" - - pngwtran.c png.h pngconf.h + pngwtran.c png.h pngconf.h pngpriv.h $ CALL MAKE pngwutil.OBJ "cc ''CCOPT' pngwutil" - - pngwutil.c png.h pngconf.h + pngwutil.c png.h pngconf.h pngpriv.h $ write sys$output "Building Libpng ..." $ CALL MAKE libpng.OLB "lib/crea libpng.olb *.obj" *.OBJ $ write sys$output "Building pngtest..." $ CALL MAKE pngtest.OBJ "cc ''CCOPT' pngtest" - diff -ru4NwbB libpng-1.2.35/scripts/pngos2.def libpng-1.4.0beta60/scripts/pngos2.def --- libpng-1.2.35/scripts/pngos2.def 2009-02-14 15:59:28.193690745 -0600 +++ libpng-1.4.0beta60/scripts/pngos2.def 2009-05-18 16:58:22.508695904 -0500 @@ -81,15 +81,13 @@ png_get_y_pixels_per_meter png_malloc png_memcpy_check png_memset_check - png_permit_empty_plte png_process_data png_progressive_combine_row png_read_end png_read_image png_read_info -; png_read_init ; deprecated png_read_png png_read_row png_read_rows png_read_update_info @@ -117,9 +115,8 @@ png_set_flush png_set_gAMA png_set_gAMA_fixed png_set_gamma -; png_set_gray_1_2_4_to_8 ; deprecated as of libpng-1.2.9 png_set_gray_to_rgb png_set_hIST png_set_iCCP png_set_interlace_handling @@ -172,30 +169,20 @@ png_write_flush png_write_image png_write_info png_write_info_before_PLTE -; png_write_init ; deprecated png_write_png png_write_row png_write_rows - png_read_init_2 - png_write_init_2 + png_write_sig png_access_version_number png_init_io png_convert_to_rfc1123 png_set_invalid ; Added at version 1.2.0: - png_mmx_support png_permit_empty_plte png_permit_mng_features - png_get_mmx_flagmask - png_get_asm_flagmask - png_get_asm_flags - png_get_mmx_bitdepth_threshold - png_get_mmx_rowbytes_threshold - png_set_asm_flags - png_init_mmx_flags ; Added at version 1.2.2: png_handle_as_unknown @@ -222,9 +209,23 @@ png_save_int_32 png_get_uint_31 png_set_expand_gray_1_2_4_to_8 +; Added at version 1.4.0 + png_write_sig +; png_benign_error +; png_benign_chunk_error +; png_set_benign_error + png_get_io_chunk_name + png_get_io_state + png_set_premultiply_alpha + png_get_chunk_cache_max + png_set_chunk_cache_max + png_check_cHRM_fixed + png_calloc + ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS + png_libpng_ver png_pass_start png_pass_inc png_pass_ystart png_pass_yinc diff -ru4NwbB libpng-1.2.35/scripts/pngw32.def libpng-1.4.0beta60/scripts/pngw32.def --- libpng-1.2.35/scripts/pngw32.def 2009-02-14 15:59:28.203583743 -0600 +++ libpng-1.4.0beta60/scripts/pngw32.def 1969-12-31 18:00:00.000000000 -0600 @@ -1,238 +0,0 @@ -;------------------------------------------ -; LIBPNG module definition file for Windows -;------------------------------------------ - -LIBRARY - -EXPORTS -;Version 1.4.0beta60 - png_build_grayscale_palette @1 - png_check_sig @2 - png_chunk_error @3 - png_chunk_warning @4 - png_convert_from_struct_tm @5 - png_convert_from_time_t @6 - png_create_info_struct @7 - png_create_read_struct @8 - png_create_write_struct @9 - png_data_freer @10 - png_destroy_info_struct @11 - png_destroy_read_struct @12 - png_destroy_write_struct @13 - png_error @14 - png_free @15 - png_free_data @16 - png_get_IHDR @17 - png_get_PLTE @18 - png_get_bKGD @19 - png_get_bit_depth @20 - png_get_cHRM @21 - png_get_cHRM_fixed @22 - png_get_channels @23 - png_get_color_type @24 - png_get_compression_buffer_size @25 - png_get_compression_type @26 - png_get_copyright @27 - png_get_error_ptr @28 - png_get_filter_type @29 - png_get_gAMA @30 - png_get_gAMA_fixed @31 - png_get_hIST @32 - png_get_header_ver @33 - png_get_header_version @34 - png_get_iCCP @35 - png_get_image_height @36 - png_get_image_width @37 - png_get_interlace_type @38 - png_get_io_ptr @39 - ; png_get_libpng_ver @40 - png_get_oFFs @41 - png_get_pCAL @42 - png_get_pHYs @43 - png_get_pixel_aspect_ratio @44 - png_get_pixels_per_meter @45 - png_get_progressive_ptr @46 - png_get_rgb_to_gray_status @47 - png_get_rowbytes @48 - png_get_rows @49 - png_get_sBIT @50 - png_get_sCAL @51 - png_get_sPLT @52 - png_get_sRGB @53 - png_get_signature @54 - png_get_tIME @55 - png_get_tRNS @56 - png_get_text @57 - png_get_unknown_chunks @58 - png_get_user_chunk_ptr @59 - png_get_user_transform_ptr @60 - png_get_valid @61 - png_get_x_offset_microns @62 - png_get_x_offset_pixels @63 - png_get_x_pixels_per_meter @64 - png_get_y_offset_microns @65 - png_get_y_offset_pixels @66 - png_get_y_pixels_per_meter @67 - png_malloc @68 - png_memcpy_check @69 - png_memset_check @70 -; png_permit_empty_plte is deprecated - png_permit_empty_plte @71 - png_process_data @72 - png_progressive_combine_row @73 - png_read_end @74 - png_read_image @75 - png_read_info @76 -; png_read_init is deprecated - png_read_init @77 - png_read_png @78 - png_read_row @79 - png_read_rows @80 - png_read_update_info @81 - png_reset_zstream @82 - png_set_IHDR @83 - png_set_PLTE @84 - png_set_bKGD @85 - png_set_background @86 - png_set_bgr @87 - png_set_cHRM @88 - png_set_cHRM_fixed @89 - png_set_compression_buffer_size @90 - png_set_compression_level @91 - png_set_compression_mem_level @92 - png_set_compression_method @93 - png_set_compression_strategy @94 - png_set_compression_window_bits @95 - png_set_crc_action @96 - png_set_dither @97 - png_set_error_fn @98 - png_set_expand @99 - png_set_filler @100 - png_set_filter @101 - png_set_filter_heuristics @102 - png_set_flush @103 - png_set_gAMA @104 - png_set_gAMA_fixed @105 - png_set_gamma @106 -; png_set_gray_1_2_4_to_8 is deprecated - png_set_gray_1_2_4_to_8 @107 - png_set_gray_to_rgb @108 - png_set_hIST @109 - png_set_iCCP @110 - png_set_interlace_handling @111 - png_set_invert_alpha @112 - png_set_invert_mono @113 - png_set_keep_unknown_chunks @114 - png_set_oFFs @115 - png_set_pCAL @116 - png_set_pHYs @117 - png_set_packing @118 - png_set_packswap @119 - png_set_palette_to_rgb @120 - png_set_progressive_read_fn @121 - png_set_read_fn @122 - png_set_read_status_fn @123 - png_set_read_user_chunk_fn @124 - png_set_read_user_transform_fn @125 - png_set_rgb_to_gray @126 - png_set_rgb_to_gray_fixed @127 - png_set_rows @128 - png_set_sBIT @129 - png_set_sCAL @130 - png_set_sPLT @131 - png_set_sRGB @132 - png_set_sRGB_gAMA_and_cHRM @133 - png_set_shift @134 - png_set_sig_bytes @135 - png_set_strip_16 @136 - png_set_strip_alpha @137 - png_set_swap @138 - png_set_swap_alpha @139 - png_set_tIME @140 - png_set_tRNS @141 - png_set_tRNS_to_alpha @142 - png_set_text @143 - png_set_unknown_chunk_location @144 - png_set_unknown_chunks @145 - png_set_user_transform_info @146 - png_set_write_fn @147 - png_set_write_status_fn @148 - png_set_write_user_transform_fn @149 - png_sig_cmp @150 - png_start_read_image @151 - png_warning @152 - png_write_chunk @153 - png_write_chunk_data @154 - png_write_chunk_end @155 - png_write_chunk_start @156 - png_write_end @157 - png_write_flush @158 - png_write_image @159 - png_write_info @160 - png_write_info_before_PLTE @161 -; png_write_init is deprecated - png_write_init @162 - png_write_png @163 - png_write_row @164 - png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. - png_read_init_2 @166 - png_write_init_2 @167 - png_access_version_number @168 -; png_sig_bytes @169 -; Removed from version 1.2.20 -; png_libpng_ver @170 -; - png_init_io @171 - png_convert_to_rfc1123 @172 - png_set_invalid @173 -; Added at version 1.0.12 -; For compatibility with 1.0.7-1.0.11 -; png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; Added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED - png_destroy_struct_2 @179 - png_create_read_struct_2 @180 - png_create_write_struct_2 @181 - png_malloc_default @182 - png_free_default @183 -; MNG features - png_permit_mng_features @184 -; MMX support - png_mmx_support @185 -; png_get_mmx_flagmask @186 - png_get_asm_flagmask @187 - png_get_asm_flags @188 -; png_get_mmx_bitdepth_threshold @189 -; png_get_mmx_rowbytes_threshold @190 - png_set_asm_flags @191 -; png_init_mmx_flags @192 -; Strip error numbers - png_set_strip_error_numbers @193 -; Added at version 1.2.2 - png_handle_as_unknown @194 -; Added at version 1.2.2 and deleted from 1.2.3 -; png_zalloc @195 -; png_zfree @196 -; Added at version 1.2.4 - png_malloc_warn @195 -; Added at version 1.2.6 - png_malloc_warn @195 - png_get_user_height_max @196 - png_get_user_width_max @197 - png_set_user_limits @198 -; Added at version 1.2.7 - png_set_add_alpha @199 -; Added at version 1.2.9 - png_get_uint_32 @200 - png_save_uint_32 @201 - png_get_uint_16 @202 - png_save_uint_16 @203 - png_get_int_32 @204 - png_save_int_32 @205 - png_get_uint_31 @206 - png_set_expand_gray_1_2_4_to_8 @207 diff -ru4NwbB libpng-1.2.35/scripts/pngw32.rc libpng-1.4.0beta60/scripts/pngw32.rc --- libpng-1.2.35/scripts/pngw32.rc 2004-11-29 14:57:51.000000000 -0600 +++ libpng-1.4.0beta60/scripts/pngw32.rc 1969-12-31 18:00:00.000000000 -0600 @@ -1,112 +0,0 @@ -#define PNG_VERSION_INFO_ONLY - -#include -#include "../png.h" - -#define _QUOTE(x) # x -#define QUOTE(x) _QUOTE(x) - -#define PNG_LIBPNG_DLLFNAME "LIBPNG" - -/* Support deprecated PRIVATEBUILD macro */ -#if defined(PRIVATEBUILD) && !defined(PNG_USER_PRIVATEBUILD) -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif - -#if defined(PNG_USER_DLLFNAME_POSTFIX) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined as a string describing the\ - custom changes made to the library." -#endif - -/* Prioritize PNG_USER_x over PNG_LIBPNG_x */ -#ifdef PNG_USER_DLLFNAME_POSTFIX -# undef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX PNG_USER_DLLFNAME_POSTFIX -#endif - -#ifdef PNG_USER_VERSIONINFO_COMMENTS -# undef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS PNG_USER_VERSIONINFO_COMMENTS -#endif - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) -# define VS_DEBUG VS_FF_DEBUG -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX "D" -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -# ifndef PNG_LIBPNG_VERSIONINFO_COMMENTS -# define PNG_LIBPNG_VERSIONINFO_COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) -# endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#else -# define VS_DEBUG 0 -# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX -# define PNG_LIBPNG_DLLFNAME_POSTFIX -# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ -#endif /* defined(DEBUG)... */ - -#ifdef PNG_USER_PRIVATEBUILD -# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD -#else -# define VS_PRIVATEBUILD 0 -#endif /* PNG_USER_PRIVATEBUILD */ - -#ifdef PNG_LIBPNG_SPECIALBUILD -# define VS_SPECIALBUILD VS_FF_SPECIALBUILD -#else -# define VS_SPECIALBUILD 0 -#endif /* PNG_LIBPNG_BUILD_SPECIAL */ - -#if ((PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_RELEASE_STATUS_MASK) !=\ - PNG_LIBPNG_BUILD_STABLE) -# define VS_PRERELEASE VS_FF_PRERELEASE -# define VS_PATCHED 0 -#else -# define VS_PRERELEASE 0 -# if (PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_BUILD_PATCHED) -# define VS_PATCHED VS_FF_PATCHED -# else -# define VS_PATCHED 0 -# endif -#endif - -VS_VERSION_INFO VERSIONINFO -FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED -FILEOS VOS__WINDOWS32 -FILETYPE VFT_DLL -FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ - BEGIN -#ifdef PNG_LIBPNG_VERSIONINFO_COMMENTS - VALUE "Comments", PNG_LIBPNG_VERSIONINFO_COMMENTS "\000" -#endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ -#ifdef PNG_USER_VERSIONINFO_COMPANYNAME - VALUE "CompanyName", PNG_USER_VERSIONINFO_COMPANYNAME "\000" -#endif /* PNG_USER_VERSIONINFO_COMPANYNAME */ - VALUE "FileDescription", "PNG image compression library\000" - VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" - VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX " (Windows 32 bit)\000" - VALUE "LegalCopyright", "\251 1998-2004 Glenn Randers-Pehrson et al.\000" -#ifdef PNG_USER_VERSIONINFO_LEGALTRADEMARKS - VALUE "LegalTrademarks", PNG_USER_VERSIONINFO_LEGALTRADEMARKS "\000" -#endif /* PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ - VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX ".DLL\000" -#ifdef PNG_USER_PRIVATEBUILD - VALUE "PrivateBuild", PNG_USER_PRIVATEBUILD "\000" -#endif /* PNG_USER_PRIVATEBUILD */ - VALUE "ProductName", "LibPNG\000" - VALUE "ProductVersion", "1\000" -#ifdef PNG_LIBPNG_SPECIALBUILD - VALUE "SpecialBuild", PNG_LIBPNG_SPECIALBUILD "\000" -#endif /* PNG_LIBPNG_SPECIALBUILD */ - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 0x04E4 - END -END diff -ru4NwbB libpng-1.2.35/scripts/pngwin.def libpng-1.4.0beta60/scripts/pngwin.def --- libpng-1.2.35/scripts/pngwin.def 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/scripts/pngwin.def 2009-05-18 16:58:22.520236598 -0500 @@ -0,0 +1,230 @@ +;------------------------------------------ +; LIBPNG module definition file for Windows +;------------------------------------------ + +LIBRARY + +EXPORTS +;Version 1.4.0beta60 + png_build_grayscale_palette + png_chunk_error + png_chunk_warning + png_convert_from_struct_tm + png_convert_from_time_t + png_create_info_struct + png_create_read_struct + png_create_write_struct + png_data_freer + png_destroy_info_struct + png_destroy_read_struct + png_destroy_write_struct + png_error + png_free + png_free_data + png_get_IHDR + png_get_PLTE + png_get_bKGD + png_get_bit_depth + png_get_cHRM + png_get_cHRM_fixed + png_get_channels + png_get_color_type + png_get_compression_buffer_size + png_get_compression_type + png_get_copyright + png_get_error_ptr + png_get_filter_type + png_get_gAMA + png_get_gAMA_fixed + png_get_hIST + png_get_header_ver + png_get_header_version + png_get_iCCP + png_get_image_height + png_get_image_width + png_get_interlace_type + png_get_io_ptr + png_get_libpng_ver + png_get_oFFs + png_get_pCAL + png_get_pHYs + png_get_pixel_aspect_ratio + png_get_pixels_per_meter + png_get_progressive_ptr + png_get_rgb_to_gray_status + png_get_rowbytes + png_get_rows + png_get_sBIT + png_get_sCAL + png_get_sPLT + png_get_sRGB + png_get_signature + png_get_tIME + png_get_tRNS + png_get_text + png_get_unknown_chunks + png_get_user_chunk_ptr + png_get_user_transform_ptr + png_get_valid + png_get_x_offset_microns + png_get_x_offset_pixels + png_get_x_pixels_per_meter + png_get_y_offset_microns + png_get_y_offset_pixels + png_get_y_pixels_per_meter + png_malloc + png_memcpy_check + png_memset_check + png_process_data + png_progressive_combine_row + png_read_end + png_read_image + png_read_info + png_read_png + png_read_row + png_read_rows + png_read_update_info + png_reset_zstream + png_set_IHDR + png_set_PLTE + png_set_bKGD + png_set_background + png_set_bgr + png_set_cHRM + png_set_cHRM_fixed + png_set_compression_buffer_size + png_set_compression_level + png_set_compression_mem_level + png_set_compression_method + png_set_compression_strategy + png_set_compression_window_bits + png_set_crc_action + png_set_dither + png_set_error_fn + png_set_expand + png_set_filler + png_set_filter + png_set_filter_heuristics + png_set_flush + png_set_gAMA + png_set_gAMA_fixed + png_set_gamma + png_set_gray_to_rgb + png_set_hIST + png_set_iCCP + png_set_interlace_handling + png_set_invert_alpha + png_set_invert_mono + png_set_keep_unknown_chunks + png_set_oFFs + png_set_pCAL + png_set_pHYs + png_set_packing + png_set_packswap + png_set_palette_to_rgb + png_set_progressive_read_fn + png_set_read_fn + png_set_read_status_fn + png_set_read_user_chunk_fn + png_set_read_user_transform_fn + png_set_rgb_to_gray + png_set_rgb_to_gray_fixed + png_set_rows + png_set_sBIT + png_set_sCAL + png_set_sPLT + png_set_sRGB + png_set_sRGB_gAMA_and_cHRM + png_set_shift + png_set_sig_bytes + png_set_strip_16 + png_set_strip_alpha + png_set_swap + png_set_swap_alpha + png_set_tIME + png_set_tRNS + png_set_tRNS_to_alpha + png_set_text + png_set_unknown_chunk_location + png_set_unknown_chunks + png_set_user_transform_info + png_set_write_fn + png_set_write_status_fn + png_set_write_user_transform_fn + png_sig_cmp + png_start_read_image + png_warning + png_write_chunk + png_write_chunk_data + png_write_chunk_end + png_write_chunk_start + png_write_end + png_write_flush + png_write_image + png_write_info + png_write_info_before_PLTE + png_write_png + png_write_row + png_write_rows + png_access_version_number + png_init_io + png_convert_to_rfc1123 + png_set_invalid +; Added at version 1.0.12 + png_read_init_3 + png_write_init_3 + png_info_init_3 + png_destroy_struct +; Added at version 1.2.0 +; For use with PNG_USER_MEM_SUPPORTED + png_destroy_struct_2 + png_create_read_struct_2 + png_create_write_struct_2 + png_malloc_default + png_free_default +; MNG features + png_permit_mng_features +; MMX support +; png_mmx_support +; png_get_mmx_flagmask +; png_get_asm_flagmask +; png_get_asm_flags +; png_get_mmx_bitdepth_threshold +; png_get_mmx_rowbytes_threshold +; png_set_asm_flags +; png_init_mmx_flags +; Strip error numbers + png_set_strip_error_numbers +; Added at version 1.2.2 + png_handle_as_unknown +; Added at version 1.2.2 and deleted from 1.2.3 +; png_zalloc +; png_zfree +; Added at version 1.2.4 + png_malloc_warn + png_get_user_height_max + png_get_user_width_max + png_set_user_limits +; Added at version 1.2.7 + png_set_add_alpha +; Added at version 1.2.9 + png_get_uint_32 + png_save_uint_32 + png_get_uint_16 + png_save_uint_16 + png_get_int_32 + png_save_int_32 + png_get_uint_31 + png_set_expand_gray_1_2_4_to_8 +; Added at version 1.4.0 + png_write_sig +; png_benign_error +; png_benign_chunk_error +; png_set_benign_error + png_get_io_chunk_name + png_get_io_state + png_set_premultiply_alpha + png_get_chunk_cache_max + png_set_chunk_cache_max + png_check_cHRM_fixed + png_calloc diff -ru4NwbB libpng-1.2.35/scripts/pngwin.rc libpng-1.4.0beta60/scripts/pngwin.rc --- libpng-1.2.35/scripts/pngwin.rc 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.4.0beta60/scripts/pngwin.rc 2006-08-15 12:28:09.000000000 -0500 @@ -0,0 +1,112 @@ +#define PNG_VERSION_INFO_ONLY + +#include +#include "../png.h" + +#define _QUOTE(x) # x +#define QUOTE(x) _QUOTE(x) + +#define PNG_LIBPNG_DLLFNAME "LIBPNG" + +/* Support deprecated PRIVATEBUILD macro */ +#if defined(PRIVATEBUILD) && !defined(PNG_USER_PRIVATEBUILD) +# define PNG_USER_PRIVATEBUILD PRIVATEBUILD +#endif + +#if defined(PNG_USER_DLLFNAME_POSTFIX) && !defined(PNG_USER_PRIVATEBUILD) +# error "PNG_USER_PRIVATEBUILD must be defined as a string describing the\ + custom changes made to the library." +#endif + +/* Prioritize PNG_USER_x over PNG_LIBPNG_x */ +#ifdef PNG_USER_DLLFNAME_POSTFIX +# undef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX PNG_USER_DLLFNAME_POSTFIX +#endif + +#ifdef PNG_USER_VERSIONINFO_COMMENTS +# undef PNG_LIBPNG_VERSIONINFO_COMMENTS +# define PNG_LIBPNG_VERSIONINFO_COMMENTS PNG_USER_VERSIONINFO_COMMENTS +#endif + +#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) +# define VS_DEBUG VS_FF_DEBUG +# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX "D" +# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ +# ifndef PNG_LIBPNG_VERSIONINFO_COMMENTS +# define PNG_LIBPNG_VERSIONINFO_COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG) +# endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ +#else +# define VS_DEBUG 0 +# ifndef PNG_LIBPNG_DLLFNAME_POSTFIX +# define PNG_LIBPNG_DLLFNAME_POSTFIX +# endif /* PNG_LIBPNG_DLLFNAME_POSTFIX */ +#endif /* defined(DEBUG)... */ + +#ifdef PNG_USER_PRIVATEBUILD +# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD +#else +# define VS_PRIVATEBUILD 0 +#endif /* PNG_USER_PRIVATEBUILD */ + +#ifdef PNG_LIBPNG_SPECIALBUILD +# define VS_SPECIALBUILD VS_FF_SPECIALBUILD +#else +# define VS_SPECIALBUILD 0 +#endif /* PNG_LIBPNG_BUILD_SPECIAL */ + +#if ((PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_RELEASE_STATUS_MASK) !=\ + PNG_LIBPNG_BUILD_STABLE) +# define VS_PRERELEASE VS_FF_PRERELEASE +# define VS_PATCHED 0 +#else +# define VS_PRERELEASE 0 +# if (PNG_LIBPNG_BUILD_BASE_TYPE & PNG_LIBPNG_BUILD_PATCHED) +# define VS_PATCHED VS_FF_PATCHED +# else +# define VS_PATCHED 0 +# endif +#endif + +VS_VERSION_INFO VERSIONINFO +FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD +PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */ + BEGIN +#ifdef PNG_LIBPNG_VERSIONINFO_COMMENTS + VALUE "Comments", PNG_LIBPNG_VERSIONINFO_COMMENTS "\000" +#endif /* PNG_LIBPNG_VERSIONINFO_COMMENTS */ +#ifdef PNG_USER_VERSIONINFO_COMPANYNAME + VALUE "CompanyName", PNG_USER_VERSIONINFO_COMPANYNAME "\000" +#endif /* PNG_USER_VERSIONINFO_COMPANYNAME */ + VALUE "FileDescription", "PNG image compression library\000" + VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000" + VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX " (Windows 32 bit)\000" + VALUE "LegalCopyright", "\251 1998-2006 Glenn Randers-Pehrson et al.\000" +#ifdef PNG_USER_VERSIONINFO_LEGALTRADEMARKS + VALUE "LegalTrademarks", PNG_USER_VERSIONINFO_LEGALTRADEMARKS "\000" +#endif /* PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ + VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_DLLNUM) PNG_LIBPNG_DLLFNAME_POSTFIX ".DLL\000" +#ifdef PNG_USER_PRIVATEBUILD + VALUE "PrivateBuild", PNG_USER_PRIVATEBUILD "\000" +#endif /* PNG_USER_PRIVATEBUILD */ + VALUE "ProductName", "LibPNG\000" + VALUE "ProductVersion", "1\000" +#ifdef PNG_LIBPNG_SPECIALBUILD + VALUE "SpecialBuild", PNG_LIBPNG_SPECIALBUILD "\000" +#endif /* PNG_LIBPNG_SPECIALBUILD */ + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04E4 + END +END