diff -ru4NwbB libpng-1.4.3/Makefile.am libpng-1.5.0beta42/Makefile.am --- libpng-1.4.3/Makefile.am 2010-06-25 19:32:32.228797313 -0500 +++ libpng-1.5.0beta42/Makefile.am 2010-08-18 08:12:27.948810344 -0500 @@ -4,15 +4,17 @@ PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ # libpng does not follow GNU file name conventions -AUTOMAKE_OPTIONS = foreign +AUTOMAKE_OPTIONS = foreign color-tests # test programs - run on make check, make distcheck -check_PROGRAMS= pngtest +check_PROGRAMS= pngtest pngvalid pngtest_SOURCES = pngtest.c pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la -TESTS = test-pngtest.sh +pngvalid_SOURCES = pngvalid.c +pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +TESTS = test-pngtest.sh pngvalid TESTS_ENVIRONMENT= srcdir=$(srcdir) # man pages dist_man_MANS= libpng.3 libpngpf.3 png.5 @@ -24,13 +26,14 @@ # rules to build libpng, only build the old library on request lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la # EXTRA_LTLIBRARIES= libpng.la -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_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 pngpriv.h +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\ + pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ + png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h + +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_CPPFLAGS = @LIBPNG_DEFINES@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ @@ -45,14 +48,12 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym endif -# Avoid depending upon Character Ranges. -AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' - #distribute headers in /usr/include/libpng/* pkgincludedir= $(includedir)/$(PNGLIB_BASENAME) pkginclude_HEADERS= png.h pngconf.h +nodist_pkginclude_HEADERS= pnglibconf.h # pkg-config stuff, note that libpng.pc is always required in order # to get the correct library pkgconfigdir = @pkgconfigdir@ @@ -61,57 +62,121 @@ #extra source distribution files. EXTRA_DIST= \ ANNOUNCE CHANGES INSTALL LICENSE README TODO \ pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ - ${srcdir}/projects/cbuilder5/* \ - ${srcdir}/projects/visualc6/* \ - ${srcdir}/projects/visualc71/* \ - ${srcdir}/projects/xcode/* \ - ${srcdir}/scripts/* \ - ${srcdir}/contrib/gregbook/* \ - ${srcdir}/contrib/pngminim/* \ - ${srcdir}/contrib/pngminus/* \ - ${srcdir}/contrib/pngsuite/* \ - ${srcdir}/contrib/visupng/* \ + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ $(TESTS) \ - example.c libpng-1.5.0beta42.txt + CMakeLists.txt example.c libpng-@PNGLIB_VERSION@.txt -CLEANFILES= pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers \ -libpng.sym +SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn + +CLEANFILES= dfn.c dfn?.out pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ + pngwin.def check.new pnglibconf.* symbols.new \ + $(SCRIPT_CLEANFILES) MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ config.sub configure depcomp install-sh ltmain.sh missing +SUFFIXES = .chk .dfn .out + $(PNGLIB_BASENAME).pc: libpng.pc cp libpng.pc $@ $(PNGLIB_BASENAME)-config: libpng-config cp libpng-config $@ -libpng.sym: png.h pngconf.h - rm -f $@ $@.new - $(CPP) @LIBPNG_DEFINES@ $(CPPFLAGS) -DPNG_BUILDSYMS $(srcdir)/png.h | \ - $(SED) -n -e \ - 's|^.*PNG_FUNCTION_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - -e 's|^.*PNG_DATA_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - >$@.new - mv $@.new $@ - -libpng.vers: libpng.sym - rm -f $@ $@.new - echo PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0 '{global:' > $@.new - $(SED) s/$$/\;/ libpng.sym >> $@.new - echo 'local: *; };' >> $@.new - mv $@.new $@ +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/symbols.out scripts/pngwin.out: png.h pngconf.h scripts/pnglibconf.h -test: check +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ +pngwin.def: scripts/pngwin.out + rm -f $@ + cp $? $@ +pnglibconf.h: pnglibconf.out + rm -f $@ + cp $? $@ +scripts/pnglibconf.h: + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) +pngvalid.o pngtest.o: pnglibconf.h + +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\ + -DPNGLIB_VERSION='@PNGLIB_VERSION@'\ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' + +.dfn.out: + rm -f $@ dfn.c dfn?.out + test -d scripts || mkdir scripts + echo '#include "$<"' >dfn.c + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) @LIBPNG_DEFINES@\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) dfn.c >dfn1.out + $(SED) -n -e 's|^.*PNG_DEFN_MAGIC-\(.*\)-PNG_DEFN_END.*$$|\1|p'\ + dfn1.out >dfn2.out + $(SED) -e 's| *@@@ *||g' -e 's| *$$||' dfn2.out >dfn3.out + rm -f dfn.c dfn[12].out + mv dfn3.out $@ + +# The .dfn file for pnglibconf.h is machine generated +pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk + rm -f $@ dfn?.out + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\ + ${srcdir}/scripts/pnglibconf.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2 + rm dfn1.out + mv dfn2.out $@ + +# Symbol checks (.def and .out files should match) +scripts/pngwin.chk: scripts/checksym.awk scripts/pngwin.def scripts/pngwin.out +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out +.out.chk: + rm -f $@ symbols.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + $< >&2 + mv symbols.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk + rm -f $@ dfn?.out + test -z "$(CPPFLAGS)" + echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out\ + logunsupported=1 - ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2 + rm dfn1.out + mv dfn2.out $@ + +$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk scripts/pngwin.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) # 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); rm -f png.h pngconf.h pnglibconf.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)/pnglibconf.h \ + pnglibconf.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 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used @@ -119,15 +184,17 @@ cd $(DESTDIR)$(bindir); rm -f libpng-config cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config @set -x;\ cd $(DESTDIR)$(libdir);\ - for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib; do\ + for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\ rm -f libpng.$$ext;\ if test -f $(PNGLIB_BASENAME).$$ext; then\ $(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\ fi;\ done uninstall-hook: - cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h + cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc rm -f $(DESTDIR)$(bindir)/libpng-config + rm -f $(DESTDIR)$(libdir)/libpng.a + rm -f $(DESTDIR)$(libdir)/libpng.la diff -ru4NwbB libpng-1.4.3/configure.ac libpng-1.5.0beta42/configure.ac --- libpng-1.4.3/configure.ac 2010-06-25 19:32:32.235225398 -0500 +++ libpng-1.5.0beta42/configure.ac 2010-08-18 08:12:27.955791595 -0500 @@ -24,9 +24,9 @@ AM_MAINTAINER_MODE PNGLIB_VERSION=1.5.0beta42 PNGLIB_MAJOR=1 -PNGLIB_MINOR=4 +PNGLIB_MINOR=5 PNGLIB_RELEASE=%RELEASE% dnl End of version number stuff @@ -37,13 +37,13 @@ AC_PROG_CC AC_PROG_LD AC_PROG_CPP AC_CHECK_TOOL(SED, sed, :) -AC_LIBTOOL_WIN32_DLL +AC_CHECK_TOOL(AWK, awk, :) AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET -AC_PROG_LIBTOOL +LT_INIT([win32-dll]) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h]) @@ -58,18 +58,22 @@ AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc])) AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) ) AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed])) -case $host_os in - aix*) - LIBPNG_DEFINES="-DPNG_CONFIGURE_LIBPNG -D_ALL_SOURCE";; - *) - LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG;; -esac +LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG LIBPNG_DEFINES=$LIBPNG_DEFINES AC_SUBST(LIBPNG_DEFINES) AC_MSG_CHECKING([if libraries can be versioned]) +# Special case for PE/COFF platforms: ld reports +# support for version-script, but doesn't actually +# DO anything with it. +case $host in +*cygwin* | *mingw32* ) + have_ld_version_script=no + AC_MSG_RESULT(no) +;; +* ) GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` if test "$GLD"; then have_ld_version_script=yes AC_MSG_RESULT(yes) @@ -77,8 +81,11 @@ have_ld_version_script=no AC_MSG_RESULT(no) AC_MSG_WARN(*** You have not enabled versioned symbols.) fi +;; +esac + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") if test "$have_ld_version_script" = "yes"; then AC_MSG_CHECKING([for symbol prefix]) diff -ru4NwbB libpng-1.4.3/contrib/gregbook/Makefile.sgi libpng-1.5.0beta42/contrib/gregbook/Makefile.sgi --- libpng-1.4.3/contrib/gregbook/Makefile.sgi 2010-06-25 19:32:26.204646483 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/Makefile.sgi 2010-08-18 08:12:21.507990644 -0500 @@ -22,11 +22,11 @@ # macros -------------------------------------------------------------------- -PNGINC = -I/usr/local/include/libpng14 -PNGLIB = -L/usr/local/lib -lpng14 # dynamically linked against libpng -#PNGLIB = /usr/local/lib/libpng14.a # statically linked against libpng +PNGINC = -I/usr/local/include/libpng15 +PNGLIB = -L/usr/local/lib -lpng15 # dynamically linked against libpng +#PNGLIB = /usr/local/lib/libpng15.a # statically linked against libpng # or: #PNGINC = -I../.. #PNGLIB = -L../.. -lpng #PNGLIB = ../../libpng.a diff -ru4NwbB libpng-1.4.3/contrib/gregbook/Makefile.unx libpng-1.5.0beta42/contrib/gregbook/Makefile.unx --- libpng-1.4.3/contrib/gregbook/Makefile.unx 2010-06-25 19:32:26.213954735 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/Makefile.unx 2010-08-18 08:12:21.517631847 -0500 @@ -25,16 +25,16 @@ # macros -------------------------------------------------------------------- #PNGDIR = /usr/local/lib -#PNGINC = -I/usr/local/include/libpng14 -#PNGLIBd = -L$(PNGDIR) -lpng14 # dynamically linked, installed libpng -#PNGLIBs = $(PNGDIR)/libpng14.a # statically linked, installed libpng +#PNGINC = -I/usr/local/include/libpng15 +#PNGLIBd = -L$(PNGDIR) -lpng15 # dynamically linked, installed libpng +#PNGLIBs = $(PNGDIR)/libpng15.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) -lpng14 # dynamically linked +PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng15 # dynamically linked PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng ZDIR = /usr/local/lib #ZDIR = /usr/lib64 diff -ru4NwbB libpng-1.4.3/contrib/gregbook/README libpng-1.5.0beta42/contrib/gregbook/README --- libpng-1.4.3/contrib/gregbook/README 2010-06-25 19:32:26.232362941 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/README 2010-08-18 08:12:21.537737351 -0500 @@ -164,9 +164,9 @@ rpng is a simple PNG viewer that can display transparent PNGs with a specified background color; for example, - rpng -bgcolor #ff0000 toucan.png + rpng -bgcolor \#ff0000 toucan.png would display the image with a red background. rpng2 is a progressive viewer that simulates a web browser in some respects; it can display images against either a background color or a dynamically generated diff -ru4NwbB libpng-1.4.3/contrib/gregbook/readpng2.c libpng-1.5.0beta42/contrib/gregbook/readpng2.c --- libpng-1.4.3/contrib/gregbook/readpng2.c 2010-06-25 19:32:26.271402013 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/readpng2.c 2010-08-18 08:12:21.581511505 -0500 @@ -54,10 +54,12 @@ ---------------------------------------------------------------------------*/ #include /* for exit() prototype */ +#include -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ +#include +#include "png.h" /* libpng header from the local directory */ #include "readpng2.h" /* typedefs, common macros, public prototypes */ /* local prototypes */ @@ -137,9 +139,9 @@ /* These byte strings were copied from png.h. If a future libpng * version recognizes more chunks, add them to this list. If a * future version of readpng2.c recognizes more chunks, delete them * from this list. */ - static const png_byte chunks_to_ignore[] = { + static /* const */ png_byte chunks_to_ignore[] = { 99, 72, 82, 77, '\0', /* cHRM */ 104, 73, 83, 84, '\0', /* hIST */ 105, 67, 67, 80, '\0', /* iCCP */ 105, 84, 88, 116, '\0', /* iTXt */ @@ -215,9 +217,13 @@ { mainprog_info *mainprog_ptr; int color_type, bit_depth; png_uint_32 width, height; +#ifdef PNG_FLOATING_POINT_SUPPORTED double gamma; +#else + png_fixed_point gamma; +#endif /* setjmp() doesn't make sense here, because we'd either have to exit(), * longjmp() ourselves, or return control to libpng, which doesn't want @@ -326,13 +332,21 @@ * the local platform. Note that mainprog_ptr->display_exponent is the * "gamma" value for the entire display system, i.e., the product of * LUT_exponent and CRT_exponent. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED if (png_get_gAMA(png_ptr, info_ptr, &gamma)) png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); else png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); - +#else + if (png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), gamma); + else + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), 45455); +#endif /* we'll let libpng expand interlaced images, too */ mainprog_ptr->passes = png_set_interlace_handling(png_ptr); @@ -479,6 +493,13 @@ fflush(stderr); exit(99); } + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ longjmp(mainprog_ptr->jmpbuf, 1); } diff -ru4NwbB libpng-1.4.3/contrib/gregbook/rpng-win.c libpng-1.5.0beta42/contrib/gregbook/rpng-win.c --- libpng-1.4.3/contrib/gregbook/rpng-win.c 2010-06-25 19:32:26.301567209 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/rpng-win.c 2010-08-18 08:12:21.614700420 -0500 @@ -84,9 +84,35 @@ #include #include #include #include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else #include /* only for _getch() */ +#endif /* #define DEBUG : this enables the Trace() macros */ #include "readpng.h" /* typedefs, common macros, readpng prototypes */ @@ -152,17 +178,18 @@ filename = (char *)NULL; - +#ifndef __CYGWIN__ /* First reenable console output, which normally goes to the bit bucket * for windowed apps. Closing the console window will terminate the * app. Thanks to David.Geldreich@realviz.com for supplying the magical * incantation. */ AllocConsole(); freopen("CONOUT$", "a", stderr); freopen("CONOUT$", "a", stdout); +#endif /* Next set the default value for our display-system exponent, i.e., * the product of the CRT exponent and the exponent corresponding to @@ -278,9 +305,11 @@ /* print usage screen if any errors up to this point */ if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng_version_info(); fprintf(stderr, "\n" @@ -292,13 +321,17 @@ " bg \tdesired background color in 7-character hex RGB format\n" "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t used with transparent images\n" "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ "Press Q or Esc to quit this usage screen.\n" +#endif "\n", PROGNAME, default_display_exponent); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(1); } @@ -332,20 +365,26 @@ } if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(2); } else { fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ fprintf(stderr, "\n [console window: closing this window will terminate %s]\n\n", PROGNAME); +#endif } /* set the title-bar string, but make sure buffer doesn't overflow */ @@ -416,9 +455,14 @@ /* wait for the user to tell us when to quit */ printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); fflush(stdout); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); diff -ru4NwbB libpng-1.4.3/contrib/gregbook/rpng2-win.c libpng-1.5.0beta42/contrib/gregbook/rpng2-win.c --- libpng-1.4.3/contrib/gregbook/rpng2-win.c 2010-06-25 19:32:26.328662793 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/rpng2-win.c 2010-08-18 08:12:21.644573331 -0500 @@ -95,9 +95,35 @@ #include /* for jmpbuf declaration in readpng2.h */ #include #include /* only for PvdM background code */ #include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else #include /* only for _getch() */ +#endif /* all for PvdM background code: */ #ifndef PI # define PI 3.141592653589793238 @@ -269,18 +295,18 @@ global_showmode = showmode; filename = (char *)NULL; memset(&rpng2_info, 0, sizeof(mainprog_info)); - +#ifndef __CYGWIN__ /* Next reenable console output, which normally goes to the bit bucket * for windowed apps. Closing the console window will terminate the * app. Thanks to David.Geldreich@realviz.com for supplying the magical * incantation. */ AllocConsole(); freopen("CONOUT$", "a", stderr); freopen("CONOUT$", "a", stdout); - +#endif /* Set the default value for our display-system exponent, i.e., the * product of the CRT exponent and the exponent corresponding to * the frame-buffer's lookup table (LUT), if any. This is not an @@ -412,9 +438,11 @@ /* print usage screen if any errors up to this point */ if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng2_version_info(); fprintf(stderr, "\n" @@ -431,18 +459,25 @@ "\t\t transparent images; overrides -bgcolor option\n" " -timing\tenables delay for every block read, to simulate modem\n" "\t\t download of image (~36 Kbps)\n" "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ "Press Q or Esc to quit this usage screen. ", +#else + , +#endif PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) +#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ + !(defined(__CYGWIN__) || defined(__MINGW32__)) (int)strlen(PROGNAME), " ", #endif (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat); fflush(stderr); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(1); } @@ -477,20 +512,26 @@ } if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(2); } else { fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ fprintf(stderr, "\n [console window: closing this window will terminate %s]\n\n", PROGNAME); +#endif fflush(stderr); } @@ -1131,9 +1172,14 @@ * that the image is done */ rpng2_info.state = kDone; printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); fflush(stdout); } diff -ru4NwbB libpng-1.4.3/contrib/gregbook/rpng2-x.c libpng-1.5.0beta42/contrib/gregbook/rpng2-x.c --- libpng-1.4.3/contrib/gregbook/rpng2-x.c 2010-06-25 19:32:26.346066715 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/rpng2-x.c 2010-08-18 08:12:21.662488963 -0500 @@ -484,11 +484,8 @@ " -pause\tpauses after displaying each pass until mouse clicked\n" "\nPress Q, Esc or mouse button 1 (within image window, after image\n" "is displayed) to quit.\n" "\n", PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - (int)strlen(PROGNAME), " ", -#endif (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1); exit(1); } @@ -783,10 +780,11 @@ if (rpng2_x_create_window()) { /* GRR TEMPORARY HACK: this is fundamentally no different from cases - * above; libpng should longjmp() back to us when png_ptr goes away. - * If we/it segfault instead, seems like a libpng bug... */ + * above; libpng should call our error handler to longjmp() back to us + * when png_ptr goes away. If we/it segfault instead, seems like a + * libpng bug... */ /* we're here via libpng callback, so if window fails, clean and bail */ readpng2_cleanup(&rpng2_info); rpng2_x_cleanup(); diff -ru4NwbB libpng-1.4.3/contrib/gregbook/writepng.c libpng-1.5.0beta42/contrib/gregbook/writepng.c --- libpng-1.4.3/contrib/gregbook/writepng.c 2010-06-25 19:32:26.380991395 -0500 +++ libpng-1.5.0beta42/contrib/gregbook/writepng.c 2010-08-18 08:12:21.699694458 -0500 @@ -103,9 +103,10 @@ /* setjmp() must be called in every function that calls a PNG-writing * libpng function, unless an alternate error handler was installed-- * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we go: */ + * (as in this program) or some other method to return control to + * application code, so here we go: */ if (setjmp(mainprog_ptr->jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); return 2; @@ -387,6 +388,13 @@ fflush(stderr); exit(99); } + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ longjmp(mainprog_ptr->jmpbuf, 1); } diff -ru4NwbB libpng-1.4.3/contrib/pngminim/README libpng-1.5.0beta42/contrib/pngminim/README --- libpng-1.4.3/contrib/pngminim/README 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/contrib/pngminim/README 2010-04-28 07:21:10.817901000 -0500 @@ -0,0 +1,4 @@ +This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa +to build minimal decoder, encoder, and progressive reader applications. + +See the individual README and pngusr.dfa files for more explanation. diff -ru4NwbB libpng-1.4.3/contrib/pngminim/decoder/README libpng-1.5.0beta42/contrib/pngminim/decoder/README --- libpng-1.4.3/contrib/pngminim/decoder/README 2010-06-25 19:32:26.798511553 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/decoder/README 2010-08-18 08:12:22.138081089 -0500 @@ -1,9 +1,10 @@ -This demonstrates the use of PNG_USER_CONFIG and pngusr.h +This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa -To build a minimal read-only decoder with embedded libpng and zlib, run +The makefile builds a minimal read-only decoder with embedded libpng +and zlib. - gather.sh # to collect needed files from pngminus, libpng, and zlib - make +Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC +on the make command line. If you prefer to use the shared libraries, go to contrib/pngminus and build the png2pnm application there. diff -ru4NwbB libpng-1.4.3/contrib/pngminim/decoder/gather.sh libpng-1.5.0beta42/contrib/pngminim/decoder/gather.sh --- libpng-1.4.3/contrib/pngminim/decoder/gather.sh 2010-06-25 19:32:26.807345545 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/decoder/gather.sh 1969-12-31 18:00:00.000000000 -0600 @@ -1,8 +0,0 @@ -cp ../../pngminus/png2pnm.c pngm2pnm.c -cp ../../../*.h . -cp ../../../*.c . -rm example.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 gz* diff -ru4NwbB libpng-1.4.3/contrib/pngminim/decoder/makefile libpng-1.5.0beta42/contrib/pngminim/decoder/makefile --- libpng-1.4.3/contrib/pngminim/decoder/makefile 2010-06-25 19:32:26.816077187 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/decoder/makefile 2010-08-18 08:12:22.147353933 -0500 @@ -3,42 +3,147 @@ #CC=cc CC=gcc LD=$(CC) +STRIP=strip + +# If awk fails try +# make AWK=nawk RM=rm -f +COPY=cp -CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \ - -DdeflateParams\(a,b,c\)=Z_OK -I. -O1 +CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1 C=.c O=.o L=.a E= +# Where to find the source code: +PNGSRC =../../.. +ZLIBSRC=$(PNGSRC)/../zlib +PROGSRC=$(PNGSRC)/contrib/pngminus + +# Zlib (minimal inflate requirements - crc32 is used by libpng) +# zutil can be eliminated if you provide your own zcalloc and zcfree +ZSRCS = adler32$(C) crc32$(C) \ + inffast$(C) inflate$(C) inftrees$(C) \ + zutil$(C) + +# Standard headers +ZH = zlib.h crc32.h inffast.h inffixed.h \ + inflate.h inftrees.h zutil.h + +# Machine generated headers +ZCONF = zconf.h + +# Headers callers use +ZINC = zlib.h $(ZCONF) + +# Headers the Zlib source uses +ZHDRS = $(ZH) $(ZCONF) + ZOBJS = adler32$(O) crc32$(O) \ - infback$(O) inffast$(O) inflate$(O) inftrees$(O) \ - trees$(O) uncompr$(O) zutil$(O) + inffast$(O) inflate$(O) inftrees$(O) \ + zutil$(O) + +# libpng +PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \ + pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \ + pngset$(C) pngtrans$(C) + +# Standard headers +PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h -OBJS = pngm2pnm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ +# Machine generated headers +PNGCONF=pnglibconf.h + +# Headers callers use +PNGINC= png.h pngconf.h pngusr.h $(PNGCONF) + +# Headers the PNG library uses +PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h + +PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \ - pngset$(O) pngtrans$(O) $(ZOBJS) + pngset$(O) pngtrans$(O) + +PROGSRCS= pngm2pnm$(C) +PROGHDRS= +PROGDOCS= +PROGOBJS= pngm2pnm$(O) + +OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # implicit make rules ------------------------------------------------------- -.c$(O): png.h pngconf.h pngpriv.h pngusr.h zlib.h +# note: dependencies do not work on implicit rule lines +.c$(O): $(CC) -c $(CFLAGS) $< # dependencies all: pngm2pnm$(E) pngm2pnm$(E): $(OBJS) $(LD) -o pngm2pnm$(E) $(OBJS) - strip pngm2pnm$(E) + $(STRIP) pngm2pnm$(E) + +# The DFA_XTRA setting turns all libpng options off then +# turns on those required for this minimal build. +# The CPP_FLAGS setting causes pngusr.h to be included in +# both the build of pnglibconf.h and, subsequently, when +# building libpng itself. +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ + $(PNGSRC)/scripts/pnglibconf.dfa \ + $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa + $(RM) pnglibconf.h pnglibconf.dfn + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + DFA_XTRA="pngusr.dfa" $@ clean: + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) clean $(RM) pngm2pnm$(O) $(RM) pngm2pnm$(E) $(RM) $(OBJS) +# distclean also removes the copied source and headers +distclean: clean + $(RM) -r scripts # historical reasons + $(RM) $(PNGSRCS) $(PNGH) + $(RM) $(ZSRCS) $(ZH) $(ZCONF) + $(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS) + +# Header file dependencies: +$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC) +$(PNGOBJS): $(PNGHDRS) $(ZINC) +$(ZOBJS): $(ZHDRS) + +# Gather the source code from the respective directories +$(PNGSRCS) $(PNGH): $(PNGSRC)/$@ + $(RM) $@ + $(COPY) $(PNGSRC)/$@ $@ + +# No dependency on the ZLIBSRC target so that it only needs +# to be specified once. +$(ZSRCS) $(ZH): + $(RM) $@ + $(COPY) $(ZLIBSRC)/$@ $@ + +# The unconfigured zconf.h varies in name according to the +# zlib release +$(ZCONF): + $(RM) $@ + @for f in zconf.h.in zconf.in.h zconf.h; do\ + test -r $(ZLIBSRC)/$$f &&\ + echo $(COPY) $(ZLIBSRC)/$$f $@ &&\ + $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\ + done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1 + +pngm2pnm.c: $(PROGSRC)/png2pnm.c + $(RM) $@ + $(COPY) $(PROGSRC)/png2pnm.c $@ + # End of makefile for pngm2pnm diff -ru4NwbB libpng-1.4.3/contrib/pngminim/decoder/pngusr.dfa libpng-1.5.0beta42/contrib/pngminim/decoder/pngusr.dfa --- libpng-1.4.3/contrib/pngminim/decoder/pngusr.dfa 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/contrib/pngminim/decoder/pngusr.dfa 2010-08-18 08:12:22.156123793 -0500 @@ -0,0 +1,33 @@ +# pngminim/decoder/pngusr.dfa +# +# Copyright (c) 2010 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# First all the build options off: +everything = off + +# All that is required is some read code. This example switches +# on the sequential read code (see ../preader for a progressive +# read example). +option SEQUENTIAL_READ on + +# You must choose fixed or floating point arithmetic: +# option FLOATING_POINT on +option FIXED_POINT on + +# You must chose the internal fixed point implementation or to +# use the system floating point. The latter is considerably +# smaller (by about 1kbyte on an x86 system): +# option FLOATING_ARITHMETIC on +option FLOATING_ARITHMETIC off + +# Your program will probably need other options. The example +# program here, pngm2pnm, requires the following. Take a look +# at pnglibconf.h to find out the full set of what has to be +# enabled to make the following work. +option SETJMP on +option STDIO on +option READ_EXPAND on diff -ru4NwbB libpng-1.4.3/contrib/pngminim/decoder/pngusr.h libpng-1.5.0beta42/contrib/pngminim/decoder/pngusr.h --- libpng-1.4.3/contrib/pngminim/decoder/pngusr.h 2010-06-25 19:32:26.824867573 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/decoder/pngusr.h 2010-08-18 08:12:22.164726044 -0500 @@ -1,7 +1,7 @@ /* minrdpngconf.h: headers to make a minimal png-read-only library * - * Copyright (c) 2007, 2009 Glenn Randers-Pehrson + * Copyright (c) 2007, 2010 Glenn Randers-Pehrson * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h @@ -11,69 +11,18 @@ #ifndef MINRDPNGCONF_H #define MINRDPNGCONF_H -#ifdef NJET - /* No 16-bit support beyond reading with strip_16 */ -#endif +/* If pngusr.h is included during the build the following must + * be defined either here or in the .dfa file (pngusr.dfa in + * this case). To include pngusr.h set -DPNG_USER_CONFIG in + * CPPFLAGS + */ +#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG decoder" +#define PNG_USER_DLLFNAME_POSTFIX "mr" +/* List options to turn off features of the build that do not + * affect the API (so are not recorded in pnglibconf.h) + */ #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_READ_BGR -#define PNG_NO_READ_GAMMA -#define PNG_NO_READ_BACKGROUND -#define PNG_NO_READ_QUANTIZE -#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 -#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_bKGD -#define PNG_NO_READ_cHRM -#define PNG_NO_READ_gAMA -#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_sRGB -#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_WRITE_SUPPORTED - -#define PNG_NO_INFO_IMAGE -#define PNG_NO_IO_STATE -#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 -#define PNG_NO_PROGRESSIVE_READ -#define PNG_NO_USER_LIMITS -#define PNG_NO_SET_USER_LIMITS -#define PNG_NO_TIME_RFC1123 #endif /* MINRDPNGCONF_H */ - diff -ru4NwbB libpng-1.4.3/contrib/pngminim/encoder/README libpng-1.5.0beta42/contrib/pngminim/encoder/README --- libpng-1.4.3/contrib/pngminim/encoder/README 2010-06-25 19:32:26.833493876 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/encoder/README 2010-08-18 08:12:22.173429315 -0500 @@ -1,9 +1,10 @@ This demonstrates the use of PNG_USER_CONFIG and pngusr.h -To build a minimal write-only decoder with embedded libpng and zlib, run +The makefile builds a minimal write-only decoder with embedded libpng +and zlib. - gather.sh # to collect needed files from pngminus, libpng, and zlib - make +Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC +on the make command line. If you prefer to use the shared libraries, go to contrib/pngminus and build the pnm2png application there. diff -ru4NwbB libpng-1.4.3/contrib/pngminim/encoder/gather.sh libpng-1.5.0beta42/contrib/pngminim/encoder/gather.sh --- libpng-1.4.3/contrib/pngminim/encoder/gather.sh 2010-06-25 19:32:26.841989759 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/encoder/gather.sh 1969-12-31 18:00:00.000000000 -0600 @@ -1,9 +0,0 @@ -cp ../../pngminus/pnm2png.c pnm2pngm.c -cp ../../../*.h . -cp ../../../*.c . -rm example.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] -rm uncompr.c minigzip.c example.c gz* diff -ru4NwbB libpng-1.4.3/contrib/pngminim/encoder/makefile libpng-1.5.0beta42/contrib/pngminim/encoder/makefile --- libpng-1.4.3/contrib/pngminim/encoder/makefile 2010-06-25 19:32:26.850807045 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/encoder/makefile 2010-08-18 08:12:22.182445098 -0500 @@ -3,40 +3,146 @@ #CC=cc CC=gcc LD=$(CC) +STRIP=strip + +# If awk fails try +# make AWK=nawk RM=rm -f +COPY=cp CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1 C=.c O=.o L=.a E= +# Where to find the source code: +PNGSRC =../../.. +ZLIBSRC=$(PNGSRC)/../zlib +PROGSRC=$(PNGSRC)/contrib/pngminus + +# Zlib +ZSRCS = adler32$(C) compress$(C) crc32$(C) deflate$(C) \ + trees$(C) zutil$(C) + +# Standard headers +#ZH = zlib.h crc32.h deflate.h trees.h zutil.h +ZH = zlib.h crc32.h deflate.h trees.h zutil.h + +# Machine generated headers +ZCONF = zconf.h + +# Headers callers use +ZINC = zlib.h $(ZCONF) + +# Headers the Zlib source uses +ZHDRS = $(ZH) $(ZCONF) + +# compress is not required; it is needed to link the zlib +# code because deflate defines an unused API function deflateBound +# which itself calls compressBound from compress. ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) \ trees$(O) zutil$(O) -OBJS = pnm2pngm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ +# libpng +PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \ + pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \ + pngwtran$(C) pngwutil$(C) + +# Standard headers +PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h + +# Machine generated headers +PNGCONF=pnglibconf.h + +# Headers callers use +PNGINC= png.h pngconf.h pngusr.h $(PNGCONF) + +# Headers the PNG library uses +PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h + +PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \ - pngwtran$(O) pngwutil$(O) $(ZOBJS) + pngwtran$(O) pngwutil$(O) + +PROGSRCS= pnm2pngm$(C) +PROGHDRS= +PROGDOCS= +PROGOBJS= pnm2pngm$(O) + +OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # implicit make rules ------------------------------------------------------- -.c$(O): png.h pngconf.h pngpriv.h pngusr.h zlib.h +.c$(O): $(CC) -c $(CFLAGS) $< # dependencies all: pnm2pngm$(E) pnm2pngm$(E): $(OBJS) $(LD) -o pnm2pngm$(E) $(OBJS) - strip pnm2pngm$(E) + $(STRIP) pnm2pngm$(E) + +# The DFA_XTRA setting turns all libpng options off then +# turns on those required for this minimal build. +# The CPP_FLAGS setting causes pngusr.h to be included in +# both the build of pnglibconf.h and, subsequently, when +# building libpng itself. +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ + $(PNGSRC)/scripts/pnglibconf.dfa \ + $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa + $(RM) pnglibconf.h pnglibconf.dfn + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + DFA_XTRA="pngusr.dfa" $@ clean: + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) clean $(RM) pnm2pngm$(O) $(RM) pnm2pngm$(E) $(RM) $(OBJS) +# distclean also removes the copied source and headers +distclean: clean + $(RM) -r scripts # historical reasons + $(RM) $(PNGSRCS) $(PNGH) + $(RM) $(ZSRCS) $(ZH) $(ZCONF) + $(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS) + +# Header file dependencies: +$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC) +$(PNGOBJS): $(PNGHDRS) $(ZINC) +$(ZOBJS): $(ZHDRS) + +# Gather the source code from the respective directories +$(PNGSRCS) $(PNGH): $(PNGSRC)/$@ + $(RM) $@ + $(COPY) $(PNGSRC)/$@ $@ + +# No dependency on the ZLIBSRC target so that it only needs +# to be specified once. +$(ZSRCS) $(ZH): + $(RM) $@ + $(COPY) $(ZLIBSRC)/$@ $@ + +# The unconfigured zconf.h varies in name according to the +# zlib release +$(ZCONF): + $(RM) $@ + @for f in zconf.h.in zconf.in.h zconf.h; do\ + test -r $(ZLIBSRC)/$$f &&\ + echo $(COPY) $(ZLIBSRC)/$$f $@ &&\ + $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\ + done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1 + +pnm2pngm.c: $(PROGSRC)/pnm2png.c + $(RM) $@ + $(COPY) $(PROGSRC)/pnm2png.c $@ + # End of makefile for pnm2pngm diff -ru4NwbB libpng-1.4.3/contrib/pngminim/encoder/pngusr.dfa libpng-1.5.0beta42/contrib/pngminim/encoder/pngusr.dfa --- libpng-1.4.3/contrib/pngminim/encoder/pngusr.dfa 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/contrib/pngminim/encoder/pngusr.dfa 2010-08-18 08:12:22.191256878 -0500 @@ -0,0 +1,30 @@ +# pngminim/encoder/pngusr.dfa +# +# Copyright (c) 2010 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# First all the build options off: +everything = off + +# Switch on the write code - this makes a minimalist encoder +option WRITE on + +# You must choose fixed or floating point arithmetic: +# option FLOATING_POINT on +option FIXED_POINT on + +# You must chose the internal fixed point implementation or to +# use the system floating point. The latter is considerably +# smaller (by about 1kbyte on an x86 system): +# option FLOATING_ARITHMETIC on +option FLOATING_ARITHMETIC off + +# Your program will probably need other options. The example +# program here, pnm2pngm, requires the following. Take a look +# at pnglibconf.h to find out the full set of what has to be +# enabled to make the following work. +option SETJMP on +option STDIO on diff -ru4NwbB libpng-1.4.3/contrib/pngminim/encoder/pngusr.h libpng-1.5.0beta42/contrib/pngminim/encoder/pngusr.h --- libpng-1.4.3/contrib/pngminim/encoder/pngusr.h 2010-06-25 19:32:26.859731821 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/encoder/pngusr.h 2010-08-18 08:12:22.199951935 -0500 @@ -1,7 +1,7 @@ /* minwrpngconf.h: headers to make a minimal png-write-only library * - * Copyright (c) 2007, 2009 Glenn Randers-Pehrson + * Copyright (c) 2007, 2010 Glenn Randers-Pehrson * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h @@ -11,66 +11,18 @@ #ifndef MINWRPNGCONF_H #define MINWRPNGCONF_H -#define PNG_NO_READ_SUPPORTED +/* If pngusr.h is included during the build the following must + * be defined either here or in the .dfa file (pngusr.dfa in + * this case). To include pngusr.h set -DPNG_USER_CONFIG in + * CPPFLAGS + */ +#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG encoder" +#define PNG_USER_DLLFNAME_POSTFIX "me" +/* List options to turn off features of the build that do not + * affect the API (so are not recorded in pnglibconf.h) + */ #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_WRITE_BACKGROUND -#define PNG_NO_WRITE_BGR -#define PNG_NO_WRITE_GAMMA -#define PNG_NO_WRITE_QUANTIZE -#define PNG_NO_WRITE_INVERT -#define PNG_NO_WRITE_SHIFT -#define PNG_NO_WRITE_PACK -#define PNG_NO_WRITE_PACKSWAP -#define PNG_NO_WRITE_FILLER -#define PNG_NO_WRITE_SWAP -#define PNG_NO_WRITE_SWAP_ALPHA -#define PNG_NO_WRITE_INVERT_ALPHA -#define PNG_NO_WRITE_RGB_TO_GRAY -#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_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 -#define PNG_NO_WRITE_EMPTY_PLTE -#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_IO_STATE -#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 -#define PNG_NO_USER_LIMITS -#define PNG_NO_SET_USER_LIMITS -#define PNG_NO_TIME_RFC1143 #endif /* MINWRPNGCONF_H */ diff -ru4NwbB libpng-1.4.3/contrib/pngminim/preader/README libpng-1.5.0beta42/contrib/pngminim/preader/README --- libpng-1.4.3/contrib/pngminim/preader/README 2010-06-25 19:32:26.868355467 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/preader/README 2010-08-18 08:12:22.208678990 -0500 @@ -1,14 +1,15 @@ This demonstrates the use of PNG_USER_CONFIG and pngusr.h -To build a minimal read-only progressive decoder embedded libpng and -zlib and with your system's X library, run +The makefile builds a minimal read-only progressive decoder with +embedded libpng, zlib and your system's X library. - gather.sh # to collect needed files from gregbook, libpng, and zlib +Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC +on the make command line. Edit makefile if required, to find your X library and include files, then - make + make ZLIBSRC=directory If you prefer to use the shared libraries, go to contrib/gregbook and build the rpng2-x application there. diff -ru4NwbB libpng-1.4.3/contrib/pngminim/preader/gather.sh libpng-1.5.0beta42/contrib/pngminim/preader/gather.sh --- libpng-1.4.3/contrib/pngminim/preader/gather.sh 2010-06-25 19:32:26.876855237 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/preader/gather.sh 1969-12-31 18:00:00.000000000 -0600 @@ -1,9 +0,0 @@ -cp ../../gregbook/rpng2-x.c ../../gregbook/readpng2.[ch] . -cp ../../gregbook/COPYING ../../gregbook/LICENSE . -cp ../../../*.h . -cp ../../../*.c . -rm example.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 gz* diff -ru4NwbB libpng-1.4.3/contrib/pngminim/preader/makefile libpng-1.5.0beta42/contrib/pngminim/preader/makefile --- libpng-1.4.3/contrib/pngminim/preader/makefile 2010-06-25 19:32:26.885497868 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/preader/makefile 2010-08-18 08:12:22.218220027 -0500 @@ -3,10 +3,15 @@ #CC=cc CC=gcc LD=$(CC) +STRIP=strip + +# If awk fails try +# make AWK=nawk RM=rm -f +COPY=cp #XINC = -I/usr/include # old-style, stock X distributions #XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX) @@ -22,39 +27,138 @@ #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 +CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. $(XINC) -O1 C=.c O=.o L=.a E= +# Where to find the source code: +PNGSRC =../../.. +ZLIBSRC=$(PNGSRC)/../zlib +PROGSRC=$(PNGSRC)/contrib/gregbook + +# Zlib (minimal inflate requirements - crc32 is used by libpng) +# zutil can be eliminated if you provide your own zcalloc and zcfree +ZSRCS = adler32$(C) crc32$(C) \ + inffast$(C) inflate$(C) inftrees$(C) \ + zutil$(C) + +# Standard headers +ZH = zlib.h crc32.h inffast.h inffixed.h \ + inflate.h inftrees.h zutil.h + +# Machine generated headers +ZCONF = zconf.h + +# Headers callers use +ZINC = zlib.h $(ZCONF) + +# Headers the Zlib source uses +ZHDRS = $(ZH) $(ZCONF) + ZOBJS = adler32$(O) crc32$(O) \ - infback$(O) inffast$(O) inflate$(O) inftrees$(O) \ - trees$(O) uncompr$(O) zutil$(O) + inffast$(O) inflate$(O) inftrees$(O) \ + zutil$(O) + +# libpng +PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \ + pngpread$(C) pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \ + pngset$(C) pngtrans$(C) + +# Standard headers +PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h -OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ +# Machine generated headers +PNGCONF=pnglibconf.h + +# Headers callers use +PNGINC= png.h pngconf.h pngusr.h $(PNGCONF) + +# Headers the PNG library uses +PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h + +PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \ - pngset$(O) pngtrans$(O) $(ZOBJS) + pngset$(O) pngtrans$(O) + +PROGSRCS= rpng2-x$(C) readpng2$(C) +PROGHDRS= readpng2.h +PROGDOCS= COPYING LICENSE +PROGOBJS= rpng2-x$(O) readpng2$(O) + +OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # implicit make rules ------------------------------------------------------- -.c$(O): png.h pngconf.h pngpriv.h readpng2.h pngusr.h zlib.h +.c$(O): $(CC) -c $(CFLAGS) $< # dependencies -all: rpng2-x$(E) +all: $(PROGDOCS) rpng2-x$(E) rpng2-x$(E): $(OBJS) $(LD) -o rpng2-x$(E) $(OBJS) $(LIBS) - strip rpng2-x$(E) + $(STRIP) rpng2-x$(E) + +# The DFA_XTRA setting turns all libpng options off then +# turns on those required for this minimal build. +# The CPP_FLAGS setting causes pngusr.h to be included in +# both the build of pnglibconf.h and, subsequently, when +# building libpng itself. +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ + $(PNGSRC)/scripts/pnglibconf.dfa \ + $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa + $(RM) pnglibconf.h pnglibconf.dfn + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + DFA_XTRA="pngusr.dfa" $@ clean: + $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) clean $(RM) rpng2-x$(O) $(RM) rpng2-x$(E) $(RM) $(OBJS) +# distclean also removes the copied source and headers +distclean: clean + $(RM) -r scripts # historical reasons + $(RM) $(PNGSRCS) $(PNGH) + $(RM) $(ZSRCS) $(ZH) $(ZCONF) + $(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS) + +# Header file dependencies: +$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC) +$(PNGOBJS): $(PNGHDRS) $(ZINC) +$(ZOBJS): $(ZHDRS) + +# Gather the source code from the respective directories +$(PNGSRCS) $(PNGH): $(PNGSRC)/$@ + $(RM) $@ + $(COPY) $(PNGSRC)/$@ $@ + +# No dependency on the ZLIBSRC target so that it only needs +# to be specified once. +$(ZSRCS) $(ZH): + $(RM) $@ + $(COPY) $(ZLIBSRC)/$@ $@ + +# The unconfigured zconf.h varies in name according to the +# zlib release +$(ZCONF): + $(RM) $@ + @for f in zconf.h.in zconf.in.h zconf.h; do\ + test -r $(ZLIBSRC)/$$f &&\ + echo $(COPY) $(ZLIBSRC)/$$f $@ &&\ + $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\ + done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1 + +$(PROGSRCS) $(PROGHDRS) $(PROGDOCS): $(PROGSRC)/$@ + $(RM) $@ + $(COPY) $(PROGSRC)/$@ $@ + # End of makefile for rpng2-x diff -ru4NwbB libpng-1.4.3/contrib/pngminim/preader/pngusr.dfa libpng-1.5.0beta42/contrib/pngminim/preader/pngusr.dfa --- libpng-1.4.3/contrib/pngminim/preader/pngusr.dfa 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/contrib/pngminim/preader/pngusr.dfa 2010-08-18 08:12:22.227456302 -0500 @@ -0,0 +1,35 @@ +# pngminim/preader/pngusr.dfa +# +# Copyright (c) 2010 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# First all the build options off: +everything = off + +# Just switch on the progressive read code +option PROGRESSIVE_READ on + +# You may choose fixed or floating point APIs: +# option FLOATING_POINT on +option FIXED_POINT on + +# You must chose the internal fixed point implementation or to +# use the system floating point. The latter is considerably +# smaller (by about 1kbyte on an x86 system): +option FLOATING_ARITHMETIC on +# option FLOATING_ARITHMETIC off + +# Your program will probably need other options. The example +# program here, rpng2-x, requires the following. Take a look +# at pnglibconf.h to find out the full set of what has to be +# enabled to make the following work. +option SETJMP on +option STDIO on +option READ_bKGD on +option READ_GAMMA on +option READ_EXPAND on +option READ_16_TO_8 on +option READ_GRAY_TO_RGB on diff -ru4NwbB libpng-1.4.3/contrib/pngminim/preader/pngusr.h libpng-1.5.0beta42/contrib/pngminim/preader/pngusr.h --- libpng-1.4.3/contrib/pngminim/preader/pngusr.h 2010-06-25 19:32:26.894447060 -0500 +++ libpng-1.5.0beta42/contrib/pngminim/preader/pngusr.h 2010-08-18 08:12:22.236313142 -0500 @@ -1,7 +1,7 @@ /* minrdpngconf.h: headers to make a minimal png-read-only library * - * Copyright (c) 2009 Glenn Randers-Pehrson + * Copyright (c) 2009, 2010 Glenn Randers-Pehrson * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h @@ -11,58 +11,18 @@ #ifndef MINPRDPNGCONF_H #define MINPRDPNGCONF_H -#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_READ_BGR -#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 -#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_WRITE_SUPPORTED +/* If pngusr.h is included during the build the following must + * be defined either here or in the .dfa file (pngusr.dfa in + * this case). To include pngusr.h set -DPNG_USER_CONFIG in + * CPPFLAGS + */ +#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG progressive reader" +#define PNG_USER_DLLFNAME_POSTFIX "mp" -#define PNG_NO_INFO_IMAGE -#define PNG_NO_IO_STATE -#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 -#define PNG_NO_USER_LIMITS -#define PNG_NO_SET_USER_LIMITS -#define PNG_NO_TIME_RFC1143 +/* List options to turn off features of the build that do not + * affect the API (so are not recorded in pnglibconf.h) + */ +#define PNG_NO_WARNINGS #endif /* MINPRDPNGCONF_H */ diff -ru4NwbB libpng-1.4.3/example.c libpng-1.5.0beta42/example.c --- libpng-1.4.3/example.c 2010-06-25 19:32:26.011908322 -0500 +++ libpng-1.5.0beta42/example.c 2010-08-18 08:12:21.306580877 -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.4.2 [May 6, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * This file has been placed in the public domain by the authors. * Maintained 1998-2010 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -30,9 +30,9 @@ * is not already defined by libpng!). */ #ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +# define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf) #endif /* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() * returns zero if the image is a PNG and nonzero if it isn't a PNG. @@ -285,9 +285,8 @@ { /* An array of colors to which the image should be quantized */ png_color std_color_cube[MAX_SCREEN_COLORS]; - /* Prior to libpng-1.4.2, this was png_set_dither(). */ png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, NULL, 0); } /* This reduces the image to the palette supplied in the file */ @@ -675,22 +678,23 @@ /* Optionally write comments into the image */ text_ptr[0].key = "Title"; text_ptr[0].text = "Mona Lisa"; text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[0].itxt_length = 0; + text_ptr[0].lang = NULL; + text_ptr[0].lang_key = NULL; text_ptr[1].key = "Author"; text_ptr[1].text = "Leonardo DaVinci"; text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[1].itxt_length = 0; + text_ptr[1].lang = NULL; + text_ptr[1].lang_key = NULL; text_ptr[2].key = "Description"; text_ptr[2].text = ""; text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; -#ifdef PNG_iTXt_SUPPORTED - text_ptr[0].lang = NULL; - text_ptr[0].lang_key = NULL; - text_ptr[1].lang = NULL; - text_ptr[1].lang_key = NULL; + text_ptr[2].itxt_length = 0; text_ptr[2].lang = NULL; text_ptr[2].lang_key = NULL; -#endif png_set_text(png_ptr, info_ptr, text_ptr, 3); /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ diff -ru4NwbB libpng-1.4.3/new_push_process_row.c libpng-1.5.0beta42/new_push_process_row.c --- libpng-1.4.3/new_push_process_row.c 2010-06-25 19:32:26.017067726 -0500 +++ libpng-1.5.0beta42/new_push_process_row.c 1969-12-31 18:00:00.000000000 -0600 @@ -1,204 +0,0 @@ -void /* PRIVATE */ -png_push_process_row(png_structp png_ptr) -{ - png_ptr->row_info.color_type = png_ptr->color_type; - png_ptr->row_info.width = png_ptr->iwidth; - png_ptr->row_info.channels = png_ptr->channels; - png_ptr->row_info.bit_depth = png_ptr->bit_depth; - png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; - - png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, - png_ptr->row_info.width); - - 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(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); - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Blow up interlaced rows to full size */ - if (png_ptr->interlaced && (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); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ - } - - 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, 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++) - { - 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, NULL); - png_read_push_finish_row(png_ptr); - } - - break; - } - - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - 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, 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); - } - - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - 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++) - { - 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); - } - - 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, 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); - } - - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - 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, 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); - } - - if (png_ptr->pass == 6) /* Skip top generated row */ - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - break; - } - 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, NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} diff -ru4NwbB libpng-1.4.3/png.c libpng-1.5.0beta42/png.c --- libpng-1.4.3/png.c 2010-06-25 19:32:26.024705152 -0500 +++ libpng-1.5.0beta42/png.c 2010-08-18 08:12:21.317154388 -0500 @@ -1,8 +1,8 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.4.2 [May 6, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,8 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -#define PNG_NO_EXTERN -#define PNG_NO_PEDANTIC_WARNINGS -#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_%; @@ -52,13 +49,15 @@ * respectively, to be less than, to match, or be greater than the correct * PNG signature (this is the same behaviour as strcmp, memcmp, etc). */ int PNGAPI -png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) +png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check) { png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + if (num_to_check > 8) num_to_check = 8; + else if (num_to_check < 1) return (-1); if (start > 7) @@ -73,10 +72,10 @@ #endif /* PNG_READ_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Function to allocate memory for zlib and clear it to 0. */ -voidpf /* PRIVATE */ -png_zalloc(voidpf png_ptr, uInt items, uInt size) +PNG_FUNCTION(voidpf /* PRIVATE */, +png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) { png_voidp ptr; png_structp p=(png_structp)png_ptr; png_uint_32 save_flags=p->flags; @@ -119,9 +119,9 @@ * also check that this data will actually be used before going to the * trouble of calculating it. */ void /* PRIVATE */ -png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) +png_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length) { int need_crc = 1; if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ @@ -145,10 +146,10 @@ * future. This should be used in favour of malloc(png_sizeof(png_info)) * and png_info_init() so that applications that want to use a shared * libpng don't have to be recompiled if png_info changes size. */ -png_infop PNGAPI -png_create_info_struct(png_structp png_ptr) +PNG_FUNCTION(png_infop,PNGAPI +png_create_info_struct,(png_structp png_ptr),PNG_ALLOCATED) { png_infop info_ptr; png_debug(1, "in png_create_info_struct"); @@ -504,10 +512,10 @@ #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert the supplied time into an RFC 1123 string suitable for use in * a "Creation Time" or other text-based time string. */ -png_charp PNGAPI -png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) +png_const_charp PNGAPI +png_convert_to_rfc1123(png_structp png_ptr, png_const_timep ptime) { static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; @@ -535,33 +544,33 @@ ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); #endif - return ((png_charp)png_ptr->time_buffer); + return png_ptr->time_buffer; } #endif /* PNG_TIME_RFC1123_SUPPORTED */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ -png_charp PNGAPI +png_const_charp PNGAPI png_get_copyright(png_structp png_ptr) { png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ #ifdef PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT #else #ifdef __STDC__ - return ((png_charp) PNG_STRING_NEWLINE \ + return PNG_STRING_NEWLINE \ "libpng version 1.5.0beta42 - August 11, 2010" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2010 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); + PNG_STRING_NEWLINE; #else - return ((png_charp) "libpng version 1.5.0beta42 - August 11, 2010\ + return "libpng version 1.5.0beta42 - August 11, 2010\ Copyright (c) 1998-2010 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; #endif #endif } @@ -572,44 +581,43 @@ * Note: now there is no difference between png_get_libpng_ver() and * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, * it is guaranteed that png.c uses the correct version of png.h. */ -png_charp PNGAPI +png_const_charp PNGAPI png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ - png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); + return png_get_header_ver(png_ptr); } -png_charp PNGAPI +png_const_charp PNGAPI png_get_header_ver(png_structp png_ptr) { /* Version of *.h files used when building libpng */ png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); + return PNG_LIBPNG_VER_STRING; } -png_charp PNGAPI +png_const_charp PNGAPI 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 + return PNG_HEADER_VERSION_STRING #ifndef PNG_READ_SUPPORTED " (NO READ SUPPORT)" #endif - PNG_STRING_NEWLINE); + PNG_STRING_NEWLINE; #else - return ((png_charp) PNG_HEADER_VERSION_STRING); + return PNG_HEADER_VERSION_STRING; #endif } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED int PNGAPI -png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) +png_handle_as_unknown(png_structp png_ptr, png_const_bytep chunk_name) { /* Check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; @@ -658,51 +669,10 @@ } #endif /* PNG_SIZE_T */ /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ -#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_CHECK_cHRM_SUPPORTED -/* - * 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 /* PRIVATE */ -png_64bit_product (long v1, long v2, unsigned long *hi_product, - unsigned long *lo_product) -{ - int a, b, c, d; - long lo, hi, x, y; - - a = (v1 >> 16) & 0xffff; - b = v1 & 0xffff; - c = (v2 >> 16) & 0xffff; - d = v2 & 0xffff; - - lo = b * d; /* BD */ - x = a * d + c * b; /* AD + CB */ - y = ((lo >> 16) & 0xffff) + x; - - lo = (lo & 0xffff) | ((y & 0xffff) << 16); - hi = (y >> 16) & 0xffff; - - hi += a * c; /* AC */ - - *hi_product = (unsigned long)hi; - *lo_product = (unsigned long)lo; -} - int /* PRIVATE */ png_check_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, @@ -771,9 +744,8 @@ return ret; } #endif /* PNG_CHECK_cHRM_SUPPORTED */ -#endif /* PNG_cHRM_SUPPORTED */ void /* PRIVATE */ png_check_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, @@ -914,5 +887,1469 @@ if (error == 1) png_error(png_ptr, "Invalid IHDR data"); } + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* ASCII to fp functions */ +/* Check an ASCII formated floating point value, see the more detailed + * comments in pngpriv.h + */ +/* The following is used internally to preserve the 'valid' flag */ +#define png_fp_add(state, flags) ((state) |= (flags)) +#define png_fp_set(state, value)\ + ((state) = (value) | ((state) & PNG_FP_WAS_VALID)) + +/* Internal type codes: bits above the base state! */ +#define PNG_FP_SIGN 0 /* [+-] */ +#define PNG_FP_DOT 4 /* . */ +#define PNG_FP_DIGIT 8 /* [0123456789] */ +#define PNG_FP_E 12 /* [Ee] */ + +int /* PRIVATE */ +png_check_fp_number(png_const_charp string, png_size_t size, int *statep, + png_size_tp whereami) +{ + int state = *statep; + png_size_t i = *whereami; + + while (i < size) + { + int type; + /* First find the type of the next character */ + { + char ch = string[i]; + + if (ch >= 48 && ch <= 57) + type = PNG_FP_DIGIT; + + else switch (ch) + { + case 43: case 45: type = PNG_FP_SIGN; break; + case 46: type = PNG_FP_DOT; break; + case 69: case 101: type = PNG_FP_E; break; + default: goto PNG_FP_End; + } + } + + /* Now deal with this type according to the current + * state, the type is arranged to not overlap the + * bits of the PNG_FP_STATE. + */ + switch ((state & PNG_FP_STATE) + type) + { + case PNG_FP_INTEGER + PNG_FP_SIGN: + if (state & PNG_FP_SAW_ANY) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, PNG_FP_SAW_SIGN); + break; + + case PNG_FP_INTEGER + PNG_FP_DOT: + /* Ok as trailer, ok as lead of fraction. */ + if (state & PNG_FP_SAW_DOT) /* two dots */ + goto PNG_FP_End; + + else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */ + png_fp_add(state, PNG_FP_SAW_DOT); + + else + png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); + + break; + + case PNG_FP_INTEGER + PNG_FP_DIGIT: + if (state & PNG_FP_SAW_DOT) /* delayed fraction */ + png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); + + png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID); + + break; + case PNG_FP_INTEGER + PNG_FP_E: + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + /* case PNG_FP_FRACTION + PNG_FP_SIGN: + goto PNG_FP_End; ** no sign in exponent */ + + /* case PNG_FP_FRACTION + PNG_FP_DOT: + goto PNG_FP_End; ** Because SAW_DOT is always set */ + + case PNG_FP_FRACTION + PNG_FP_DIGIT: + png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID); + break; + + case PNG_FP_FRACTION + PNG_FP_E: + /* This is correct because the trailing '.' on an + * integer is handled above - so we can only get here + * with the sequence ".E" (with no preceding digits). + */ + if ((state & PNG_FP_SAW_DIGIT) == 0) + goto PNG_FP_End; + + png_fp_set(state, PNG_FP_EXPONENT); + + break; + + case PNG_FP_EXPONENT + PNG_FP_SIGN: + if (state & PNG_FP_SAW_ANY) + goto PNG_FP_End; /* not a part of the number */ + + png_fp_add(state, PNG_FP_SAW_SIGN); + + break; + + /* case PNG_FP_EXPONENT + PNG_FP_DOT: + goto PNG_FP_End; */ + + case PNG_FP_EXPONENT + PNG_FP_DIGIT: + png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID); + + break; + + /* case PNG_FP_EXPONEXT + PNG_FP_E: + goto PNG_FP_End; */ + + default: goto PNG_FP_End; /* I.e. break 2 */ + } + + /* The character seems ok, continue. */ + ++i; + } + +PNG_FP_End: + /* Here at the end, update the state and return the correct + * return code. + */ + *statep = state; + *whereami = i; + + return (state & PNG_FP_SAW_DIGIT) != 0; +} + + +/* The same but for a complete string. */ +int +png_check_fp_string(png_const_charp string, png_size_t size) +{ + int state=0; + png_size_t index=0; + + return png_check_fp_number(string, size, &state, &index) && + (index == size || string[index] == 0); +} +#endif /* pCAL or sCAL */ + +#ifdef PNG_READ_sCAL_SUPPORTED +# ifdef PNG_FLOATING_POINT_SUPPORTED +/* Utility used below - a simple accurate power of ten from an integral + * exponent. + */ +static double +png_pow10(int power) +{ + int recip = 0; + double d = 1; + + /* Handle negative exponent with a reciprocal at the end because + * 10 is exact whereas .1 is inexact in base 2 + */ + if (power < 0) + { + if (power < DBL_MIN_10_EXP) return 0; + recip = 1, power = -power; + } + + if (power > 0) + { + /* Decompose power bitwise. */ + double mult = 10; + do + { + if (power & 1) d *= mult; + mult *= mult; + power >>= 1; + } + while (power > 0); + + if (recip) d = 1/d; + } + /* else power is 0 and d is 1 */ + + return d; +} + +/* Function to format a floating point value in ASCII with a given + * precision. + */ +void /* PRIVATE */ +png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, + double fp, unsigned int precision) +{ + /* We use standard functions from math.h, but not printf because + * that would require stdio. The caller must supply a buffer of + * sufficient size or we will png_error. The tests on size and + * the space in ascii[] consumed are indicated below. + */ + if (precision < 1) + precision = DBL_DIG; + + /* Enforce the limit of the implementation precision too. */ + if (precision > DBL_DIG+1) + precision = DBL_DIG+1; + + /* Basic sanity checks */ + if (size >= precision+5) /* See the requirements below. */ + { + if (fp < 0) + { + fp = -fp; + *ascii++ = 45; /* '-' PLUS 1 TOTAL 1*/ + --size; + } + + if (fp >= DBL_MIN && fp <= DBL_MAX) + { + int exp; /* A base 10 exponent */ + double base; /* 10^exp */ + + /* First extract a base 10 exponent of the number, + * the calculation below rounds down when converting + * from base 2 to base 10 (multiply by log10(2) - + * 0.3010, but 77/256 is 0.3008, so exp needs to + * be increased. Note that the arithmetic shift + * performs a floor() unlike C arithmetic - using a + * C multiply would break the following for negative + * exponents. + */ + (void)frexp(fp, &exp); /* exponent to base 2 */ + + exp = (exp * 77) >> 8; /* <= exponent to base 10 */ + + /* Avoid underflow here. */ + base = png_pow10(exp); /* May underflow */ + + while (base < DBL_MIN || base < fp) + { + /* And this may overflow. */ + double test = png_pow10(exp+1); + + if (test <= DBL_MAX) + ++exp, base = test; + + else + break; + } + + /* Normalize fp and correct exp, after this fp is in the + * range [.1,1) and exp is both the exponent and the digit + * *before* which the decimal point should be inserted + * (starting with 0 for the first digit). Note that this + * works even if 10^exp is out of range because of the + * test on DBL_MAX above. + */ + fp /= base; + while (fp >= 1) fp /= 10, ++exp; + + /* Because of the code above fp may, at this point, be + * less than .1, this is ok because the code below can + * handle the leading zeros this generates, so no attempt + * is made to correct that here. + */ + + { + int czero, clead, cdigits; + char exponent[10]; + + /* Allow up to two leading zeros - this will not lengthen + * the number compared to using E-n. + */ + if (exp < 0 && exp > -3) /* PLUS 3 TOTAL 4 */ + { + czero = -exp; /* PLUS 2 digits: TOTAL 3 */ + exp = 0; /* Dot added below before first output. */ + } + else + czero = 0; /* No zeros to add */ + + /* Generate the digit list, stripping trailing zeros and + * inserting a '.' before a digit if the exponent is 0. + */ + clead = czero; /* Count of leading zeros */ + cdigits = 0; /* Count of digits in list. */ + + do + { + double d; + + fp *= 10; + /* Use modf here, not floor and subtract, so that + * the separation is done in one step. At the end + * of the loop don't break the number into parts so + * that the final digit is rounded. + */ + if (cdigits+czero-clead+1 < (int)precision) + fp = modf(fp, &d); + + else + { + d = floor(fp + .5); + + if (d > 9) + { + /* Rounding up to 10, handle that here. */ + if (czero > 0) + { + --czero, d = 1; + if (cdigits == 0) --clead; + } + else + { + while (cdigits > 0 && d > 9) + { + int ch = *--ascii; + + if (exp != (-1)) + ++exp; + + else if (ch == 46) + { + ch = *--ascii, ++size; + /* Advance exp to '1', so that the + * decimal point happens after the + * previous digit. + */ + exp = 1; + } + + --cdigits; + d = ch - 47; /* I.e. 1+(ch-48) */ + } + + /* Did we reach the beginning? If so adjust the + * exponent but take into account the leading + * decimal point. + */ + if (d > 9) /* cdigits == 0 */ + { + if (exp == (-1)) + { + /* Leading decimal point (plus zeros?), if + * we lose the decimal point here it must + * be reentered below. + */ + int ch = *--ascii; + + if (ch == 46) + ++size, exp = 1; + + /* Else lost a leading zero, so 'exp' is + * still ok at (-1) + */ + } + else + ++exp; + + /* In all cases we output a '1' */ + d = 1; + } + } + } + fp = 0; /* Guarantees termination below. */ + } + + if (d == 0) + { + ++czero; + if (cdigits == 0) ++clead; + } + else + { + /* Included embedded zeros in the digit count. */ + cdigits += czero - clead; + clead = 0; + + while (czero > 0) + { + /* exp == (-1) means we just output the decimal + * place - after the DP don't adjust 'exp' any + * more! + */ + if (exp != (-1)) + { + if (exp == 0) *ascii++ = 46, --size; + /* PLUS 1: TOTAL 4 */ + --exp; + } + *ascii++ = 48, --czero; + } + + if (exp != (-1)) + { + if (exp == 0) *ascii++ = 46, --size; /* counted above */ + --exp; + } + *ascii++ = (char)(48 + (int)d), ++cdigits; + } + } + while (cdigits+czero-clead < (int)precision && fp > DBL_MIN); + + /* The total output count (max) is now 4+precision */ + + /* Check for an exponent, if we don't need one we are + * done and just need to terminate the string. At + * this point exp==(-1) is effectively if flag - it got + * to '-1' because of the decrement after outputing + * the decimal point above (the exponent required is + * *not* -1!) + */ + if (exp >= (-1) && exp <= 2) + { + /* The following only happens if we didn't output the + * leading zeros above for negative exponent, so this + * doest add to the digit requirement. Note that the + * two zeros here can only be output if the two leading + * zeros were *not* output, so this doesn't increase + * the output count. + */ + while (--exp >= 0) *ascii++ = 48; + + *ascii = 0; + + /* Total buffer requirement (including the '\0') is + * 5+precision - see check at the start. + */ + return; + } + + /* Here if an exponent is required, adjust size for + * the digits we output but did not count. The total + * digit output here so far is at most 1+precision - no + * decimal point and no leading or trailing zeros have + * been output. + */ + size -= cdigits; + + *ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision*/ + if (exp < 0) + { + *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ + exp = -exp; + } + + cdigits = 0; + + while (exp > 0) + { + exponent[cdigits++] = 48 + exp % 10; + exp /= 10; + } + + /* Need another size check here for the exponent digits, so + * this need not be considered above. + */ + if ((int)size > cdigits) + { + while (cdigits > 0) *ascii++ = exponent[--cdigits]; + + *ascii = 0; + + return; + } + } + } + else if (!(fp >= DBL_MIN)) + { + *ascii++ = 48; /* '0' */ + *ascii = 0; + return; + } + else + { + *ascii++ = 105; /* 'i' */ + *ascii++ = 110; /* 'n' */ + *ascii++ = 102; /* 'f' */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} + +# endif /* FLOATING_POINT */ + +# ifdef PNG_FIXED_POINT_SUPPORTED +/* Function to format a fixed point value in ASCII. + */ +void /* PRIVATE */ +png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size, + png_fixed_point fp) +{ + /* Require space for 10 decimal digits, a decimal point, a minus sign and a + * trailing \0, 13 characters: + */ + if (size > 12) + { + png_uint_32 num; + + /* Avoid overflow here on the minimum integer. */ + if (fp < 0) + *ascii++ = 45, --size, num = -fp; + else + num = fp; + + if (num <= 0x80000000U) /* else overflowed */ + { + unsigned int ndigits = 0, first = 16/*flag value*/; + char digits[10]; + + while (num) + { + /* Split the low digit off num: */ + unsigned int tmp = num/10; + num -= tmp*10; + digits[ndigits++] = (char)(48 + num); + /* Record the first non-zero digit, note that this is a number + * starting at 1, it's not actually the array index. + */ + if (first == 16 && num > 0) + first = ndigits; + num = tmp; + } + + if (ndigits > 0) + { + while (ndigits > 5) *ascii++ = digits[--ndigits]; + /* The remaining digits are fractional digits, ndigits is '5' or + * smaller at this point. It is certainly not zero. Check for a + * non-zero fractional digit: + */ + if (first <= 5) + { + unsigned int i; + *ascii++ = 46; /* decimal point */ + /* ndigits may be <5 for small numbers, output leading zeros + * then ndigits digits to first: + */ + i = 5; + while (ndigits < i) *ascii++ = 48, --i; + while (ndigits >= first) *ascii++ = digits[--ndigits]; + /* Don't output the trailing zeros! */ + } + } + else + *ascii++ = 48; + + /* And null terminate the string: */ + *ascii = 0; + return; + } + } + + /* Here on buffer too small. */ + png_error(png_ptr, "ASCII conversion buffer too small"); +} +# endif /* FIXED_POINT */ +#endif /* READ_SCAL */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) +png_fixed_point +png_fixed(png_structp png_ptr, double fp, png_const_charp text) +{ + double r = floor(100000 * fp + .5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; + + png_fixed_error(png_ptr, text); + /*NOT REACHED*/ +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || \ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG__READ_pHYs_SUPPORTED) +/* muldiv functions */ +/* This API takes signed arguments and rounds the result to the nearest + * integer (or, for a fixed point number - the standard argument - to + * the nearest .00001). Overflow and divide by zero are signalled in + * the result, a boolean - true on success, false on overflow. + */ +int +png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, + png_int_32 div) +{ + /* Return a * times / div, rounded. */ + if (div != 0) + { + if (a == 0 || times == 0) + { + *res = 0; + return 1; + } + else + { +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a; + r *= times; + r /= div; + r = floor(r+.5); + + /* A png_fixed_point is a 32 bit integer. */ + if (r <= 2147483647. && r >= -2147483648.) + { + *res = (png_fixed_point)r; + return 1; + } +#else + int negative = 0; + png_uint_32 A, T, D; + + if (a < 0) + negative = 1, A = -a; + else + A = a; + + if (times < 0) + negative = !negative, T = -times; + else + T = times; + + if (div < 0) + negative = !negative, D = -div; + else + D = div; + + /* Following can't overflow because the arguments only + * have 31 bits each, however the result may be 32 bits. + */ + png_uint_32 s16 = (A >> 16) * (T & 0xffff) + + (A & 0xffff) * (T >> 16); + /* Can't overflow because the a*times bit is only 30 + * bits at most. + */ + png_uint_32 s32 = (A >> 16) * (T >> 16) + (s16 >> 16); + png_uint_32 s00 = (A & 0xffff) * (T & 0xffff); + + s16 = (s16 & 0xffff) << 16; + s00 += s16; + + if (s00 < s16) + ++s32; /* carry */ + + if (s32 < D) /* else overflow */ + { + /* s32.s00 is now the 64 bit product, do a standard + * division, we know that s32 < D, so the maximum + * required shift is 31. + */ + int bitshift = 32; + png_fixed_point result = 0; /* NOTE: signed */ + + while (--bitshift >= 0) + { + png_uint_32 d32, d00; + + if (bitshift > 0) + d32 = D >> (32-bitshift), d00 = D << bitshift; + + else + d32 = 0, d00 = D; + + if (s32 > d32) + { + if (s00 < d00) --s32; /* carry */ + s32 -= d32, s00 -= d00, result += 1<= d00) + s32 = 0, s00 -= d00, result += 1<= (D >> 1)) + ++result; + + if (negative) + result = -result; + + /* Check for overflow. */ + if (negative && result <= 0 || !negative && result >= 0) + { + *res = result; + return 1; + } + } +#endif + } + } + + return 0; +} +#endif /* READ_GAMMA || INCH_CONVERSIONS */ + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* The following is for when the caller doesn't much care about the + * result. + */ +png_fixed_point +png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times, + png_int_32 div) +{ + png_fixed_point result; + + if (png_muldiv(&result, a, times, div)) + return result; + + png_warning(png_ptr, "fixed point overflow ignored"); + return 0; +} +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gammma */ +/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ +png_fixed_point +png_reciprocal(png_fixed_point a) +{ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(1E10/a+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, 100000, 100000, a)) + return res; +#endif + + return 0; /* error/overflow */ +} + +/* A local convenience routine. */ +static png_fixed_point +png_product2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b, the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = a * 1E-5; + r *= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + png_fixed_point res; + + if (png_muldiv(&res, a, b, 100000)) + return res; +#endif + + return 0; /* overflow */ +} + +/* The inverse of the above. */ +png_fixed_point +png_reciprocal2(png_fixed_point a, png_fixed_point b) +{ + /* The required result is 1/a * 1/b, the following preserves accuracy. */ +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = 1E15/a; + r /= b; + r = floor(r+.5); + + if (r <= 2147483647. && r >= -2147483648.) + return (png_fixed_point)r; +#else + /* This may overflow because the range of png_fixed_point isn't symmetric, + * but this API is only used for the product of file and screen gamma so it + * doesn't matter that the smallest number it can produce is 1/21474, not + * 1/100000 + */ + png_fixed_point res = png_product2(a, b); + + if (res != 0) + return png_reciprocal(res); +#endif + + return 0; /* overflow */ +} +#endif /* READ_GAMMA */ + +#ifdef PNG_CHECK_cHRM_SUPPORTED +/* Added at libpng version 1.2.34 (Dec 8, 2008) and 1.4.0 (Jan 2, + * 2010: moved from pngset.c) */ +/* + * 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 /* PRIVATE */ +png_64bit_product (long v1, long v2, unsigned long *hi_product, + unsigned long *lo_product) +{ + int a, b, c, d; + long lo, hi, x, y; + + a = (v1 >> 16) & 0xffff; + b = v1 & 0xffff; + c = (v2 >> 16) & 0xffff; + d = v2 & 0xffff; + + lo = b * d; /* BD */ + x = a * d + c * b; /* AD + CB */ + y = ((lo >> 16) & 0xffff) + x; + + lo = (lo & 0xffff) | ((y & 0xffff) << 16); + hi = (y >> 16) & 0xffff; + + hi += a * c; /* AC */ + + *hi_product = (unsigned long)hi; + *lo_product = (unsigned long)lo; +} +#endif /* CHECK_cHRM */ + +#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */ +#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED +/* Fixed point gamma. + * + * To calculate gamma this code implements fast log() and exp() calls using only + * fixed point arithmetic. This code has sufficient precision for either 8 or + * 16 bit sample values. + * + * The tables used here were calculated using simple 'bc' programs, but C double + * precision floating point arithmetic would work fine. The programs are given + * at the head of each table. + * + * 8 bit log table + * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to + * 255, so it's the base 2 logarithm of a normalized 8 bit floating point + * mantissa. The numbers are 32 bit fractions. + */ +static png_uint_32 +png_8bit_l2[128] = +{ +# if PNG_DO_BC + for (i=128;i<256;++i) { .5 - l(i/255)/l(2)*65536*65536; } +# endif + 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U, + 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U, + 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U, + 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U, + 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U, + 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U, + 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U, + 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U, + 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U, + 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U, + 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U, + 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U, + 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U, + 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U, + 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U, + 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U, + 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U, + 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U, + 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U, + 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U, + 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U, + 24347096U, 0U +#if 0 + /* The following are the values for 16 bit tables - these work fine for the 8 + * bit conversions but produce very slightly larger errors in the 16 bit log + * (about 1.2 as opposed to 0.7 absolute error in the final value). To use + * these all the shifts below must be adjusted appropriately. + */ + 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054, + 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803, + 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068, + 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782, + 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887, + 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339, + 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098, + 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132, + 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415, + 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523, + 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495, + 1119, 744, 372 +#endif +}; + +static png_uint_32 +png_log8bit(unsigned int x) +{ + unsigned int log = 0; + /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, + * because the log is actually negate that means adding 1. The final + * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 + * input), return 7.99998 for the overflow (log 0) case - so the result is + * always at most 19 bits. + */ + if ((x &= 0xff) == 0) + return 0xffffffff; + + if ((x & 0xf0) == 0) + log = 4, x <<= 4; + + if ((x & 0xc0) == 0) + log += 2, x <<= 2; + + if ((x & 0x80) == 0) + log += 1, x <<= 1; + + return (log << 16) + ((png_8bit_l2[x-128]+32768)>>16); +} + +/* The above gives exact (to 16 binary places) log2 values for 8 bit images, + * for 16 bit images we use the most significant 8 bits of the 16 bit value to + * get an approximation then multiply the approximation by a correction factor + * determined by the remaining up to 8 bits. This requires an additional step + * in the 16 bit case. + * + * We want log2(value/65535), we have log2(v'/255), where: + * + * value = v' * 256 + v'' + * = v' * f + * + * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128 + * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less + * than 258. The final factor also needs to correct for the fact that our 8 bit + * value is scaled by 255, whereas the 16 bit values must be scaled by 65535. + * + * This gives a final formula using a calculated value 'x' which is value/v' and + * scaling by 65536 to match the above table: + * + * log2(x/257) * 65536 + * + * Since these numbers are so close to '1' we can use simple linear + * interpolation between the two end values 256/257 (result -368.61) and 258/257 + * (result 367.179). The values used below are scaled by a further 64 to give + * 16 bit precision in the interpolation: + * + * Start (256): -23591 + * Zero (257): 0 + * End (258): 23499 + */ +static png_uint_32 +png_log16bit(png_uint_32 x) +{ + unsigned int log = 0; + + /* As above, but now the input has 16 bits. */ + if ((x &= 0xffff) == 0) + return 0xffffffff; + + if ((x & 0xff00) == 0) + log = 8, x <<= 8; + + if ((x & 0xf000) == 0) + log += 4, x <<= 4; + + if ((x & 0xc000) == 0) + log += 2, x <<= 2; + + if ((x & 0x8000) == 0) + log += 1, x <<= 1; + + /* Calculate the base logarithm from the top 8 bits as a 28 bit fractional + * value. + */ + log <<= 28; + log += (png_8bit_l2[(x>>8)-128]+8) >> 4; + + /* Now we need to interpolate the factor, this requires a division by the top + * 8 bits. Do this with maximum precision. + */ + x = ((x << 16) + (x >> 9)) / (x >> 8); + + /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, + * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly + * 16 bits to interpolate to get the low bits of the result. Round the + * answer. Note that the end point values are scaled by 64 to retain overall + * precision and that 'log' is current scaled by an extra 12 bits, so adjust + * the overall scaling by 6-12. Round at every step. + */ + x -= 1U << 24; + + if (x <= 65536U) /* <= '257' */ + log += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); + + else + log -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); + + return (log + 2048) >> 12; +} + +/* The 'exp()' case must invert the above, taking a 20 bit fixed point + * logarithmic value and returning a 16 or 8 bit number as appropriate. In + * each case only the low 16 bits are relevant - the fraction - since the + * integer bits (the top 4) simply determine a shift. + * + * The worst case is the 16 bit distinction between 65535 and 65534, this + * requires perhaps spurious accuracty in the decoding of the logarithm to + * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance + * of getting this accuracy in practice. + * + * To deal with this the following exp() function works out the exponent of the + * frational part of the logarithm by using an accurate 32 bit value from the + * top four fractional bits then multiplying in the remaining bits. + */ +static png_uint_32 +png_32bit_exp[16] = +{ +# if PNG_DO_BC + for (i=0;i<16;++i) { .5 + e(-i/16*l(2))*2^32; } +# endif + /* NOTE: the first entry is deliberately set to the maximum 32 bit value. */ + 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U, + 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U, + 2553802834U, 2445529972U, 2341847524U, 2242560872U +}; + +/* Adjustment table; provided to explain the numbers in the code below. */ +#if PNG_DO_BC +for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"} + 11 44937.64284865548751208448 + 10 45180.98734845585101160448 + 9 45303.31936980687359311872 + 8 45364.65110595323018870784 + 7 45395.35850361789624614912 + 6 45410.72259715102037508096 + 5 45418.40724413220722311168 + 4 45422.25021786898173001728 + 3 45424.17186732298419044352 + 2 45425.13273269940811464704 + 1 45425.61317555035558641664 + 0 45425.85339951654943850496 +#endif + +static png_uint_32 +png_exp(png_uint_32 x) +{ + if (x <= 0xfffff) /* Else zero */ + { + /* Obtain a 4 bit approximation */ + png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf]; + + /* Incorporate the low 12 bits - these decrease the returned value by + * multiplying by a number less than 1 if the bit is set. The multiplier + * is determined by the above table and the shift. Notice that the values + * converge on 45426 and this is used to allow linear interpolation of the + * low bits. + */ + if (x & 0x800) + e -= (((e >> 16) * 44938U) + 16U) >> 5; + + if (x & 0x400) + e -= (((e >> 16) * 45181U) + 32U) >> 6; + + if (x & 0x200) + e -= (((e >> 16) * 45303U) + 64U) >> 7; + + if (x & 0x100) + e -= (((e >> 16) * 45365U) + 128U) >> 8; + + if (x & 0x080) + e -= (((e >> 16) * 45395U) + 256U) >> 9; + + if (x & 0x040) + e -= (((e >> 16) * 45410U) + 512U) >> 10; + + /* And handle the low 6 bits in a single block. */ + e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; + + /* Handle the upper bits of x. */ + e >>= x >> 16; + return e; + } + + return 0; +} + +static png_byte +png_exp8bit(png_uint_32 log) +{ + /* Get a 32 bit value: */ + png_uint_32 x = png_exp(log); + + /* Convert the 32 bit value to 0..255 by multiplying by 256-1, note that the + * second, rounding, step can't overflow because of the first, subtraction, + * step. + */ + x -= x >> 8; + return (x + 0x7fffffU) >> 24; +} + +static png_uint_16 +png_exp16bit(png_uint_32 log) +{ + /* Get a 32 bit value: */ + png_uint_32 x = png_exp(log); + + /* Convert the 32 bit value to 0..65535 by multiplying by 65536-1: */ + x -= x >> 16; + return (x + 32767U) >> 16; +} +#endif /* FLOATING_ARITHMETIC */ + +png_byte +png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma) +{ + if (value > 0 && value < 255) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(255*pow(value/255.,gamma*.00001)+.5); + return (png_byte)r; +# else + png_uint_32 log = png_log8bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma, log, PNG_FP_1)) + return png_exp8bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_byte)value; +} + +png_uint_16 +png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma) +{ + if (value > 0 && value < 65535) + { +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + double r = floor(65535*pow(value/65535.,gamma*.00001)+.5); + return (png_uint_16)r; +# else + png_uint_32 log = png_log16bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma, log, PNG_FP_1)) + return png_exp16bit(res); + + /* Overflow. */ + value = 0; +# endif + } + + return (png_uint_16)value; +} + +/* This does the right thing based on the bit_depth field of the + * png_struct, interpreting values as 8 or 16 bit. While the result + * is nominally a 16 bit value if bit depth is 8 then the result is + * 8 bit (as are the arguments.) + */ +png_uint_16 /* PRIVATE */ +png_gamma_correct(png_structp png_ptr, unsigned int value, + png_fixed_point gamma) +{ + if (png_ptr->bit_depth == 8) + return png_gamma_8bit_correct(value, gamma); + + else + return png_gamma_16bit_correct(value, gamma); +} + +/* This is the shared test on whether a gamma value is 'significant' - whether + * it is worth doing gamma correction. + */ +int /* PRIVATE */ +png_gamma_significant(png_fixed_point gamma) +{ + return gamma < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || + gamma > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; +} + +/* Internal function to build a single 16 bit table - the table consists of + * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount + * to shift the input values right (or 16-number_of_signifiant_bits). + * + * The caller is respoonsible for ensuring that the table gets cleaned up on + * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument + * should be somewhere that will be cleaned. + */ +static void +png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma) +{ + /* Various values derived from 'shift': */ + PNG_CONST unsigned int num = 1U << (8U - shift); + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); + unsigned int i; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p)); + + for (i = 0; i < num; i++) + { + png_uint_16p sub_table = table[i] = + (png_uint_16p)png_malloc(png_ptr, 256 * png_sizeof(png_uint_16)); + + /* The 'threshold' test is repeated here because it can arise for one of + * the 16 bit tables even if the others don't hit it. + */ + if (png_gamma_significant(gamma)) + { + /* The old code would overflow at the end and this would cause the + * 'pow' function to return a result >1, resulting in an + * arithmetic error. This code follows the spec exactly; ig is + * the recovered input sample, it always has 8-16 bits. + * + * We want input * 65535/max, rounded, the arithmetic fits in 32 + * bits (unsigned) so long as max <= 32767. + */ + unsigned int j; + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* Inline the 'max' scaling operation: */ + double d = floor(65535*pow(ig/(double)max, gamma*.00001)+.5); + sub_table[j] = (png_uint_16)d; +# else + if (shift) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = png_gamma_16bit_correct(ig, gamma); +# endif + } + } + else + { + /* We must still build a table, but do it the fast way. */ + unsigned int j; + + for (j = 0; j < 256; j++) + { + png_uint_32 ig = (j << (8-shift)) + i; + + if (shift) + ig = (ig * 65535U + max_by_2)/max; + + sub_table[j] = (png_uint_16)ig; + } + } + } +} + +/* NOTE: this function expects the *inverse* of the overall gamma transformation + * required. + */ +static void +png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable, + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma) +{ + PNG_CONST unsigned int num = 1U << (8U - shift); + PNG_CONST unsigned int max = (1U << (16U - shift))-1U; + unsigned int i; + png_uint_32 last; + + png_uint_16pp table = *ptable = + (png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p)); + + /* 'num' is the number of tables and also the number of low bits of low + * bits of the input 16 bit value used to select a table. Each table is + * itself index by the high 8 bits of the value. + */ + for (i = 0; i < num; i++) + table[i] = (png_uint_16p)png_malloc(png_ptr, + 256 * png_sizeof(png_uint_16)); + + /* 'gamma' is set to the reciprocal of the value calculated above, so + * pow(out,g) is an *input* value. 'last' is the last input value set. + * + * In the loop 'i' is used to find output values. Since the output is 8 + * bit there are only 256 possible values. The tables are set up to + * select the closest possible output value for each input by finding + * the input value at the boundary between each pair of output values + * and filling the table up to that boundary with the lower output + * value. + * + * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9 bit + * values the code below uses a 16 bit value in i; the values start at + * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last + * entries are filled with 255). Start i at 128 and fill all 'last' + * table entries <= 'max' + */ + last = 0; + for (i = 0; i < 255; ++i) /* 8 bit output value */ + { + /* Find the corresponding maximum input value */ + png_uint_16 out = (png_uint_16)(i * 257U); /* 16 bit output value */ + + /* Find the boundary value in 16 bits: */ + png_uint_16 bound = png_gamma_16bit_correct(out+128U, gamma); + + /* Adjust (round) to (16-shift) bits: */ + bound = (png_uint_16)(((png_uint_32)bound * max + 32768U)/65535U); + + while (last <= bound) + { + table[last & (0xffU >> shift)][last >> (8U - shift)] = out; + last++; + } + } + + /* And fill in the final entries. */ + while (last < (num << 8)) + { + table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; + last++; + } +} + +/* Build a single 8 bit table: same as the 16 bit case but much simpler (and + * typically much faster). Note that libpng currently does no sBIT processing + * (apparently contrary to the spec) so a 256 entry table is always generated. + */ +static void +png_build_8bit_table(png_structp png_ptr, png_bytepp ptable, + PNG_CONST png_fixed_point gamma) +{ + unsigned int i; + png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); + + if (png_gamma_significant(gamma)) for (i=0; i<256; i++) + table[i] = png_gamma_8bit_correct(i, gamma); + + else for (i=0; i<256; ++i) + table[i] = (png_byte)i; +} + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structp png_ptr, png_byte bit_depth) +{ + png_debug(1, "in png_build_gamma_table"); + + if (bit_depth <= 8) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_table, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, + png_reciprocal(png_ptr->gamma)); + + png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->gamma/* Probably doing rgb_to_gray */); + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + else + { + png_byte shift, sig_bit; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit = png_ptr->sig_bit.red; + + if (png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + + if (png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + sig_bit = png_ptr->sig_bit.gray; + + /* 16 bit gamma code uses this equation: + * + * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] + * + * Where 'iv' is the input color value and 'ov' is the output value - + * pow(iv, gamma). + * + * Thus the gamma table consists of up to 256 256 entry tables. The table + * is selected by the (8-gamma_shift) most significant of the low 8 bits of + * the color value then indexed by the upper 8 bits: + * + * table[low bits][high 8 bits] + * + * So the table 'n' corresponds to all those 'iv' of: + * + * ..<(n+1 << gamma_shift)-1> + * + */ + if (sig_bit > 0) + shift = 16U - sig_bit; /* shift == insignificant bits */ + + else + shift = 0; /* keep all 16 bits */ + + if (png_ptr->transformations & PNG_16_TO_8) + { + /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively + * the significant bits in the *input* when the output will + * eventually be 8 bits. By default it is 11. + */ + if (shift < (16U - PNG_MAX_GAMMA_8)) + shift = (16U - PNG_MAX_GAMMA_8); + } + + if (shift > 8U) + shift = 8U; /* Guarantees at least one table! */ + + png_ptr->gamma_shift = shift; + + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) + png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_product2(png_ptr->gamma, + png_ptr->screen_gamma) : PNG_FP_1); + + else + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->gamma, + png_ptr->screen_gamma) : PNG_FP_1); + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) + { + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, + png_reciprocal(png_ptr->gamma)); + + /* Notice that the '16 from 1' table should be full precision, however + * the lookup on this table still uses gamma_shift, so it can't be. + * TODO: fix this. + */ + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->gamma/* Probably doing rgb_to_gray */); + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } +} +#endif /* READ_GAMMA */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff -ru4NwbB libpng-1.4.3/png.h libpng-1.5.0beta42/png.h --- libpng-1.4.3/png.h 2010-06-25 19:32:25.987938871 -0500 +++ libpng-1.5.0beta42/png.h 2010-08-18 08:12:21.267871150 -0500 @@ -136,16 +136,12 @@ * 1.4.0 14 10400 14.so.14.0[.0] * 1.4.1beta01-03 14 10401 14.so.14.1[.0] * 1.4.1rc01 14 10401 14.so.14.1[.0] * 1.4.1beta04-12 14 10401 14.so.14.1[.0] - * 1.4.1rc02-04 14 10401 14.so.14.1[.0] * 1.4.1 14 10401 14.so.14.1[.0] - * 1.4.2beta01 14 10402 14.so.14.2[.0] - * 1.4.2rc02-06 14 10402 14.so.14.2[.0] * 1.4.2 14 10402 14.so.14.2[.0] - * 1.4.3beta01-05 14 10403 14.so.14.3[.0] - * 1.4.3rc01-03 14 10403 14.so.14.3[.0] * 1.4.3 14 10403 14.so.14.3[.0] + * 1.5.0beta01-42 15 10500 15.so.15.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 @@ -247,10 +243,10 @@ * to the following restrictions: * * 1. The origin of this source code must not be misrepresented. * - * 2. Altered versions must be plainly marked as such and - * must not be misrepresented as being the original source. + * 2. Altered versions must be plainly marked as such and must not + * be misrepresented as being the original source. * * 3. This Copyright notice may not be removed or altered from * any source or altered source distribution. * @@ -293,10 +289,10 @@ * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.5.0beta42 are Y2K compliant. It is my belief that earlier - * versions were also Y2K compliant. + * upward through 1.5.0beta42 are Y2K compliant. It is my belief that + * earlier versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer * that will hold years up to 65535. The other two hold the date in text * format, and will hold years up to 9999. @@ -391,15 +387,32 @@ * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ #define PNG_LIBPNG_VER %VER_NUM% /* %MAJOR%.%MINOR%.%RELEASE% */ +/* Library configuration: these options cannot be changed after + * the library has been built. + */ +#ifndef PNGLCONF_H +# include "pnglibconf.h" +#endif + #ifndef PNG_VERSION_INFO_ONLY -/* Include the compression library's header */ -#include "zlib.h" +/* Standard header files (not needed for the version info) */ +# ifdef PNG_SETJMP_SUPPORTED +# include +# endif + +/* Need the time information for converting tIME chunks, it + * defines struct tm: + */ +#ifdef PNG_CONVERT_tIME_SUPPORTED + /* "time.h" functions are not supported on all operating systems */ +# include #endif -/* Include all user configurable info, including optional assembler routines */ +/* Machine specific configuration. */ #include "pngconf.h" +#endif /* * Added at libpng-1.2.8 * @@ -413,9 +426,9 @@ * file of the same version number. If this value is given, the * StringFileInfo block must contain a SpecialBuild string. */ -#ifdef PNG_USER_PRIVATEBUILD +#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ # define PNG_LIBPNG_BUILD_TYPE \ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) #else # ifdef PNG_LIBPNG_SPECIALBUILD @@ -432,23 +445,58 @@ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -/* This file is arranged in several sections. The first section contains - * structure and type definitions. The second section contains the external - * library functions, while the third has the internal library functions, - * which applications aren't expected to use directly. - */ - -/* 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. */ #define png_libpng_ver png_get_header_ver(NULL) -#endif /* PNG_NO_EXTERN */ - +/* This file is arranged in several sections: + * + * 1. Any configuration options that can be specified by for the application + * code when it is built. (Build time configuration is in pnglibconf.h) + * 2. Type definitions (base types are defined in pngconf.h), structure + * definitions. + * 3. Exported library functions. + * + * The library source code has additional files (principally pngpriv.h) that + * allow configuration of the library. + */ +/* Section 1: run time configuration + * See pnglibconf.h for build time configuration + * + * Run time configuration allows the application to choose between + * implementations of certain arithmetic APIs. The default is set + * at build time and recorded in pnglibconf.h, but it is safe to + * override these (and only these) settings. Note that this won't + * change what the library does, only application code, and the + * settings can (and probably should) be made on a per-file basis + * by setting the #defines before including png.h + * + * Use macros to read integers from PNG data or use the exported + * functions? + * PNG_USE_READ_MACROS: use the macros (see below) Note that + * the macros evaluate their argument multiple times. + * PNG_NO_USE_READ_MACROS: call the relevant library function. + * + * Use the alternative algorithm for compositing alpha samples that + * does not use division? + * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' + * algorithm. + * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. + * + * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is + * false? + * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error + * APIs to png_warning. + * Otherwise the calls are mapped to png_error. + */ + +/* Section 2: type definitions, including structures and compile time + * constants. + * See pngconf.h for base types that vary by machine/system + */ /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to * be png_byte or png_uint_16 (as defined below). */ @@ -458,8 +506,9 @@ png_byte green; png_byte blue; } png_color; typedef png_color FAR * png_colorp; +typedef PNG_CONST png_color FAR * png_const_colorp; typedef png_color FAR * FAR * png_colorpp; typedef struct png_color_16_struct { @@ -469,8 +518,9 @@ png_uint_16 blue; png_uint_16 gray; /* for use in grayscale files */ } png_color_16; typedef png_color_16 FAR * png_color_16p; +typedef PNG_CONST png_color_16 FAR * png_const_color_16p; typedef png_color_16 FAR * FAR * png_color_16pp; typedef struct png_color_8_struct { @@ -480,8 +530,9 @@ png_byte gray; /* for use in grayscale files */ png_byte alpha; /* for alpha channel files */ } png_color_8; typedef png_color_8 FAR * png_color_8p; +typedef PNG_CONST png_color_8 FAR * png_const_color_8p; typedef png_color_8 FAR * FAR * png_color_8pp; /* * The following two structures are used for the in-core representation @@ -495,8 +546,9 @@ png_uint_16 alpha; png_uint_16 frequency; } png_sPLT_entry; typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp; typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; /* When the depth of the sPLT palette is 8 bits, the color and alpha samples * occupy the LSB of their respective members, and the MSB of each member @@ -510,8 +562,9 @@ png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */ } png_sPLT_t; typedef png_sPLT_t FAR * png_sPLT_tp; +typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp; typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, @@ -532,17 +585,16 @@ png_charp key; /* keyword, 1-79 character description of "text" */ png_charp text; /* comment, may be an empty string (ie "") or a NULL pointer */ png_size_t text_length; /* length of the text string */ -#ifdef PNG_iTXt_SUPPORTED png_size_t itxt_length; /* length of the itxt string */ png_charp lang; /* language code, 0-79 characters or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more chars or a NULL pointer */ -#endif } png_text; typedef png_text FAR * png_textp; +typedef PNG_CONST png_text FAR * png_const_textp; typedef png_text FAR * FAR * png_textpp; #endif /* Supported compression types for text in PNG files (tEXt, and zTXt). @@ -570,8 +622,9 @@ png_byte minute; /* minute of hour, 0 - 59 */ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ } png_time; typedef png_time FAR * png_timep; +typedef PNG_CONST png_time FAR * png_const_timep; typedef png_time FAR * FAR * png_timepp; #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) @@ -590,321 +643,27 @@ png_byte location; /* mode of operation at read time */ } png_unknown_chunk; typedef png_unknown_chunk FAR * png_unknown_chunkp; +typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp; typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; #endif -/* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, then call png_write_info(). - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. - * - * In any case, the order of the parameters in png_info_struct should NOT - * be changed for as long as possible to keep compatibility with applications - * that use the old direct-access method with png_info_struct. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -typedef struct png_info_struct -{ - /* the following are necessary for every PNG file */ - png_uint_32 width PNG_DEPSTRUCT; /* width of image in pixels (from IHDR) */ - png_uint_32 height PNG_DEPSTRUCT; /* height of image in pixels (from IHDR) */ - png_uint_32 valid PNG_DEPSTRUCT; /* valid chunk data (see PNG_INFO_ - below) */ - png_size_t rowbytes PNG_DEPSTRUCT; /* bytes needed to hold an untransformed - row */ - png_colorp palette PNG_DEPSTRUCT; /* array of color values - (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in - "palette" (PLTE) */ - png_uint_16 num_trans PNG_DEPSTRUCT; /* number of transparent palette - color (tRNS) */ - png_byte bit_depth PNG_DEPSTRUCT; /* 1, 2, 4, 8, or 16 bits/channel - (from IHDR) */ - png_byte color_type PNG_DEPSTRUCT; /* see PNG_COLOR_TYPE_ below - (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type PNG_DEPSTRUCT; /* must be - PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type PNG_DEPSTRUCT; /* must be PNG_FILTER_TYPE_BASE - (from IHDR) */ - png_byte interlace_type PNG_DEPSTRUCT; /* One of PNG_INTERLACE_NONE, - PNG_INTERLACE_ADAM7 */ - - /* The following is informational only on read, and not used on writes. */ - png_byte channels PNG_DEPSTRUCT; /* number of data channels per - pixel (1, 2, 3, 4) */ - png_byte pixel_depth PNG_DEPSTRUCT; /* number of bits per pixel */ - png_byte spare_byte PNG_DEPSTRUCT; /* to align the data, and for - future use */ - png_byte signature[8] PNG_DEPSTRUCT; /* magic bytes read by libpng - from start of file */ - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) - /* The gAMA chunk describes the gamma characteristics of the system - * on which the image was created, normally in the range [1.0, 2.5]. - * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. - */ - float gamma PNG_DEPSTRUCT; /* gamma value of image, - if (valid & PNG_INFO_gAMA) */ -#endif - -#ifdef PNG_sRGB_SUPPORTED - /* GR-P, 0.96a */ - /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ - png_byte srgb_intent PNG_DEPSTRUCT; /* sRGB rendering intent - [0, 1, 2, or 3] */ -#endif - -#ifdef PNG_TEXT_SUPPORTED - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text PNG_DEPSTRUCT; /* number of comments read/to write */ - int max_text PNG_DEPSTRUCT; /* current size of text array */ - png_textp text PNG_DEPSTRUCT; /* array of comments read/to write */ -#endif /* PNG_TEXT_SUPPORTED */ - -#ifdef PNG_tIME_SUPPORTED - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time PNG_DEPSTRUCT; -#endif - -#ifdef PNG_sBIT_SUPPORTED - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for paletted - image */ - png_color_16 trans_color PNG_DEPSTRUCT; /* 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 - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background PNG_DEPSTRUCT; -#endif - -#ifdef PNG_oFFs_SUPPORTED - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset PNG_DEPSTRUCT; /* x offset on page */ - png_int_32 y_offset PNG_DEPSTRUCT; /* y offset on page */ - png_byte offset_unit_type PNG_DEPSTRUCT; /* offset units type */ -#endif - -#ifdef PNG_pHYs_SUPPORTED - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit PNG_DEPSTRUCT; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit PNG_DEPSTRUCT; /* vertical pixel density */ - png_byte phys_unit_type PNG_DEPSTRUCT; /* resolution type (see - PNG_RESOLUTION_ below) */ -#endif - -#ifdef PNG_hIST_SUPPORTED - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist PNG_DEPSTRUCT; -#endif - -#ifdef PNG_cHRM_SUPPORTED - /* The cHRM chunk describes the CIE color characteristics of the monitor - * on which the PNG was created. This data allows the viewer to do gamut - * mapping of the input image to ensure that the viewer sees the same - * colors in the image as the creator. Values are in the range - * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float x_white PNG_DEPSTRUCT; - float y_white PNG_DEPSTRUCT; - float x_red PNG_DEPSTRUCT; - float y_red PNG_DEPSTRUCT; - float x_green PNG_DEPSTRUCT; - float y_green PNG_DEPSTRUCT; - float x_blue PNG_DEPSTRUCT; - float y_blue PNG_DEPSTRUCT; -#endif -#endif - -#ifdef PNG_pCAL_SUPPORTED - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose PNG_DEPSTRUCT; /* pCAL chunk description string */ - png_int_32 pcal_X0 PNG_DEPSTRUCT; /* minimum value */ - png_int_32 pcal_X1 PNG_DEPSTRUCT; /* maximum value */ - png_charp pcal_units PNG_DEPSTRUCT; /* Latin-1 string giving physical - units */ - png_charpp pcal_params PNG_DEPSTRUCT; /* ASCII strings containing - parameter values */ - png_byte pcal_type PNG_DEPSTRUCT; /* equation type - (see PNG_EQUATION_ below) */ - png_byte pcal_nparams PNG_DEPSTRUCT; /* number of parameters given - in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ - png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is - responsible for freeing */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ - defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) - /* Storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks PNG_DEPSTRUCT; - png_size_t unknown_chunks_num PNG_DEPSTRUCT; -#endif - -#ifdef PNG_iCCP_SUPPORTED - /* iCCP chunk data. */ - png_charp iccp_name PNG_DEPSTRUCT; /* profile name */ - png_charp iccp_profile PNG_DEPSTRUCT; /* International Color Consortium - profile data */ - /* Note to maintainer: should be png_bytep */ - png_uint_32 iccp_proflen PNG_DEPSTRUCT; /* ICC profile data length */ - png_byte iccp_compression PNG_DEPSTRUCT; /* Always zero */ -#endif - -#ifdef PNG_sPLT_SUPPORTED - /* Data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes PNG_DEPSTRUCT; - png_uint_32 splt_palettes_num PNG_DEPSTRUCT; -#endif - -#ifdef PNG_sCAL_SUPPORTED - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponsing to one pixel - * in the image. This external representation is converted to double - * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. - */ - png_byte scal_unit PNG_DEPSTRUCT; /* unit of physical scale */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - double scal_pixel_width PNG_DEPSTRUCT; /* width of one pixel */ - double scal_pixel_height PNG_DEPSTRUCT; /* height of one pixel */ -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp scal_s_width PNG_DEPSTRUCT; /* string containing height */ - png_charp scal_s_height PNG_DEPSTRUCT; /* string containing width */ -#endif -#endif - -#ifdef PNG_INFO_IMAGE_SUPPORTED - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) - non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers PNG_DEPSTRUCT; /* the image bits */ -#endif - -#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) - png_fixed_point int_gamma PNG_DEPSTRUCT; /* gamma of image, - if (valid & PNG_INFO_gAMA) */ -#endif - -#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) - png_fixed_point int_x_white PNG_DEPSTRUCT; - png_fixed_point int_y_white PNG_DEPSTRUCT; - png_fixed_point int_x_red PNG_DEPSTRUCT; - png_fixed_point int_y_red PNG_DEPSTRUCT; - png_fixed_point int_x_green PNG_DEPSTRUCT; - png_fixed_point int_y_green PNG_DEPSTRUCT; - png_fixed_point int_x_blue PNG_DEPSTRUCT; - png_fixed_point int_y_blue PNG_DEPSTRUCT; -#endif - -} png_info; - +typedef struct png_info_def png_info; typedef png_info FAR * png_infop; typedef png_info FAR * FAR * png_infopp; /* 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)) +/* These are constants for fixed point values encoded in the + * PNG specification manner (x100000) + */ +#define PNG_FP_1 100000 +#define PNG_FP_HALF 50000 + /* These describe the color_type field in png_info. */ /* color type masks */ #define PNG_COLOR_MASK_PALETTE 1 #define PNG_COLOR_MASK_COLOR 2 @@ -1012,48 +771,64 @@ /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. + * user read/write data functions. Note that the 'write' function must not + * modify the buffer it is passed. The 'read' function, on the other hand, is + * expected to return the read data in the buffer. */ typedef struct png_struct_def png_struct; typedef png_struct FAR * png_structp; -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); +typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp),); +typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t),); +typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp),); +typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, + int),); +typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, + int),); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, - png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); +typedef PNG_CALLBACK(void, *png_progressive_info_ptr, + (png_structp, png_infop),); +typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop),); +typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, + png_uint_32, int),); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); +typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, + png_bytep),); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, - png_unknown_chunkp)); +typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, + png_unknown_chunkp),); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp),); #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in , and the * application must include this before png.h to obtain the definition - * of jmp_buf. + * of jmp_buf. The function is required to be PNG_NORETURN. (Note that + * PNG_PTR_NORETURN is used here because current versions of the Microsoft + * C compiler do not support the PNG_NORETURN attribute on a pointer.) + * + * If you get a type warning from the compiler when linking against this line + * then your compiler has 'longjmp' that does not match the requirements of the + * compiler that built libpng. You will have to write a wrapper function for + * your compiler's longjmp and call png_set_longjmp_fn directly (not via the + * png_jmpbuf macro.) + * + * If you get a warning here while building the library you will need to make + * changes to ensure that pnglibconf.h records the calling convention used by + * your compiler. This may be very difficult - try using a different compiler + * to build the library! */ -typedef void (PNGAPI *png_longjmp_ptr) PNGARG((jmp_buf, int)); +typedef PNG_FUNCTION(void,(PNGCAPI *png_longjmp_ptr),PNGARG((jmp_buf, int)), + PNG_PTR_NORETURN); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ @@ -1079,449 +854,67 @@ #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_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 - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf PNG_DEPSTRUCT; /* used in png_error */ - png_longjmp_ptr longjmp_fn PNG_DEPSTRUCT;/* setjmp non-local goto - function. */ -#endif - png_error_ptr error_fn PNG_DEPSTRUCT; /* function for printing - errors and aborting */ - png_error_ptr warning_fn PNG_DEPSTRUCT; /* function for printing - warnings */ - png_voidp error_ptr PNG_DEPSTRUCT; /* user supplied struct for - error functions */ - png_rw_ptr write_data_fn PNG_DEPSTRUCT; /* function for writing - output data */ - png_rw_ptr read_data_fn PNG_DEPSTRUCT; /* function for reading - input data */ - png_voidp io_ptr PNG_DEPSTRUCT; /* ptr to application struct - for I/O functions */ - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr read_user_transform_fn PNG_DEPSTRUCT; /* user read - transform */ -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr write_user_transform_fn PNG_DEPSTRUCT; /* user write - transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr PNG_DEPSTRUCT; /* user supplied struct - for user transform */ - png_byte user_transform_depth PNG_DEPSTRUCT; /* bit depth of user - transformed pixels */ - png_byte user_transform_channels PNG_DEPSTRUCT; /* channels in user - transformed pixels */ -#endif -#endif - - png_uint_32 mode PNG_DEPSTRUCT; /* tells us where we are in - the PNG file */ - png_uint_32 flags PNG_DEPSTRUCT; /* flags indicating various - things to libpng */ - png_uint_32 transformations PNG_DEPSTRUCT; /* which transformations - to perform */ - - z_stream zstream PNG_DEPSTRUCT; /* pointer to decompression - structure (below) */ - png_bytep zbuf PNG_DEPSTRUCT; /* buffer for zlib */ - png_size_t zbuf_size PNG_DEPSTRUCT; /* size of zbuf */ - int zlib_level PNG_DEPSTRUCT; /* holds zlib compression level */ - int zlib_method PNG_DEPSTRUCT; /* holds zlib compression method */ - int zlib_window_bits PNG_DEPSTRUCT; /* holds zlib compression window - bits */ - int zlib_mem_level PNG_DEPSTRUCT; /* holds zlib compression memory - level */ - int zlib_strategy PNG_DEPSTRUCT; /* holds zlib compression - strategy */ - - png_uint_32 width PNG_DEPSTRUCT; /* width of image in pixels */ - png_uint_32 height PNG_DEPSTRUCT; /* height of image in pixels */ - png_uint_32 num_rows PNG_DEPSTRUCT; /* number of rows in current pass */ - png_uint_32 usr_width PNG_DEPSTRUCT; /* width of row at start of write */ - png_size_t rowbytes PNG_DEPSTRUCT; /* size of row in bytes */ -#if 0 /* Replaced with the following in libpng-1.4.1 */ - png_size_t irowbytes PNG_DEPSTRUCT; -#endif -/* Added in libpng-1.4.1 */ -#ifdef PNG_USER_LIMITS_SUPPORTED - /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk - * can occupy when decompressed. 0 means unlimited. - * We will change the typedef from png_size_t to png_alloc_size_t - * in libpng-1.6.0 - */ - png_alloc_size_t user_chunk_malloc_max PNG_DEPSTRUCT; -#endif - png_uint_32 iwidth PNG_DEPSTRUCT; /* width of current interlaced - row in pixels */ - png_uint_32 row_number PNG_DEPSTRUCT; /* current row in interlace pass */ - png_bytep prev_row PNG_DEPSTRUCT; /* buffer to save previous - (unfiltered) row */ - png_bytep row_buf PNG_DEPSTRUCT; /* buffer to save current - (unfiltered) row */ - png_bytep sub_row PNG_DEPSTRUCT; /* buffer to save "sub" row - when filtering */ - png_bytep up_row PNG_DEPSTRUCT; /* buffer to save "up" row - when filtering */ - png_bytep avg_row PNG_DEPSTRUCT; /* buffer to save "avg" row - when filtering */ - png_bytep paeth_row PNG_DEPSTRUCT; /* buffer to save "Paeth" row - when filtering */ - png_row_info row_info PNG_DEPSTRUCT; /* used for transformation - routines */ - - png_uint_32 idat_size PNG_DEPSTRUCT; /* current IDAT size for read */ - png_uint_32 crc PNG_DEPSTRUCT; /* current chunk CRC value */ - png_colorp palette PNG_DEPSTRUCT; /* palette from the input file */ - png_uint_16 num_palette PNG_DEPSTRUCT; /* number of color entries in - palette */ - png_uint_16 num_trans PNG_DEPSTRUCT; /* number of transparency values */ - png_byte chunk_name[5] PNG_DEPSTRUCT; /* null-terminated name of current - chunk */ - png_byte compression PNG_DEPSTRUCT; /* file compression type - (always 0) */ - png_byte filter PNG_DEPSTRUCT; /* file filter type (always 0) */ - png_byte interlaced PNG_DEPSTRUCT; /* PNG_INTERLACE_NONE, - PNG_INTERLACE_ADAM7 */ - png_byte pass PNG_DEPSTRUCT; /* current interlace pass (0 - 6) */ - png_byte do_filter PNG_DEPSTRUCT; /* row filter flags (see - PNG_FILTER_ below ) */ - png_byte color_type PNG_DEPSTRUCT; /* color type of file */ - png_byte bit_depth PNG_DEPSTRUCT; /* bit depth of file */ - png_byte usr_bit_depth PNG_DEPSTRUCT; /* bit depth of users row */ - png_byte pixel_depth PNG_DEPSTRUCT; /* number of bits per pixel */ - png_byte channels PNG_DEPSTRUCT; /* number of channels in file */ - png_byte usr_channels PNG_DEPSTRUCT; /* channels at start of write */ - png_byte sig_bytes PNG_DEPSTRUCT; /* magic bytes read/written from - start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) - png_uint_16 filler PNG_DEPSTRUCT; /* filler bytes for pixel - expansion */ -#endif - -#ifdef PNG_bKGD_SUPPORTED - png_byte background_gamma_type PNG_DEPSTRUCT; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma PNG_DEPSTRUCT; -# endif - png_color_16 background PNG_DEPSTRUCT; /* background color in - screen gamma space */ -#ifdef PNG_READ_GAMMA_SUPPORTED - png_color_16 background_1 PNG_DEPSTRUCT; /* background normalized - to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#ifdef PNG_WRITE_FLUSH_SUPPORTED - png_flush_ptr output_flush_fn PNG_DEPSTRUCT; /* Function for flushing - output */ - png_uint_32 flush_dist PNG_DEPSTRUCT; /* how many rows apart to flush, - 0 - no flush */ - png_uint_32 flush_rows PNG_DEPSTRUCT; /* number of rows written since - last flush */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift PNG_DEPSTRUCT; /* number of "insignificant" bits - 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma PNG_DEPSTRUCT; /* file gamma value */ - float screen_gamma PNG_DEPSTRUCT; /* screen gamma value - (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table PNG_DEPSTRUCT; /* gamma table for 8-bit - depth files */ - png_bytep gamma_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to screen */ - png_bytep gamma_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_table PNG_DEPSTRUCT; /* gamma table for 16-bit - depth files */ - png_uint_16pp gamma_16_from_1 PNG_DEPSTRUCT; /* converts from 1.0 to - screen */ - png_uint_16pp gamma_16_to_1 PNG_DEPSTRUCT; /* converts from file to 1.0 */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit PNG_DEPSTRUCT; /* significant bits in each - available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift PNG_DEPSTRUCT; /* shift for significant bit - tranformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans_alpha PNG_DEPSTRUCT; /* alpha values for - paletted files */ - png_color_16 trans_color PNG_DEPSTRUCT; /* transparent color for - non-paletted files */ -#endif - - png_read_status_ptr read_row_fn PNG_DEPSTRUCT; /* called after each - row is decoded */ - png_write_status_ptr write_row_fn PNG_DEPSTRUCT; /* called after each - row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn PNG_DEPSTRUCT; /* called after header - data fully read */ - png_progressive_row_ptr row_fn PNG_DEPSTRUCT; /* called after each - prog. row is decoded */ - png_progressive_end_ptr end_fn PNG_DEPSTRUCT; /* called after image - is complete */ - png_bytep save_buffer_ptr PNG_DEPSTRUCT; /* current location in - save_buffer */ - png_bytep save_buffer PNG_DEPSTRUCT; /* buffer for previously - read data */ - png_bytep current_buffer_ptr PNG_DEPSTRUCT; /* current location in - current_buffer */ - png_bytep current_buffer PNG_DEPSTRUCT; /* buffer for recently - used data */ - png_uint_32 push_length PNG_DEPSTRUCT; /* size of current input - chunk */ - png_uint_32 skip_length PNG_DEPSTRUCT; /* bytes to skip in - input data */ - png_size_t save_buffer_size PNG_DEPSTRUCT; /* amount of data now - in save_buffer */ - png_size_t save_buffer_max PNG_DEPSTRUCT; /* total size of - save_buffer */ - png_size_t buffer_size PNG_DEPSTRUCT; /* total amount of - available input data */ - png_size_t current_buffer_size PNG_DEPSTRUCT; /* amount of data now - in current_buffer */ - int process_mode PNG_DEPSTRUCT; /* what push library - is currently doing */ - int cur_palette PNG_DEPSTRUCT; /* current push library - palette index */ - -# ifdef PNG_TEXT_SUPPORTED - png_size_t current_text_size PNG_DEPSTRUCT; /* current size of - text input data */ - png_size_t current_text_left PNG_DEPSTRUCT; /* how much text left - to read in input */ - png_charp current_text PNG_DEPSTRUCT; /* current text chunk - buffer */ - png_charp current_text_ptr PNG_DEPSTRUCT; /* current location - in current_text */ -# 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 */ - png_bytepp offset_table_ptr PNG_DEPSTRUCT; - png_bytep offset_table PNG_DEPSTRUCT; - png_uint_16 offset_table_number PNG_DEPSTRUCT; - png_uint_16 offset_table_count PNG_DEPSTRUCT; - png_uint_16 offset_table_count_free PNG_DEPSTRUCT; -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - png_bytep palette_lookup PNG_DEPSTRUCT; /* lookup table for quantizing */ - png_bytep quantize_index PNG_DEPSTRUCT; /* index translation for palette - files */ -#endif - -#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist PNG_DEPSTRUCT; /* histogram */ -#endif - -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - png_byte heuristic_method PNG_DEPSTRUCT; /* heuristic for row - filter selection */ - png_byte num_prev_filters PNG_DEPSTRUCT; /* number of weights - for previous rows */ - png_bytep prev_filters PNG_DEPSTRUCT; /* filter type(s) of - previous row(s) */ - png_uint_16p filter_weights PNG_DEPSTRUCT; /* weight(s) for previous - line(s) */ - png_uint_16p inv_filter_weights PNG_DEPSTRUCT; /* 1/weight(s) for - previous line(s) */ - png_uint_16p filter_costs PNG_DEPSTRUCT; /* relative filter - calculation cost */ - png_uint_16p inv_filter_costs PNG_DEPSTRUCT; /* 1/relative filter - calculation cost */ -#endif - -#ifdef PNG_TIME_RFC1123_SUPPORTED - png_charp time_buffer PNG_DEPSTRUCT; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - - png_uint_32 free_me PNG_DEPSTRUCT; /* flags items libpng is - responsible for freeing */ - -#ifdef PNG_USER_CHUNKS_SUPPORTED - png_voidp user_chunk_ptr PNG_DEPSTRUCT; - png_user_chunk_ptr read_user_chunk_fn PNG_DEPSTRUCT; /* user read - chunk handler */ -#endif - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int num_chunk_list PNG_DEPSTRUCT; - png_bytep chunk_list PNG_DEPSTRUCT; -#endif - -/* New members added in libpng-1.0.3 */ -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - png_byte rgb_to_gray_status PNG_DEPSTRUCT; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff PNG_DEPSTRUCT; - png_uint_16 rgb_to_gray_green_coeff PNG_DEPSTRUCT; - png_uint_16 rgb_to_gray_blue_coeff PNG_DEPSTRUCT; -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.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 */ - png_uint_32 mng_features_permitted PNG_DEPSTRUCT; -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma PNG_DEPSTRUCT; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#ifdef PNG_MNG_FEATURES_SUPPORTED - png_byte filter_type PNG_DEPSTRUCT; -#endif - -/* New members added in libpng-1.2.0 */ - -/* 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 PNG_DEPSTRUCT; /* user supplied struct for - mem functions */ - png_malloc_ptr malloc_fn PNG_DEPSTRUCT; /* function for - allocating memory */ - png_free_ptr free_fn PNG_DEPSTRUCT; /* function for - freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf PNG_DEPSTRUCT; /* buffer to save current - (unfiltered) row */ - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep quantize_sort PNG_DEPSTRUCT; /* working sort array */ - png_bytep index_to_palette PNG_DEPSTRUCT; /* where the original - index currently is - in the palette */ - png_bytep palette_to_index PNG_DEPSTRUCT; /* which original index - points to this - palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type PNG_DEPSTRUCT; - -#ifdef PNG_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max PNG_DEPSTRUCT; - png_uint_32 user_height_max PNG_DEPSTRUCT; - /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown - * chunks that can be stored (0 means unlimited). - */ - png_uint_32 user_chunk_cache_max PNG_DEPSTRUCT; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED - /* Storage for unknown chunk that the library doesn't recognize. */ - png_unknown_chunk unknown_chunk PNG_DEPSTRUCT; -#endif - -/* New members added in libpng-1.2.26 */ - png_uint_32 old_big_row_buf_size PNG_DEPSTRUCT; - png_uint_32 old_prev_row_size PNG_DEPSTRUCT; - -/* New member added in libpng-1.2.30 */ - png_charp chunkdata PNG_DEPSTRUCT; /* buffer for reading chunk data */ - -#ifdef PNG_IO_STATE_SUPPORTED -/* New member added in libpng-1.4.0 */ - png_uint_32 io_state PNG_DEPSTRUCT; -#endif -}; - +/* NOTE: prior to 1.5 these functions had no 'API' style declaration, + * this allowed the zlib default functions to be used on Windows + * platforms. In 1.5 the zlib default malloc (which just calls malloc and + * ignores the first argument) should be completely compatible with the + * following. + */ +typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, + png_alloc_size_t),); +typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp),); /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ typedef png_structp version_%_VER_%; typedef png_struct FAR * FAR * png_structpp; -/* Here are the function definitions most commonly used. This is not +/* Section 3: exported functions + * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. */ /* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); +PNG_EXPORT(png_uint_32,png_access_version_number,(void),,1); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); +PNG_EXPORT(void,png_set_sig_bytes,(png_structp png_ptr, int num_bytes),,2); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); +PNG_EXPORT(int,png_sig_cmp,(png_const_bytep sig, png_size_t start, + png_size_t num_to_check),,3); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #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, - png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED; +PNG_EXPORT(png_structp,png_create_read_struct,(png_const_charp user_png_ver, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), + PNG_ALLOCATED,4); /* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)) PNG_ALLOCATED; +PNG_EXPORT(png_structp,png_create_write_struct,(png_const_charp user_png_ver, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), + PNG_ALLOCATED,5); -extern PNG_EXPORT(png_size_t,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_size_t,png_get_compression_buffer_size,(png_structp png_ptr),,6); -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_size_t size)); +PNG_EXPORT(void,png_set_compression_buffer_size,(png_structp png_ptr, + png_size_t size),,7); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ @@ -1532,288 +925,307 @@ * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ -extern PNG_EXPORT(jmp_buf*, png_set_longjmp_fn) - PNGARG((png_structp png_ptr, png_longjmp_ptr longjmp_fn, size_t - jmp_buf_size)); +PNG_EXPORT(jmp_buf*,png_set_longjmp_fn,(png_structp png_ptr, + png_longjmp_ptr longjmp_fn, size_t jmp_buf_size),,8); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif +/* This function should be used by libpng applications in place of + * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it + * will use it; otherwise it will call PNG_ABORT(). This function was + * added in libpng-1.5.0. + */ +PNG_EXPORT(void,png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN,9); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); +PNG_EXPORT(int,png_reset_zstream,(png_structp png_ptr),,10); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED; -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)) PNG_ALLOCATED; +PNG_EXPORT(png_structp,png_create_read_struct_2,(png_const_charp user_png_ver, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED,11); +PNG_EXPORT(png_structp,png_create_write_struct_2,(png_const_charp user_png_ver, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED,12); #endif /* Write the PNG file signature. */ -extern PNG_EXPORT(void,png_write_sig) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_write_sig,(png_structp png_ptr),,13); /* 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)); +PNG_EXPORT(void,png_write_chunk,(png_structp png_ptr, png_const_bytep + chunk_name, png_const_bytep data, png_size_t length),,14); /* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); +PNG_EXPORT(void,png_write_chunk_start,(png_structp png_ptr, + png_const_bytep chunk_name, png_uint_32 length),,15); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); +PNG_EXPORT(void,png_write_chunk_data,(png_structp png_ptr, png_const_bytep data, + png_size_t length),,16); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_write_chunk_end,(png_structp png_ptr),,17); /* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)) PNG_ALLOCATED; +PNG_EXPORT(png_infop,png_create_info_struct,(png_structp png_ptr), + PNG_ALLOCATED,18); -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); +PNG_EXPORT(void,png_info_init_3,(png_infopp info_ptr, + png_size_t png_info_struct_size),,19); /* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(void,png_write_info_before_PLTE,(png_structp png_ptr, + png_infop info_ptr),,20); +PNG_EXPORT(void,png_write_info,(png_structp png_ptr, png_infop info_ptr),,21); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(void,png_read_info,(png_structp png_ptr, png_infop info_ptr),,22); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); +PNG_EXPORT(png_const_charp,png_convert_to_rfc1123,(png_structp png_ptr, + png_const_timep ptime),,23); #endif #ifdef PNG_CONVERT_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)); +PNG_EXPORT(void,png_convert_from_struct_tm,(png_timep ptime, + PNG_CONST struct tm FAR * ttime),,24); /* 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)); +PNG_EXPORT(void,png_convert_from_time_t,(png_timep ptime, time_t ttime),,25); #endif /* PNG_CONVERT_tIME_SUPPORTED */ #ifdef 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)); -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -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)); +PNG_EXPORT(void,png_set_expand,(png_structp png_ptr),,26); +PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8,(png_structp png_ptr),,27); +PNG_EXPORT(void,png_set_palette_to_rgb,(png_structp png_ptr),,28); +PNG_EXPORT(void,png_set_tRNS_to_alpha,(png_structp png_ptr),,29); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_bgr,(png_structp png_ptr),,30); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif +PNG_EXPORT(void,png_set_gray_to_rgb,(png_structp png_ptr),,31); -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); +PNG_FP_EXPORT(void,png_set_rgb_to_gray,(png_structp png_ptr, int error_action, + double red, double green ),,32); +PNG_FIXED_EXPORT(void,png_set_rgb_to_gray_fixed,(png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green),,33); + +PNG_EXPORT(png_byte,png_get_rgb_to_gray_status,(png_structp png_ptr),,34); #endif -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); +PNG_EXPORT(void,png_build_grayscale_palette,(int bit_depth, + png_colorp palette),,35); #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_strip_alpha,(png_structp png_ptr),,36); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_swap_alpha,(png_structp png_ptr),,37); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_invert_alpha,(png_structp png_ptr),,38); #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)); +PNG_EXPORT(void,png_set_filler,(png_structp png_ptr, png_uint_32 filler, + int flags),,39); /* 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. */ -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); +PNG_EXPORT(void,png_set_add_alpha,(png_structp png_ptr, png_uint_32 filler, + int flags),,40); #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. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_swap,(png_structp png_ptr),,41); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_packing,(png_structp png_ptr),,42); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_packswap,(png_structp png_ptr),,43); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); +PNG_EXPORT(void,png_set_shift,(png_structp png_ptr, png_const_color_8p + true_bits),,44); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +/* Have the code handle the interlacing. Returns the number of passes. + * MUST be called before png_read_update_info or png_start_read_image, otherwise + * it will not have the desired effect. Note that it is still necessary to call + * png_read_row or png_read_rows png_get_image_height times for each pass. + */ +PNG_EXPORT(int,png_set_interlace_handling,(png_structp png_ptr),,45); +#endif + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Alternatively call this to get the number of rows in the current pass. Call + * this after png_read_update_info or png_start_read_image; if you call it + * before it will just return the image height (which is also what it returns + * for a non-interlaced image!). + * + * NOTE: you need to call these to find out how many times to call png_read_row + * if you handle your own de-interlacing. + */ +PNG_EXPORT(int,png_get_num_passes,(png_structp png_ptr),,215); +PNG_EXPORT(png_uint_32,png_get_num_rows,(png_structp png_ptr),,216); +PNG_EXPORT(png_uint_32,png_get_num_cols,(png_structp png_ptr),,218); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_invert_mono,(png_structp png_ptr),,46); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); +PNG_FP_EXPORT(void,png_set_background,(png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma),,47); +PNG_FIXED_EXPORT(void,png_set_background_fixed,(png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma),,217); #endif +#ifdef PNG_READ_BACKGROUND_SUPPORTED #define PNG_BACKGROUND_GAMMA_UNKNOWN 0 #define PNG_BACKGROUND_GAMMA_SCREEN 1 #define PNG_BACKGROUND_GAMMA_FILE 2 #define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_16_TO_8_SUPPORTED /* Strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_strip_16,(png_structp png_ptr),,48); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors - * available. Prior to libpng-1.4.2, this was png_set_dither(). + * available. */ -extern PNG_EXPORT(void,png_set_quantize) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_quantize)); +PNG_EXPORT(void,png_set_quantize,(png_structp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_const_uint_16p histogram, + int full_quantize),,49); #endif -/* This migration aid will be removed from libpng-1.5.0 */ -#define png_set_dither png_set_quantize #ifdef PNG_READ_GAMMA_SUPPORTED +/* The threshold on gamma processing is configurable but hard-wired into the + * library. The following is the floating point variant. + */ +#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) + /* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif +PNG_FP_EXPORT(void,png_set_gamma,(png_structp png_ptr, double screen_gamma, + double default_file_gamma),,50); +PNG_FIXED_EXPORT(void,png_set_gamma_fixed,(png_structp png_ptr, + png_fixed_point screen_gamma, png_fixed_point default_file_gamma),,208); #endif #ifdef 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)); +PNG_EXPORT(void,png_set_flush,(png_structp png_ptr, int nrows),,51); /* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_write_flush,(png_structp png_ptr),,52); #endif /* Optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_start_read_image,(png_structp png_ptr),,53); /* Optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(void,png_read_update_info,(png_structp png_ptr, png_infop info_ptr),, + 54); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); +PNG_EXPORT(void,png_read_rows,(png_structp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows),,55); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); +PNG_EXPORT(void,png_read_row,(png_structp png_ptr, png_bytep row, + png_bytep display_row),,56); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); +PNG_EXPORT(void,png_read_image,(png_structp png_ptr, png_bytepp image),,57); #endif /* Write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); +PNG_EXPORT(void,png_write_row,(png_structp png_ptr, png_const_bytep row),,58); -/* Write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); +/* Write a few rows of image data: (*row) is not written; however, the type is + * declared as writeable to maintain compatibility with previous versions of + * libpng and to allow the 'display_row' array from read_rows to be passed + * unchanged to write_rows. + */ +PNG_EXPORT(void,png_write_rows,(png_structp png_ptr, png_bytepp row, + png_uint_32 num_rows),,59); /* Write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); +PNG_EXPORT(void,png_write_image,(png_structp png_ptr, png_bytepp image),,60); /* Write the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(void,png_write_end,(png_structp png_ptr, png_infop info_ptr),,61); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); +PNG_EXPORT(void,png_read_end,(png_structp png_ptr, png_infop info_ptr),,62); #endif /* Free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); +PNG_EXPORT(void,png_destroy_info_struct,(png_structp png_ptr, + png_infopp info_ptr_ptr),,63); /* Free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); +PNG_EXPORT(void,png_destroy_read_struct,(png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr),,64); /* Free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); +PNG_EXPORT(void,png_destroy_write_struct,(png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr),,65); /* Set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); +PNG_EXPORT(void,png_set_crc_action,(png_structp png_ptr, int crit_action, + int ancil_action),,66); /* Values for png_set_crc_action() to say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical @@ -1840,10 +1252,10 @@ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); +PNG_EXPORT(void,png_set_filter,(png_structp png_ptr, int method, int filters),, + 67); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. @@ -1896,13 +1308,14 @@ * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif +PNG_FP_EXPORT(void,png_set_filter_heuristics,(png_structp png_ptr, + int heuristic_method, int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs),,68); +PNG_FIXED_EXPORT(void,png_set_filter_heuristics_fixed,(png_structp png_ptr, + int heuristic_method, int num_weights, png_const_fixed_point_p + filter_weights, png_const_fixed_point_p filter_costs),,209); #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. @@ -1918,22 +1331,21 @@ * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); +PNG_EXPORT(void,png_set_compression_level,(png_structp png_ptr, int level),,69); -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); +PNG_EXPORT(void,png_set_compression_mem_level,(png_structp png_ptr, + int mem_level),,70); -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); +PNG_EXPORT(void,png_set_compression_strategy,(png_structp png_ptr, + int strategy),,71); -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); +PNG_EXPORT(void,png_set_compression_window_bits,(png_structp png_ptr, + int window_bits),,72); -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); +PNG_EXPORT(void,png_set_compression_method,(png_structp png_ptr, int method),, + 73); /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and @@ -1944,10 +1356,9 @@ */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, - png_FILE_p fp)); +PNG_EXPORT(void,png_init_io,(png_structp png_ptr, png_FILE_p fp),,74); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still @@ -1956,13 +1367,13 @@ * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); +PNG_EXPORT(void,png_set_error_fn,(png_structp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn),,75); /* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_voidp,png_get_error_ptr,(png_structp png_ptr),,76); /* 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 @@ -1972,103 +1383,100 @@ * 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)); +PNG_EXPORT(void,png_set_write_fn,(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn),,77); /* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); +PNG_EXPORT(void,png_set_read_fn,(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn),,78); /* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_voidp,png_get_io_ptr,(png_structp png_ptr),,79); -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); +PNG_EXPORT(void,png_set_read_status_fn,(png_structp png_ptr, + png_read_status_ptr read_row_fn),,80); -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); +PNG_EXPORT(void,png_set_write_status_fn,(png_structp png_ptr, + png_write_status_ptr write_row_fn),,81); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +PNG_EXPORT(void,png_set_mem_fn,(png_structp png_ptr, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn),,82); /* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_voidp,png_get_mem_ptr,(png_structp png_ptr),,83); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); +PNG_EXPORT(void,png_set_read_user_transform_fn,(png_structp png_ptr, + png_user_transform_ptr read_user_transform_fn),,84); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); +PNG_EXPORT(void,png_set_write_user_transform_fn,(png_structp png_ptr, + png_user_transform_ptr write_user_transform_fn),,85); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); +PNG_EXPORT(void,png_set_user_transform_info,(png_structp png_ptr, + png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels),,86); /* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_voidp,png_get_user_transform_ptr,(png_structp png_ptr),,87); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); +PNG_EXPORT(void,png_set_read_user_chunk_fn,(png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn),,88); +PNG_EXPORT(png_voidp,png_get_user_chunk_ptr,(png_structp png_ptr),,89); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((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)); +PNG_EXPORT(void,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),,90); /* Returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_voidp,png_get_progressive_ptr,(png_structp png_ptr),,91); /* Function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); +PNG_EXPORT(void,png_process_data,(png_structp png_ptr, png_infop info_ptr, + png_bytep buffer, png_size_t buffer_size),,92); -/* Function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? +/* Function that combines rows. 'new_row' is a flag that should come from the + * callback and be non-NULL if anything needs to be done; the library stores its + * own version of the new data internally and ignores the passed in value. */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); +PNG_EXPORT(void,png_progressive_combine_row,(png_structp png_ptr, + png_bytep old_row, png_const_bytep new_row),,93); #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_alloc_size_t size)) PNG_ALLOCATED; +PNG_EXPORT(png_voidp,png_malloc,(png_structp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED,94); /* Added at libpng version 1.4.0 */ -extern PNG_EXPORT(png_voidp,png_calloc) PNGARG((png_structp png_ptr, - png_alloc_size_t size)) PNG_ALLOCATED; +PNG_EXPORT(png_voidp,png_calloc,(png_structp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED,95); /* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_alloc_size_t size)) PNG_ALLOCATED; +PNG_EXPORT(png_voidp,png_malloc_warn,(png_structp png_ptr, + png_alloc_size_t size),PNG_ALLOCATED,96); /* Frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); +PNG_EXPORT(void,png_free,(png_structp png_ptr, png_voidp ptr),,97); /* 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)); +PNG_EXPORT(void,png_free_data,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 free_me, int num),,98); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); +PNG_EXPORT(void,png_data_freer,(png_structp png_ptr, png_infop info_ptr, + int freer, png_uint_32 mask),,99); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 @@ -2087,48 +1495,56 @@ #define PNG_FREE_ALL 0x7fff #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_alloc_size_t size)) PNG_ALLOCATED; -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); +PNG_EXPORT(png_voidp,png_malloc_default,(png_structp png_ptr, + png_alloc_size_t size),PNG_ALLOCATED,100); +PNG_EXPORT(void,png_free_default,(png_structp png_ptr, png_voidp ptr),,101); #endif -#ifndef PNG_NO_ERROR_TEXT +#ifdef PNG_ERROR_TEXT_SUPPORTED /* 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)) PNG_NORETURN; +PNG_EXPORT(void,png_error,(png_structp png_ptr, png_const_charp error_message), + PNG_NORETURN,102); /* 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)) PNG_NORETURN; +PNG_EXPORT(void,png_chunk_error,(png_structp png_ptr, + png_const_charp error_message),PNG_NORETURN,103); #else /* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)) PNG_NORETURN; +PNG_EXPORT(void,png_err,(png_structp png_ptr),PNG_NORETURN,104); #endif /* 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)); +PNG_EXPORT(void,png_warning,(png_structp png_ptr, + png_const_charp warning_message),,105); /* 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)); +PNG_EXPORT(void,png_chunk_warning,(png_structp png_ptr, + png_const_charp warning_message),,106); #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)); +# undef png_benign_error +PNG_EXPORT(void,png_benign_error,(png_structp png_ptr, + png_const_charp warning_message),,107); /* 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)); +# undef png_chunk_benign_error +PNG_EXPORT(void,png_chunk_benign_error,(png_structp png_ptr, + png_const_charp warning_message),,108); -extern PNG_EXPORT(void,png_set_benign_errors) PNGARG((png_structp - png_ptr, int allowed)); +PNG_EXPORT(void,png_set_benign_errors,(png_structp png_ptr, int allowed),,109); +#else +# ifdef PNG_ALLOW_BENIGN_ERRORS +# define png_benign_error png_warning +# define png_chunk_benign_error png_chunk_warning +# else +# define png_benign_error png_error +# define png_chunk_benign_error png_chunk_error +# endif #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 @@ -2142,260 +1558,246 @@ * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); +PNG_EXPORT(png_uint_32,png_get_valid,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 flag),,110); /* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_size_t,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(png_size_t,png_get_rowbytes,(png_structp png_ptr, + png_infop info_ptr),,111); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(png_bytepp,png_get_rows,(png_structp png_ptr, png_infop info_ptr),, + 112); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); +PNG_EXPORT(void,png_set_rows,(png_structp png_ptr, png_infop info_ptr, + png_bytepp row_pointers),,113); #endif /* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_channels,(png_structp png_ptr, png_infop info_ptr),, + 114); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_uint_32,png_get_image_width,(png_structp png_ptr, + png_infop info_ptr),,115); /* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_uint_32,png_get_image_height,(png_structp png_ptr, + png_infop info_ptr),,116); /* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_bit_depth,(png_structp png_ptr, png_infop info_ptr), + ,117); /* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_color_type,(png_structp png_ptr, + png_infop info_ptr),,118); /* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_filter_type,(png_structp png_ptr, + png_infop info_ptr),,119); /* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_interlace_type,(png_structp png_ptr, + png_infop info_ptr),,120); /* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_byte,png_get_compression_type,(png_structp png_ptr, + png_infop info_ptr),,121); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_uint_32,png_get_pixels_per_meter,(png_structp png_ptr, + png_infop info_ptr),,122); +PNG_EXPORT(png_uint_32,png_get_x_pixels_per_meter,(png_structp png_ptr, + png_infop info_ptr),,123); +PNG_EXPORT(png_uint_32,png_get_y_pixels_per_meter,(png_structp png_ptr, + png_infop info_ptr),,124); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif +PNG_FP_EXPORT(float,png_get_pixel_aspect_ratio,(png_structp png_ptr, + png_infop info_ptr),,125); +PNG_FIXED_EXPORT(png_fixed_point,png_get_pixel_aspect_ratio_fixed, + (png_structp png_ptr, png_infop info_ptr),,210); /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); +PNG_EXPORT(png_int_32,png_get_x_offset_pixels,(png_structp png_ptr, + png_infop info_ptr),,126); +PNG_EXPORT(png_int_32,png_get_y_offset_pixels,(png_structp png_ptr, + png_infop info_ptr),,127); +PNG_EXPORT(png_int_32,png_get_x_offset_microns,(png_structp png_ptr, + png_infop info_ptr),,128); +PNG_EXPORT(png_int_32, png_get_y_offset_microns,(png_structp png_ptr, + png_infop info_ptr),,129); #endif /* PNG_EASY_ACCESS_SUPPORTED */ /* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); +PNG_EXPORT(png_const_bytep,png_get_signature,(png_structp png_ptr, + png_infop info_ptr),,130); #ifdef PNG_bKGD_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); +PNG_EXPORT(png_uint_32,png_get_bKGD,(png_structp png_ptr, png_infop info_ptr, + png_color_16p *background),,131); #endif #ifdef PNG_bKGD_SUPPORTED -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); +PNG_EXPORT(void,png_set_bKGD,(png_structp png_ptr, png_infop info_ptr, + png_const_color_16p background),,132); #endif #ifdef PNG_cHRM_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, +PNG_FP_EXPORT(png_uint_32,png_get_cHRM,(png_structp png_ptr, png_infop info_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 -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_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)); + double *blue_y),,133); +#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */ +PNG_FIXED_EXPORT(png_uint_32,png_get_cHRM_fixed,(png_structp png_ptr, + png_infop info_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),,134); #endif #endif #ifdef PNG_cHRM_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_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 -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_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 +PNG_FP_EXPORT(void,png_set_cHRM,(png_structp png_ptr, png_infop info_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),,135); +PNG_FIXED_EXPORT(void,png_set_cHRM_fixed,(png_structp png_ptr, + png_infop info_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),,136); #endif #ifdef PNG_gAMA_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); +PNG_FP_EXPORT(png_uint_32,png_get_gAMA,(png_structp png_ptr, png_infop info_ptr, + double *file_gamma),,137); +PNG_FIXED_EXPORT(png_uint_32,png_get_gAMA_fixed,(png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma),,138); #endif #ifdef PNG_gAMA_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); +PNG_FP_EXPORT(void,png_set_gAMA,(png_structp png_ptr, png_infop info_ptr, + double file_gamma),,139); +PNG_FIXED_EXPORT(void,png_set_gAMA_fixed,(png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma),,140); #endif #ifdef PNG_hIST_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); +PNG_EXPORT(png_uint_32,png_get_hIST,(png_structp png_ptr, png_infop info_ptr, + png_uint_16p *hist),,141); #endif #ifdef PNG_hIST_SUPPORTED -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); +PNG_EXPORT(void,png_set_hIST,(png_structp png_ptr, png_infop info_ptr, + png_const_uint_16p hist),,142); #endif -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); +PNG_EXPORT(png_uint_32,png_get_IHDR,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, + int *interlace_method, int *compression_method, int *filter_method),,143); + +PNG_EXPORT(void,png_set_IHDR,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, + int interlace_method, int compression_method, int filter_method),,144); #ifdef PNG_oFFs_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); +PNG_EXPORT(png_uint_32,png_get_oFFs,(png_structp png_ptr, png_infop info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type),,145); #endif #ifdef PNG_oFFs_SUPPORTED -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); +PNG_EXPORT(void,png_set_oFFs,(png_structp png_ptr, png_infop info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type),,146); #endif #ifdef PNG_pCAL_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((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_EXPORT(png_uint_32,png_get_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),,147); #endif #ifdef PNG_pCAL_SUPPORTED -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((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_EXPORT(void,png_set_pCAL,(png_structp png_ptr, png_infop info_ptr, + png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, + int nparams, png_const_charp units, png_charpp params),,148); #endif #ifdef PNG_pHYs_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +PNG_EXPORT(png_uint_32,png_get_pHYs,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type),,149); #endif #ifdef PNG_pHYs_SUPPORTED -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +PNG_EXPORT(void,png_set_pHYs,(png_structp png_ptr, png_infop info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type),,150); #endif -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); +PNG_EXPORT(png_uint_32,png_get_PLTE,(png_structp png_ptr, png_infop info_ptr, + png_colorp *palette, int *num_palette),,151); -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); +PNG_EXPORT(void,png_set_PLTE,(png_structp png_ptr, png_infop info_ptr, + png_const_colorp palette, int num_palette),,152); #ifdef PNG_sBIT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); +PNG_EXPORT(png_uint_32,png_get_sBIT,(png_structp png_ptr, png_infop info_ptr, + png_color_8p *sig_bit),,153); #endif #ifdef PNG_sBIT_SUPPORTED -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); +PNG_EXPORT(void,png_set_sBIT,(png_structp png_ptr, png_infop info_ptr, + png_const_color_8p sig_bit),,154); #endif #ifdef PNG_sRGB_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); +PNG_EXPORT(png_uint_32,png_get_sRGB,(png_structp png_ptr, png_infop info_ptr, + int *intent),,155); #endif #ifdef PNG_sRGB_SUPPORTED -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); +PNG_EXPORT(void,png_set_sRGB,(png_structp png_ptr, png_infop info_ptr, + int intent),,156); +PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM,(png_structp png_ptr, + png_infop info_ptr, int intent),,157); #endif #ifdef PNG_iCCP_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ +PNG_EXPORT(png_uint_32,png_get_iCCP,(png_structp png_ptr, png_infop info_ptr, + png_charpp name, int *compression_type, png_bytepp profile, + png_uint_32 *proflen),,158); #endif #ifdef PNG_iCCP_SUPPORTED -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ +PNG_EXPORT(void,png_set_iCCP,(png_structp png_ptr, png_infop info_ptr, + png_const_charp name, int compression_type, png_const_bytep profile, + png_uint_32 proflen),,159); #endif #ifdef PNG_sPLT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); +PNG_EXPORT(png_uint_32,png_get_sPLT,(png_structp png_ptr, png_infop info_ptr, + png_sPLT_tpp entries),,160); #endif #ifdef PNG_sPLT_SUPPORTED -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); +PNG_EXPORT(void,png_set_sPLT,(png_structp png_ptr, png_infop info_ptr, + png_const_sPLT_tp entries, int nentries),,161); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); +PNG_EXPORT(png_uint_32,png_get_text,(png_structp png_ptr, png_infop info_ptr, + png_textp *text_ptr, int *num_text),,162); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure @@ -2404,61 +1806,58 @@ * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); +PNG_EXPORT(void,png_set_text,(png_structp png_ptr, png_infop info_ptr, + png_const_textp text_ptr, int num_text),,163); #endif #ifdef PNG_tIME_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); +PNG_EXPORT(png_uint_32,png_get_tIME,(png_structp png_ptr, png_infop info_ptr, + png_timep *mod_time),,164); #endif #ifdef PNG_tIME_SUPPORTED -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans_alpha, int *num_trans, - png_color_16p *trans_color)); +PNG_EXPORT(void,png_set_tIME,(png_structp png_ptr, png_infop info_ptr, + png_const_timep mod_time),,165); #endif #ifdef PNG_tRNS_SUPPORTED -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans_alpha, int num_trans, - png_color_16p trans_color)); +PNG_EXPORT(png_uint_32,png_get_tRNS,(png_structp png_ptr, png_infop info_ptr, + png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color),,166); #endif #ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(void,png_set_tRNS,(png_structp png_ptr, png_infop info_ptr, + png_const_bytep trans_alpha, int num_trans, + png_const_color_16p trans_color),,167); #endif #ifdef PNG_sCAL_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif +PNG_FP_EXPORT(png_uint_32,png_get_sCAL,(png_structp png_ptr, png_infop info_ptr, + int *unit, double *width, double *height),,168); +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED +/* NOTE: this API is currently implemented using floating point arithmetic, + * consequently it can only be used on systems with floating point support. + * In any case the range of values supported by png_fixed_point is small and it + * is highly recommended that png_get_sCAL_s be used instead. + */ +PNG_FIXED_EXPORT(png_uint_32,png_get_sCAL_fixed,(png_structp png_ptr, + png_infop info_ptr, int *unit, png_fixed_point *width, + png_fixed_point *height),,214); +#endif +PNG_EXPORT(png_uint_32,png_get_sCAL_s,(png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight),,169); + +PNG_FP_EXPORT(void,png_set_sCAL,(png_structp png_ptr, png_infop info_ptr, + int unit, double width, double height),,170); +PNG_FIXED_EXPORT(void,png_set_sCAL_fixed,(png_structp png_ptr, + png_infop info_ptr, int unit, png_fixed_point width, + png_fixed_point height),,213); +PNG_EXPORT(void,png_set_sCAL_s,(png_structp png_ptr, png_infop info_ptr, + int unit, png_const_charp swidth, png_const_charp sheight),,171); #endif /* PNG_sCAL_SUPPORTED */ -#ifdef PNG_sCAL_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED /* Provide a list of chunks and how they are to be handled, if the built-in handling or default unknown chunk handling is not desired. Any chunks not listed will be handled in the default manner. The IHDR and IEND chunks @@ -2467,50 +1866,46 @@ = 1: do not keep = 2: keep only if safe-to-copy = 3: keep even if unsafe-to-copy */ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); +PNG_EXPORT(void, png_set_keep_unknown_chunks,(png_structp png_ptr, int keep, + png_const_bytep chunk_list, int num_chunks),,172); +PNG_EXPORT(int,png_handle_as_unknown,(png_structp png_ptr, + png_const_bytep chunk_name),,173); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +PNG_EXPORT(void, png_set_unknown_chunks,(png_structp png_ptr, + png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns),, + 174); +PNG_EXPORT(void, png_set_unknown_chunk_location, (png_structp png_ptr, + png_infop info_ptr, int chunk, int location),,175); +PNG_EXPORT(png_uint_32,png_get_unknown_chunks,(png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkpp entries),,176); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); +PNG_EXPORT(void, png_set_invalid,(png_structp png_ptr, png_infop info_ptr, + int mask),,177); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); +PNG_EXPORT(void, png_read_png,(png_structp png_ptr, png_infop info_ptr, + int transforms, png_voidp params),,178); +PNG_EXPORT(void, png_write_png,(png_structp png_ptr, png_infop info_ptr, + int transforms, png_voidp params),,179); #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)); +PNG_EXPORT(png_const_charp,png_get_copyright,(png_structp png_ptr),,180); +PNG_EXPORT(png_const_charp,png_get_header_ver,(png_structp png_ptr),,181); +PNG_EXPORT(png_const_charp,png_get_header_version,(png_structp png_ptr),,182); +PNG_EXPORT(png_const_charp,png_get_libpng_ver,(png_structp png_ptr),,183); #ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); +PNG_EXPORT(png_uint_32,png_permit_mng_features,(png_structp png_ptr, + png_uint_32 mng_features_permitted),,184); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 @@ -2521,60 +1916,65 @@ /* 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)); +PNG_EXPORT(void,png_set_strip_error_numbers,(png_structp png_ptr, + png_uint_32 strip_mode),,185); #endif /* 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)); +PNG_EXPORT(void,png_set_user_limits,(png_structp png_ptr, + png_uint_32 user_width_max, png_uint_32 user_height_max),,186); +PNG_EXPORT(png_uint_32,png_get_user_width_max,(png_structp png_ptr),,187); +PNG_EXPORT(png_uint_32,png_get_user_height_max,(png_structp png_ptr),,188); /* 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)); +PNG_EXPORT(void,png_set_chunk_cache_max,(png_structp png_ptr, + png_uint_32 user_chunk_cache_max),,189); +PNG_EXPORT(png_uint_32,png_get_chunk_cache_max,(png_structp png_ptr),,190); /* Added in libpng-1.4.1 */ -extern PNG_EXPORT(void,png_set_chunk_malloc_max) PNGARG((png_structp - png_ptr, png_alloc_size_t user_chunk_cache_max)); -extern PNG_EXPORT(png_alloc_size_t,png_get_chunk_malloc_max) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(void,png_set_chunk_malloc_max,(png_structp png_ptr, + png_alloc_size_t user_chunk_cache_max),,191); +PNG_EXPORT(png_alloc_size_t,png_get_chunk_malloc_max,(png_structp png_ptr),, + 192); +#endif + +#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) +PNG_EXPORT(png_uint_32,png_get_pixels_per_inch,(png_structp png_ptr, + png_infop info_ptr),,193); + +PNG_EXPORT(png_uint_32,png_get_x_pixels_per_inch,(png_structp png_ptr, + png_infop info_ptr),,194); + +PNG_EXPORT(png_uint_32,png_get_y_pixels_per_inch,(png_structp png_ptr, + png_infop info_ptr),,195); + +PNG_FP_EXPORT(float,png_get_x_offset_inches,(png_structp png_ptr, + png_infop info_ptr),,196); +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(png_fixed_point,png_get_x_offset_inches_fixed, + (png_structp png_ptr, png_infop info_ptr),,211); +#endif + +PNG_FP_EXPORT(float,png_get_y_offset_inches,(png_structp png_ptr, + png_infop info_ptr),,197); +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(png_fixed_point,png_get_y_offset_inches_fixed, + (png_structp png_ptr, png_infop info_ptr),,212); #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)); - #ifdef 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)); +PNG_EXPORT(png_uint_32,png_get_pHYs_dpi,(png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type), + ,198); #endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS_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)); +PNG_EXPORT(png_uint_32,png_get_io_state,(png_structp png_ptr),,199); -extern PNG_EXPORT(png_bytep,png_get_io_chunk_name) - PNGARG((png_structp png_ptr)); +PNG_EXPORT(png_const_bytep,png_get_io_chunk_name,(png_structp png_ptr),,200); /* 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 */ @@ -2586,12 +1986,8 @@ #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 /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two @@ -2637,61 +2033,59 @@ /* 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)))) -#ifdef 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)); -#ifdef PNG_GET_INT_32_SUPPORTED -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffff)+1)) \ + : (png_int_32)png_get_uint_32(buf))) #endif + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(png_uint_32,png_get_uint_32,(png_const_bytep buf),,201); +PNG_EXPORT(png_uint_16,png_get_uint_16,(png_const_bytep buf),,202); +PNG_EXPORT(png_int_32,png_get_int_32,(png_const_bytep buf),,203); #endif -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); + +PNG_EXPORT(png_uint_32,png_get_uint_31,(png_structp png_ptr, + png_const_bytep buf),,204); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(void,png_save_uint_32,(png_bytep buf, png_uint_32 i),,205); +#endif +#ifdef PNG_SAVE_INT_32_SUPPORTED +PNG_EXPORT(void,png_save_int_32,(png_bytep buf, png_int_32 i),,206); +#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. */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(void,png_save_uint_16,(png_bytep buf, unsigned int i),,207); /* No png_save_int_16 -- may be added if there's a real need for it. */ +#endif -/* ************************************************************************* */ +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project + * defs + */ -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. +/* The last ordinal number (this is the *last* one, the next one to + * use is one more than this.) */ -#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 +#ifdef PNG_EXPORT_LAST_ORDINAL + PNG_EXPORT_LAST_ORDINAL(218); +#endif #ifdef __cplusplus } #endif diff -ru4NwbB libpng-1.4.3/pngconf.h libpng-1.5.0beta42/pngconf.h --- libpng-1.4.3/pngconf.h 2010-06-25 19:32:25.996648919 -0500 +++ libpng-1.5.0beta42/pngconf.h 2010-08-18 08:12:21.274764248 -0500 @@ -1,9 +1,9 @@ /* pngconf.h - machine configurable file for libpng * * libpng version 1.5.0beta42 - August 11, 2010 - * For conditions of distribution and use, see copyright notice in png.h + * * Copyright (c) 1998-2010 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.) * @@ -21,283 +21,55 @@ #ifndef PNGCONF_H #define PNGCONF_H +/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C + * definition file for machine specific limits, this may impact the + * correctness of the definitons below (see uses of INT_MAX). + */ #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 -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD -# endif -# include "pngusr.h" -#endif - -/* - * 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." - * #define PNG_USER_DLLFNAME_POSTFIX - * e.g. // private DLL "libpng13gx.dll" - * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the - * DLL VERSIONINFO structure. - * - PNG_USER_VERSIONINFO_COMMENTS - * - PNG_USER_VERSIONINFO_COMPANYNAME - * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS +/* For the memory copy APIs (i.e. the standard definitions of these), + * because this file defines png_memcpy and so on the base APIs must + * be defined here. */ - -#ifdef __STDC__ -# ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -# endif - -# ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -# endif -#endif /* __STDC__ */ - -/* End of material added to libpng-1.2.8 */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* 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 - * calculations. Making this an extremely small size will slow - * the library down, but you may want to experiment to determine - * where it becomes significant, if you are concerned with memory - * usage. Note that zlib allocates at least 32Kb also. For readers, - * this describes the size of the buffer available to read the data in. - * Unless this gets smaller than the size of a row (compressed), - * it should not make much difference how big this is. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#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 +#ifdef BSD +# include #else -# ifndef PNG_BENIGN_ERRORS_SUPPORTED -# define png_benign_error png_error -# define png_chunk_benign_error png_chunk_error -# endif -#endif - -/* Added at libpng version 1.4.0 */ -#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED) -# define PNG_WARNINGS_SUPPORTED -#endif - -/* Added at libpng version 1.4.0 */ -#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED) -# define PNG_ERROR_TEXT_SUPPORTED -#endif - -/* Added at libpng version 1.4.0 */ -#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED) -# define PNG_CHECK_cHRM_SUPPORTED -#endif - -/* Added at libpng version 1.4.0 */ -#if !defined(PNG_NO_ALIGNED_MEMORY) && !defined(PNG_ALIGNED_MEMORY_SUPPORTED) -# define PNG_ALIGNED_MEMORY_SUPPORTED -#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 */ -#ifndef PNG_NO_MNG_FEATURES -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -/* Added at libpng version 1.4.0 */ -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif +# include #endif -/* Added at libpng-1.4.0beta49 for testing (this test is no longer used - in libpng and png_calloc() is always present) - */ -#define PNG_CALLOC_SUPPORTED - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K +/* For png_FILE_p - this provides the standard definition of a + * FILE */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K +#ifdef PNG_STDIO_SUPPORTED +# include #endif -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO. - */ -#ifdef __CYGWIN__ -# ifdef ALL_STATIC -# ifdef PNG_BUILD_DLL -# undef PNG_BUILD_DLL -# endif -# ifdef PNG_USE_DLL -# undef PNG_USE_DLL -# endif -# ifdef PNG_DLL -# undef PNG_DLL -# endif -# ifndef PNG_STATIC -# define PNG_STATIC -# endif -# else -# ifdef PNG_BUILD_DLL -# ifdef PNG_STATIC -# undef PNG_STATIC -# endif -# ifdef PNG_USE_DLL -# undef PNG_USE_DLL -# endif -# ifndef PNG_DLL -# define PNG_DLL -# endif -# else -# ifdef PNG_STATIC -# ifdef PNG_USE_DLL -# undef PNG_USE_DLL -# endif -# ifdef PNG_DLL -# undef PNG_DLL -# endif -# else -# ifndef PNG_USE_DLL -# define PNG_USE_DLL -# endif -# ifndef PNG_DLL -# define PNG_DLL -# endif -# endif +/* This controls optimization of the reading of 16 and 32 bit values + * from PNG files. It can be set on a per-app-file basis - it + * just changes whether a macro is used to the function is called. + * The library builder sets the default, if read functions are not + * built into the library the macro implementation is forced on. + */ +#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED +# define PNG_USE_READ_MACROS # endif +#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +# if PNG_DEFAULT_READ_MACROS +# define PNG_USE_READ_MACROS # endif #endif -/* This protects us against compilers that run on a windowing system - * and thus don't have or would rather us not use the stdio types: - * stdin, stdout, and stderr. The only one currently used is stderr - * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will - * prevent these from being compiled and used. #defining PNG_NO_STDIO - * will also prevent these, plus will prevent the entire set of stdio - * macros and functions (FILE *, printf, etc.) from being compiled and used, - * unless (PNG_DEBUG > 0) has been #defined. +/* COMPILER SPECIFIC OPTIONS. * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO + * These options are provided so that a variety of difficult compilers + * can be used. Some are fixed at build time (e.g. PNG_API_RULE + * below) but still have compiler specific implementations, others + * may be changed on a per-file basis when compiling against libpng. */ - -#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED) -# define PNG_STDIO_SUPPORTED -#endif - - -#ifdef PNG_BUILD_DLL -# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO) -# define PNG_NO_CONSOLE_IO -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include -# endif -# endif -# else -# include -# endif - -#if !(defined PNG_NO_CONSOLE_IO) && !defined(PNG_CONSOLE_IO_SUPPORTED) -# define PNG_CONSOLE_IO_SUPPORTED -#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. * I've always been able to use _NO_PROTO as the indicator, but you may @@ -319,776 +91,374 @@ #endif /* OF */ #endif /* PNGARG */ -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. +/* Function calling conventions. + * ============================= + * Normally it is not necessary to specify to the compiler how to call + * a function - it just does it - however on x86 systems derived from + * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems + * and some others) there are multiple ways to call a function and the + * default can be changed on the compiler command line. For this reason + * libpng specifies the calling convention of every exported function and + * every function called via a user supplied function pointer. This is + * done in this file by defining the following macros: + * + * PNGAPI Calling convention for exported functions. + * PNGCBAPI Calling convention for user provided (callback) functions. + * PNGCAPI Calling convention used by the ANSI-C library (required + * for longjmp callbacks and sometimes used internally to + * specify the calling convention for zlib). + * + * These macros should never be overridden. If it is necessary to + * change calling convention in a private build this can be done + * by setting PNG_API_RULE (which defaults to 0) to one of the values + * below to select the correct 'API' variants. + * + * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. + * This is correct in every known environment. + * PNG_API_RULE=1 Use the operating system convention for PNGAPI and + * the 'C' calling convention (from PNGCAPI) for + * callbacks (PNGCBAPI). This is no longer required + * in any known environment - if it has to be used + * please post an explanation of the problem to the + * libpng mailing list. + * + * These cases only differ if the operating system does not use the C + * calling convention, at present this just means the above cases + * (x86 DOS/Windows sytems) and, even then, this does not apply to + * Cygwin running on those systems. + * + * Note that the value must be defined in pnglibconf.h so that what + * the application uses to call the library matches the conventions + * set when building the library. + */ + +/* Symbol export + * ============= + * When building a shared library it is almost always necessary to tell + * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' + * is used to mark the symbols. On some systems these symbols can be + * extracted at link time and need no special processing by the compiler, + * on other systems the symbols are flagged by the compiler and just + * the declaration requires a special tag applied (unfortunately) in a + * compiler dependent way. Some systems can do either. + * + * A small number of older systems also require a symbol from a DLL to + * be flagged to the program that calls it. This is a problem because + * we do not know in the header file included by application code that + * the symbol will come from a shared library, as opposed to a statically + * linked one. For this reason the application must tell us by setting + * the magic flag PNG_USE_DLL to turn on the special processing before + * it includes png.h. + * + * Four additional macros are used to make this happen: + * + * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from + * the build or imported if PNG_USE_DLL is set - compiler + * and system specific. + * + * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to + * 'type', compiler specific. + * + * PNG_DLL_EXPORT Set to the magic to use during a libpng build to + * make a symbol exported from the DLL. + * + * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come + * from a DLL - used to define PNG_IMPEXP when + * PNG_USE_DLL is set. + */ + +/* System specific discovery. + * ========================== + * This code is used at build time to find PNG_IMPEXP, the API settings + * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL + * import processing is possible. On Windows/x86 systems it also sets + * compiler-specific macros to the values required to change the calling + * conventions of the various functions. + */ +#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ + defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ + ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ + defined(_M_X64) || defined(_M_IA64) ) + /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes + * builds under Cygwin or MinGW. Also includes Watcom builds but these need + * special treatment because they are not compatible with GCC or Visual C + * because of different calling conventions. + */ +# if PNG_API_RULE == 2 + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif +# define PNGCAPI __watcall #endif -/* Enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) -# include -#endif - -/* PNG_SETJMP_NOT_SUPPORTED and PNG_NO_SETJMP_SUPPORTED are deprecated. */ -#if !defined(PNG_NO_SETJMP) && \ - !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#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 -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __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 -# ifdef _BSD_SOURCE -# undef _BSD_SOURCE -# endif -# define _BSD_SOURCE -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include -#else -# include -#endif - -/* Other defines for things like memory and the like can go here. */ - -/* This controls how fine the quantizing gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with quantizing quality can decrease some or all of these. - */ - -/* Prior to libpng-1.4.2, these were PNG_DITHER_*_BITS - * These migration aids will be removed from libpng-1.5.0. - */ -#ifdef PNG_DITHER_RED_BITS -# define PNG_QUANTIZE_RED_BITS PNG_DITHER_RED_BITS -#endif -#ifdef PNG_DITHER_GREEN_BITS -# define PNG_QUANTIZE_GREEN_BITS PNG_DITHER_GREEN_BITS -#endif -#ifdef PNG_DITHER_BLUE_BITS -# define PNG_QUANTIZE_BLUE_BITS PNG_DITHER_BLUE_BITS -#endif - -#ifndef PNG_QUANTIZE_RED_BITS -# define PNG_QUANTIZE_RED_BITS 5 -#endif -#ifndef PNG_QUANTIZE_GREEN_BITS -# define PNG_QUANTIZE_GREEN_BITS 5 -#endif -#ifndef PNG_QUANTIZE_BLUE_BITS -# define PNG_QUANTIZE_BLUE_BITS 5 -#endif - -/* This controls how fine the gamma correction becomes when you - * are only interested in 8 bits anyway. Increasing this value - * results in more memory being used, and more pow() functions - * being called to fill in the gamma tables. Don't set this value - * less then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGCAPI __cdecl +# if PNG_API_RULE == 1 +# define PNGAPI __stdcall #endif - -/* 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. - */ - -#ifndef PNG_CONST -# ifndef PNG_NO_CONST -# define PNG_CONST const # else -# define PNG_CONST -# endif -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with PNG_NO_READ|WRITE_TRANSFORMS on the compile line, - * then pick and choose which ones to define without having to edit this - * file. It is safe to use the PNG_NO_READ|WRITE_TRANSFORMS - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency; PNG_*_TRANSFORMS_NOT_SUPPORTED deprecated in - * 1.4.0) - */ - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifdef PNG_READ_SUPPORTED - -/* PNG_READ_TRANSFORMS_NOT_SUPPORTED is deprecated. */ -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_QUANTIZE - /* Prior to libpng-1.4.0 this was PNG_READ_DITHER_SUPPORTED */ -# ifndef PNG_NO_READ_DITHER /* This migration aid will be removed */ -# define PNG_READ_QUANTIZE_SUPPORTED -# endif -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -/* PNG_PROGRESSIVE_READ_NOT_SUPPORTED is deprecated. */ -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !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 define: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ - -/* PNG_NO_SEQUENTIAL_READ_SUPPORTED is deprecated. */ -#if !defined(PNG_NO_SEQUENTIAL_READ) && \ - !defined(PNG_SEQUENTIAL_READ_SUPPORTED) && \ - !defined(PNG_NO_SEQUENTIAL_READ_SUPPORTED) -# define PNG_SEQUENTIAL_READ_SUPPORTED -#endif - -#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_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 */ - -#ifdef PNG_WRITE_SUPPORTED - -/* PNG_WRITE_TRANSFORMS_NOT_SUPPORTED is deprecated. */ -#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* This is not required for PNG-compliant encoders, but can cause - * trouble if left undefined - */ -# define PNG_WRITE_INTERLACING_SUPPORTED -#endif - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -#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 */ - -#define PNG_NO_ERROR_NUMBERS - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#if defined(PNG_STDIO_SUPPORTED) && !defined(PNG_TIME_RFC1123_SUPPORTED) -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* Added at libpng-1.2.0 */ -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif - -/* Added at libpng-1.2.6 */ -#ifndef PNG_NO_SET_USER_LIMITS -# ifndef PNG_SET_USER_LIMITS_SUPPORTED -# define PNG_SET_USER_LIMITS_SUPPORTED -# endif - /* Feature added at libpng-1.4.0, this flag added at 1.4.1 */ -# ifndef PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -# define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -# endif - /* Feature added at libpng-1.4.1, this flag added at 1.4.1 */ -# ifndef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -# define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -# endif -#endif - -/* Added at libpng-1.2.43 */ -#ifndef PNG_USER_LIMITS_SUPPORTED -# ifndef PNG_NO_USER_LIMITS -# define PNG_USER_LIMITS_SUPPORTED -# endif -#endif - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGs no matter - * how large, set these two limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* Added at libpng-1.2.43. To accept all valid PNGs no matter - * how large, set these two limits to 0. + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. */ -#ifndef PNG_USER_CHUNK_CACHE_MAX -# define PNG_USER_CHUNK_CACHE_MAX 0 +# ifndef PNGCAPI +# define PNGCAPI _cdecl #endif - -/* Added at libpng-1.2.43 */ -#ifndef PNG_USER_CHUNK_MALLOC_MAX -# define PNG_USER_CHUNK_MALLOC_MAX 0 -#endif - -/* Added at libpng-1.4.0 */ -#if !defined(PNG_NO_IO_STATE) && !defined(PNG_IO_STATE_SUPPORTED) -# define PNG_IO_STATE_SUPPORTED +# if PNG_API_RULE == 1 && !defined(PNGAPI) +# define PNGAPI _stdcall #endif +# endif /* compiler/api */ + /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ -#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" +# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) + ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed #endif -/* These are currently experimental features, define them if you want */ - -/* Very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif +# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ + (defined(__BORLANDC__) && __BORLANDC__ < 0x500) + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. */ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED +# ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP #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 PNG_NO_POINTER_INDEXING */ - -#if !defined(PNG_NO_POINTER_INDEXING) && \ - !defined(PNG_POINTER_INDEXING_SUPPORTED) -# define PNG_POINTER_INDEXING_SUPPORTED +# define PNG_DLL_EXPORT __export +# else /* newer compiler */ +# define PNG_DLL_EXPORT __declspec(dllexport) +# ifndef PNG_DLL_IMPORT +# define PNG_DLL_IMPORT __declspec(dllimport) #endif +# endif /* compiler */ - -/* 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 - * a bit smaller. - */ - -/* 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.4.0. - */ - -/* PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */ -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -/* PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED is deprecated. */ -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif - -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# ifndef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_READ_USER_CHUNKS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_USER_CHUNKS -# ifndef PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_READ_USER_CHUNKS_SUPPORTED -# endif -# ifndef PNG_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED +#else /* !Windows/x86 */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# else /* !Windows/x86 && !OS/2 */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ +# endif /* other system, !OS/2 */ +#endif /* !Windows/x86 */ + +/* Now do all the defaulting . */ +#ifndef PNGCAPI +# define PNGCAPI # endif +#ifndef PNGCBAPI +# define PNGCBAPI PNGCAPI #endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED +#ifndef PNGAPI +# define PNGAPI PNGCAPI # endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED + +/* The default for PNG_IMPEXP depends on whether the library is + * being built or used. + */ +#ifndef PNG_IMPEXP +# ifdef PNGLIB_BUILD + /* Building the library */ +# if (defined(DLL_EXPORT)/*from libtool*/ ||\ + defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\ + defined(_USRDLL) ||\ + defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT) + /* Building a DLL. */ +# define PNG_IMPEXP PNG_DLL_EXPORT +# endif /* DLL */ +# else + /* Using the library */ +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT # endif #endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED + +# ifndef PNG_IMPEXP +# define PNG_IMPEXP # endif #endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED + +/* THe following complexity is concerned with getting the 'attributes' of the + * declared function in the correct place. This potentially requires a separate + * PNG_EXPORT function for every compiler. + */ +#ifndef PNG_FUNCTION +# ifdef __GNUC__ +# define PNG_FUNCTION(type, name, args, attributes)\ + attributes type name args +# else /* !GNUC */ +# ifdef _MSC_VER +# define PNG_FUNCTION(type, name, args, attributes)\ + attributes type name args +# else /* !MSC */ +# define PNG_FUNCTION(type, name, args, attributes)\ + type name args # endif #endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED # endif + +#ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED + +#ifndef PNG_EXPORT + /* The ordinal value is only relevant when preprocessing png.h for symbol + * table entries. + */ +# define PNG_EXPORT(type, name, args, attributes, ordinal)\ + extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\ + attributes) # endif + +/* Use PNG_REMOVED to comment out a removed interface. */ +#ifndef PNG_REMOVED +# define PNG_REMOVED(type, name, args, attributes, ordinal) #endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED + +#ifndef PNG_CALLBACK +# define PNG_CALLBACK(type, name, args, attributes)\ + type (PNGCBAPI name) PNGARG(args) attributes # endif + +/* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. + * + * Added at libpng-1.2.41. + */ + +#ifndef PNG_NO_PEDANTIC_WARNINGS +# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED +# define PNG_PEDANTIC_WARNINGS_SUPPORTED #endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED # endif + +#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED + /* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. Added at libpng + * version 1.2.41. + */ +# ifdef __GNUC__ +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) #endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED +# ifndef PNG_NORETURN +# define PNG_NORETURN __attribute__((__noreturn__)) # endif +# ifndef PNG_PTR_NORETURN +# define PNG_PTR_NORETURN __attribute__((__noreturn__)) #endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __attribute__((__malloc__)) # endif + + /* This specifically protects structure members that should only be + * accessed from within the library, therefore should be empty during + * a library build. + */ +# ifndef PNGLIB_BUILD +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) #endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED +# ifndef PNG_DEPSTRUCT +# define PNG_DEPSTRUCT __attribute__((__deprecated__)) # endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) #endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED +# endif /* PNG_PRIVATE */ +# endif /* PNGLIB_BUILD */ +# endif /* __GNUC__ */ +# ifdef _MSC_VER /* may need to check value */ +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /*not supported*/ # endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __declspec(noreturn) #endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED +# ifndef PNG_PTR_NORETURN +# define PNG_PTR_NORETURN /*not supported*/ # endif +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __declspec(restrict) #endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED + + /* This specifically protects structure members that should only be + * accessed from within the library, therefore should be empty during + * a library build. + */ +# ifndef PNGLIB_BUILD +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __declspec(deprecated) # endif +# ifndef PNG_DEPSTRUCT +# define PNG_DEPSTRUCT __declspec(deprecated) #endif +# ifndef PNG_PRIVATE +# define PNG_PRIVATE __declspec(deprecated) +# endif /* PNG_PRIVATE */ +# endif /* PNGLIB_BUILD */ +# endif /* __GNUC__ */ +#endif /* PNG_PEDANTIC_WARNINGS */ -#ifdef PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_NO_CONVERT_tIME -# ifndef _WIN32_WCE -/* The "tm" structure is not supported on WindowsCE */ -# ifndef PNG_CONVERT_tIME_SUPPORTED -# define PNG_CONVERT_tIME_SUPPORTED +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED /* Use of this function is deprecated */ # endif +#ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* The result of this function must be checked */ # endif +#ifndef PNG_NORETURN +# define PNG_NORETURN /* This function does not return */ # endif +#ifndef PNG_ALLOCATED +# define PNG_ALLOCATED /* The result of the function is new memory */ #endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifndef PNG_NO_WRITE_FILTER -# ifndef PNG_WRITE_FILTER_SUPPORTED -# define PNG_WRITE_FILTER_SUPPORTED +#ifndef PNG_DEPSTRUCT +# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */ # endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE /* This is a private libpng function */ #endif - -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED +#ifndef PNG_FP_EXPORT /* A floating point API. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(type, name, args, attributes, ordinal)\ + PNG_EXPORT(type, name, args, attributes, ordinal) +# else /* No floating point APIs */ +# define PNG_FP_EXPORT(type, name, args, attributes, ordinal) # endif #endif -#ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ +# ifdef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal)\ + PNG_EXPORT(type, name, args, attributes, ordinal) +# else /* No fixed point APIs */ +# define PNG_FIXED_EXPORT(type, name, args, attributes, ordinal) # endif #endif -#endif /* PNG_WRITE_SUPPORTED */ -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. +/* 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. + * + * This should not change how the APIs are called, so it can be done + * on a per-file basis in the application. */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED +#ifndef PNG_CONST +# ifndef PNG_NO_CONST +# define PNG_CONST const +# else +# define PNG_CONST #endif - -/* Need the time information for converting tIME chunks */ -#ifdef PNG_CONVERT_tIME_SUPPORTED - /* "time.h" functions are not supported on WindowsCE */ -# include #endif /* Some typedefs to get us started. These should be safe on most of the * common platforms. The typedefs should be at least as large as the @@ -1113,9 +483,9 @@ typedef unsigned int png_size_t; #else typedef size_t png_size_t; #endif -#define png_sizeof(x) sizeof(x) +#define png_sizeof(x) (sizeof (x)) /* The following is needed for medium model support. It cannot be in the * pngpriv.h header. Needs modification for other compilers besides * MSC. Model independent support declares all arrays and pointers to be @@ -1135,9 +505,9 @@ # define LDATA 0 # endif /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K +# define PNG_MAX_MALLOC_64K /* only used in build */ # if (LDATA != 1) # ifndef FAR # define FAR __far # endif @@ -1176,28 +546,39 @@ # define FARDATA #endif /* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ + * to fixed-point with a multiple of 100,000, e.g., gamma + */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void FAR * png_voidp; +typedef PNG_CONST void FAR * png_const_voidp; typedef png_byte FAR * png_bytep; +typedef PNG_CONST png_byte FAR * png_const_bytep; typedef png_uint_32 FAR * png_uint_32p; +typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p; typedef png_int_32 FAR * png_int_32p; +typedef PNG_CONST png_int_32 FAR * png_const_int_32p; typedef png_uint_16 FAR * png_uint_16p; +typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p; typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; +typedef PNG_CONST png_int_16 FAR * png_const_int_16p; typedef char FAR * png_charp; +typedef PNG_CONST char FAR * png_const_charp; typedef png_fixed_point FAR * png_fixed_point_p; +typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p; +typedef png_size_t FAR * png_size_tp; +typedef PNG_CONST png_size_t FAR * png_const_size_tp; -#ifndef PNG_NO_STDIO +#ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double FAR * png_doublep; +typedef PNG_CONST double FAR * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte FAR * FAR * png_bytepp; @@ -1214,271 +595,8 @@ /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char FAR * FAR * FAR * png_charppp; -/* Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif - -#ifdef __CYGWIN__ -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */ - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# ifndef PNG_IMPEXP - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# ifdef PNG_BUILD_DLL -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# ifndef PNG_IMPEXP -# ifdef PNG_BUILD_DLL -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. - * - * Added at libpng-1.2.41. - */ - -#ifndef PNG_NO_PEDANTIC_WARNINGS -# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED -# define PNG_PEDANTIC_WARNINGS_SUPPORTED -# endif -#endif - -#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. Added at libpng - * version 1.2.41. - */ -# ifdef __GNUC__ -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif - - /* This specifically protects structure members that should only be - * accessed from within the library, therefore should be empty during - * a library build. - */ -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_DEPSTRUCT -# define PNG_DEPSTRUCT __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif -# endif /* PNG_PRIVATE */ -# endif /* __GNUC__ */ -#endif /* PNG_PEDANTIC_WARNINGS */ - -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED /* Use of this function is deprecated */ -#endif -#ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* The result of this function must be checked */ -#endif -#ifndef PNG_NORETURN -# define PNG_NORETURN /* This function does not return */ -#endif -#ifndef PNG_ALLOCATED -# define PNG_ALLOCATED /* The result of the function is new memory */ -#endif -#ifndef PNG_DEPSTRUCT -# define PNG_DEPSTRUCT /* Access to this struct member is deprecated */ -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE /* This is a private libpng function */ -#endif - -/* Users may want to use these so they are not private. Any library - * functions that are passed far data must be model-independent. - */ - -/* memory model/platform independent fns */ -#ifndef PNG_ABORT -# ifdef _WINDOWS_ -# define PNG_ABORT() ExitProcess(0) -# else -# define PNG_ABORT() abort() -# endif -#endif - -#ifdef 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_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 -# define png_sprintf sprintf -#else -# ifdef _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 -# define png_snprintf6 _snprintf -# else -# define png_snprintf snprintf /* Added to v 1.2.19 */ -# define png_snprintf2 snprintf -# define png_snprintf6 snprintf -# endif -# else - /* You don't have or don't want to use snprintf(). Caution: Using - * sprintf instead of snprintf exposes your application to accidental - * or malevolent buffer overflows. If you don't have snprintf() - * as a general rule you should provide one (you can get one from - * Portable OpenSSH). - */ -# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) -# 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 -# endif -#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 @@ -1487,39 +605,23 @@ * 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) + /* This is an attempt to detect an old Windows system where (int) is + * actually 16 bits, in that case png_malloc must have an argument with a + * bigger size to accomodate the requirements of the library. + */ +# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \ + (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) 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. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - - -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNGCONF_H */ diff -ru4NwbB libpng-1.4.3/pngdebug.h libpng-1.5.0beta42/pngdebug.h --- libpng-1.4.3/pngdebug.h 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/pngdebug.h 2010-08-18 08:12:21.299306130 -0500 @@ -0,0 +1,157 @@ + +/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c + * + * Copyright (c) 1998-2010 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.) + * + * Last changed in libpng version 1.5.0 - August 11, 2010 + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + * + * png_debug[1-2]?(level, message ,arg{0-2}) + * Expands to a statement (either a simple expression or a compound + * do..while(0) statement) that outputs a message with parameter + * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG + * is undefined, 0 or 1 every png_debug expands to a simple expression + * (actually ((void)0)). + * + * level: level of detail of message, starting at 0. A level 'n' + * message is preceded by 'n' tab characters (not implemented + * on Microsoft compilers unless PNG_DEBUG_FILE is also + * defined, to allow debug DLL compilation with no standard IO). + * message: a printf(3) style text string. A trailing '\n' is added + * to the message. + * arg: 0 to 2 arguments for printf(3) style substitution in message. + */ +#ifndef PNGDEBUG_H +#define PNGDEBUG_H +/* These settings control the formatting of messages in png.c and pngerror.c */ +/* Moved to pngdebug.h at 1.5.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 + +#ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +# include +# if (PNG_DEBUG > 1) +# ifndef _DEBUG +# define _DEBUG +# endif +# ifndef png_debug +# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +# endif +# endif +# else /* PNG_DEBUG_FILE || !_MSC_VER */ +# ifndef PNG_STDIO_SUPPORTED +# include /* not included yet */ +# endif +# ifndef PNG_DEBUG_FILE +# define PNG_DEBUG_FILE stderr +# endif /* PNG_DEBUG_FILE */ + +# if (PNG_DEBUG > 1) +/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on + * non-ISO compilers + */ +# ifdef __STDC__ +# ifndef png_debug +# define png_debug(l,m) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ + } while (0) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ + } while (0) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + do { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ + } while (0) +# endif +# else /* __STDC __ */ +# ifndef png_debug +# define png_debug(l,m) \ + do { \ + 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); \ + } while (0) +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + do { \ + 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); \ + } while (0) +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + do { \ + 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); \ + } while (0) +# endif +# endif /* __STDC __ */ +# endif /* (PNG_DEBUG > 1) */ + +# endif /* _MSC_VER */ +# endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +# define png_debug(l, m) ((void)0) +#endif +#ifndef png_debug1 +# define png_debug1(l, m, p1) ((void)0) +#endif +#ifndef png_debug2 +# define png_debug2(l, m, p1, p2) ((void)0) +#endif +#endif /* PNGDEBUG_H */ diff -ru4NwbB libpng-1.4.3/pngerror.c libpng-1.5.0beta42/pngerror.c --- libpng-1.4.3/pngerror.c 2010-06-25 19:32:26.030486270 -0500 +++ libpng-1.5.0beta42/pngerror.c 2010-08-18 08:12:21.322966037 -0500 @@ -1,8 +1,8 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.4.0 [January 3, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -15,16 +15,15 @@ * and use png_set_error_fn() to use those functions. See the instructions * at each function. */ -#define PNG_NO_PEDANTIC_WARNINGS -#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)) PNG_NORETURN; +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + +static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr, + png_const_charp error_message)),PNG_NORETURN); + #ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ png_default_warning PNGARG((png_structp png_ptr, png_const_charp warning_message)); @@ -35,10 +34,10 @@ * you should supply a replacement error function and use png_set_error_fn() * to replace the error function at run-time. */ #ifdef PNG_ERROR_TEXT_SUPPORTED -void PNGAPI -png_error(png_structp png_ptr, png_const_charp error_message) +PNG_FUNCTION(void,PNGAPI +png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; if (png_ptr != NULL) @@ -83,10 +85,10 @@ use the default handler, which will not return. */ png_default_error(png_ptr, error_message); } #else -void PNGAPI -png_err(png_structp png_ptr) +PNG_FUNCTION(void,PNGAPI +png_err,(png_structp png_ptr),PNG_NORETURN) { if (png_ptr != NULL && png_ptr->error_fn != NULL) (*(png_ptr->error_fn))(png_ptr, '\0'); @@ -184,12 +188,14 @@ png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT); buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0'; } } +#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ -#ifdef PNG_READ_SUPPORTED -void PNGAPI -png_chunk_error(png_structp png_ptr, png_const_charp error_message) +#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_FUNCTION(void,PNGAPI +png_chunk_error,(png_structp png_ptr, png_const_charp error_message), + PNG_NORETURN) { char msg[18+PNG_MAX_ERROR_TEXT]; if (png_ptr == NULL) png_error(png_ptr, error_message); @@ -198,10 +205,9 @@ png_format_buffer(png_ptr, msg, error_message); png_error(png_ptr, msg); } } -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */ #ifdef PNG_WARNINGS_SUPPORTED void PNGAPI png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) @@ -229,8 +237,30 @@ } #endif #endif /* PNG_READ_SUPPORTED */ +#ifdef PNG_ERROR_TEXT_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_FUNCTION(void, +png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN) +{ +# define fixed_message "fixed point overflow in " +# define fixed_message_ln ((sizeof fixed_message)-1) + int iin; + char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; + png_memcpy(msg, fixed_message, fixed_message_ln); + iin = 0; + if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) + { + msg[fixed_message_ln + iin] = name[iin]; + ++iin; + } + msg[fixed_message_ln + iin] = 0; + png_error(png_ptr, msg); +} +#endif +#endif + #ifdef PNG_SETJMP_SUPPORTED /* This API only exists if ANSI-C style error handling is used, * otherwise it is necessary for png_default_error to be overridden. */ @@ -241,19 +271,20 @@ if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf)) return NULL; png_ptr->longjmp_fn = longjmp_fn; - return &png_ptr->jmpbuf; + return &png_ptr->png_jmpbuf; } #endif /* 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 * error function pointer in png_set_error_fn(). */ -static void /* PRIVATE */ -png_default_error(png_structp png_ptr, png_const_charp error_message) +static PNG_FUNCTION(void /* PRIVATE */, +png_default_error,(png_structp png_ptr, png_const_charp error_message), + PNG_NORETURN) { #ifdef PNG_CONSOLE_IO_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == PNG_LITERAL_SHARP) @@ -287,28 +320,34 @@ fprintf(stderr, "libpng error: %s", error_message); fprintf(stderr, PNG_STRING_NEWLINE); } #endif +#ifndef PNG_CONSOLE_IO_SUPPORTED + error_message = error_message; /* Make compiler happy */ +#endif + png_longjmp(png_ptr, 1); +} +PNG_FUNCTION(void,PNGAPI +png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN) +{ #ifdef PNG_SETJMP_SUPPORTED if (png_ptr && png_ptr->longjmp_fn) { # ifdef USE_FAR_KEYWORD { - jmp_buf jmpbuf; - png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf)); - png_ptr->longjmp_fn(jmpbuf, 1); + jmp_buf png_jmpbuf; + png_memcpy(png_jmpbuf, png_ptr->png_jmpbuf, png_sizeof(jmp_buf)); + png_ptr->longjmp_fn(png_jmpbuf, val); } + # else - png_ptr->longjmp_fn(png_ptr->jmpbuf, 1); + png_ptr->longjmp_fn(png_ptr->png_jmpbuf, val); # endif } #endif /* Here if not setjmp support or if png_ptr is null. */ PNG_ABORT(); -#ifndef PNG_CONSOLE_IO_SUPPORTED - error_message = error_message; /* Make compiler happy */ -#endif } #ifdef PNG_WARNINGS_SUPPORTED /* This function is called when there is a warning, but the library thinks @@ -360,9 +402,9 @@ /* This function is called when the application wants to use another method * of handling errors and warnings. Note that the error function MUST NOT * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) + * method used in the default routine calls longjmp(png_ptr->png_jmpbuf, 1) */ void PNGAPI png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn) @@ -394,9 +438,10 @@ { if (png_ptr != NULL) { png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | + PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); } } #endif #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff -ru4NwbB libpng-1.4.3/pngget.c libpng-1.5.0beta42/pngget.c --- libpng-1.4.3/pngget.c 2010-06-25 19:32:26.037548583 -0500 +++ libpng-1.5.0beta42/pngget.c 2010-08-18 08:12:21.330533673 -0500 @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.4.2 [May 6, 2010] + * Last changed in libpng 1.4.1 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -11,13 +11,12 @@ * and license in png.h * */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #include "pngpriv.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) { if (png_ptr != NULL && info_ptr != NULL) @@ -182,9 +181,9 @@ float PNGAPI png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) -#ifdef PNG_pHYs_SUPPORTED +#ifdef PNG_READ_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); @@ -202,8 +201,29 @@ return ((float)0.0); } #endif +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr) +{ +#ifdef PNG_READ_pHYs_SUPPORTED + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) + && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0) + { + png_fixed_point res; + + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); + + if (png_muldiv(&res, info_ptr->y_pixels_per_unit, PNG_FP_1, + info_ptr->x_pixels_per_unit)) + return res; + } +#endif + return 0; +} +#endif + png_int_32 PNGAPI png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) @@ -254,9 +274,9 @@ #ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); @@ -276,9 +296,9 @@ #ifdef PNG_oFFs_SUPPORTED if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); @@ -290,43 +310,108 @@ #endif return (0); } -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED +static png_uint_32 +ppi_from_ppm(png_uint_32 ppm) +{ +#if 0 + /* The conversion is *(2.54/100), in binary (32 digits): + * .00000110100000001001110101001001 + */ + png_uint_32 t1001, t1101; + ppm >>= 1; /* .1 */ + t1001 = ppm + (ppm >> 3); /* .1001 */ + t1101 = t1001 + (ppm >> 1); /* .1101 */ + ppm >>= 20; /* .000000000000000000001 */ + t1101 += t1101 >> 15; /* .1101000000000001101 */ + t1001 >>= 11; /* .000000000001001 */ + t1001 += t1001 >> 12; /* .000000000001001000000001001 */ + ppm += t1001; /* .000000000001001000001001001 */ + ppm += t1101; /* .110100000001001110101001001 */ + return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ +#else + /* The argument is a PNG unsigned integer, so it is not permitted + * to be bigger than 2^31. + */ + png_fixed_point result; + if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, ppm, 127, 5000)) + return result; + + /* Overflow. */ + return 0; +#endif +} + png_uint_32 PNGAPI png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { - return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); } png_uint_32 PNGAPI png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { - return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); } png_uint_32 PNGAPI png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { - return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) - *.0254 +.5)); + return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); +} + +#ifdef PNG_FIXED_POINT_SUPPORTED +static png_fixed_point +png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns) +{ + /* Convert from metres * 1,000,000 to inches * 100,000, meters to + * inches is simply *(100/2.54), so we want *(10/2.54) == 1000/254. + * Notice that this can overflow - a warning is output and 0 is + * returned. + */ + return png_muldiv_warn(png_ptr, microns, 500, 127); } +png_fixed_point PNGAPI +png_get_x_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_x_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FIXED_POINT_SUPPORTED +png_fixed_point PNGAPI +png_get_y_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr) +{ + return png_fixed_inches_from_microns(png_ptr, + png_get_y_offset_microns(png_ptr, info_ptr)); +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) { - return ((float)png_get_x_offset_microns(png_ptr, info_ptr) - *.00003937); + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return png_get_x_offset_microns(png_ptr, info_ptr) * .00003937f; } +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) { - return ((float)png_get_y_offset_microns(png_ptr, info_ptr) - *.00003937); + /* To avoid the overflow do the conversion directly in floating + * point. + */ + return png_get_y_offset_microns(png_ptr, info_ptr) * .00003937f; } +#endif #ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, @@ -361,9 +448,9 @@ } return (retval); } #endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* png_get_channels really belongs in here, too, but it's been around longer */ #endif /* PNG_EASY_ACCESS_SUPPORTED */ @@ -376,9 +464,9 @@ else return (0); } -png_bytep PNGAPI +png_const_bytep PNGAPI png_get_signature(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->signature); @@ -414,23 +503,23 @@ { png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) - *white_x = (double)info_ptr->x_white; + *white_x = png_float(png_ptr, info_ptr->x_white, "cHRM white X"); if (white_y != NULL) - *white_y = (double)info_ptr->y_white; + *white_y = png_float(png_ptr, info_ptr->y_white, "cHRM white Y"); if (red_x != NULL) - *red_x = (double)info_ptr->x_red; + *red_x = png_float(png_ptr, info_ptr->x_red, "cHRM red X"); if (red_y != NULL) - *red_y = (double)info_ptr->y_red; + *red_y = png_float(png_ptr, info_ptr->y_red, "cHRM red Y"); if (green_x != NULL) - *green_x = (double)info_ptr->x_green; + *green_x = png_float(png_ptr, info_ptr->x_green, "cHRM green X"); if (green_y != NULL) - *green_y = (double)info_ptr->y_green; + *green_y = png_float(png_ptr, info_ptr->y_green, "cHRM green Y"); if (blue_x != NULL) - *blue_x = (double)info_ptr->x_blue; + *blue_x = png_float(png_ptr, info_ptr->x_blue, "cHRM blue X"); if (blue_y != NULL) - *blue_y = (double)info_ptr->y_blue; + *blue_y = png_float(png_ptr, info_ptr->y_blue, "cHRM blue Y"); return (PNG_INFO_cHRM); } return (0); } @@ -446,60 +536,55 @@ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { if (white_x != NULL) - *white_x = info_ptr->int_x_white; + *white_x = info_ptr->x_white; if (white_y != NULL) - *white_y = info_ptr->int_y_white; + *white_y = info_ptr->y_white; if (red_x != NULL) - *red_x = info_ptr->int_x_red; + *red_x = info_ptr->x_red; if (red_y != NULL) - *red_y = info_ptr->int_y_red; + *red_y = info_ptr->y_red; if (green_x != NULL) - *green_x = info_ptr->int_x_green; + *green_x = info_ptr->x_green; if (green_y != NULL) - *green_y = info_ptr->int_y_green; + *green_y = info_ptr->y_green; if (blue_x != NULL) - *blue_x = info_ptr->int_x_blue; + *blue_x = info_ptr->x_blue; if (blue_y != NULL) - *blue_y = info_ptr->int_y_blue; + *blue_y = info_ptr->y_blue; return (PNG_INFO_cHRM); } return (0); } #endif #endif #ifdef PNG_gAMA_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) +png_uint_32 PNGFAPI +png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *file_gamma) { png_debug1(1, "in %s retrieval function", "gAMA"); if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && file_gamma != NULL) { - *file_gamma = (double)info_ptr->gamma; + *file_gamma = info_ptr->gamma; return (PNG_INFO_gAMA); } + return (0); } -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI -png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, - png_fixed_point *int_file_gamma) -{ - png_debug1(1, "in %s retrieval function", "gAMA"); - - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) - && int_file_gamma != NULL) +png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) { - *int_file_gamma = info_ptr->int_gamma; - return (PNG_INFO_gAMA); - } - return (0); + png_fixed_point igamma; + png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma); + if (ok) + *file_gamma = png_float(png_ptr, igamma, "png_get_gAMA"); + return ok; } #endif #endif @@ -522,9 +608,9 @@ #ifdef PNG_iCCP_SUPPORTED png_uint_32 PNGAPI png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen) + png_bytepp profile, png_uint_32 *proflen) { png_debug1(1, "in %s retrieval function", "iCCP"); if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) @@ -656,8 +747,29 @@ } #endif #ifdef PNG_sCAL_SUPPORTED +#ifdef PNG_FIXED_POINT_SUPPORTED +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, + int *unit, png_fixed_point *width, png_fixed_point *height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + /*TODO: make this work without FP support */ + *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); + *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), + "sCAL height"); + return (PNG_INFO_sCAL); + } + + return(0); +} +#endif /*FLOATING_ARITHMETIC*/ +#endif /*FIXED_POINT*/ #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_sCAL(png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height) @@ -665,16 +777,16 @@ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { *unit = info_ptr->scal_unit; - *width = info_ptr->scal_pixel_width; - *height = info_ptr->scal_pixel_height; + *width = atof(info_ptr->scal_s_width); + *height = atof(info_ptr->scal_s_height); return (PNG_INFO_sCAL); } + return(0); } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED +#endif png_uint_32 PNGAPI png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, int *unit, png_charpp width, png_charpp height) { @@ -685,13 +797,12 @@ *width = info_ptr->scal_s_width; *height = info_ptr->scal_s_height; return (PNG_INFO_sCAL); } + return(0); } #endif -#endif -#endif #ifdef PNG_pHYs_SUPPORTED png_uint_32 PNGAPI png_get_pHYs(png_structp png_ptr, png_infop info_ptr, @@ -766,10 +880,10 @@ { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { png_debug1(1, "in %s retrieval function", - (png_ptr->chunk_name[0] == '\0' ? "text" - : (png_const_charp)png_ptr->chunk_name)); + (png_ptr->chunk_name[0] == '\0' ? "text" : + (png_const_charp)png_ptr->chunk_name)); if (text_ptr != NULL) *text_ptr = info_ptr->text; @@ -901,10 +1022,9 @@ /* This function was added to libpng 1.4.1 */ png_alloc_size_t PNGAPI png_get_chunk_malloc_max (png_structp png_ptr) { - return (png_ptr? - png_ptr->user_chunk_malloc_max : 0); + return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ /* These functions were added to libpng 1.4.0 */ @@ -914,9 +1034,9 @@ { return png_ptr->io_state; } -png_bytep PNGAPI +png_const_bytep PNGAPI png_get_io_chunk_name (png_structp png_ptr) { return png_ptr->chunk_name; } diff -ru4NwbB libpng-1.4.3/pnginfo.h libpng-1.5.0beta42/pnginfo.h --- libpng-1.4.3/pnginfo.h 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/pnginfo.h 2010-08-18 08:12:21.294224164 -0500 @@ -0,0 +1,270 @@ + +/* pnginfo.h - header file for PNG reference library + * + * Copyright (c) 1998-2010 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.) + * + * Last changed in libpng version 1.5.0 - August 11, 2010 + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + + /* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, using png_set_*() functions, then + * call png_write_info(). + * + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. In libpng-1.5.0 this was moved into a separate private + * file that is not visible to applications. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +#ifndef PNGINFO_H +#define PNGINFO_H + +struct png_info_def +{ + /* 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_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) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following is informational only on read, and not used on writes. */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_gAMA_SUPPORTED) + /* The gAMA chunk describes the gamma characteristics of the system + * on which the image was created, normally in the range [1.0, 2.5]. + * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. + */ + png_fixed_point gamma; +#endif + +#ifdef PNG_sRGB_SUPPORTED + /* GR-P, 0.96a */ + /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ + png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ +#endif + +#ifdef PNG_TEXT_SUPPORTED + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read or comments to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read or comments to write */ +#endif /* PNG_TEXT_SUPPORTED */ + +#ifdef PNG_tIME_SUPPORTED + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#ifdef PNG_sBIT_SUPPORTED + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans; /* alpha values for paletted image */ + png_bytep trans_alpha; /* alpha values for paletted 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 + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#ifdef PNG_oFFs_SUPPORTED + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#ifdef PNG_pHYs_SUPPORTED + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#ifdef PNG_hIST_SUPPORTED + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_cHRM_SUPPORTED + /* The cHRM chunk describes the CIE color characteristics of the monitor + * on which the PNG was created. This data allows the viewer to do gamut + * mapping of the input image to ensure that the viewer sees the same + * colors in the image as the creator. Values are in the range + * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. + */ + png_fixed_point x_white; + png_fixed_point y_white; + png_fixed_point x_red; + png_fixed_point y_red; + png_fixed_point x_green; + png_fixed_point y_green; + png_fixed_point x_blue; + png_fixed_point y_blue; +#endif + +#ifdef PNG_pCAL_SUPPORTED + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + /* Storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + png_size_t unknown_chunks_num; +#endif + +#ifdef PNG_iCCP_SUPPORTED + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_bytep iccp_profile; /* International Color Consortium profile data */ + png_uint_32 iccp_proflen; /* ICC profile data length */ + png_byte iccp_compression; /* Always zero */ +#endif + +#ifdef PNG_sPLT_SUPPORTED + /* Data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + png_uint_32 splt_palettes_num; +#endif + +#ifdef PNG_sCAL_SUPPORTED + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is + * non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif + +#ifdef PNG_INFO_IMAGE_SUPPORTED + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) + non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +}; +#endif /* PNGINFO_H */ diff -ru4NwbB libpng-1.4.3/pngmem.c libpng-1.5.0beta42/pngmem.c --- libpng-1.4.3/pngmem.c 2010-06-25 19:32:26.043778474 -0500 +++ libpng-1.5.0beta42/pngmem.c 2010-08-18 08:12:21.336936906 -0500 @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.4.2 [May 6, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -16,29 +16,29 @@ * png_create_read_struct_2() and png_create_write_struct_2() to * identify the replacement functions. */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #include "pngpriv.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + /* 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 */ /* Allocate memory for a png_struct. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_create_struct,(int type),PNG_ALLOCATED) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_struct_2(type, NULL, NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr), + PNG_ALLOCATED) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; png_voidp struct_ptr; @@ -114,10 +119,10 @@ * 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. */ -png_voidp PNGAPI -png_calloc(png_structp png_ptr, png_alloc_size_t size) +PNG_FUNCTION(png_voidp,PNGAPI +png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; ret = (png_malloc(png_ptr, size)); @@ -120,15 +125,17 @@ { 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_FUNCTION(png_voidp,PNGAPI +png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; if (png_ptr == NULL || size == 0) @@ -136,17 +143,20 @@ #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr->malloc_fn != NULL) 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"); + return (ret); } -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_alloc_size_t size) +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -333,30 +356,29 @@ } } if (ptr != NULL) - { farfree(ptr); } -} #else /* Not the Borland DOS special memory handler */ /* 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 to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct(int type) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_create_struct,(int type),PNG_ALLOCATED) { #ifdef PNG_USER_MEM_SUPPORTED 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 to improve performance noticably. */ -png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +PNG_FUNCTION(png_voidp /* PRIVATE */, +png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr), + PNG_ALLOCATED) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; png_voidp struct_ptr; @@ -441,10 +471,10 @@ * need to allocate exactly 64K, so whatever you call here must * have the ability to do that. */ -png_voidp PNGAPI -png_calloc(png_structp png_ptr, png_alloc_size_t size) +PNG_FUNCTION(png_voidp,PNGAPI +png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; ret = (png_malloc(png_ptr, size)); @@ -447,15 +477,17 @@ { 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_FUNCTION(png_voidp,PNGAPI +png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; #ifdef PNG_USER_MEM_SUPPORTED @@ -463,17 +495,20 @@ return (NULL); if (png_ptr->malloc_fn != NULL) 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"); + return (ret); } -png_voidp PNGAPI -png_malloc_default(png_structp png_ptr, png_alloc_size_t size) +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ @@ -563,10 +609,10 @@ * 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_alloc_size_t size) +PNG_FUNCTION(png_voidp,PNGAPI +png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) { png_voidp ptr; png_uint_32 save_flags; if (png_ptr == NULL) diff -ru4NwbB libpng-1.4.3/pngpread.c libpng-1.5.0beta42/pngpread.c --- libpng-1.4.3/pngpread.c 2010-06-25 19:32:26.052596370 -0500 +++ libpng-1.5.0beta42/pngpread.c 2010-08-18 08:12:21.345804448 -0500 @@ -1,8 +1,8 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.4.3 [June 26, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,13 +10,12 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED #include "pngpriv.h" +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + /* Push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 #define PNG_READ_IDAT_MODE 2 @@ -624,9 +626,9 @@ png_ptr->process_mode = PNG_READ_CHUNK_MODE; } } -void PNGAPI +void PNGCBAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; @@ -847,9 +855,9 @@ { int ret; /* We have data for zlib, but we must check that zlib - * has somewhere to put the results. It doesn't matter + * has someplace to put the results. It doesn't matter * if we don't expect any results -- it may be the input * data is just the LZ end code. */ if (!(png_ptr->zstream.avail_out > 0)) @@ -860,13 +869,13 @@ png_ptr->zstream.next_out = png_ptr->row_buf; } /* Using Z_SYNC_FLUSH here means that an unterminated - * LZ stream can still be handled (a stream with a missing - * end code), otherwise (Z_NO_FLUSH) a future zlib - * implementation might defer output and, therefore, - * change the current behavior. (See comments in inflate.c - * for why this doesn't happen at present with zlib 1.2.5.) + * LZ stream (a stream with a missing end code) can still + * be handled, otherwise (Z_NO_FLUSH) a future zlib + * implementation might defer output and therefore + * change the current behavior (see comments in inflate.c + * for why this doesn't happen at present with zlib 1.2.5). */ ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH); /* Check for any failure before proceeding. */ @@ -921,9 +932,9 @@ * is left at this point we have bytes of IDAT data * after the zlib end code. */ if (png_ptr->zstream.avail_in > 0) - png_warning(png_ptr, "Extra compression data"); + png_warning(png_ptr, "Extra compression data in IDAT"); } void /* PRIVATE */ png_push_process_row(png_structp png_ptr) @@ -1159,10 +1170,10 @@ #ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) { png_ptr->row_number = 0; - png_memset(png_ptr->prev_row, 0, - png_ptr->rowbytes + 1); + png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + do { png_ptr->pass++; if ((png_ptr->pass == 1 && png_ptr->width < 5) || @@ -1200,10 +1211,11 @@ length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { - png_error(png_ptr, "Out of place tEXt"); info_ptr = info_ptr; /* To quiet some compiler warnings */ + png_error(png_ptr, "Out of place tEXt"); + /*NOT REACHED*/ } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ @@ -1269,16 +1281,14 @@ if (text < key + png_ptr->current_text_size) text++; - text_ptr = (png_textp)png_malloc(png_ptr, - png_sizeof(png_text)); + text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED + text_ptr->itxt_length = 0; text_ptr->lang = NULL; text_ptr->lang_key = NULL; -#endif text_ptr->text = text; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); @@ -1298,10 +1308,11 @@ length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { - png_error(png_ptr, "Out of place zTXt"); info_ptr = info_ptr; /* To quiet some compiler warnings */ + png_error(png_ptr, "Out of place zTXt"); + /*NOT REACHED*/ } #ifdef PNG_MAX_MALLOC_64K /* We can't handle zTXt chunks > 64K, since we don't have enough space @@ -1475,12 +1489,11 @@ text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED + text_ptr->itxt_length = 0; text_ptr->lang = NULL; text_ptr->lang_key = NULL; -#endif text_ptr->text = text; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); @@ -1499,10 +1512,11 @@ length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { - png_error(png_ptr, "Out of place iTXt"); info_ptr = info_ptr; /* To quiet some compiler warnings */ + png_error(png_ptr, "Out of place iTXt"); + /*NOT REACHED*/ } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ @@ -1725,10 +1740,10 @@ (int)png_ptr->pass); } void PNGAPI -png_progressive_combine_row (png_structp png_ptr, - png_bytep old_row, png_bytep new_row) +png_progressive_combine_row (png_structp png_ptr, png_bytep old_row, + png_const_bytep new_row) { PNG_CONST int FARDATA png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; diff -ru4NwbB libpng-1.4.3/pngpriv.h libpng-1.5.0beta42/pngpriv.h --- libpng-1.4.3/pngpriv.h 2010-06-25 19:32:26.004448928 -0500 +++ libpng-1.5.0beta42/pngpriv.h 2010-08-18 08:12:21.282846774 -0500 @@ -23,27 +23,116 @@ #ifndef PNGPRIV_H #define PNGPRIV_H -#ifndef PNG_VERSION_INFO_ONLY - +/* This is required for the definition of abort(), used as a last ditch + * error handler when all else fails. + */ #include +#define PNGLIB_BUILD +#ifdef PNG_USER_CONFIG +# include "pngusr.h" +#endif +#include "png.h" +#include "pnginfo.h" +#include "pngstruct.h" + +/* This is used for 16 bit gamma tables - only the top level pointers are const, + * this could be changed: + */ +typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp; + +/* Added at libpng-1.2.9 */ +/* Moved to pngpriv.h at libpng-1.5.0 */ + +/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the "configure" + * script. We may need it here to get the correct configuration on things + * like limits. + */ +#ifdef PNG_CONFIGURE_LIBPNG +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif +#endif + +/* Moved to pngpriv.h at libpng-1.5.0 */ +/* NOTE: some of these may be used in external applications as these definitions + * were exposed in pngconf.h prior to 1.5. + */ +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. + * + * zlib provides 'MAXSEG_64K' which, if defined, indicates the + * same limit and pngconf.h (already included) sets the limit + * if certain operating systems are detected. + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +/* If warnings or errors are turned off the code is disabled + * or redirected here. + */ +#ifndef PNG_WARNINGS_SUPPORTED +# define png_warning(s1,s2) ((void)0) +# define png_chunk_warning(s1,s2) ((void)0) +#endif +#ifndef PNG_ERROR_TEXT_SUPPORTED +# define png_error(s1,s2) png_err(s1) +# define png_chunk_error(s1,s2) png_err(s1) +# define png_fixed_error(s1,s2) png_err(s1) +#endif + +#ifndef PNG_EXTERN /* 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 +#endif + +/* Some fixed point APIs are still required even if not exported because + * they get used by the corresponding floating point APIs. This magic + * deals with this: + */ +#ifdef PNG_FIXED_POINT_SUPPORTED +# define PNGFAPI PNGAPI +#else +# define PNGFAPI /* PRIVATE */ +#endif /* 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) ||\ + defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) + /* png.c requires the following ANSI-C constants if the conversion of + * floating point to ASCII is implemented therein: + * + * DBL_DIG Maximum number of decimal digits (can be set to any constant) + * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) + * DBL_MAX Maximum floating point number (can be set to an arbitrary value) + */ +# include -#ifdef PNG_FLOATING_POINT_SUPPORTED -# ifdef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) /* 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. */ @@ -60,13 +149,8 @@ # 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 @@ -74,14 +158,89 @@ #if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ defined(_WIN32) || defined(__WIN32__) # include /* defines _WINDOWS_ macro */ -/* I have no idea why is this necessary... */ +#endif + +/* Moved here around 1.5.0beta36 from pngconf.h */ +/* Users may want to use these so they are not private. Any library + * functions that are passed far data must be model-independent. + */ + +/* Memory model/platform independent fns */ +#ifndef PNG_ABORT +# ifdef _WINDOWS_ +# define PNG_ABORT() ExitProcess(0) +# else +# define PNG_ABORT() abort() +# endif +#endif + +#ifdef 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_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 +# define png_sprintf sprintf +#else +# ifdef _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 +# endif +#endif +/* End of memory model/platform independent support */ + +#ifndef PNG_NO_SNPRINTF # ifdef _MSC_VER -# include +# define png_snprintf _snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 _snprintf +# define png_snprintf6 _snprintf +# else +# define png_snprintf snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 snprintf +# define png_snprintf6 snprintf # endif +#else + /* You don't have or don't want to use snprintf(). Caution: Using + * sprintf instead of snprintf exposes your application to accidental + * or malevolent buffer overflows. If you don't have snprintf() + * as a general rule you should provide one (you can get one from + * Portable OpenSSH). + */ +# define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1) +# define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2) +# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ + png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) #endif +/* End of 1.5.0beta36 move from pngconf.h */ +/* CONSTANTS and UTILITY MACROS + * These are used internally by libpng and not exposed in the API + */ /* 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 @@ -105,9 +264,9 @@ #define PNG_PACK 0x0004 #define PNG_SHIFT 0x0008 #define PNG_SWAP_BYTES 0x0010 #define PNG_INVERT_MONO 0x0020 -#define PNG_QUANTIZE 0x0040 /* formerly PNG_DITHER */ +#define PNG_QUANTIZE 0x0040 #define PNG_BACKGROUND 0x0080 #define PNG_BACKGROUND_EXPAND 0x0100 /* 0x0200 unused */ #define PNG_16_TO_8 0x0400 @@ -137,11 +296,9 @@ #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 @@ -204,8 +361,46 @@ */ #define PNG_OUT_OF_RANGE(value, ideal, delta) \ ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) +/* Conversions between fixed and floating point, only defined if + * required (to make sure the code doesn't accidentally use float + * when it is supposedly disabled.) + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* The floating point conversion can't overflow, though it can and + * does lose accuracy relative to the original fixed point value. + * In practice this doesn't matter because png_fixed_point only + * stores numbers with very low precision. The png_ptr and s + * arguments are unused by default but are there in case error + * checking becomes a requirement. + */ +#define png_float(png_ptr, fixed, s) (.00001 * (fixed)) + +/* The fixed point conversion performs range checking and evaluates + * its argument multiple times, so must be used with care. The + * range checking uses the PNG specification values for a signed + * 32 bit fixed point value except that the values are deliberately + * rounded-to-zero to an integral value - 21474. 's' is a string + * that describes the value being converted. + * + * NOTE: this macro will raise a png_error if the range check fails, + * therefore it is normally only appropriate to use this on values + * that come from API calls or other sources where an out of range + * error indicates a programming error, not a data error! + * + * NOTE: by default this is off - the macro is not used - because the + * function call saves a lot of code. + */ +#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED +#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ + ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) +#else +PNG_EXTERN png_fixed_point png_fixed PNGARG((png_structp png_ptr, double fp, + png_const_charp text)); +#endif +#endif + /* Constant strings for known chunk types. If you need to add a chunk, * define the name here, and add an invocation of the macro wherever it's * needed. */ @@ -244,54 +439,59 @@ * 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)); +PNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct,PNGARG((int type)), + PNG_ALLOCATED); /* 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 PNG_FUNCTION(png_voidp,png_create_struct_2, + PNGARG((int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)), + PNG_ALLOCATED); 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)); +PNG_EXTERN PNG_FUNCTION(voidpf,png_zalloc,PNGARG((voidpf png_ptr, uInt items, + uInt size)),PNG_ALLOCATED); /* 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. */ +/* Next four functions are used internally as callbacks. PNGCBAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to + * PNGCBAPI at 1.5.0 + */ -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, +PNG_EXTERN void PNGCBAPI 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_EXTERN void PNGCBAPI 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_EXTERN void PNGCBAPI png_default_write_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); #ifdef PNG_WRITE_FLUSH_SUPPORTED #ifdef PNG_STDIO_SUPPORTED -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +PNG_EXTERN void PNGCBAPI 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)); +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, + png_const_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)); @@ -320,10 +520,10 @@ /* 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)); +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, + png_const_bytep ptr, png_size_t length)); #ifdef PNG_WRITE_FLUSH_SUPPORTED PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); #endif @@ -337,10 +537,10 @@ 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_PLTE PNGARG((png_structp png_ptr, + png_const_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)); @@ -356,10 +556,10 @@ #endif #endif #ifdef PNG_WRITE_sBIT_SUPPORTED -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, + png_const_color_8p sbit, int color_type)); #endif #ifdef PNG_WRITE_cHRM_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED @@ -381,58 +581,59 @@ #endif #ifdef 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)); + png_const_charp name, int compression_type, + png_const_charp profile, int proflen)); /* Note to maintainer: profile should be png_bytep */ #endif #ifdef PNG_WRITE_sPLT_SUPPORTED PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); + png_const_sPLT_tp palette)); #endif #ifdef 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)); +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, + png_const_bytep trans, png_const_color_16p values, int number, + int color_type)); #endif #ifdef PNG_WRITE_bKGD_SUPPORTED PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); + png_const_color_16p values, int color_type)); #endif #ifdef PNG_WRITE_hIST_SUPPORTED -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, + png_const_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)); + png_const_charp key, png_charpp new_key)); #endif #ifdef 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)); +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_const_charp key, + png_const_charp text, png_size_t text_len)); #endif #ifdef 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)); +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_const_charp key, + png_const_charp text, png_size_t text_len, int compression)); #endif #ifdef 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)); + int compression, png_const_charp key, png_const_charp lang, + png_const_charp lang_key, png_const_charp text)); #endif #ifdef 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)); + png_infop info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_WRITE_oFFs_SUPPORTED PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, @@ -441,9 +642,9 @@ #ifdef 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)); + png_const_charp units, png_charpp params)); #endif #ifdef PNG_WRITE_pHYs_SUPPORTED PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, @@ -452,34 +653,22 @@ #endif #ifdef PNG_WRITE_tIME_SUPPORTED PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); + png_const_timep mod_time)); #endif #ifdef PNG_WRITE_sCAL_SUPPORTED -#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) -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 + int unit, png_const_charp width, png_const_charp height)); #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)); -#ifdef PNG_READ_GAMMA_SUPPORTED -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr, - png_byte bit_depth)); -#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)); @@ -501,9 +690,10 @@ #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)); + png_row_infop row_info, png_bytep row, png_const_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)); @@ -552,92 +742,102 @@ 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)); +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)); +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, + png_bytep row)); #endif #ifdef 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)); +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, png_bytep row)); #endif #ifdef PNG_READ_PACK_SUPPORTED -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, + png_bytep row)); #endif #ifdef PNG_READ_SHIFT_SUPPORTED -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, + png_bytep row, png_const_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)); +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, + png_bytep row)); #endif #ifdef PNG_READ_16_TO_8_SUPPORTED -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, + png_bytep row)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup)); + png_bytep row, png_const_bytep palette_lookup, + png_const_bytep quantize_lookup)); # ifdef 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)); +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, + png_bytep row)); #endif #ifdef 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 #ifdef PNG_WRITE_SHIFT_SUPPORTED -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, + png_bytep row, png_const_color_8p bit_depth)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED #ifdef 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)); +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, + png_bytep row, png_const_color_16p trans_color, + png_const_color_16p background, png_const_color_16p background_1, + png_const_bytep gamma_table, png_const_bytep gamma_from_1, + png_const_bytep gamma_to_1, png_const_uint_16pp gamma_16, + png_const_uint_16pp gamma_16_from_1, png_const_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)); +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, + png_bytep row, png_const_color_16p trans_color, + png_const_color_16p background)); #endif #endif #ifdef 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)); +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, + png_bytep row, png_const_bytep gamma_table, + png_const_uint_16pp gamma_16_table, int gamma_shift)); #endif #ifdef 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_bytep row, png_const_colorp palette, png_const_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)); + png_bytep row, png_const_color_16p trans_color)); #endif /* The following decodes the appropriate chunks, and does error correction, * then calls the appropriate callback for the chunk if it is valid. @@ -671,9 +871,9 @@ png_uint_32 length)); #endif #ifdef PNG_READ_iCCP_SUPPORTED -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, +PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif /* PNG_READ_iCCP_SUPPORTED */ #ifdef PNG_READ_iTXt_SUPPORTED @@ -706,9 +906,9 @@ png_uint_32 length)); #endif #ifdef PNG_READ_sPLT_SUPPORTED -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, +PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif /* PNG_READ_sPLT_SUPPORTED */ #ifdef PNG_READ_sRGB_SUPPORTED @@ -739,9 +939,9 @@ 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)); + png_const_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)); @@ -804,153 +1004,200 @@ png_bytep row)); #endif /* Added at libpng version 1.4.0 */ -#ifdef PNG_cHRM_SUPPORTED +#ifdef PNG_CHECK_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 -#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_CHECK_cHRM_SUPPORTED /* Added at libpng version 1.2.34 and 1.4.0 */ +/* Currently only used by png_check_cHRM_fixed */ PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2, unsigned long *hi_product, unsigned long *lo_product)); #endif -#endif /* Added at libpng version 1.4.0 */ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)); /* Free all memory used by the read (old method - NOT DLL EXPORTED) */ -extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); +PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr, png_infop end_info_ptr)); /* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -extern void png_write_destroy PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr)); #ifdef USE_FAR_KEYWORD /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, +PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr, png_voidp ptr, int check)); #endif /* USE_FAR_KEYWORD */ -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include -#if (PNG_DEBUG > 1) -#ifndef _DEBUG -# define _DEBUG -#endif -#ifndef png_debug -#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) -#endif -#ifndef png_debug1 -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) -#endif -#ifndef png_debug2 -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) -#endif -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ - -#if (PNG_DEBUG > 1) -/* 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" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ - } +#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) +PNG_EXTERN PNG_FUNCTION(void, png_fixed_error, (png_structp png_ptr, + png_const_charp name),PNG_NORETURN); # endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) \ - { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ - } -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ - } -# 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); \ - } -# 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); \ - } -# 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); \ - } + +/* ASCII to FP interfaces, currently only implemented if sCAL + * support is required. + */ +#if defined(PNG_READ_sCAL_SUPPORTED) +/* MAX_DIGITS is actually the maximum number of characters in an sCAL + * width or height, derived from the precision (number of significant + * digits - a build time settable option) and assumpitions about the + * maximum ridiculous exponent. + */ +#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) + +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_ascii_from_fp PNGARG((png_structp png_ptr, png_charp ascii, + png_size_t size, double fp, unsigned int precision)); +#endif /* FLOATING_POINT */ + +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr, + png_charp ascii, png_size_t size, png_fixed_point fp)); +#endif /* FIXED_POINT */ +#endif /* READ_sCAL */ + +#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) +/* An internal API to validate the format of a floating point number. + * The result is the index of the next character. If the number is + * not valid it will be the index of a character in the supposed number. + * + * The format of a number is defined in the PNG extensions specification + * and this API is strictly conformant to that spec, not anyone elses! + * + * The format as a regular expression is: + * + * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? + * + * or: + * + * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? + * + * The complexity is that either integer or fraction must be present and the + * fraction is permitted to have no digits only if the integer is present. + * + * NOTE: The dangling E problem. + * There is a PNG valid floating point number in the following: + * + * PNG floating point numb1.ers are not greedy. + * + * Working this out requires *TWO* character lookahead (because of the + * sign), the parser does not do this - it will fail at the 'r' - this + * doesn't matter for PNG sCAL chunk values, but it requires more care + * if the value were ever to be embedded in something more complex. Use + * ANSI-C strtod if you need the lookahead. + */ +/* State table for the parser. */ +#define PNG_FP_INTEGER 0 /* before or in integer */ +#define PNG_FP_FRACTION 1 /* before or in fraction */ +#define PNG_FP_EXPONENT 2 /* before or in exponent */ +#define PNG_FP_STATE 3 /* mask for the above */ +#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */ +#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */ +#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */ +#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */ +#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */ +#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */ +#define PNG_FP_INVALID 128 /* Available for callers as a distinct value */ + +/* Result codes for the parser (boolean - true meants ok, false means + * not ok yet.) + */ +#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ +#define PNG_FP_OK 1 /* The number is valid */ + +/* The actual parser. This can be called repeatedly, it updates + * the index into the string and the state variable (which must + * be initialzed to 0). It returns a result code, as above. There + * is no point calling the parser any more if it fails to advance to + * the end of the string - it is stuck on an invalid character (or + * terminated by '\0'). + * + * Note that the pointer will consume an E or even an E+ then leave + * a 'maybe' state even though a preceding integer.fraction is valid. + * The PNG_FP_WAS_VALID flag indicates that a preceding substring was + * a valid number. It's possible to recover from this by calling + * the parser again (from the start, with state 0) but with a string + * that omits the last character (i.e. set the size to the index of + * the problem character.) This has not been tested within libpng. + */ +PNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string, + png_size_t size, int *statep, png_size_tp whereami)); + +/* This is the same but it checks a complete string and returns true + * only if it just contains a floating point number. + */ +PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string, + png_size_t size)); +#endif /* pCAL || sCAL */ + +#if defined(PNG_READ_GAMMA_SUPPORTED) ||\ + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) +/* Added at libpng version 1.5.0 */ +/* This is a utility to provide a*times/div (rounded) and indicate + * if there is an overflow. The result is a boolean - false (0) + * for overflow, true (1) if no overflow, in which case *res + * holds the result. + */ +PNG_EXTERN int png_muldiv PNGARG((png_fixed_point_p res, png_fixed_point a, + png_int_32 times, png_int_32 div)); # endif -# endif /* __STDC __ */ -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) +/* Same deal, but issue a warning on overflow and return 0. */ +PNG_EXTERN png_fixed_point png_muldiv_warn PNGARG((png_structp png_ptr, + png_fixed_point a, png_int_32 times, png_int_32 div)); #endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Calculate a reciprocal - used for gamma values. This returns + * 0 if the argument is 0 in order to maintain an undefined value, + * there are no warnings. + */ +PNG_EXTERN png_fixed_point png_reciprocal PNGARG((png_fixed_point a)); + +/* The same but gives a reciprocal of the product of two fixed point + * values. Accuracy is suitable for gamma calculations but this is + * not exact - use png_muldiv for that. + */ +PNG_EXTERN png_fixed_point png_reciprocal2 PNGARG((png_fixed_point a, + png_fixed_point b)); #endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Internal fixed point gamma correction. These APIs are called as + * required to convert single values - they don't need to be fast, + * they are not used when processing image pixel values. + * + * While the input is an 'unsigned' value it must actually be the + * correct bit value - 0..255 or 0..65535 as required. + */ +PNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr, + unsigned int value, png_fixed_point gamma)); +PNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma)); +PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value, + png_fixed_point gamma)); +PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value, + png_fixed_point gamma)); +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr, + png_byte bit_depth)); #endif /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#include "pngdebug.h" + #ifdef __cplusplus } #endif -#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNGPRIV_H */ diff -ru4NwbB libpng-1.4.3/pngread.c libpng-1.5.0beta42/pngread.c --- libpng-1.4.3/pngread.c 2010-06-25 19:32:26.061337464 -0500 +++ libpng-1.5.0beta42/pngread.c 2010-08-18 08:12:21.353956257 -0500 @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -13,18 +13,16 @@ * This file contains routines that an application calls directly to * read a PNG file or stream. */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_READ_SUPPORTED #include "pngpriv.h" +#ifdef PNG_READ_SUPPORTED /* 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, - png_error_ptr error_fn, png_error_ptr warn_fn) +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, @@ -33,12 +31,12 @@ /* Alternate create PNG structure for reading, and allocate any memory * needed. */ -png_structp PNGAPI -png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, +PNG_FUNCTION(png_structp,PNGAPI +png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { #endif /* PNG_USER_MEM_SUPPORTED */ #ifdef PNG_SETJMP_SUPPORTED @@ -48,9 +46,9 @@ volatile int png_cleanup_needed = 0; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; + jmp_buf png_jmpbuf; #endif #endif int i; @@ -84,15 +84,15 @@ /* 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)) + if (setjmp(png_jmpbuf)) #else if (setjmp(png_jmpbuf(png_ptr))) /* Sets longjmp to match setjmp */ #endif PNG_ABORT(); #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(png_ptr), jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf)); #endif #endif /* PNG_SETJMP_SUPPORTED */ #ifdef PNG_USER_MEM_SUPPORTED @@ -124,27 +126,26 @@ if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || (user_png_ver[0] == '0' && user_png_ver[2] < '9')) { -#ifdef PNG_STDIO_SUPPORTED +#ifdef PNG_CONSOLE_IO_SUPPORTED char msg[80]; 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_snprintf2(msg, 80, + "Application built with libpng-%.20s" + " but running with %.20s", + user_png_ver, png_libpng_ver); png_warning(png_ptr, msg); + } +#else + png_warning(png_ptr, + "Incompatible libpng version in application and library"); #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags = 0; #endif - png_warning(png_ptr, - "Incompatible libpng version in application and library"); png_cleanup_needed = 1; } } @@ -152,13 +153,14 @@ if (!png_cleanup_needed) { /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; - png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr, - 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; @@ -165,14 +167,26 @@ if (!png_cleanup_needed) { switch (inflateInit(&png_ptr->zstream)) { - case Z_OK: /* Do nothing */ break; + case Z_OK: + break; /* Do nothing */ + case Z_MEM_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; + png_warning(png_ptr, "zlib memory error"); + png_cleanup_needed = 1; + break; + + case Z_STREAM_ERROR: + png_warning(png_ptr, "zlib stream 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; } } @@ -428,13 +471,16 @@ png_debug(1, "in png_read_update_info"); if (png_ptr == NULL) return; + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); + else png_warning(png_ptr, - "Ignoring extra png_read_update_info() call; row buffer not reallocated"); + "Ignoring extra png_read_update_info() call;" + " row buffer not reallocated"); png_read_transform_info(png_ptr, info_ptr); } @@ -450,10 +496,15 @@ png_debug(1, "in png_start_read_image"); if (png_ptr == NULL) return; + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); + else + png_warning(png_ptr, + "Ignoring extra png_start_read_image() call;" + " row buffer not reallocated"); } #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ #ifdef PNG_SEQUENTIAL_READ_SUPPORTED @@ -668,14 +740,14 @@ */ png_do_read_interlace(png_ptr); if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, - png_pass_dsp_mask[png_ptr->pass]); + png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); + if (row != NULL) - png_combine_row(png_ptr, row, - png_pass_mask[png_ptr->pass]); + png_combine_row(png_ptr, row, png_pass_mask[png_ptr->pass]); } + else #endif { if (row != NULL) @@ -779,9 +855,33 @@ if (png_ptr == NULL) return; #ifdef PNG_READ_INTERLACING_SUPPORTED + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + { + pass = png_set_interlace_handling(png_ptr); + /* And make sure transforms are initialized. */ + png_start_read_image(png_ptr); + } + else + { + if (!(png_ptr->transformations & PNG_INTERLACE)) + { + /* Caller called png_start_read_image or png_read_update_info without + * first turning on the PNG_INTERLACE transform. We can fix this here, + * but the caller should do it! + */ + png_warning(png_ptr, "Interlace handling should be turned on when " + "using png_read_image"); + /* Make sure this is set correctly */ + png_ptr->num_rows = png_ptr->height; + } + + /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in + * the above error case. + */ pass = png_set_interlace_handling(png_ptr); + } #else if (png_ptr->interlaced) png_error(png_ptr, "Cannot read interlaced image -- interlace handler disabled"); @@ -784,14 +884,13 @@ #else if (png_ptr->interlaced) png_error(png_ptr, "Cannot read interlaced image -- interlace handler disabled"); + pass = 1; #endif - image_height=png_ptr->height; - png_ptr->num_rows = image_height; /* Make sure this is set correctly */ for (j = 0; j < pass; j++) { rp = image; @@ -1157,9 +1289,9 @@ /* Save the important info out of the png_struct, in case it is * being used again. */ #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf)); #endif error_fn = png_ptr->error_fn; warning_fn = png_ptr->warning_fn; @@ -1177,9 +1309,9 @@ png_ptr->free_fn = free_fn; #endif #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); + png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif } @@ -1282,40 +1415,35 @@ } #endif #ifdef PNG_READ_BGR_SUPPORTED - /* Flip the RGB pixels to BGR (or RGBA to BGRA) - */ + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (transforms & PNG_TRANSFORM_BGR) png_set_bgr(png_ptr); #endif #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED - /* 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) */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif #ifdef PNG_READ_SWAP_SUPPORTED - /* Swap bytes of 16 bit files to least significant byte first - */ + /* Swap bytes of 16 bit files to least significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) png_set_swap(png_ptr); #endif /* Added at libpng-1.2.41 */ #ifdef PNG_READ_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 /* Added at libpng-1.2.41 */ #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* Expand grayscale image to RGB - */ + /* Expand grayscale image to RGB */ if (transforms & PNG_TRANSFORM_GRAY_TO_RGB) png_set_gray_to_rgb(png_ptr); #endif diff -ru4NwbB libpng-1.4.3/pngrio.c libpng-1.5.0beta42/pngrio.c --- libpng-1.4.3/pngrio.c 2010-06-25 19:32:26.066255903 -0500 +++ libpng-1.5.0beta42/pngrio.c 2010-08-18 08:12:21.359048900 -0500 @@ -1,8 +1,8 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -17,13 +17,12 @@ * function, but rather write a replacement function and then make * libpng use it at run time with png_set_read_fn(...). */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_READ_SUPPORTED #include "pngpriv.h" +#ifdef PNG_READ_SUPPORTED + /* 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 @@ -46,9 +46,9 @@ * 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 +void PNGCBAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; @@ -70,9 +71,9 @@ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) -static void PNGAPI +static void PNGCBAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; png_byte *n_data; @@ -150,11 +158,10 @@ if (png_ptr->write_data_fn != NULL) { 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"); + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); } #ifdef PNG_WRITE_FLUSH_SUPPORTED png_ptr->output_flush_fn = NULL; diff -ru4NwbB libpng-1.4.3/pngrtran.c libpng-1.5.0beta42/pngrtran.c --- libpng-1.4.3/pngrtran.c 2010-06-25 19:32:26.081580070 -0500 +++ libpng-1.5.0beta42/pngrtran.c 2010-08-18 08:12:21.373797407 -0500 @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.4.2 [May 6, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -15,13 +15,12 @@ * Transformations that are used in both reading and writing are * in pngtrans.c. */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_READ_SUPPORTED #include "pngpriv.h" +#ifdef PNG_READ_SUPPORTED + /* 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) { @@ -88,20 +87,20 @@ break; } } -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS via a background color */ -void PNGAPI -png_set_background(png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) +void PNGFAPI +png_set_background_fixed(png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma) { - png_debug(1, "in png_set_background"); + png_debug(1, "in png_set_background_fixed"); 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; @@ -109,13 +108,24 @@ png_ptr->transformations |= PNG_BACKGROUND; png_memcpy(&(png_ptr->background), background_color, png_sizeof(png_color_16)); - png_ptr->background_gamma = (float)background_gamma; + png_ptr->background_gamma = background_gamma; png_ptr->background_gamma_type = (png_byte)(background_gamma_code); png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); } -#endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_background(png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) +{ + png_set_background_fixed(png_ptr, background_color, background_gamma_code, + need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); +} +# endif /* FLOATING_POINT */ +#endif /* READ_BACKGROUND */ #ifdef PNG_READ_16_TO_8_SUPPORTED /* Strip 16 bit depth files to 8 bit depth */ void PNGAPI @@ -141,14 +153,14 @@ } #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Quantize file to 8 bit. Supply a palette, the current number +/* 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 * of colors is greater then the maximum number, the palette will be * modified to fit in the maximum number. "full_quantize" indicates - * whether we need a quantizeing cube set up for RGB images, or if we + * whether we need a quantizing cube set up for RGB images, or if we * simply are reducing the number of colors in a paletted image. */ typedef struct png_dsort_struct @@ -161,9 +173,9 @@ typedef png_dsort FAR * FAR * png_dsortpp; void PNGAPI png_set_quantize(png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_uint_16p histogram, + int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize) { png_debug(1, "in png_set_quantize"); @@ -537,9 +558,9 @@ } } #endif /* PNG_READ_QUANTIZE_SUPPORTED */ -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED /* Transform the image from the file_gamma to the screen_gamma. We * only do transformations on images where the file_gamma and screen_gamma * are not close reciprocals, otherwise it slows things down slightly, and * also needlessly introduces small errors. @@ -547,24 +568,50 @@ * We will turn off gamma transformation later if no semitransparent entries * are present in the tRNS array for palette images. We can't do it here * because we don't necessarily have the tRNS chunk yet. */ -void PNGAPI -png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) +static int /* PRIVATE */ +png_gamma_threshold(png_fixed_point scrn_gamma, png_fixed_point file_gamma) +{ + /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma + * correction as a difference of the overall transform from 1.0 + * + * We want to compare the threshold with s*f - 1, if we get + * overflow here it is because of wacky gamma values so we + * turn on processing anyway. + */ + png_fixed_point gtest; + return !png_muldiv(>est, scrn_gamma, file_gamma, PNG_FP_1) || + png_gamma_significant(gtest); +} + +void PNGFAPI +png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma, + png_fixed_point file_gamma) { - png_debug(1, "in png_set_gamma"); + png_debug(1, "in png_set_gamma_fixed"); 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)) + if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + png_gamma_threshold(scrn_gamma, file_gamma)) png_ptr->transformations |= PNG_GAMMA; - png_ptr->gamma = (float)file_gamma; - png_ptr->screen_gamma = (float)scrn_gamma; + png_ptr->gamma = file_gamma; + png_ptr->screen_gamma = scrn_gamma; } -#endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) +{ + png_set_gamma_fixed(png_ptr, + png_fixed(png_ptr, scrn_gamma, "png_set_gamma screen gamma"), + png_fixed(png_ptr, file_gamma, "png_set_gamma file gamma")); +} +# endif /* FLOATING_POINT_SUPPORTED */ +#endif /* READ_GAMMA */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand paletted images to RGB, expand grayscale images of * less than 8-bit depth to 8-bit depth, and expand tRNS chunks @@ -650,26 +697,9 @@ } #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, - 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; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); -} -#endif - -void PNGAPI +void PNGFAPI 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"); @@ -678,15 +708,18 @@ return; switch(error_action) { - case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; + case 1: + png_ptr->transformations |= PNG_RGB_TO_GRAY; break; - case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + case 2: + png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; break; - case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + case 3: + png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #ifdef PNG_READ_EXPAND_SUPPORTED png_ptr->transformations |= PNG_EXPAND; @@ -720,8 +757,27 @@ png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768 - red_int - green_int); } } + +#ifdef PNG_FLOATING_POINT_SUPPORTED +/* Convert a RGB image to a grayscale of the same width. This allows us, + * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. + */ + +void PNGAPI +png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, + double green) +{ + if (png_ptr == NULL) + return; + + png_set_rgb_to_gray_fixed(png_ptr, error_action, + png_fixed(png_ptr, red, "rgb to gray red coefficient"), + png_fixed(png_ptr, green, "rgb to gray green coefficient")); +} +#endif /* FLOATING POINT */ + #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) @@ -772,9 +828,11 @@ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && !(color_type & PNG_COLOR_MASK_COLOR)) { png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } else if ((png_ptr->transformations & PNG_BACKGROUND) && + } + + else if ((png_ptr->transformations & PNG_BACKGROUND) && !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && (png_ptr->transformations & PNG_GRAY_TO_RGB) && png_ptr->background.red == png_ptr->background.green && png_ptr->background.red == png_ptr->background.blue) @@ -857,9 +915,10 @@ */ int i, istop; istop=(int)png_ptr->num_trans; for (i=0; itrans_alpha[i] = (png_byte)(255 - png_ptr->trans_alpha[i]); + png_ptr->trans_alpha[i] = (png_byte)(255 - + png_ptr->trans_alpha[i]); } } #endif @@ -869,13 +928,12 @@ #if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) png_ptr->background_1 = png_ptr->background; #endif -#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) +#ifdef PNG_READ_GAMMA_SUPPORTED if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) - && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) - < PNG_GAMMA_THRESHOLD)) + && png_gamma_threshold(png_ptr->screen_gamma, png_ptr->gamma)) { int i, k; k=0; for (i=0; inum_trans; i++) @@ -887,9 +945,9 @@ png_ptr->transformations &= ~PNG_GAMMA; } if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && - png_ptr->gamma != 0.0) + png_ptr->gamma != 0) { png_build_gamma_table(png_ptr, png_ptr->bit_depth); #ifdef PNG_READ_BACKGROUND_SUPPORTED @@ -913,33 +972,35 @@ back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; } else { - double g, gs; + png_fixed_point g, gs; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: g = (png_ptr->screen_gamma); - gs = 1.0; + gs = PNG_FP_1; break; case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->gamma); + gs = png_reciprocal2(png_ptr->gamma, + png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, png_ptr->screen_gamma); break; default: - g = 1.0; /* back_1 */ - gs = 1.0; /* back */ + g = PNG_FP_1; /* back_1 */ + gs = PNG_FP_1; /* back */ + break; } - if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) + if ( png_gamma_significant(gs) ) { back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; @@ -943,25 +1004,23 @@ back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; } + else { - back.red = (png_byte)(pow( - (double)png_ptr->background.red/%F255%, gs) * 255.0 + .5); - back.green = (png_byte)(pow( - (double)png_ptr->background.green/%F255%, gs) * 255.0 - + .5); - back.blue = (png_byte)(pow( - (double)png_ptr->background.blue/%F255%, gs) * 255.0 + .5); - } - - back_1.red = (png_byte)(pow( - (double)png_ptr->background.red/%F255%, g) * 255.0 + .5); - back_1.green = (png_byte)(pow( - (double)png_ptr->background.green/%F255%, g) * 255.0 + .5); - back_1.blue = (png_byte)(pow( - (double)png_ptr->background.blue/%F255%, g) * 255.0 + .5); + back.red = png_gamma_8bit_correct(png_ptr->background.red, + gs); + back.green = png_gamma_8bit_correct(png_ptr->background.green, + gs); + back.blue = png_gamma_8bit_correct(png_ptr->background.blue, + gs); + } + back_1.red = png_gamma_8bit_correct(png_ptr->background.red, g); + back_1.green = png_gamma_8bit_correct(png_ptr->background.green, + g); + back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, + g); } for (i = 0; i < num_palette; i++) { if (i < (int)png_ptr->num_trans && png_ptr->trans_alpha[i] != 0xff) @@ -1006,54 +1066,60 @@ /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ else /* color_type != PNG_COLOR_TYPE_PALETTE */ { - double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); - double g = 1.0; - double gs = 1.0; + png_fixed_point g = PNG_FP_1; + png_fixed_point gs = PNG_FP_1; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = 1.0; + g = png_ptr->screen_gamma; + /* gs = PNG_FP_1; */ break; case PNG_BACKGROUND_GAMMA_FILE: - g = 1.0 / (png_ptr->gamma); - gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + g = png_reciprocal(png_ptr->gamma); + gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: - g = 1.0 / (png_ptr->background_gamma); - gs = 1.0 / (png_ptr->background_gamma * + g = png_reciprocal(png_ptr->background_gamma); + gs = png_reciprocal2(png_ptr->background_gamma, png_ptr->screen_gamma); break; } - png_ptr->background_1.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, g) * m + .5); - png_ptr->background.gray = (png_uint_16)(pow( - (double)png_ptr->background.gray / m, gs) * m + .5); + png_ptr->background_1.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, g); + + png_ptr->background.gray = png_gamma_correct(png_ptr, + png_ptr->background.gray, gs); if ((png_ptr->background.red != png_ptr->background.green) || (png_ptr->background.red != png_ptr->background.blue) || (png_ptr->background.red != png_ptr->background.gray)) { /* RGB or RGBA with color background */ - png_ptr->background_1.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, g) * m + .5); - png_ptr->background_1.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, g) * m + .5); - png_ptr->background_1.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, g) * m + .5); - png_ptr->background.red = (png_uint_16)(pow( - (double)png_ptr->background.red / m, gs) * m + .5); - png_ptr->background.green = (png_uint_16)(pow( - (double)png_ptr->background.green / m, gs) * m + .5); - png_ptr->background.blue = (png_uint_16)(pow( - (double)png_ptr->background.blue / m, gs) * m + .5); + png_ptr->background_1.red = png_gamma_correct(png_ptr, + png_ptr->background.red, g); + + png_ptr->background_1.green = png_gamma_correct(png_ptr, + png_ptr->background.green, g); + + png_ptr->background_1.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, g); + + png_ptr->background.red = png_gamma_correct(png_ptr, + png_ptr->background.red, gs); + + png_ptr->background.green = png_gamma_correct(png_ptr, + png_ptr->background.green, gs); + + png_ptr->background.blue = png_gamma_correct(png_ptr, + png_ptr->background.blue, gs); } + else { /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ png_ptr->background_1.red = png_ptr->background_1.green @@ -1085,9 +1152,9 @@ } #ifdef PNG_READ_BACKGROUND_SUPPORTED else #endif -#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ +#endif /* PNG_READ_GAMMA_SUPPORTED */ #ifdef PNG_READ_BACKGROUND_SUPPORTED /* No GAMMA transformation */ if ((png_ptr->transformations & PNG_BACKGROUND) && (color_type == PNG_COLOR_TYPE_PALETTE)) @@ -1204,14 +1280,9 @@ #ifdef PNG_READ_GAMMA_SUPPORTED if (png_ptr->transformations & PNG_GAMMA) { -#ifdef PNG_FLOATING_POINT_SUPPORTED info_ptr->gamma = png_ptr->gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_ptr->int_gamma; -#endif } #endif #ifdef PNG_READ_16_TO_8_SUPPORTED @@ -1306,9 +1380,9 @@ png_debug(1, "in png_do_read_transformations"); if (png_ptr->row_buf == NULL) { -#ifdef PNG_STDIO_SUPPORTED +#ifdef PNG_CONSOLE_IO_SUPPORTED char msg[50]; png_snprintf2(msg, 50, "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number, @@ -1453,14 +1530,15 @@ #ifdef PNG_READ_QUANTIZE_SUPPORTED if (png_ptr->transformations & PNG_QUANTIZE) { - png_do_quantize((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, + png_do_quantize(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->palette_lookup, png_ptr->quantize_index); + if (png_ptr->row_info.rowbytes == (png_uint_32)0) png_error(png_ptr, "png_do_quantize returned rowbytes=0"); } -#endif +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ #ifdef PNG_READ_INVERT_SUPPORTED if (png_ptr->transformations & PNG_INVERT_MONO) png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); @@ -1640,9 +1726,10 @@ * a row of bit depth 8, but only 5 are significant, this will shift * the values back to 0 through 31. */ void /* PRIVATE */ -png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) +png_do_unshift(png_row_infop row_info, png_bytep row, + png_const_color_8p sig_bits) { png_debug(1, "in png_do_unshift"); if ( @@ -1893,17 +1983,17 @@ #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { + png_uint_32 row_width; png_debug(1, "in png_do_read_invert_alpha"); - { - png_uint_32 row_width = row_info->width; + row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in RGBA */ png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; @@ -1948,11 +2038,11 @@ } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in GA */ png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; @@ -1961,11 +2051,11 @@ *(--dp) = (png_byte)(255 - *(--sp)); *(--dp) = *(--sp); } } - /* This inverts the alpha channel in GGAA */ else { + /* This inverts the alpha channel in GGAA */ png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; @@ -1982,9 +2072,8 @@ } } } } -} #endif #ifdef PNG_READ_FILLER_SUPPORTED /* Add filler channel if we have RGB color */ @@ -2004,11 +2093,11 @@ row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { - /* This changes the data from G to GX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from G to GX */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) { @@ -2019,11 +2108,12 @@ row_info->channels = 2; row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } - /* This changes the data from G to XG */ + else { + /* This changes the data from G to XG */ png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) { @@ -2034,13 +2124,14 @@ row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } } + else if (row_info->bit_depth == 16) { - /* This changes the data from GG to GGXX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from GG to GGXX */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) { @@ -2054,11 +2145,12 @@ row_info->channels = 2; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - /* This changes the data from GG to XXGG */ + else { + /* This changes the data from GG to XXGG */ png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { @@ -2076,11 +2168,11 @@ else if (row_info->color_type == PNG_COLOR_TYPE_RGB) { if (row_info->bit_depth == 8) { - /* This changes the data from RGB to RGBX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from RGB to RGBX */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) { @@ -2093,11 +2185,12 @@ row_info->channels = 4; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } - /* This changes the data from RGB to XRGB */ + else { + /* This changes the data from RGB to XRGB */ png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) { @@ -2110,13 +2203,14 @@ row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } } + else if (row_info->bit_depth == 16) { - /* This changes the data from RRGGBB to RRGGBBXX */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This changes the data from RRGGBB to RRGGBBXX */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) { @@ -2134,11 +2228,12 @@ row_info->channels = 4; row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } - /* This changes the data from RRGGBB to XXRRGGBB */ + else { + /* This changes the data from RRGGBB to XXRRGGBB */ png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { @@ -2176,8 +2272,9 @@ if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { + /* This changes G to RGB */ png_bytep sp = row + (png_size_t)row_width - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { @@ -2185,10 +2282,12 @@ *(dp--) = *sp; *(dp--) = *(sp--); } } + else { + /* This changes GG to RRGGBB */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) { @@ -2204,8 +2304,9 @@ else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (row_info->bit_depth == 8) { + /* This changes GA to RGBA */ png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { @@ -2214,10 +2315,12 @@ *(dp--) = *sp; *(dp--) = *(sp--); } } + else { + /* This changes GGAA to RRGGBBAA */ png_bytep sp = row + (png_size_t)row_width * 4 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) { @@ -2344,17 +2451,18 @@ blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; if (red == green && red == blue) w = red; + else { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> - png_ptr->gamma_shift][red>>8]; + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) + >> png_ptr->gamma_shift][red>>8]; png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> - png_ptr->gamma_shift][blue>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) + >> png_ptr->gamma_shift][blue>>8]; png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + bc*blue_1)>>15); w = png_ptr->gamma_16_from_1[(gray16&0xff) >> png_ptr->gamma_shift][gray16 >> 8]; @@ -2558,14 +2679,14 @@ * 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_color, png_color_16p background + png_const_color_16p trans_color, png_const_color_16p background #ifdef 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, - png_uint_16pp gamma_16_to_1, int gamma_shift + , png_const_color_16p background_1, png_const_bytep gamma_table, + png_const_bytep gamma_from_1, png_const_bytep gamma_to_1, + png_const_uint_16pp gamma_16, png_const_uint_16pp gamma_16_from_1, + png_const_uint_16pp gamma_16_to_1, int gamma_shift #endif ) { png_bytep sp, dp; @@ -2730,29 +2865,24 @@ sp = row; for (i = 0; i < row_width; i++, sp++) { if (*sp == trans_color->gray) - { *sp = (png_byte)background->gray; - } + else - { *sp = gamma_table[*sp]; } } - } else #endif { sp = row; for (i = 0; i < row_width; i++, sp++) { if (*sp == trans_color->gray) - { *sp = (png_byte)background->gray; } } - } break; } case 16: @@ -2853,10 +2987,15 @@ sp = row; for (i = 0; i < row_width; i++, sp += 6) { 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)); + + 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_color->red && g == trans_color->green && b == trans_color->blue) { /* Background is already in screen gamma */ @@ -2887,10 +3030,14 @@ sp = row; for (i = 0; i < row_width; i++, sp += 6) { 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)); + + 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_color->red && g == trans_color->green && b == trans_color->blue) { @@ -2921,11 +3068,10 @@ { png_uint_16 a = *(sp + 1); if (a == 0xff) - { *dp = gamma_table[*sp]; - } + else if (a == 0) { /* Background is already in screen gamma */ *dp = (png_byte)background->gray; @@ -2949,20 +3096,17 @@ { png_byte a = *(sp + 1); if (a == 0xff) - { *dp = *sp; - } + #ifdef PNG_READ_GAMMA_SUPPORTED else if (a == 0) - { *dp = (png_byte)background->gray; - } + else - { png_composite(*dp, *sp, a, background_1->gray); - } + #else *dp = (png_byte)background->gray; #endif } @@ -2977,9 +3121,10 @@ sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 2) { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); if (a == (png_uint_16)0xffff) { png_uint_16 v; @@ -3018,13 +3165,14 @@ sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 2) { - png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + if (a == (png_uint_16)0xffff) - { png_memcpy(dp, sp, 2); - } + #ifdef PNG_READ_GAMMA_SUPPORTED else if (a == 0) #else else @@ -3252,19 +3425,18 @@ * build_gamma_table(). */ void /* PRIVATE */ png_do_gamma(png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, + png_const_bytep gamma_table, png_const_uint_16pp gamma_16_table, int gamma_shift) { png_bytep sp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_gamma"); - if ( - ((row_info->bit_depth <= 8 && gamma_table != NULL) || + if (((row_info->bit_depth <= 8 && gamma_table != NULL) || (row_info->bit_depth == 16 && gamma_16_table != NULL))) { switch (row_info->color_type) { @@ -3438,19 +3620,18 @@ * upon whether you supply trans and num_trans. */ void /* PRIVATE */ png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_colorp palette, png_bytep trans_alpha, int num_trans) + png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand_palette"); - if ( - row_info->color_type == PNG_COLOR_TYPE_PALETTE) + if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) { if (row_info->bit_depth < 8) { switch (row_info->bit_depth) @@ -3582,9 +3772,9 @@ * expanded transparency value is supplied, an alpha channel is built. */ void /* PRIVATE */ png_do_expand(png_row_infop row_info, png_bytep row, - png_color_16p trans_value) + png_const_color_16p trans_value) { int shift, value; png_bytep sp, dp; png_uint_32 i; @@ -3792,9 +3996,9 @@ #ifdef PNG_READ_QUANTIZE_SUPPORTED void /* PRIVATE */ png_do_quantize(png_row_infop row_info, png_bytep row, - png_bytep palette_lookup, png_bytep quantize_lookup) + png_const_bytep palette_lookup, png_const_bytep quantize_lookup) { png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; @@ -3876,268 +4085,9 @@ } } } } -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -#ifdef PNG_READ_GAMMA_SUPPORTED -static PNG_CONST int png_gamma_shift[] = - {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - * - * See the PNG extensions document for an integer algorithm for creating - * the gamma tables. Maybe we will implement that here someday. - * - * We should only reach this point if - * - * the file_gamma is known (i.e., the gAMA or sRGB chunk is present, - * or the application has provided a file_gamma) - * - * AND - * { - * the screen_gamma is known - * - * OR - * - * RGB_to_gray transformation is being performed - * } - * - * AND - * { - * the screen_gamma is different from the reciprocal of the - * file_gamma by more than the specified threshold - * - * OR - * - * a background color has been specified and the file_gamma - * and screen_gamma are not 1.0, within the specified threshold. - * } - */ - -void /* PRIVATE */ -png_build_gamma_table(png_structp png_ptr, png_byte bit_depth) -{ - png_debug(1, "in png_build_gamma_table"); - - if (bit_depth <= 8) - { - int i; - double g; - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - - else - g = 1.0; - - png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - } - - - png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, - (png_uint_32)256); - - if (png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - - else - g = png_ptr->gamma; /* Probably doing rgb_to_gray */ - - for (i = 0; i < 256; i++) - { - png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, - g) * 255.0 + .5); - - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } - else - { - double g; - int i, j, shift, num; - int sig_bit; - png_uint_32 ig; - - if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit = (int)png_ptr->sig_bit.red; - - if ((int)png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - - if ((int)png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - { - sig_bit = (int)png_ptr->sig_bit.gray; - } - - if (sig_bit > 0) - shift = 16 - sig_bit; - - else - shift = 0; - - if (png_ptr->transformations & PNG_16_TO_8) - { - if (shift < (16 - PNG_MAX_GAMMA_8)) - shift = (16 - PNG_MAX_GAMMA_8); - } - - if (shift > 8) - shift = 8; - - if (shift < 0) - shift = 0; - - png_ptr->gamma_shift = (png_byte)shift; - - num = (1 << (8 - shift)); - - if (png_ptr->screen_gamma > .000001) - g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); - else - g = 1.0; - - png_ptr->gamma_16_table = (png_uint_16pp)png_calloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p))); - - if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) - { - double fin, fout; - png_uint_32 last, max; - - 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))); - } - - g = 1.0 / g; - last = 0; - for (i = 0; i < 256; i++) - { - fout = ((double)i + 0.5) / 256.0; - fin = pow(fout, g); - max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); - while (last <= max) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)( - (png_uint_16)i | ((png_uint_16)i << 8)); - last++; - } - } - while (last < ((png_uint_32)num << 8)) - { - png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] - [(int)(last >> (8 - shift))] = (png_uint_16)65535L; - last++; - } - } - else - { - 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))); - - ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); - - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_table[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) - { - - g = 1.0 / (png_ptr->gamma); - - png_ptr->gamma_16_to_1 = (png_uint_16pp)png_calloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p ))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof(png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_to_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - - if (png_ptr->screen_gamma > 0.000001) - g = 1.0 / png_ptr->screen_gamma; - - else - g = png_ptr->gamma; /* Probably doing rgb_to_gray */ - - png_ptr->gamma_16_from_1 = (png_uint_16pp)png_calloc(png_ptr, - (png_uint_32)(num * png_sizeof(png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof(png_uint_16))); - - ig = (((png_uint_32)i * - (png_uint_32)png_gamma_shift[shift]) >> 4); - - for (j = 0; j < 256; j++) - { - png_ptr->gamma_16_from_1[i][j] = - (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / - 65535.0, g) * 65535.0 + .5); - } - } - } -#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ - } -} -#endif -/* To do: install integer version of png_build_gamma_table here */ -#endif +#endif /* PNG_READ_QUANTIZE_SUPPORTED */ #ifdef PNG_MNG_FEATURES_SUPPORTED /* Undoes intrapixel differencing */ void /* PRIVATE */ diff -ru4NwbB libpng-1.4.3/pngrutil.c libpng-1.5.0beta42/pngrutil.c --- libpng-1.4.3/pngrutil.c 2010-06-25 19:32:26.095302257 -0500 +++ libpng-1.5.0beta42/pngrutil.c 2010-08-18 08:12:21.387169830 -0500 @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.4.3 [June 26, 2010] + * Last changed in libpng 1.4.1 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -13,60 +13,89 @@ * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_READ_SUPPORTED #include "pngpriv.h" +#ifdef PNG_READ_SUPPORTED + # define png_strtod(p,a,b) strtod(a,b) png_uint_32 PNGAPI -png_get_uint_31(png_structp png_ptr, png_bytep buf) +png_get_uint_31(png_structp png_ptr, png_const_bytep buf) { png_uint_32 i = png_get_uint_32(buf); if (i > PNG_UINT_31_MAX) png_error(png_ptr, "PNG unsigned integer out of range"); return (i); } -#ifndef PNG_USE_READ_MACROS + +#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) +/* The following is a variation on the above for use with the fixed + * point values used for gAMA and cHRM. Instead of png_error it + * issues a warning and returns (-1) - an invalid value because both + * gAMA and cHRM use *unsigned* integers for fixed point values. + */ +#define PNG_FIXED_ERROR (-1) + +static png_fixed_point /* PRIVATE */ +png_get_fixed_point(png_structp png_ptr, png_const_bytep buf) +{ + png_uint_32 u = png_get_uint_32(buf); + if (u <= PNG_UINT_31_MAX) + return (png_fixed_point)u; /* known to be in range */ + + /* The caller can turn off the warning by passing NULL. */ + if (png_ptr != NULL) + png_warning(png_ptr, "PNG fixed point integer out of range"); + return PNG_FIXED_ERROR; +} +#endif + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +/* NOTE: the read macros will obscure these definitions, so that if + * PNG_USE_READ_MACROS is set the library will not use them internally, + * but the APIs will still be available externally. + */ /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 PNGAPI -png_get_uint_32(png_bytep buf) +png_uint_32 (PNGAPI +png_get_uint_32)(png_const_bytep buf) { - png_uint_32 i = ((png_uint_32)(*buf) << 24) + + 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)); + ((png_uint_32)(*(buf + 3)) ) ; return (i); } /* 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. - */ -png_int_32 PNGAPI -png_get_int_32(png_bytep buf) -{ - png_int_32 i = ((png_int_32)(*buf) << 24) + - ((png_int_32)(*(buf + 1)) << 16) + - ((png_int_32)(*(buf + 2)) << 8) + - (png_int_32)(*(buf + 3)); + * data is stored in the PNG file in two's complement format and there + * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore + * the following code does a two's complement to native conversion. + */ +png_int_32 (PNGAPI +png_get_int_32)(png_const_bytep buf) +{ + png_uint_32 u = png_get_uint_32(buf); + if ((u & 0x80000000) == 0) /* non-negative */ + return u; - return (i); + u = (u ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ + return -(png_int_32)u; } /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 PNGAPI -png_get_uint_16(png_bytep buf) +png_uint_16 (PNGAPI +png_get_uint_16)(png_const_bytep buf) { - png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + - (png_uint_16)(*(buf + 1))); + png_uint_16 i = + ((png_uint_32)(*buf) << 8) + + ((png_uint_32)(*(buf + 1))); return (i); } -#endif /* PNG_USE_READ_MACROS */ +#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */ /* Read the chunk header (length + type name). * Put the type name into png_ptr->chunk_name, and return the length. */ @@ -89,9 +118,9 @@ /* 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_debug2(0, "Reading %s chunk, length = %u", png_ptr->chunk_name, length); /* Reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); @@ -201,14 +235,14 @@ #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ defined(PNG_READ_iCCP_SUPPORTED) static png_size_t -png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size, +png_inflate(png_structp png_ptr, png_bytep data, png_size_t size, png_bytep output, png_size_t output_size) { png_size_t count = 0; - png_ptr->zstream.next_in = (png_bytep)data; /* const_cast: VALID */ + png_ptr->zstream.next_in = data; png_ptr->zstream.avail_in = size; while (1) { @@ -230,9 +264,10 @@ { if (output != 0 && output_size > count) { int copy = output_size - count; - if (avail < copy) copy = avail; + if (avail < copy) + copy = avail; png_memcpy(output + count, png_ptr->zbuf, copy); } count += avail; } @@ -254,15 +289,16 @@ * buffer if available. */ { PNG_CONST char *msg; +#ifdef PNG_CONSOLE_IO_SUPPORTED + char umsg[52]; +#endif if (png_ptr->zstream.msg != 0) msg = png_ptr->zstream.msg; else { -#ifdef PNG_STDIO_SUPPORTED - char umsg[52]; - +#ifdef PNG_CONSOLE_IO_SUPPORTED switch (ret) { case Z_BUF_ERROR: msg = "Buffer error in compressed datastream in %s chunk"; @@ -284,9 +322,9 @@ png_warning(png_ptr, msg); } - /* 0 means an error - notice that this code simple ignores + /* 0 means an error - notice that this code simply ignores * zero length compressed chunks as a result. */ return 0; } @@ -316,9 +354,10 @@ { png_size_t expanded_size = png_inflate(png_ptr, (png_bytep)(png_ptr->chunkdata + prefix_size), chunklength - prefix_size, - 0/*output*/, 0/*output size*/); + 0, /*output*/ + 0); /*output size*/ /* Now check the limits on this chunk - if the limit fails the * compressed data will be removed, the prefix will remain. */ @@ -339,11 +378,12 @@ * error case below. */ #if defined(PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED) || \ defined(PNG_USER_CHUNK_MALLOC_MAX) - else -#endif + else if (expanded_size > 0) +#else if (expanded_size > 0) +#endif { /* Success (maybe) - really uncompress the chunk. */ png_size_t new_size = 0; png_charp text = png_malloc_warn(png_ptr, @@ -378,10 +418,10 @@ { #ifdef PNG_STDIO_SUPPORTED char umsg[50]; - png_snprintf(umsg, sizeof umsg, "Unknown zTXt compression type %d", - comp_type); + png_snprintf(umsg, sizeof umsg, + "Unknown zTXt compression type %d", comp_type); png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Unknown zTXt compression type"); #endif @@ -480,9 +520,9 @@ 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); png_debug1(3, "channels = %d", png_ptr->channels); - png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes); + png_debug1(3, "rowbytes = %u", png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } @@ -567,9 +607,9 @@ palette[i].blue = buf[2]; } #endif - /* If we actually NEED the PLTE chunk (ie for a paletted image), we do + /* 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. */ @@ -582,11 +622,12 @@ #ifndef PNG_READ_OPT_PLTE_SUPPORTED else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ { /* If we don't want to use the data from an ancillary chunk, - we have two options: an error abort, or a warning and we - ignore the data in this chunk (which should be OK, since - it's considered ancillary for a RGB or RGBA image). */ + * we have two options: an error abort, or a warning and we + * ignore the data in this chunk (which should be OK, since + * it's considered ancillary for a RGB or RGBA image). + */ if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) { @@ -654,11 +698,8 @@ void /* PRIVATE */ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_fixed_point igamma; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif png_byte buf[4]; png_debug(1, "in png_handle_gAMA"); @@ -695,14 +736,14 @@ png_crc_read(png_ptr, buf, 4); if (png_crc_finish(png_ptr, 0)) return; - igamma = (png_fixed_point)png_get_uint_32(buf); - /* Check for zero gamma */ - if (igamma == 0) + igamma = png_get_fixed_point(NULL, buf); + /* Check for zero gamma or an error. */ + if (igamma <= 0) { png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); + "Ignoring gAMA chunk with out of range gamma"); return; } #ifdef PNG_READ_sRGB_SUPPORTED @@ -717,18 +758,14 @@ return; } #endif /* PNG_READ_sRGB_SUPPORTED */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float)igamma / (float)100000.0; # ifdef PNG_READ_GAMMA_SUPPORTED - png_ptr->gamma = file_gamma; -# endif - png_set_gAMA(png_ptr, info_ptr, file_gamma); + /* Gamma correction on read is supported. */ + png_ptr->gamma = igamma; #endif -#ifdef PNG_FIXED_POINT_SUPPORTED + /* And set the 'info' structure members. */ png_set_gAMA_fixed(png_ptr, info_ptr, igamma); -#endif } #endif #ifdef PNG_READ_sBIT_SUPPORTED @@ -801,15 +845,10 @@ void /* PRIVATE */ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[32]; -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue; - - png_uint_32 uint_x, uint_y; + png_fixed_point x_white, y_white, x_red, y_red, x_green, y_green, x_blue, + y_blue; png_debug(1, "in png_handle_cHRM"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) @@ -845,82 +886,56 @@ png_crc_read(png_ptr, buf, 32); if (png_crc_finish(png_ptr, 0)) return; - uint_x = png_get_uint_32(buf); - uint_y = png_get_uint_32(buf + 4); - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - - uint_x = png_get_uint_32(buf + 8); - uint_y = png_get_uint_32(buf + 12); - int_x_red = (png_fixed_point)uint_x; - int_y_red = (png_fixed_point)uint_y; - - uint_x = png_get_uint_32(buf + 16); - uint_y = png_get_uint_32(buf + 20); - int_x_green = (png_fixed_point)uint_x; - int_y_green = (png_fixed_point)uint_y; - - uint_x = png_get_uint_32(buf + 24); - uint_y = png_get_uint_32(buf + 28); - int_x_blue = (png_fixed_point)uint_x; - int_y_blue = (png_fixed_point)uint_y; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float)int_x_white / (float)100000.0; - white_y = (float)int_y_white / (float)100000.0; - red_x = (float)int_x_red / (float)100000.0; - red_y = (float)int_y_red / (float)100000.0; - green_x = (float)int_x_green / (float)100000.0; - green_y = (float)int_y_green / (float)100000.0; - blue_x = (float)int_x_blue / (float)100000.0; - blue_y = (float)int_y_blue / (float)100000.0; -#endif + x_white = png_get_fixed_point(NULL, buf); + y_white = png_get_fixed_point(NULL, buf + 4); + x_red = png_get_fixed_point(NULL, buf + 8); + y_red = png_get_fixed_point(NULL, buf + 12); + x_green = png_get_fixed_point(NULL, buf + 16); + y_green = png_get_fixed_point(NULL, buf + 20); + x_blue = png_get_fixed_point(NULL, buf + 24); + y_blue = png_get_fixed_point(NULL, buf + 28); + if (x_white == PNG_FIXED_ERROR || + y_white == PNG_FIXED_ERROR || + x_red == PNG_FIXED_ERROR || + y_red == PNG_FIXED_ERROR || + x_green == PNG_FIXED_ERROR || + y_green == PNG_FIXED_ERROR || + x_blue == PNG_FIXED_ERROR || + y_blue == PNG_FIXED_ERROR) + { + png_warning(png_ptr, "Ignoring cHRM chunk with negative chromaticities"); + return; + } #ifdef PNG_READ_sRGB_SUPPORTED if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) { - if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) + if (PNG_OUT_OF_RANGE(x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(y_blue, 6000, 1000)) { png_warning(png_ptr, "Ignoring incorrect cHRM value when sRGB is also present"); #ifdef PNG_CONSOLE_IO_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n", - white_x, white_y, red_x, red_y); - fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n", - green_x, green_y, blue_x, blue_y); -#else - fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", - (long)int_x_white, (long)int_y_white, - (long)int_x_red, (long)int_y_red); - fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n", - (long)int_x_green, (long)int_y_green, - (long)int_x_blue, (long)int_y_blue); -#endif + fprintf(stderr, "wx=%d, wy=%d, rx=%d, ry=%d\n", + x_white, y_white, x_red, y_red); + fprintf(stderr, "gx=%d, gy=%d, bx=%d, by=%d\n", + x_green, y_green, x_blue, y_blue); #endif /* PNG_CONSOLE_IO_SUPPORTED */ } return; } #endif /* PNG_READ_sRGB_SUPPORTED */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_cHRM_fixed(png_ptr, info_ptr, - int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, - int_y_green, int_x_blue, int_y_blue); -#endif + png_set_cHRM_fixed(png_ptr, info_ptr, x_white, y_white, x_red, y_red, + x_green, y_green, x_blue, y_blue); } #endif #ifdef PNG_READ_sRGB_SUPPORTED @@ -972,50 +990,33 @@ #if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) { - png_fixed_point igamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - igamma=info_ptr->int_gamma; -#else -# ifdef PNG_FLOATING_POINT_SUPPORTED - igamma=(png_fixed_point)(info_ptr->gamma * 100000.); -# endif -#endif - if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) + if (PNG_OUT_OF_RANGE(info_ptr->gamma, 45500L, 500)) { png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifdef PNG_CONSOLE_IO_SUPPORTED -# ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr, "incorrect gamma=(%d/100000)\n", - (int)png_ptr->int_gamma); -# else -# ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma); -# endif -# endif + fprintf(stderr, "incorrect gamma=(%d/100000)\n", info_ptr->gamma); #endif } } #endif /* PNG_READ_gAMA_SUPPORTED */ #ifdef PNG_READ_cHRM_SUPPORTED -#ifdef PNG_FIXED_POINT_SUPPORTED if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) - if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || - PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) + if (PNG_OUT_OF_RANGE(info_ptr->x_white, 31270, 1000) || + PNG_OUT_OF_RANGE(info_ptr->y_white, 32900, 1000) || + PNG_OUT_OF_RANGE(info_ptr->x_red, 64000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->y_red, 33000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->x_green, 30000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->y_green, 60000L, 1000) || + PNG_OUT_OF_RANGE(info_ptr->x_blue, 15000, 1000) || + PNG_OUT_OF_RANGE(info_ptr->y_blue, 6000, 1000)) { png_warning(png_ptr, "Ignoring incorrect cHRM value when sRGB is also present"); } -#endif /* PNG_FIXED_POINT_SUPPORTED */ #endif /* PNG_READ_cHRM_SUPPORTED */ png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); } @@ -1129,26 +1132,27 @@ if (profile_size > profile_length) { png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; - png_warning(png_ptr, "Ignoring truncated iCCP profile"); #ifdef PNG_STDIO_SUPPORTED { - char umsg[50]; + char umsg[80]; - png_snprintf(umsg, 50, "declared profile size = %lu", - (unsigned long)profile_size); - png_warning(png_ptr, umsg); - png_snprintf(umsg, 50, "actual profile length = %lu", - (unsigned long)profile_length); + png_snprintf2(umsg, 80, + "Ignoring iCCP chunk with declared size = %u " + "and actual length = %u", profile_size, profile_length); png_warning(png_ptr, umsg); } +#else + png_warning(png_ptr, + "Ignoring iCCP chunk with uncompressed size mismatch"); #endif return; } png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata, - compression_type, png_ptr->chunkdata + prefix_length, profile_length); + compression_type, (png_bytep)png_ptr->chunkdata + prefix_length, + profile_length); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; } #endif /* PNG_READ_iCCP_SUPPORTED */ @@ -1462,9 +1484,10 @@ /* We convert the index value into RGB components so that we can allow * arbitrary RGB values for background when we have transparency, and * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. */ + * from the info_ptr struct. + */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { png_ptr->background.index = buf[0]; if (info_ptr && info_ptr->num_palette) @@ -1668,12 +1707,13 @@ png_crc_finish(png_ptr, length); return; } - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)", + png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)", length + 1); 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"); return; @@ -1696,9 +1737,10 @@ endptr = png_ptr->chunkdata + slength; /* We need to have at least 12 bytes after the purpose string - in order to get the parameter information. */ + * in order to get the parameter information. + */ if (endptr <= buf + 12) { png_warning(png_ptr, "Invalid pCAL data"); png_free(png_ptr, png_ptr->chunkdata); @@ -1714,9 +1756,10 @@ units = buf + 11; png_debug(3, "Checking pCAL equation type and number of parameters"); /* Check that we have the right number of parameters for known - equation types. */ + * equation types. + */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || (type == PNG_EQUATION_BASE_E && nparams != 3) || (type == PNG_EQUATION_ARBITRARY && nparams != 3) || (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) @@ -1778,18 +1822,10 @@ /* Read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_charp ep; -#ifdef PNG_FLOATING_POINT_SUPPORTED - double width, height; - png_charp vp; -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_charp swidth, sheight; -#endif -#endif - png_size_t slength; + png_size_t slength, index; + int state; png_debug(1, "in png_handle_sCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) @@ -1806,11 +1844,12 @@ png_crc_finish(png_ptr, length); return; } - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)", + png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", length + 1); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "Out of memory while processing sCAL chunk"); png_crc_finish(png_ptr, length); @@ -1815,120 +1854,54 @@ png_warning(png_ptr, "Out of memory while processing sCAL chunk"); png_crc_finish(png_ptr, length); return; } + slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); - - if (png_crc_finish(png_ptr, 0)) - { - png_free(png_ptr, png_ptr->chunkdata); - png_ptr->chunkdata = NULL; - return; - } - png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ - ep = png_ptr->chunkdata + 1; /* Skip unit byte */ - -#ifdef PNG_FLOATING_POINT_SUPPORTED - width = png_strtod(png_ptr, ep, &vp); - if (*vp) - { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - png_free(png_ptr, png_ptr->chunkdata); - png_ptr->chunkdata = NULL; - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - png_free(png_ptr, png_ptr->chunkdata); - png_ptr->chunkdata = NULL; - return; - } - png_memcpy(swidth, ep, png_strlen(ep)); -#endif -#endif - - for (ep = png_ptr->chunkdata; *ep; ep++) - /* Empty loop */ ; - ep++; - - if (png_ptr->chunkdata + slength < ep) + if (png_crc_finish(png_ptr, 0)) { - png_warning(png_ptr, "Truncated sCAL chunk"); -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); -#endif png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } -#ifdef PNG_FLOATING_POINT_SUPPORTED - height = png_strtod(png_ptr, ep, &vp); - if (*vp) + /* Validate the unit. */ + if (png_ptr->chunkdata[0] != 1 && png_ptr->chunkdata[0] != 2) { - png_warning(png_ptr, "malformed height string in sCAL chunk"); + png_warning(png_ptr, "Invalid sCAL ignored: invalid unit"); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); -#endif - return; - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); - if (sheight == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - png_free(png_ptr, png_ptr->chunkdata); - png_ptr->chunkdata = NULL; -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); -#endif return; } - png_memcpy(sheight, ep, png_strlen(ep)); -#endif -#endif - if (png_ptr->chunkdata + slength < ep -#ifdef PNG_FLOATING_POINT_SUPPORTED - || width <= 0. || height <= 0. -#endif - ) + /* Validate the ASCII numbers, need two ASCII numbers separated by + * a '\0' and they need to fit exactly in the chunk data. + */ + index = 0; + state = 0; + if (png_ptr->chunkdata[1] == 45 /* negative width */ || + !png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || + index >= slength || png_ptr->chunkdata[index++] != 0) + png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format"); + else { - png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, png_ptr->chunkdata); - png_ptr->chunkdata = NULL; -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif - return; + png_size_t heighti = index; + if (png_ptr->chunkdata[index] == 45 /* negative height */ || + !png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || + index != slength) + png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format"); + else + /* This is the (only) success case. */ + png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], + png_ptr->chunkdata+1, png_ptr->chunkdata+heighti); } - -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight); -#endif -#endif - + /* Clean up - just free the temporarily allocated buffer. */ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; -#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); - png_free(png_ptr, sheight); -#endif } #endif #ifdef PNG_READ_tIME_SUPPORTED @@ -2056,15 +2033,14 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; -#ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; -#endif text_ptr->text = text; text_ptr->text_length = png_strlen(text); ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); @@ -2114,9 +2092,10 @@ png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ + * there is no hard and fast rule to tell us where to stop. + */ if (length > (png_uint_32)65535L) { png_warning(png_ptr, "zTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); @@ -2176,15 +2160,14 @@ png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = NULL; return; } + text_ptr->compression = comp_type; text_ptr->key = png_ptr->chunkdata; -#ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; -#endif text_ptr->text = png_ptr->chunkdata + prefix_len; text_ptr->text_length = data_len; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); @@ -2235,9 +2220,10 @@ png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K /* We will no doubt have problems with chunks even half this size, but - there is no hard and fast rule to tell us where to stop. */ + * there is no hard and fast rule to tell us where to stop. + */ if (length > (png_uint_32)65535L) { png_warning(png_ptr, "iTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); @@ -2343,12 +2341,13 @@ } #endif /* This function is called when we haven't found a handler for a - chunk. If there isn't a problem with the chunk itself (ie bad - chunk name, CRC, or a critical chunk), the chunk is silently ignored - -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which - case it will be saved away to be written out later. */ + * chunk. If there isn't a problem with the chunk itself (ie bad + * chunk name, CRC, or a critical chunk), the chunk is silently ignored + * -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which + * case it will be saved away to be written out later. + */ void /* PRIVATE */ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip = 0; @@ -2458,17 +2468,18 @@ #endif } /* This function is called to verify that a chunk name is valid. - This function can't have the "critical chunk check" incorporated - into it, since in the future we will need to be able to call user - functions to handle unknown critical chunks after we check that - the chunk name itself is valid. */ + * This function can't have the "critical chunk check" incorporated + * into it, since in the future we will need to be able to call user + * functions to handle unknown critical chunks after we check that + * the chunk name itself is valid. + */ #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) void /* PRIVATE */ -png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) +png_check_chunk_name(png_structp png_ptr, png_const_bytep chunk_name) { png_debug(1, "in png_check_chunk_name"); if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) @@ -2477,17 +2488,18 @@ } } /* Combines the row recently read in with the existing pixels in the - row. This routine takes care of alpha and transparency if requested. - This routine also handles the two methods of progressive display - of interlaced images, depending on the mask value. - The mask value describes which pixels are to be combined with - the row. The pattern always repeats every 8 pixels, so just 8 - bits are needed. A one indicates the pixel is to be combined, - a zero indicates the pixel is to be skipped. This is in addition - to any alpha or transparency value associated with the pixel. If - you want all pixels to be combined, pass 0xff (255) in mask. */ + * row. This routine takes care of alpha and transparency if requested. + * This routine also handles the two methods of progressive display + * of interlaced images, depending on the mask value. + * The mask value describes which pixels are to be combined with + * the row. The pattern always repeats every 8 pixels, so just 8 + * bits are needed. A one indicates the pixel is to be combined, + * a zero indicates the pixel is to be skipped. This is in addition + * to any alpha or transparency value associated with the pixel. If + * you want all pixels to be combined, pass 0xff (255) in mask. + */ void /* PRIVATE */ png_combine_row(png_structp png_ptr, png_bytep row, int mask) { @@ -2689,12 +2715,8 @@ } } #ifdef PNG_READ_INTERLACING_SUPPORTED -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ void /* PRIVATE */ png_do_read_interlace(png_structp png_ptr) { png_row_infop row_info = &(png_ptr->row_info); @@ -2916,12 +2955,12 @@ #endif /* PNG_READ_INTERLACING_SUPPORTED */ void /* PRIVATE */ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, - png_bytep prev_row, int filter) + png_const_bytep prev_row, int filter) { png_debug(1, "in png_read_filter_row"); - png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter); + png_debug2(2, "row = %u, filter = %d", png_ptr->row_number, filter); switch (filter) { case PNG_FILTER_VALUE_NONE: break; @@ -2944,9 +2984,9 @@ { png_uint_32 i; png_uint_32 istop = row_info->rowbytes; png_bytep rp = row; - png_bytep pp = prev_row; + png_const_bytep pp = prev_row; for (i = 0; i < istop; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); @@ -2957,9 +2997,9 @@ case PNG_FILTER_VALUE_AVG: { png_uint_32 i; png_bytep rp = row; - png_bytep pp = prev_row; + png_const_bytep pp = prev_row; png_bytep lp = row; png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; png_uint_32 istop = row_info->rowbytes - bpp; @@ -2981,11 +3021,11 @@ case PNG_FILTER_VALUE_PAETH: { png_uint_32 i; png_bytep rp = row; - png_bytep pp = prev_row; + png_const_bytep pp = prev_row; png_bytep lp = row; - png_bytep cp = prev_row; + png_const_bytep cp = prev_row; png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; png_uint_32 istop=row_info->rowbytes - bpp; for (i = 0; i < bpp; i++) @@ -3031,10 +3073,10 @@ } break; } default: - png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row = 0; + png_error(png_ptr, "Ignoring bad adaptive filter type"); + /*NOT REACHED */ break; } } @@ -3340,10 +3412,11 @@ #ifdef PNG_ALIGNED_MEMORY_SUPPORTED /* Use 16-byte aligned memory for row_buf with at least 16 bytes * of padding before and after row_buf. */ - png_ptr->row_buf = png_ptr->big_row_buf + 32 - - (((png_alloc_size_t)&(png_ptr->big_row_buf[0]) + 15) % 16); + png_ptr->row_buf = png_ptr->big_row_buf + 32 - + (((png_alloc_size_t)png_ptr->big_row_buf + 15) & 0x0F); + png_ptr->old_big_row_buf_size = row_bytes + 48; #else /* Use 32 bytes of padding before and 16 bytes after row_buf. */ png_ptr->row_buf = png_ptr->big_row_buf + 32; @@ -3367,15 +3443,64 @@ } 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); - png_debug1(3, "num_rows = %lu,", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu", + png_debug1(3, "width = %u,", png_ptr->width); + png_debug1(3, "height = %u,", png_ptr->height); + png_debug1(3, "iwidth = %u,", png_ptr->iwidth); + png_debug1(3, "num_rows = %u,", png_ptr->num_rows); + png_debug1(3, "rowbytes = %u,", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %u", PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); png_ptr->flags |= PNG_FLAG_ROW_INIT; } + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +int PNGAPI +png_get_num_passes(png_structp png_ptr) +{ + if (png_ptr != NULL) + { + if (png_ptr->interlaced) + return 7; + else + return 1; + } + + /* Here on error */ + return 0; +} + +png_uint_32 PNGAPI +png_get_num_rows(png_structp png_ptr) +{ + if (png_ptr != NULL) + { + if (png_ptr->flags & PNG_FLAG_ROW_INIT) + return png_ptr->num_rows; + else + png_error(png_ptr, "Call png_start_read_image or png_read_update_info " + "before png_get_num_rows"); + } + + /* Here on error */ + return 0; +} + +png_uint_32 PNGAPI +png_get_num_cols(png_structp png_ptr) +{ + if (png_ptr != NULL) + { + if (png_ptr->flags & PNG_FLAG_ROW_INIT) + return png_ptr->iwidth; + else + png_error(png_ptr, "Call png_start_read_image or png_read_update_info " + "before png_get_num_cols"); + } + + /* Here on error */ + return 0; +} +#endif /* SEQUENTIAL READ */ #endif /* PNG_READ_SUPPORTED */ diff -ru4NwbB libpng-1.4.3/pngset.c libpng-1.5.0beta42/pngset.c --- libpng-1.4.3/pngset.c 2010-06-25 19:32:26.103627142 -0500 +++ libpng-1.5.0beta42/pngset.c 2010-08-18 08:12:21.395293768 -0500 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -15,16 +15,16 @@ * 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_NO_PEDANTIC_WARNINGS -#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #include "pngpriv.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + #ifdef PNG_bKGD_SUPPORTED void PNGAPI -png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) +png_set_bKGD(png_structp png_ptr, png_infop info_ptr, + png_const_color_16p background) { png_debug1(1, "in %s storage function", "bKGD"); if (png_ptr == NULL || info_ptr == NULL) @@ -35,43 +35,9 @@ } #endif #ifdef PNG_cHRM_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_structp png_ptr, png_infop info_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) -{ - png_debug1(1, "in %s storage function", "cHRM"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_white = (float)white_x; - info_ptr->y_white = (float)white_y; - info_ptr->x_red = (float)red_x; - info_ptr->y_red = (float)red_y; - info_ptr->x_green = (float)green_x; - info_ptr->y_green = (float)green_y; - info_ptr->x_blue = (float)blue_x; - info_ptr->y_blue = (float)blue_y; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); - info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); - info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); - info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); - info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); - info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); - info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); - info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); -#endif - info_ptr->valid |= PNG_INFO_cHRM; -} -#endif /* PNG_FLOATING_POINT_SUPPORTED */ - -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI +void PNGFAPI png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) @@ -85,102 +51,80 @@ if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) #endif { - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif + info_ptr->x_white = white_x; + info_ptr->y_white = white_y; + info_ptr->x_red = red_x; + info_ptr->y_red = red_y; + info_ptr->x_green = green_x; + info_ptr->y_green = green_y; + info_ptr->x_blue = blue_x; + info_ptr->y_blue = blue_y; info_ptr->valid |= PNG_INFO_cHRM; } } -#endif /* PNG_FIXED_POINT_SUPPORTED */ -#endif /* PNG_cHRM_SUPPORTED */ -#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI -png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +png_set_cHRM(png_structp png_ptr, png_infop info_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) { - double png_gamma; - - png_debug1(1, "in %s storage function", "gAMA"); + png_set_cHRM_fixed(png_ptr, info_ptr, + png_fixed(png_ptr, white_x, "cHRM White X"), + png_fixed(png_ptr, white_y, "cHRM White Y"), + png_fixed(png_ptr, red_x, "cHRM Red X"), + png_fixed(png_ptr, red_y, "cHRM Red Y"), + png_fixed(png_ptr, green_x, "cHRM Green X"), + png_fixed(png_ptr, green_y, "cHRM Green Y"), + png_fixed(png_ptr, blue_x, "cHRM Blue X"), + png_fixed(png_ptr, blue_y, "cHRM Blue Y")); +} +#endif /* PNG_FLOATING_POINT_SUPPORTED */ - if (png_ptr == NULL || info_ptr == NULL) - return; +#endif /* PNG_cHRM_SUPPORTED */ - /* Check for overflow */ - if (file_gamma > 21474.83) - { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - png_gamma=21474.83; - } - else - png_gamma = file_gamma; - info_ptr->gamma = (float)png_gamma; -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(png_gamma*100000.+.5); -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if (png_gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); -} -#endif -void PNGAPI +#ifdef PNG_gAMA_SUPPORTED +void PNGFAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - int_gamma) + 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"); - png_gamma=PNG_UINT_31_MAX; - } + /* Previously these values were limited, however they must be + * wrong, therefore storing them (and setting PNG_INFO_gAMA) + * must be wrong too. + */ + if (gamma > (png_fixed_point)PNG_UINT_31_MAX) + png_warning(png_ptr, "Gamma too large, ignored"); + + else if (gamma <= 0) + png_warning(png_ptr, "Negative or zero gamma ignored"); + else { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - png_gamma = 0; + info_ptr->gamma = gamma; + info_ptr->valid |= PNG_INFO_gAMA; } - else - png_gamma = int_gamma; } + #ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(png_gamma/100000.); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = png_gamma; -#endif - info_ptr->valid |= PNG_INFO_gAMA; - if (png_gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); +void PNGAPI +png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +{ + png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, + "png_set_gAMA")); } #endif +#endif #ifdef PNG_hIST_SUPPORTED void PNGAPI -png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) +png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist) { int i; png_debug1(1, "in %s storage function", "hIST"); @@ -251,9 +201,9 @@ info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); /* Check for potential overflow */ if (width > (PNG_UINT_32_MAX - >> 3) /* 8-byte RGBA pixels */ + >> 3) /* 8-byte RRGGBBAA pixels */ - 64 /* bigrowbuf hack */ - 1 /* filter byte */ - 7*8 /* rounding of width to multiple of 8 pixels */ - 8) /* extra max_pixel_depth pad */ @@ -281,10 +231,10 @@ #ifdef PNG_pCAL_SUPPORTED void PNGAPI 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_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, + int nparams, png_const_charp units, png_charpp params) { png_size_t length; int i; @@ -295,8 +245,20 @@ length = png_strlen(purpose) + 1; png_debug1(3, "allocating purpose for info (%lu bytes)", (unsigned long)length); + + /* TODO: validate format of calibration name and unit name */ + + /* Check that the type matches the specification. */ + if (type < 0 || type > 3) + png_error(png_ptr, "Invalid pCAL equation type"); + + /* Validate params[nparams] */ + for (i=0; ipcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL purpose"); @@ -349,69 +317,123 @@ info_ptr->free_me |= PNG_FREE_PCAL; } #endif -#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED +#ifdef PNG_sCAL_SUPPORTED void PNGAPI -png_set_sCAL(png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height) +png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int unit, png_const_charp swidth, png_const_charp sheight) { + png_size_t lengthw = 0, lengthh = 0; + png_debug1(1, "in %s storage function", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; - info_ptr->scal_unit = (png_byte)unit; - info_ptr->scal_pixel_width = width; - info_ptr->scal_pixel_height = height; + /* Double check the unit (should never get here with an invalid + * unit unless this is an API call.) + */ + if (unit != 1 && unit != 2) + png_error(png_ptr, "Invalid sCAL unit"); - info_ptr->valid |= PNG_INFO_sCAL; -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, - int unit, png_charp swidth, png_charp sheight) -{ - png_size_t length; + if (swidth == NULL || (lengthw = png_strlen(swidth)) <= 0 || + swidth[0] == 45 /*'-'*/ || !png_check_fp_string(swidth, lengthw)) + png_error(png_ptr, "Invalid sCAL width"); + + if (sheight == NULL || (lengthh = png_strlen(sheight)) <= 0 || + sheight[0] == 45 /*'-'*/ || !png_check_fp_string(sheight, lengthh)) + png_error(png_ptr, "Invalid sCAL height"); - png_debug1(1, "in %s storage function", "sCAL"); + info_ptr->scal_unit = (png_byte)unit; - if (png_ptr == NULL || info_ptr == NULL) - return; + ++lengthw; - info_ptr->scal_unit = (png_byte)unit; + png_debug1(3, "allocating unit for info (%u bytes)", lengthw); + + info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw); - length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%u bytes)", - (unsigned int)length); - 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"); + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); return; } - 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); - info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); + png_memcpy(info_ptr->scal_s_width, swidth, lengthw); + + ++lengthh; + + png_debug1(3, "allocating unit for info (%u bytes)", lengthh); + + info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh); + if (info_ptr->scal_s_height == NULL) { 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"); + + png_warning(png_ptr, "Memory allocation failed while processing sCAL"); return; } - png_memcpy(info_ptr->scal_s_height, sheight, length); + + png_memcpy(info_ptr->scal_s_height, sheight, lengthh); + info_ptr->valid |= PNG_INFO_sCAL; info_ptr->free_me |= PNG_FREE_SCAL; } + +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, + double height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fp(png_ptr, swidth, sizeof swidth, width, + PNG_sCAL_PRECISION); + png_ascii_from_fp(png_ptr, sheight, sizeof sheight, height, + PNG_sCAL_PRECISION); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} #endif + +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit, + png_fixed_point width, png_fixed_point height) +{ + png_debug1(1, "in %s storage function", "sCAL"); + + /* Check the arguments. */ + if (width <= 0) + png_warning(png_ptr, "Invalid sCAL width ignored"); + else if (height <= 0) + png_warning(png_ptr, "Invalid sCAL height ignored"); + else + { + /* Convert 'width' and 'height' to ASCII. */ + char swidth[PNG_sCAL_MAX_DIGITS+1]; + char sheight[PNG_sCAL_MAX_DIGITS+1]; + + png_ascii_from_fixed(png_ptr, swidth, sizeof swidth, width); + png_ascii_from_fixed(png_ptr, sheight, sizeof sheight, height); + + png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); + } +} #endif #endif #ifdef PNG_pHYs_SUPPORTED @@ -432,9 +454,9 @@ #endif void PNGAPI png_set_PLTE(png_structp png_ptr, png_infop info_ptr, - png_colorp palette, int num_palette) + png_const_colorp palette, int num_palette) { png_debug1(1, "in %s storage function", "PLTE"); @@ -475,9 +499,9 @@ #ifdef PNG_sBIT_SUPPORTED void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, - png_color_8p sig_bit) + png_const_color_8p sig_bit) { png_debug1(1, "in %s storage function", "sBIT"); if (png_ptr == NULL || info_ptr == NULL) @@ -504,84 +528,40 @@ void PNGAPI png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, int intent) { -#ifdef PNG_gAMA_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED - float file_gamma; -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - png_fixed_point int_file_gamma; -#endif -#endif -#ifdef PNG_cHRM_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED - float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; -#endif - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y; -#endif png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; png_set_sRGB(png_ptr, info_ptr, intent); #ifdef PNG_gAMA_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED - file_gamma = (float).45455; - png_set_gAMA(png_ptr, info_ptr, file_gamma); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED - int_file_gamma = 45455L; - png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); -#endif + png_set_gAMA_fixed(png_ptr, info_ptr, 45455L); #endif #ifdef PNG_cHRM_SUPPORTED - int_white_x = 31270L; - int_white_y = 32900L; - int_red_x = 64000L; - int_red_y = 33000L; - int_green_x = 30000L; - int_green_y = 60000L; - int_blue_x = 15000L; - int_blue_y = 6000L; - -#ifdef PNG_FLOATING_POINT_SUPPORTED - white_x = (float).3127; - white_y = (float).3290; - red_x = (float).64; - red_y = (float).33; - green_x = (float).30; - green_y = (float).60; - blue_x = (float).15; - blue_y = (float).06; -#endif - -#ifdef PNG_FIXED_POINT_SUPPORTED png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, - int_green_y, int_blue_x, int_blue_y); -#endif -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); -#endif + /* color x y */ + /* white */ 31270L, 32900L, + /* red */ 64000L, 33000L, + /* green */ 30000L, 60000L, + /* blue */ 15000L, 6000L + ); #endif /* cHRM */ } #endif /* sRGB */ #ifdef PNG_iCCP_SUPPORTED void PNGAPI png_set_iCCP(png_structp png_ptr, png_infop info_ptr, - png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen) + png_const_charp name, int compression_type, + png_const_bytep profile, png_uint_32 proflen) { png_charp new_iccp_name; - png_charp new_iccp_profile; + png_bytep new_iccp_profile; png_uint_32 length; png_debug1(1, "in %s storage function", "iCCP"); @@ -595,9 +575,10 @@ 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); + new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen); + if (new_iccp_profile == NULL) { png_free (png_ptr, new_iccp_name); png_warning(png_ptr, @@ -621,9 +603,9 @@ #endif #ifdef PNG_TEXT_SUPPORTED void PNGAPI -png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, +png_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr, int num_text) { int ret; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); @@ -631,10 +614,10 @@ png_error(png_ptr, "Insufficient memory to store text"); } int /* PRIVATE */ -png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) +png_set_text_2(png_structp png_ptr, png_infop info_ptr, + png_const_textp text_ptr, int num_text) { int i; png_debug1(1, "in %s storage function", ((png_ptr == NULL || @@ -747,9 +740,9 @@ (int)textp->key); 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) { textp->lang = textp->key + key_len + 1; png_memcpy(textp->lang, text_ptr[i].lang, lang_len); @@ -758,20 +751,20 @@ png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); *(textp->lang_key + lang_key_len) = '\0'; textp->text = textp->lang_key + lang_key_len + 1; } + else -#endif { -#ifdef PNG_iTXt_SUPPORTED textp->lang=NULL; textp->lang_key=NULL; -#endif textp->text = textp->key + key_len + 1; } + if (text_length) png_memcpy(textp->text, text_ptr[i].text, (png_size_t)(text_length)); + *(textp->text + text_length) = '\0'; #ifdef PNG_iTXt_SUPPORTED if (textp->compression > 0) @@ -778,17 +771,16 @@ { textp->text_length = 0; textp->itxt_length = text_length; } + else #endif - { textp->text_length = text_length; -#ifdef PNG_iTXt_SUPPORTED textp->itxt_length = 0; -#endif } + info_ptr->num_text++; png_debug1(3, "transferred text chunk %d", info_ptr->num_text); } return(0); @@ -796,9 +788,9 @@ #endif #ifdef PNG_tIME_SUPPORTED void PNGAPI -png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) +png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time) { png_debug1(1, "in %s storage function", "tIME"); if (png_ptr == NULL || info_ptr == NULL || @@ -812,9 +804,9 @@ #ifdef PNG_tRNS_SUPPORTED void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, - png_bytep trans_alpha, int num_trans, png_color_16p trans_color) + png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) { png_debug1(1, "in %s storage function", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) @@ -829,10 +821,11 @@ png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans_alpha = info_ptr->trans_alpha = (png_bytep)png_malloc(png_ptr, - (png_size_t)PNG_MAX_PALETTE_LENGTH); + png_ptr->trans_alpha = info_ptr->trans_alpha = + (png_bytep)png_malloc(png_ptr, (png_size_t)PNG_MAX_PALETTE_LENGTH); + if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) png_memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); } @@ -864,9 +861,9 @@ #ifdef PNG_sPLT_SUPPORTED void PNGAPI png_set_sPLT(png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries) + png_infop info_ptr, png_const_sPLT_tp entries, int nentries) /* * entries - array of png_sPLT_t structures * to be added to the list of palettes * in the info structure. @@ -896,9 +895,9 @@ for (i = 0; i < nentries; i++) { png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; + png_const_sPLT_tp from = entries + i; png_uint_32 length; length = png_strlen(from->name) + 1; to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length); @@ -934,9 +938,9 @@ #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED void PNGAPI png_set_unknown_chunks(png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) + png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) { png_unknown_chunkp np; int i; @@ -960,12 +966,11 @@ for (i = 0; i < num_unknowns; i++) { png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; + png_const_unknown_chunkp from = unknowns + i; - png_memcpy((png_charp)to->name, (png_charp)from->name, - png_sizeof(from->name)); + png_memcpy(to->name, from->name, png_sizeof(from->name)); to->name[png_sizeof(to->name)-1] = '\0'; to->size = from->size; /* Note our location in the read or write sequence */ to->location = (png_byte)(png_ptr->mode & 0xff); @@ -1017,9 +1027,9 @@ #endif #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED void PNGAPI -png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep +png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks) { png_bytep new_list, p; int i, old_num_chunks; diff -ru4NwbB libpng-1.4.3/pngstruct.h libpng-1.5.0beta42/pngstruct.h --- libpng-1.4.3/pngstruct.h 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/pngstruct.h 2010-08-18 08:12:21.288611006 -0500 @@ -0,0 +1,308 @@ + +/* pngstruct.h - header file for PNG reference library + * + * Copyright (c) 1998-2010 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.) + * + * Last changed in libpng version 1.5.0 - August 11, 2010 + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* 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 + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application. + */ + +#ifndef PNGSTRUCT_H +#define PNGSTRUCT_H +/* zlib.h defines the structure z_stream, an instance of which is included + * in this structure and is required for decompressing the LZ compressed + * data in PNG files. + */ +#include "zlib.h" + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf png_jmpbuf; /* used in png_error */ + png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + 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_size_t rowbytes; /* size of 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 */ + 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 */ + 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 */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif + +#ifdef PNG_bKGD_SUPPORTED + png_byte background_gamma_type; + png_fixed_point background_gamma; + png_color_16 background; /* background color in screen gamma space */ +#ifdef PNG_READ_GAMMA_SUPPORTED + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#ifdef PNG_WRITE_FLUSH_SUPPORTED + png_flush_ptr output_flush_fn; /* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ + png_fixed_point gamma; /* file gamma value */ + png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans_alpha; /* alpha values for 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 */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# ifdef PNG_TEXT_SUPPORTED + 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_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 */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED + png_bytep palette_lookup; /* lookup table for quantizing */ + png_bytep quantize_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#ifdef PNG_TIME_RFC1123_SUPPORTED + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + +#ifdef PNG_USER_CHUNKS_SUPPORTED + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.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 */ + png_uint_32 mng_features_permitted; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#ifdef PNG_MNG_FEATURES_SUPPORTED + png_byte filter_type; +#endif + +/* New members added in libpng-1.2.0 */ + +/* 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 */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep quantize_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is + in the palette */ + png_bytep palette_to_index; /* which original index points to this + palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_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 (0 means unlimited). + */ + png_uint_32 user_chunk_cache_max; + + /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk + * can occupy when decompressed. 0 means unlimited. + */ + png_uint_32 user_chunk_malloc_max; +#endif + +/* New member added in libpng-1.0.25 and 1.2.17 */ +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED + /* Storage for unknown chunk that the library doesn't recognize. */ + png_unknown_chunk unknown_chunk; +#endif + +/* New members added in libpng-1.2.26 */ + png_uint_32 old_big_row_buf_size; + png_uint_32 old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + +#ifdef PNG_IO_STATE_SUPPORTED +/* New member added in libpng-1.4.0 */ + png_uint_32 io_state; +#endif +}; +#endif /* PNGSTRUCT_H */ diff -ru4NwbB libpng-1.4.3/pngtest.c libpng-1.5.0beta42/pngtest.c --- libpng-1.4.3/pngtest.c 2010-06-25 19:32:26.112778757 -0500 +++ libpng-1.5.0beta42/pngtest.c 2010-08-18 08:12:21.403920194 -0500 @@ -1,8 +1,8 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -30,28 +30,53 @@ * testing a wide variety of files easily. You can also test a number * of files at once by typing "pngtest -m file1.png file2.png ..." */ +#include "zlib.h" #include "png.h" -#include "pngpriv.h" - +/* Copied from pngpriv.h but only used in error messages below. */ +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif # include # include +# include # define FCLOSE(file) fclose(file) #ifndef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ +/* Makes pngtest verbose so we can find problems. */ #ifndef PNG_DEBUG # define PNG_DEBUG 0 #endif +#if PNG_DEBUG > 1 +# define pngtest_debug(m) ((void)fprintf(stderr, m "\n")) +# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1)) +# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2)) +#else +# define pngtest_debug(m) ((void)0) +# define pngtest_debug1(m,p1) ((void)0) +# define pngtest_debug2(m,p1,p2) ((void)0) +#endif + #if !PNG_DEBUG # define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */ #endif +/* The code uses memcmp and memcpy on large objects (typically row pointers) so + * it is necessary to do soemthing special on certain architectures, note that + * the actual support for this was effectively removed in 1.4, so only the + * memory remains in this program: + */ +#define CVT_PTR(ptr) (ptr) +#define CVT_PTR_NOCHECK(ptr) (ptr) +#define png_memcmp memcmp +#define png_memcpy memcpy +#define png_memset memset + /* Turn on CPU timing #define PNGTEST_TIMING */ @@ -81,13 +106,8 @@ /* Defined so I can write to a file on gui/windowing platforms */ /* #define STDERR stderr */ #define STDERR stdout /* For DOS */ -/* In case a system header (e.g., on AIX) defined jmpbuf */ -#ifdef jmpbuf -# undef jmpbuf -#endif - /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ #ifndef png_jmpbuf # define png_jmpbuf(png_ptr) png_ptr->jmpbuf #endif @@ -96,11 +116,11 @@ static int status_pass = 1; static int status_dots_requested = 0; static int status_dots = 1; -void +void PNGCBAPI read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void +void PNGCBAPI 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; @@ -115,14 +138,15 @@ { fprintf(stdout, "\n "); status_dots=30; } + fprintf(stdout, "r"); } -void +void PNGCBAPI write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass); -void +void PNGCBAPI 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; @@ -135,11 +160,11 @@ * 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 +void PNGCBAPI count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void +void PNGCBAPI 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)]; @@ -152,15 +177,16 @@ */ static png_uint_32 zero_samples; -void +void PNGCBAPI count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data); -void +void PNGCBAPI count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) { png_bytep dp = data; - if (png_ptr == NULL)return; + if (png_ptr == NULL) + return; /* Contents of row_info: * png_uint_32 width width of row * png_uint_32 rowbytes number of bytes in row @@ -263,9 +299,9 @@ * than changing the library. */ #ifndef USE_FAR_KEYWORD -static void +static void PNGCBAPI pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check = 0; png_voidp io_ptr; @@ -292,18 +328,18 @@ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) -static void +static void PNGCBAPI pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { 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); + io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr)); if ((png_bytep)n_data == data) { check = fread(n_data, 1, length, io_ptr); } @@ -332,9 +370,9 @@ } #endif /* USE_FAR_KEYWORD */ #ifdef PNG_WRITE_FLUSH_SUPPORTED -static void +static void PNGCBAPI pngtest_flush(png_structp png_ptr) { /* Do nothing; fflush() is said to be just a waste of energy. */ png_ptr = png_ptr; /* Stifle compiler warning */ @@ -346,14 +384,15 @@ * 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 +static void PNGCBAPI pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; - check = fwrite(data, 1, length, (png_FILE_p)png_ptr->io_ptr); + check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr)); + if (check != length) { png_error(png_ptr, "Write Error"); } @@ -366,18 +405,19 @@ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) -static void +static void PNGCBAPI pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { 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); + io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr)); + if ((png_bytep)near_data == data) { check = fwrite(near_data, 1, length, io_ptr); } @@ -412,9 +455,9 @@ * it can continue anyway. Replacement functions don't have to do anything * here if you don't want to. In the default configuration, png_ptr is * not used, but it is passed in case it may be useful. */ -static void +static void PNGCBAPI pngtest_warning(png_structp png_ptr, png_const_charp message) { PNG_CONST char *name = "UNKNOWN (ERROR!)"; char *test; @@ -429,9 +474,9 @@ * 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 * error function pointer in png_set_error_fn(). */ -static void +static void PNGCBAPI 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 @@ -466,14 +511,14 @@ 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_alloc_size_t size)); -void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); +png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, + png_alloc_size_t size)); +void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); png_voidp -png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) +PNGCBAPI 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 @@ -510,11 +560,13 @@ pinfo->next = pinformation; pinformation = pinfo; /* Make sure the caller isn't assuming zeroed memory. */ png_memset(pinfo->pointer, 0xdd, pinfo->size); + if (verbose) - printf("png_malloc %lu bytes at %x\n", (unsigned long)size, + printf("png_malloc %lu bytes at %p\n", (unsigned long)size, pinfo->pointer); + return (png_voidp)(pinfo->pointer); } } @@ -518,9 +570,9 @@ } } /* Free a pointer. It is removed from the list at the same time. */ -void +void PNGCBAPI png_debug_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL) fprintf(STDERR, "NULL pointer to png_debug_free.\n"); @@ -561,9 +618,10 @@ } /* Finally free the data. */ if (verbose) - printf("Freeing %x\n", ptr); + printf("Freeing %p\n", ptr); + png_free_default(png_ptr, ptr); ptr = NULL; } #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ @@ -583,9 +641,9 @@ * 2: vpAg height * 3: vpAg units */ -static int read_user_chunk_callback(png_struct *png_ptr, +static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) { png_uint_32 *my_user_chunk_data; @@ -660,9 +720,9 @@ int num_pass, pass; int bit_depth, color_type; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; + jmp_buf png_jmpbuf; #endif #endif char inbuf[256], outbuf[256]; @@ -681,14 +741,13 @@ FCLOSE(fpin); return (1); } - png_debug(0, "Allocating read and write structures"); + pngtest_debug("Allocating read and write structures"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG read_ptr = 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); + NULL, NULL, NULL, png_debug_malloc, png_debug_free); #else read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); #endif @@ -719,20 +778,20 @@ png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif #endif - png_debug(0, "Allocating read_info, write_info and end_info structures"); + pngtest_debug("Allocating read_info, write_info and end_info structures"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); #ifdef PNG_WRITE_SUPPORTED write_info_ptr = png_create_info_struct(write_ptr); write_end_info_ptr = png_create_info_struct(write_ptr); #endif #ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct"); + pngtest_debug("Setting jmpbuf for read struct"); #ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) + if (setjmp(png_jmpbuf)) #else if (setjmp(png_jmpbuf(read_ptr))) #endif { @@ -748,15 +807,16 @@ FCLOSE(fpout); return (1); } #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr), jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(read_ptr), png_jmpbuf, png_sizeof(jmp_buf)); #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct"); + pngtest_debug("Setting jmpbuf for write struct"); #ifdef USE_FAR_KEYWORD - if (setjmp(jmpbuf)) + + if (setjmp(png_jmpbuf)) #else if (setjmp(png_jmpbuf(write_ptr))) #endif { @@ -769,15 +829,16 @@ FCLOSE(fpin); FCLOSE(fpout); return (1); } + #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr), jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(write_ptr), png_jmpbuf, png_sizeof(jmp_buf)); #endif #endif #endif - png_debug(0, "Initializing input and output streams"); + pngtest_debug("Initializing input and output streams"); #ifdef PNG_STDIO_SUPPORTED png_init_io(read_ptr, fpin); # ifdef PNG_WRITE_SUPPORTED png_init_io(write_ptr, fpout); @@ -835,12 +900,12 @@ png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, NULL, 0); #endif - png_debug(0, "Reading info struct"); + pngtest_debug("Reading info struct"); png_read_info(read_ptr, read_info_ptr); - png_debug(0, "Transferring info struct"); + pngtest_debug("Transferring info struct"); { int interlace_type, compression_type, filter_type; if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, @@ -901,9 +968,9 @@ #endif /* Fixed point */ #ifdef PNG_iCCP_SUPPORTED { png_charp name; - png_charp profile; + png_bytep profile; png_uint_32 proflen; int compression_type; if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, @@ -1025,9 +1092,9 @@ int num_text; if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); + pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); } } #endif @@ -1095,9 +1164,9 @@ } #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Writing info struct"); + pngtest_debug("Writing info struct"); /* If we wanted, we could write info in two steps: * png_write_info_before_PLTE(write_ptr, write_info_ptr); */ @@ -1138,14 +1210,15 @@ #endif #endif #ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "Allocating row buffer..."); + pngtest_debug("Allocating row buffer..."); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx", (unsigned long)row_buf); + + pngtest_debug1("\t0x%08lx", (unsigned long)row_buf); #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data"); + pngtest_debug("Writing row data"); #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) num_pass = png_set_interlace_handling(read_ptr); @@ -1162,17 +1235,19 @@ t_start = t_stop; #endif for (pass = 0; pass < num_pass; pass++) { - png_debug1(0, "Writing row data for pass %d", pass); + pngtest_debug1("Writing row data for pass %d", pass); for (y = 0; y < height; y++) { #ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Allocating row buffer (pass %d, y = %ld)...", pass, y); + pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf, + + pngtest_debug2("\t0x%08lx (%u 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, NULL, 1); #ifdef PNG_WRITE_SUPPORTED @@ -1189,9 +1264,9 @@ #endif #endif /* PNG_WRITE_SUPPORTED */ #ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y); + pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y); png_free(read_ptr, row_buf); row_buf = NULL; #endif /* !SINGLE_ROWBUF_ALLOC */ } @@ -1203,9 +1278,9 @@ #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); #endif - png_debug(0, "Reading and writing end_info data"); + pngtest_debug("Reading and writing end_info data"); png_read_end(read_ptr, end_info_ptr); #ifdef PNG_TEXT_SUPPORTED { @@ -1213,9 +1288,9 @@ int num_text; if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); + pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); } } #endif @@ -1274,28 +1352,28 @@ (unsigned long)iwidth, (unsigned long)iheight); } #endif - png_debug(0, "Destroying data structs"); + pngtest_debug("Destroying data structs"); #ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr"); + pngtest_debug("destroying row_buf for read_ptr"); png_free(read_ptr, row_buf); row_buf = NULL; #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr"); + pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr"); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr"); + pngtest_debug("destroying write_end_info_ptr"); png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr"); + pngtest_debug("destroying write_ptr, write_info_ptr"); png_destroy_write_struct(&write_ptr, &write_info_ptr); #endif - png_debug(0, "Destruction complete."); + pngtest_debug("Destruction complete."); FCLOSE(fpin); FCLOSE(fpout); - png_debug(0, "Opening files for comparison"); + pngtest_debug("Opening files for comparison"); if ((fpin = fopen(inname, "rb")) == NULL) { fprintf(STDERR, "Could not find file %s\n", inname); return (1); @@ -1387,13 +1469,12 @@ /* Show the version of libpng used in building the library */ fprintf(STDERR, " library (%lu):%s", (unsigned long)png_access_version_number(), png_get_header_version(NULL)); + /* Show the version of libpng used in building the application */ fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, PNG_HEADER_VERSION_STRING); - 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 @@ -1536,13 +1625,19 @@ int kerror; #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG int allocation_now = current_allocation; #endif - if (i == 1) status_dots_requested = 1; - else if (verbose == 0)status_dots_requested = 0; + if (i == 1) + status_dots_requested = 1; + + else if (verbose == 0) + status_dots_requested = 0; + if (i == 0 || verbose == 1 || ierror != 0) fprintf(STDERR, "\n Testing %s:", inname); + kerror = test_one_file(inname, outname); + if (kerror == 0) { if (verbose == 1 || i == 2) { diff -ru4NwbB libpng-1.4.3/pngtrans.c libpng-1.5.0beta42/pngtrans.c --- libpng-1.4.3/pngtrans.c 2010-06-25 19:32:26.119519791 -0500 +++ libpng-1.5.0beta42/pngtrans.c 2010-08-18 08:12:21.410558942 -0500 @@ -1,8 +1,8 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.4.2 [April 29, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,13 +10,12 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #include "pngpriv.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Turn on BGR-to-RGB mapping */ void PNGAPI png_set_bgr(png_structp png_ptr) @@ -75,9 +78,9 @@ #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) void PNGAPI -png_set_shift(png_structp png_ptr, png_color_8p true_bits) +png_set_shift(png_structp png_ptr, png_const_color_8p true_bits) { png_debug(1, "in png_set_shift"); if (png_ptr == NULL) @@ -134,9 +141,9 @@ png_ptr->usr_channels = 4; } /* Also I added this in libpng-1.0.2a (what happens when we expand - * a less-than-8-bit grayscale to GA? */ + * a less-than-8-bit grayscale to GA?) */ if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) { png_ptr->usr_channels = 2; @@ -251,10 +264,9 @@ png_do_swap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_swap"); - if ( - row_info->bit_depth == 16) + if (row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; png_uint_32 istop= row_info->width * row_info->channels; @@ -380,21 +392,24 @@ png_do_packswap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_packswap"); - if ( - row_info->bit_depth < 8) + if (row_info->bit_depth < 8) { - png_bytep rp, end, table; + png_bytep rp; + png_const_bytep end, table; end = row + row_info->rowbytes; if (row_info->bit_depth == 1) - table = (png_bytep)onebppswaptable; + table = onebppswaptable; + else if (row_info->bit_depth == 2) - table = (png_bytep)twobppswaptable; + table = twobppswaptable; + else if (row_info->bit_depth == 4) - table = (png_bytep)fourbppswaptable; + table = fourbppswaptable; + else return; for (rp = row; rp < end; rp++) @@ -504,20 +524,21 @@ row_info->channels == 2) { if (row_info->bit_depth == 8) { - /* This converts from GX or GA to G */ if (flags & PNG_FLAG_FILLER_AFTER) { + /* This converts from GX or GA to G */ for (i = 0; i < row_width; i++) { *dp++ = *sp++; sp++; } } - /* This converts from XG or AG to G */ + else { + /* This converts from XG or AG to G */ for (i = 0; i < row_width; i++) { sp++; *dp++ = *sp++; @@ -566,10 +592,9 @@ png_do_bgr(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_bgr"); - if ( - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) { diff -ru4NwbB libpng-1.4.3/pngvalid.c libpng-1.5.0beta42/pngvalid.c --- libpng-1.4.3/pngvalid.c 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/pngvalid.c 2010-08-18 08:12:21.420488003 -0500 @@ -0,0 +1,2121 @@ + +/* pngvalid.c - validate libpng by constructing then reading png files. + * + * Last changed in libpng 1.5.0 [July 5, 2010] + * Copyright (c) 2010-2010 Glenn Randers-Pehrson + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * NOTES: + * This is a C program that is intended to be linked against libpng. It + * generates bitmaps internally, stores them as PNG files (using the + * sequential write code) then reads them back (using the sequential + * read code) and validates that the result has the correct data. + * + * The program can be modified and extended to test the correctness of + * transformations performed by libpng. + */ + +#include "png.h" +#include "zlib.h" /* For crc32 */ + +#include /* For malloc */ +#include /* For memcpy, memset */ +#include /* For jmp_buf, setjmp, longjmp */ +#include /* For floor */ + +/* Unused formal parameter errors are removed using the following macro which is + * expected to have no bad effects on performance. + */ +#ifndef UNUSED +#define UNUSED(param) param = param; +#endif + +/******************************* ERROR UTILITIES ******************************/ +static size_t safecat(char *buffer, size_t bufsize, size_t pos, + PNG_CONST char *cat) +{ + while (pos < bufsize && cat != NULL && *cat != 0) buffer[pos++] = *cat++; + if (pos >= bufsize) pos = bufsize-1; + buffer[pos] = 0; + return pos; +} + +static size_t safecatn(char *buffer, size_t bufsize, size_t pos, int n) +{ + char number[64]; + sprintf(number, "%d", n); + return safecat(buffer, bufsize, pos, number); +} + +static size_t safecatd(char *buffer, size_t bufsize, size_t pos, double d, + int precision) +{ + char number[64]; + sprintf(number, "%.*f", precision, d); + return safecat(buffer, bufsize, pos, number); +} + +static PNG_CONST char invalid[] = "invalid"; +static PNG_CONST char sep[] = ": "; + +/* NOTE: this is indexed by ln2(bit_depth)! */ +static PNG_CONST char *bit_depths[8] = +{ + "1", "2", "4", "8", "16", invalid, invalid, invalid +}; + +static PNG_CONST char *colour_types[8] = +{ + "greyscale", invalid, "truecolour", "indexed-colour", + "greyscale with alpha", invalid, "truecolour with alpha", invalid +}; + +/* Convenience API to list valid formats: */ +static int +next_format(png_bytep colour_type, png_bytep bit_depth) +{ + if (*bit_depth == 0) + { + *colour_type = 0, *bit_depth = 1; + return 1; + } + else switch (*colour_type) + { + case 0: + *bit_depth <<= 1; + if (*bit_depth <= 16) return 1; + *colour_type = 2; + *bit_depth = 8; + return 1; + case 2: + *bit_depth <<= 1; + if (*bit_depth <= 16) return 1; + *colour_type = 3; + *bit_depth = 1; + return 1; + case 3: + *bit_depth <<= 1; + if (*bit_depth <= 8) return 1; + *colour_type = 4; + *bit_depth = 8; + return 1; + case 4: + *bit_depth <<= 1; + if (*bit_depth <= 16) return 1; + *colour_type = 6; + *bit_depth = 8; + return 1; + case 6: + *bit_depth <<= 1; + if (*bit_depth <= 16) return 1; + break; + } + + /* Here at the end. */ + return 0; +} + +static unsigned int +sample(png_byte *row, png_byte colour_type, png_byte bit_depth, png_uint_32 x, + unsigned int sample) +{ + png_uint_32 index, result; + + /* Find a sample index for the desired sample: */ + x *= bit_depth; + index = x; + if ((colour_type & 1) == 0) /* !palette */ + { + if (colour_type & 2) + index *= 3, index += sample; /* Colour channels; select one */ + if (colour_type & 4) index += x; /* Alpha channel */ + } + + /* Return the sample from the row as an integer. */ + row += index >> 3; + result = *row; + if (bit_depth == 8) + return result; + else if (bit_depth > 8) + return (result << 8) + *++row; + /* Less than 8 bits per sample. */ + index &= 7; + return (result >> (8-index-bit_depth)) & ((1U<verbose = 0; + ps->nerrors = ps->nwarnings = 0; + ps->treat_warnings_as_errors = 0; + ps->pread = NULL; + ps->piread = NULL; + ps->saved = ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; + ps->pwrite = NULL; + ps->piwrite = NULL; + ps->writepos = 0; + ps->new.prev = NULL; +} + +static void +store_freebuffer(png_store_buffer* psb) +{ + if (psb->prev) + { + store_freebuffer(psb->prev); + free(psb->prev); + psb->prev = NULL; + } +} + +static void +store_freenew(png_store *ps) +{ + store_freebuffer(&ps->new); + ps->writepos = 0; +} + +static void +store_storenew(png_store *ps) +{ + png_store_buffer *pb; + if (ps->writepos != STORE_BUFFER_SIZE) + png_error(ps->pwrite, "invalid store call"); + pb = malloc(sizeof *pb); + if (pb == NULL) + png_error(ps->pwrite, "store new: OOM"); + *pb = ps->new; + ps->new.prev = pb; + ps->writepos = 0; +} + +/* Currently unused: */ +#if 0 +static void +store_freefile(png_store_file *pf) +{ + if (pf->next) + store_freefile(pf->next); + pf->next = NULL; + store_freebuffer(&pf->data); + pf->datacount = 0; + free(pf); +} +#endif + +/* Main interface to file storeage, after writing a new PNG file (see the API + * below) call store_storefile to store the result with the given name and id. + */ +static void +store_storefile(png_store *ps, png_uint_32 id) +{ + png_store_file *pf = malloc(sizeof *pf); + if (pf == NULL) + png_error(ps->pwrite, "storefile: OOM"); + safecat(pf->name, sizeof pf->name, 0, ps->wname); + pf->id = id; + pf->data = ps->new; + pf->datacount = ps->writepos; + ps->new.prev = NULL; + ps->writepos = 0; + + /* And save it. */ + pf->next = ps->saved; + ps->saved = pf; +} + +/* Generate an error message (in the given buffer) */ +static size_t +store_message(png_structp pp, char *buffer, size_t bufsize, PNG_CONST char *msg) +{ + size_t pos = 0; + png_store *ps = png_get_error_ptr(pp); + + if (pp == ps->pread) + { + /* Reading a file */ + pos = safecat(buffer, bufsize, pos, "read: "); + if (ps->current != NULL) + { + pos = safecat(buffer, bufsize, pos, ps->current->name); + pos = safecat(buffer, bufsize, pos, sep); + } + } + else if (pp == ps->pwrite) + { + /* Writing a file */ + pos = safecat(buffer, bufsize, pos, "write: "); + pos = safecat(buffer, bufsize, pos, ps->wname); + } + else + { + /* Neither reading nor writing */ + pos = safecat(buffer, bufsize, pos, "pngvalid: "); + } + + pos = safecat(buffer, bufsize, pos, ps->test); + pos = safecat(buffer, bufsize, pos, " "); + pos = safecat(buffer, bufsize, pos, msg); + return pos; +} + +/* Functions to use as PNG callbacks. */ +static void +store_error(png_structp pp, png_const_charp message) /* PNG_NORETURN */ +{ + png_store *ps = png_get_error_ptr(pp); + char buffer[256]; + + store_message(pp, buffer, sizeof buffer, message); + + if (ps->nerrors++ == 0) + safecat(ps->error, sizeof ps->error, 0, buffer); + + if (ps->verbose) + fprintf(stderr, "error: %s\n", buffer); + + /* The longjmp argument is because, by UTSL, libpng calls longjmp with 1, and + * libpng is *not* expected to ever call longjmp, so this is a sanity + * check. The code below ensures that libpng gets a copy of our jmp_buf. + */ + longjmp(ps->jmpbuf, STORE_ERROR); +} + +static void +store_warning(png_structp pp, png_const_charp message) +{ + png_store *ps = png_get_error_ptr(pp); + char buffer[256]; + + store_message(pp, buffer, sizeof buffer, message); + + if (ps->nwarnings++ == 0 && ps->nerrors == 0) + safecat(ps->error, sizeof ps->error, 0, buffer); + + if (ps->verbose) + fprintf(stderr, "warning: %s\n", buffer); +} + +static void +store_write(png_structp pp, png_bytep pb, png_size_t st) +{ + png_store *ps = png_get_io_ptr(pp); + if (ps->pwrite != pp) + png_error(pp, "store state damaged"); + while (st > 0) + { + size_t cb; + + if (ps->writepos >= STORE_BUFFER_SIZE) + store_storenew(ps); + + cb = st; + if (cb > STORE_BUFFER_SIZE - ps->writepos) + cb = STORE_BUFFER_SIZE - ps->writepos; + memcpy(ps->new.buffer + ps->writepos, pb, cb); + pb += cb; + st -= cb; + ps->writepos += cb; + } +} + +static void +store_flush(png_structp pp) +{ + pp = pp; + /*DOES NOTHING*/ +} + +static size_t +store_read_buffer_size(png_store *ps) +{ + /* Return the bytes available for read in the current buffer. */ + if (ps->next != &ps->current->data) + return STORE_BUFFER_SIZE; + + return ps->current->datacount; +} + +static int +store_read_buffer_next(png_store *ps) +{ + png_store_buffer *pbOld = ps->next; + png_store_buffer *pbNew = &ps->current->data; + if (pbOld != pbNew) + { + while (pbNew != NULL && pbNew->prev != pbOld) + pbNew = pbNew->prev; + if (pbNew != NULL) + { + ps->next = pbNew; + ps->readpos = 0; + return 1; + } + + png_error(ps->pread, "buffer lost"); + } + + return 0; /* EOF or error */ +} + +static void +store_read(png_structp pp, png_bytep pb, png_size_t st) +{ + png_store *ps = png_get_io_ptr(pp); + if (ps->pread != pp || ps->current == NULL || ps->next == NULL) + png_error(pp, "store state damaged"); + while (st > 0) + { + size_t cbAvail = store_read_buffer_size(ps) - ps->readpos; + + if (cbAvail > 0) + { + if (cbAvail > st) cbAvail = st; + memcpy(pb, ps->next->buffer + ps->readpos, cbAvail); + st -= cbAvail; + pb += cbAvail; + ps->readpos += cbAvail; + } + else if (!store_read_buffer_next(ps)) + png_error(pp, "read beyond end of file"); + } +} + +/* Setup functions. */ +/* Cleanup when aborting a write or after storing the new file. */ +static void +store_write_reset(png_store *ps) +{ + if (ps->pwrite != NULL) + { + png_destroy_write_struct(&ps->pwrite, &ps->piwrite); + ps->pwrite = NULL; + ps->piwrite = NULL; + } + + store_freenew(ps); +} + +/* The following is the main write function, it returns a png_struct and, + * optionally, a png)info suitable for writiing a new PNG file. Use + * store_storefile above to record this file after it has been written. The + * returned libpng structures as destroyed by store_write_reset above. + */ +static png_structp +set_store_for_write(png_store *ps, png_infopp ppi, + PNG_CONST char * volatile name) +{ + if (setjmp(ps->jmpbuf) != 0) + return NULL; + + if (ps->pwrite != NULL) + png_error(ps->pwrite, "store already in use"); + + store_write_reset(ps); + safecat(ps->wname, sizeof ps->wname, 0, name); + + ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING, ps, store_error, + store_warning); + png_set_write_fn(ps->pwrite, ps, store_write, store_flush); + + if (ppi != NULL) + *ppi = ps->piwrite = png_create_info_struct(ps->pwrite); + + return ps->pwrite; +} + +/* Cleanup when finished reading (either due to error or in the success case. ) + */ +static void +store_read_reset(png_store *ps) +{ + if (ps->pread != NULL) + { + png_destroy_read_struct(&ps->pread, &ps->piread, NULL); + ps->pread = NULL; + ps->piread = NULL; + } + + ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; +} + +static void +store_read_set(png_store *ps, png_uint_32 id) +{ + png_store_file *pf = ps->saved; + + while (pf != NULL) + { + if (pf->id == id) + { + ps->current = pf; + ps->next = NULL; + store_read_buffer_next(ps); + return; + } + + pf = pf->next; + } + + png_error(ps->pread, "unable to find file to read"); +} + +/* The main interface for reading a saved file - pass the id number of the file + * to retrieve. Ids must be unique or the earlier file will be hidden. The API + * returns a png_struct and, optionally, a png_info. Both of these will be + * destroyed by store_read_reset above. + */ +static png_structp +set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id, + PNG_CONST char *name) +{ + safecat(ps->test, sizeof ps->test, 0, name); + + if (setjmp(ps->jmpbuf) != 0) + return NULL; + + if (ps->pread != NULL) + png_error(ps->pread, "store already in use"); + + store_read_reset(ps); + + ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error, + store_warning); + store_read_set(ps, id); + png_set_read_fn(ps->pread, ps, store_read); + + if (ppi != NULL) + *ppi = ps->piread = png_create_info_struct(ps->pread); + + return ps->pread; +} + +/*********************** PNG FILE MODIFICATION ON READ ************************/ +/* Files may be modified on read. The following structure contains a complete + * png_store together with extra members to handle modification and a special + * read callback for libpng. To use this the 'modifications' field must be set + * to a list of png_modification structures that actually perform the + * modification, otherwise a png_modifier is functionally equivalent to a + * png_store. There is a special read function, set_modifier_for_read, which + * replaces set_store_for_read. + */ +typedef struct png_modifier +{ + png_store this; /* I am a png_store */ + struct png_modification *modifications; /* Changes to make */ + enum modifier_state + { + modifier_start, /* Initial value */ + modifier_signature, /* Have a signature */ + modifier_IHDR /* Have an IHDR */ + } state; /* My state */ + + /* Information from IHDR: */ + png_byte bit_depth; /* From IHDR */ + png_byte colour_type; /* From IHDR */ + + /* While handling PLTE, IDAT and IEND these chunks may be pended to allow + * other chunks to be inserted. + */ + png_uint_32 pending_len; + png_uint_32 pending_chunk; + + /* Test values */ + double *gammas; + unsigned int ngammas; + + /* Lowest sbit to test (libpng fails for sbit < 8) */ + png_byte sbitlow; + + /* Error control - these are the limits on errors accepted by the gamma tests + * below. + */ + double maxout8; /* Maximum output value error */ + double maxabs8; /* Absolute sample error 0..1 */ + double maxpc8; /* Percentage sample error 0..100% */ + double maxout16; /* Maximum output value error */ + double maxabs16; /* Absolute sample error 0..1 */ + double maxpc16; /* Percentage sample error 0..100% */ + + /* Logged 8 and 16 bit errors ('output' values): */ + double error_gray_2; + double error_gray_4; + double error_gray_8; + double error_gray_16; + double error_color_8; + double error_color_16; + + /* Flags: */ + /* When to use the use_input_precision option: */ + unsigned int use_input_precision :1; + unsigned int use_input_precision_sbit :1; + unsigned int use_input_precision_16to8 :1; + unsigned int log :1; /* Log max error */ + + /* Buffer information, the buffer size limits the size of the chunks that can + * be modified - they must fit (including header and CRC) into the buffer! + */ + size_t flush; /* Count of bytes to flush */ + size_t buffer_count; /* Bytes in buffer */ + size_t buffer_position; /* Position in buffer */ + png_byte buffer[1024]; +} png_modifier; + +static double abserr(png_modifier *pm, png_byte bit_depth) +{ + return bit_depth == 16 ? pm->maxabs16 : pm->maxabs8; +} + +static double pcerr(png_modifier *pm, png_byte bit_depth) +{ + return (bit_depth == 16 ? pm->maxpc16 : pm->maxpc8) * .01; +} + +static double outerr(png_modifier *pm, png_byte bit_depth) +{ + /* There is a serious error in the 2 and 4 bit grayscale transform because + * the gamma table value (8 bits) is simply shifted, not rouned, so the + * error in 4 bit greyscale gamma is up to the value below. This is a hack + * to allow pngvalid to succeed: + */ + if (bit_depth == 2) return .73182-.5; + if (bit_depth == 4) return .90644-.5; + if (bit_depth == 16) return pm->maxout16; + return pm->maxout8; +} + +/* This returns true if the test should be stopped now because it has already + * failed and it is running silently. + */ +static int fail(png_modifier *pm) +{ + return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 || + (pm->this.treat_warnings_as_errors && pm->this.nwarnings > 0)); +} + +static void +modifier_init(png_modifier *pm) +{ + memset(pm, 0, sizeof *pm); + store_init(&pm->this); + pm->modifications = NULL; + pm->state = modifier_start; + pm->sbitlow = 1U; + pm->maxout8 = pm->maxpc8 = pm->maxabs8 = 0; + pm->maxout16 = pm->maxpc16 = pm->maxabs16 = 0; + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0; + pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0; + pm->use_input_precision = 0; + pm->use_input_precision_sbit = 0; + pm->use_input_precision_16to8 = 0; + pm->log = 0; + + /* Rely on the memset for all the other fields - there are no pointers */ +} + +/* One modification strucutre must be provided for each chunk to be modified (in + * fact more than one can be provided if multiple separate changes are desired + * for a single chunk.) Modifications include adding a new chunk when a + * suitable chunk does not exist. + * + * The caller of modify_fn will reset the CRC of the chunk and record 'modified' + * or 'added' as appropriate if the modify_fn returns 1 (true). If the + * modify_fn is NULL the chunk is simply removed. + */ +typedef struct png_modification +{ + struct png_modification *next; + png_uint_32 chunk; + /* If the following is NULL all matching chunks will be removed: */ + int (*modify_fn)(png_structp pp, struct png_modifier *pm, + struct png_modification *me, int add); + /* If the following is set to PLTE, IDAT or IEND and the chunk has not been + * found and modified (and there is a modify_fn) the modify_fn will be called + * to add the chunk before the relevant chunk. + */ + png_uint_32 add; + int modified :1; /* Chunk was modified */ + int added :1; /* Chunk was added */ + int removed :1; /* Chunk was removed */ +} png_modification; + +static void modification_reset(png_modification *pmm) +{ + if (pmm != NULL) + { + pmm->modified = 0; + pmm->added = 0; + pmm->removed = 0; + modification_reset(pmm->next); + } +} + +static void +modification_init(png_modification *pmm) +{ + memset(pmm, 0, sizeof *pmm); + pmm->next = NULL; + pmm->chunk = 0; + pmm->modify_fn = NULL; + pmm->add = 0; + modification_reset(pmm); +} + +static void +modifier_reset(png_modifier *pm) +{ + store_read_reset(&pm->this); + pm->modifications = NULL; + pm->state = modifier_start; + pm->bit_depth = pm->colour_type = 0; + pm->pending_len = pm->pending_chunk = 0; + pm->flush = pm->buffer_count = pm->buffer_position = 0; +} + +/* Convenience macros. */ +#define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) +#define CHUNK_IHDR CHUNK(73,72,68,82) +#define CHUNK_PLTE CHUNK(80,76,84,69) +#define CHUNK_IDAT CHUNK(73,68,65,84) +#define CHUNK_IEND CHUNK(73,69,78,68) +#define CHUNK_cHRM CHUNK(99,72,82,77) +#define CHUNK_gAMA CHUNK(103,65,77,65) +#define CHUNK_sBIT CHUNK(115,66,73,84) +#define CHUNK_sRGB CHUNK(115,82,71,66) + +/* The guts of modification are performed during a read. */ +static void +modifier_crc(png_bytep buffer) +{ + /* Recalculate the chunk CRC - a complete chunk must be in + * the buffer, at the start. + */ + uInt datalen = png_get_uint_32(buffer); + png_save_uint_32(buffer+datalen+8, crc32(0L, buffer+4, datalen+4)); +} + +static void +modifier_setbuffer(png_modifier *pm) +{ + modifier_crc(pm->buffer); + pm->buffer_count = png_get_uint_32(pm->buffer)+12; + pm->buffer_position = 0; +} + +static void +modifier_read(png_structp pp, png_bytep pb, png_size_t st) +{ + png_modifier *pm = png_get_io_ptr(pp); + + while (st > 0) + { + size_t cb; + png_uint_32 len, chunk; + png_modification *mod; + + if (pm->buffer_position >= pm->buffer_count) switch (pm->state) + { + static png_byte sign[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; + case modifier_start: + store_read(pp, pm->buffer, 8); /* size of signature. */ + pm->buffer_count = 8; + pm->buffer_position = 0; + + if (memcmp(pm->buffer, sign, 8) != 0) + png_error(pp, "invalid PNG file signature"); + pm->state = modifier_signature; + break; + + case modifier_signature: + store_read(pp, pm->buffer, 13+12); /* size of IHDR */ + pm->buffer_count = 13+12; + pm->buffer_position = 0; + + if (png_get_uint_32(pm->buffer) != 13 || + png_get_uint_32(pm->buffer+4) != CHUNK_IHDR) + png_error(pp, "invalid IHDR"); + + /* Check the list of modifiers for modifications to the IHDR. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == CHUNK_IHDR && mod->modify_fn && + (*mod->modify_fn)(pp, pm, mod, 0)) + { + mod->modified = 1; + modifier_setbuffer(pm); + } + + /* Ignore removal or add if IHDR! */ + mod = mod->next; + } + + /* Cache information from the IHDR (the modified one.) */ + pm->bit_depth = pm->buffer[8+8]; + pm->colour_type = pm->buffer[8+8+1]; + + pm->state = modifier_IHDR; + pm->flush = 0; + break; + + case modifier_IHDR: + default: + /* Read a new chunk and process it until we see PLTE, IDAT or + * IEND. 'flush' indicates that there is still some data to + * output from the preceding chunk. + */ + if ((cb = pm->flush) > 0) + { + if (cb > st) cb = st; + pm->flush -= cb; + store_read(pp, pb, cb); + pb += cb; + st -= cb; + if (st <= 0) return; + } + + /* No more bytes to flush, read a header, or handle a pending + * chunk. + */ + if (pm->pending_chunk != 0) + { + png_save_uint_32(pm->buffer, pm->pending_len); + png_save_uint_32(pm->buffer+4, pm->pending_chunk); + pm->pending_len = 0; + pm->pending_chunk = 0; + } + else + store_read(pp, pm->buffer, 8); + + pm->buffer_count = 8; + pm->buffer_position = 0; + + /* Check for something to modify or a terminator chunk. */ + len = png_get_uint_32(pm->buffer); + chunk = png_get_uint_32(pm->buffer+4); + + /* Terminators first, they may have to be delayed for added + * chunks + */ + if (chunk == CHUNK_PLTE || chunk == CHUNK_IDAT || chunk == CHUNK_IEND) + { + mod = pm->modifications; + + while (mod != NULL) + { + if ((mod->add == chunk || + (mod->add == CHUNK_PLTE && chunk == CHUNK_IDAT)) && + mod->modify_fn != NULL && !mod->modified && !mod->added) + { + /* Regardless of what the modify function does do not run this + * again. + */ + mod->added = 1; + + if ((*mod->modify_fn)(pp, pm, mod, 1/*add*/)) + { + /* Reset the CRC on a new chunk */ + if (pm->buffer_count > 0) + modifier_setbuffer(pm); + else + { + pm->buffer_position = 0; + mod->removed = 1; + } + + /* The buffer has been filled with something (we assume) so + * output this. Pend the current chunk. + */ + pm->pending_len = len; + pm->pending_chunk = chunk; + break; /* out of while */ + } + } + + mod = mod->next; + } + + /* Don't do any further processing if the buffer was modified - + * otherwise the code will end up modifying a chunk that was just + * added. + */ + if (mod != NULL) + break; /* out of switch */ + } + + /* If we get to here then this chunk may need to be modified. To do + * this is must be less than 1024 bytes in total size, otherwise + * it just gets flushed. + */ + if (len+12 <= sizeof pm->buffer) + { + store_read(pp, pm->buffer+pm->buffer_count, + len+12-pm->buffer_count); + pm->buffer_count = len+12; + + /* Check for a modification, else leave it be. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == chunk) + { + if (mod->modify_fn == NULL) + { + /* Remove this chunk */ + pm->buffer_count = pm->buffer_position = 0; + mod->removed = 1; + break; /* Terminate the while loop */ + } + else if ((*mod->modify_fn)(pp, pm, mod, 0)) + { + mod->modified = 1; + /* The chunk may have been removed: */ + if (pm->buffer_count == 0) + { + pm->buffer_position = 0; + break; + } + modifier_setbuffer(pm); + } + } + + mod = mod->next; + } + } + else + pm->flush = len+12 - pm->buffer_count; /* data + crc */ + + /* Take the data from the buffer (if there is any). */ + break; + } + + /* Here to read from the modifier buffer (not directly from + * the store, as in the flush case above.) + */ + cb = pm->buffer_count - pm->buffer_position; + if (cb > st) cb = st; + memcpy(pb, pm->buffer + pm->buffer_position, cb); + st -= cb; + pb += cb; + pm->buffer_position += cb; + } +} + +/* Set up a modifier. */ +static png_structp +set_modifier_for_read(png_modifier *pm, png_infopp ppi, png_uint_32 id, + PNG_CONST char *name) +{ + volatile png_structp ppSafe = set_store_for_read(&pm->this, ppi, id, name); + + if (ppSafe != NULL) + { + if (setjmp(pm->this.jmpbuf) == 0) + { + png_set_read_fn(ppSafe, pm, modifier_read); + + pm->state = modifier_start; + pm->bit_depth = 0; + pm->colour_type = 255; + + pm->pending_len = 0; + pm->pending_chunk = 0; + pm->flush = 0; + pm->buffer_count = 0; + pm->buffer_position = 0; + } + else + { + store_read_reset(&pm->this); + ppSafe = NULL; + } + } + + return ppSafe; +} + +/***************************** STANDARD PNG FILES *****************************/ +/* Standard files - write and save standard files. */ +/* The standard files are constructed with rows which fit into a 1024 byte row + * buffer. This makes allocation easier below. Further regardless of the file + * format every file has 128 pixels (giving 1024 bytes for 64bpp formats). + * + * Files are stored with no gAMA or sBIT chunks, with a PLTE only when needed + * and with an ID derived from the colour type and bit depth as follows: + */ +#define FILEID(col, depth) ((png_uint_32)((col) + ((depth)<<3))) +#define COL_FROM_ID(id) ((id)& 0x7U) +#define DEPTH_FROM_ID(id) (((id) >> 3) & 0x1fU) + +#define STD_WIDTH 128U +#define STD_ROWMAX (STD_WIDTH*8U) + +static unsigned int +bit_size(png_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (colour_type) + { + case 0: return bit_depth; + case 2: return 3*bit_depth; + case 3: return bit_depth; + case 4: return 2*bit_depth; + case 6: return 4*bit_depth; + default: png_error(pp, "invalid color type"); + } +} + +static size_t +standard_rowsize(png_structp pp, png_byte colour_type, png_byte bit_depth) +{ + return (STD_WIDTH * bit_size(pp, colour_type, bit_depth)) / 8; +} + +/* standard_wdith(pp, colour_type, bit_depth) current returns the same number + * every time, so just use a macro: + */ +#define standard_width(pp, colour_type, bit_depth) STD_WIDTH + +static png_uint_32 +standard_height(png_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + case 2: + case 4: + default: + return 1; /* Total of 128 pixels */ + case 8: + return 2; /* Total of 256 pixels/bytes */ + case 16: + return 512; /* Total of 65536 pixels */ + case 24: + case 32: + return 512; /* 65536 pixels */ + case 48: + case 64: + return 2048;/* 4 x 65536 pixels. */ + } +} + +static void +standard_row(png_structp pp, png_byte buffer[STD_ROWMAX], png_byte colour_type, + png_byte bit_depth, png_uint_32 y) +{ + png_uint_32 v = y << 7; + png_uint_32 i = 0; + + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + while (i<128/8) buffer[i] = v & 0xff, v += 17, ++i; + return; + case 2: + while (i<128/4) buffer[i] = v & 0xff, v += 33, ++i; + return; + case 4: + while (i<128/2) buffer[i] = v & 0xff, v += 65, ++i; + return; + case 8: + /* 256 bytes total, 128 bytes in each row set as follows: */ + while (i<128) buffer[i] = v & 0xff, ++v, ++i; + return; + case 16: + /* Generate all 65536 pixel values in order, this includes the 8 bit GA + * case as we as the 16 bit G case. + */ + while (i<128) + buffer[2*i] = (v>>8) & 0xff, buffer[2*i+1] = v & 0xff, ++v, ++i; + return; + case 24: + /* 65535 pixels, but rotate the values. */ + while (i<128) + { + /* Three bytes per pixel, r, g, b, make b by r^g */ + buffer[3*i+0] = (v >> 8) & 0xff; + buffer[3*i+1] = v & 0xff; + buffer[3*i+2] = ((v >> 8) ^ v) & 0xff; + ++v; + ++i; + } + return; + case 32: + /* 65535 pixels, r, g, b, a; just replicate */ + while (i<128) + { + buffer[4*i+0] = (v >> 8) & 0xff; + buffer[4*i+1] = v & 0xff; + buffer[4*i+2] = (v >> 8) & 0xff; + buffer[4*i+3] = v & 0xff; + ++v; + ++i; + } + return; + case 48: + /* y is maximum 2047, giving 4x65536 pixels, make 'r' increase by 1 at + * each pixel, g increase by 257 (0x101) and 'b' by 0x1111: + */ + while (i<128) + { + png_uint_32 t = v++; + buffer[6*i+0] = (t >> 8) & 0xff; + buffer[6*i+1] = t & 0xff; + t *= 257; + buffer[6*i+2] = (t >> 8) & 0xff; + buffer[6*i+3] = t & 0xff; + t *= 17; + buffer[6*i+4] = (t >> 8) & 0xff; + buffer[6*i+5] = t & 0xff; + ++i; + } + return; + case 64: + /* As above in the 32 bit case. */ + while (i<128) + { + png_uint_32 t = v++; + buffer[8*i+0] = (t >> 8) & 0xff; + buffer[8*i+1] = t & 0xff; + buffer[8*i+4] = (t >> 8) & 0xff; + buffer[8*i+5] = t & 0xff; + t *= 257; + buffer[8*i+2] = (t >> 8) & 0xff; + buffer[8*i+3] = t & 0xff; + buffer[8*i+6] = (t >> 8) & 0xff; + buffer[8*i+7] = t & 0xff; + ++i; + } + return; + } + + png_error(pp, "internal error"); +} + +static void +make_standard(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, + int PNG_CONST bdloIn, int PNG_CONST bdhi) +{ + volatile int bdlo = bdloIn; + + for (; bdlo <= bdhi; ++bdlo) + { + png_byte bit_depth; + png_uint_32 h, y; + png_structp pp; + png_infop pi; + + { + size_t pos; + char name[64]; /* Same size as the buffer in a file. */ + + /* Build a name */ + pos = safecat(name, sizeof name, 0, bit_depths[bdlo]); + pos = safecat(name, sizeof name, pos, "bit "); + pos = safecat(name, sizeof name, pos, colour_types[colour_type]); + + /* Get a png_struct for writing the image. */ + pp = set_store_for_write(ps, &pi, name); + } + if (pp == NULL) return; + + /* Do the honourable write stuff, protected by a local setjmp */ + if (setjmp(ps->jmpbuf) != 0) + { + store_write_reset(ps); + continue; + } + + bit_depth = 1U << bdlo; + h = standard_height(pp, colour_type, bit_depth), + png_set_IHDR(pp, pi, standard_width(pp, colour_type, bit_depth), h, + bit_depth, colour_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE); + + if (colour_type == 3) /* palette */ + { + unsigned int i = 0; + png_color pal[256]; + do + pal[i].red = pal[i].green = pal[i].blue = (png_byte)i; + while(++i < 256U); + png_set_PLTE(pp, pi, pal, 256); + } + + png_write_info(pp, pi); + + if (png_get_rowbytes(pp, pi) != + standard_rowsize(pp, colour_type, bit_depth)) + png_error(pp, "row size incorrect"); + + else for (y=0; yjmpbuf) != 0) + { + store_read_reset(ps); + continue; + } + + h = standard_height(pp, colour_type, bit_depth); + + /* Check the header values: */ + png_read_info(pp, pi); + + if (png_get_image_width(pp, pi) != + standard_width(pp, colour_type, bit_depth)) + png_error(pp, "validate: image width changed"); + if (png_get_image_height(pp, pi) != h) + png_error(pp, "validate: image height changed"); + if (png_get_bit_depth(pp, pi) != bit_depth) + png_error(pp, "validate: bit depth changed"); + if (png_get_color_type(pp, pi) != colour_type) + png_error(pp, "validate: color type changed"); + if (png_get_filter_type(pp, pi) != PNG_FILTER_TYPE_BASE) + png_error(pp, "validate: filter type changed"); + if (png_get_interlace_type(pp, pi) != PNG_INTERLACE_NONE) + png_error(pp, "validate: interlacing changed"); + if (png_get_compression_type(pp, pi) != PNG_COMPRESSION_TYPE_BASE) + png_error(pp, "validate: compression type changed"); + if (png_set_interlace_handling(pp) != 1) + png_error(pp, "validate: interlacing unexpected"); + + if (colour_type == 3) /* palette */ + { + png_colorp pal; + int num; + if (png_get_PLTE(pp, pi, &pal, &num) & PNG_INFO_PLTE) + { + int i; + if (num != 256) + png_error(pp, "validate: color type 3 PLTE chunk size changed"); + for (i=0; ithis, 0, 0, 4); + if (fail(pm)) return; + test_standard(&pm->this, 2, 3, 4); + if (fail(pm)) return; + test_standard(&pm->this, 3, 0, 3); + if (fail(pm)) return; + test_standard(&pm->this, 4, 3, 4); + if (fail(pm)) return; + test_standard(&pm->this, 6, 3, 4); +} + + +/********************************* GAMMA TESTS ********************************/ +/* Gamma test images. */ +typedef struct gamma_modification +{ + png_modification this; + png_fixed_point gamma; +} +gamma_modification; + +static int +gamma_modify(png_structp pp, png_modifier *pm, png_modification *me, int add) +{ + UNUSED(pp); + UNUSED(add); + /* This simply dumps the given gamma value into the buffer. */ + png_save_uint_32(pm->buffer, 4); + png_save_uint_32(pm->buffer+4, CHUNK_gAMA); + png_save_uint_32(pm->buffer+8, ((gamma_modification*)me)->gamma); + return 1; +} + +static void +gamma_modification_init(gamma_modification *me, png_modifier *pm, double gamma) +{ + double g; + + modification_init(&me->this); + me->this.chunk = CHUNK_gAMA; + me->this.modify_fn = gamma_modify; + me->this.add = CHUNK_PLTE; + g = floor(gamma * 100000 + .5); + me->gamma = (png_fixed_point)g; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct srgb_modification +{ + png_modification this; + png_byte intent; +} +srgb_modification; + +static int +srgb_modify(png_structp pp, png_modifier *pm, png_modification *me, int add) +{ + UNUSED(pp); + UNUSED(add); + /* As above, ignore add and just make a new chunk */ + png_save_uint_32(pm->buffer, 1); + png_save_uint_32(pm->buffer+4, CHUNK_sRGB); + pm->buffer[8] = ((srgb_modification*)me)->intent; + return 1; +} + +static void +srgb_modification_init(srgb_modification *me, png_modifier *pm, png_byte intent) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + if (intent <= 3) /* if valid, else *delete* sRGB chunks */ + { + me->this.modify_fn = srgb_modify; + me->this.add = CHUNK_PLTE; + me->intent = intent; + } + else + { + me->this.modify_fn = 0; + me->this.add = 0; + me->intent = 0; + } + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct sbit_modification +{ + png_modification this; + png_byte sbit; +} +sbit_modification; + +static int +sbit_modify(png_structp pp, png_modifier *pm, png_modification *me, int add) +{ + png_byte sbit = ((sbit_modification*)me)->sbit; + if (pm->bit_depth > sbit) + { + int cb = 0; + switch (pm->colour_type) + { + case 0: cb = 1; break; + case 2: + case 3: cb = 3; break; + case 4: cb = 2; break; + case 6: cb = 4; break; + default: + png_error(pp, "unexpected colour type in sBIT modification"); + } + + png_save_uint_32(pm->buffer, cb); + png_save_uint_32(pm->buffer+4, CHUNK_sBIT); + while (cb > 0) + (pm->buffer+8)[--cb] = sbit; + + return 1; + } + else if (!add) + { + /* Remove the sBIT chunk */ + pm->buffer_count = pm->buffer_position = 0; + return 1; + } + else + return 0; /* do nothing */ +} + +static void +sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + me->this.modify_fn = sbit_modify; + me->this.add = CHUNK_PLTE; + me->sbit = sbit; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +/* maxabs: maximum absolute error as a fraction + * maxout: maximum output error in the output units + * maxpc: maximum percentage error (as a percentage) + */ +static void +gamma_test(png_modifier *pm, PNG_CONST png_byte colour_type, + PNG_CONST png_byte bit_depth, PNG_CONST double file_gamma, + PNG_CONST double screen_gamma, PNG_CONST png_byte sbit, + PNG_CONST int threshold_test, PNG_CONST char *name, PNG_CONST int speed, + PNG_CONST int use_input_precision, PNG_CONST int strip16) +{ + png_structp pp; + png_infop pi; + double maxerrout = 0, maxerrpc = 0, maxerrabs = 0; + + gamma_modification gamma_mod; + srgb_modification srgb_mod; + sbit_modification sbit_mod; + + /* Make an appropriate modifier to set the PNG file gamma to the + * given gamma value and the sBIT chunk to the given precision. + */ + pm->modifications = NULL; + gamma_modification_init(&gamma_mod, pm, file_gamma); + srgb_modification_init(&srgb_mod, pm, 127/*delete*/); + sbit_modification_init(&sbit_mod, pm, sbit); + + modification_reset(pm->modifications); + + /* Get a png_struct for writing the image. */ + pp = set_modifier_for_read(pm, &pi, FILEID(colour_type, bit_depth), name); + if (pp == NULL) return; + + /* Do the honourable write stuff, protected by a local setjmp */ + if (setjmp(pm->this.jmpbuf) != 0) + { + modifier_reset(pm); + return; + } + + /* Set up gamma processing. */ + png_set_gamma(pp, screen_gamma, file_gamma); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* If requested strip 16 to 8 bits - this is handled automagically below + * because the output bit depth is read from the library. Note that there + * are interactions with sBIT but, internally, libpng makes sbit at most + * PNG_MAX_GAMMA_8 when doing the following. + */ + if (strip16) + png_set_strip_16(pp); + + if (png_set_interlace_handling(pp) != 1) + png_error(pp, "gamma: interlaced images not supported"); + + png_read_update_info(pp, pi); + + { + PNG_CONST png_byte out_ct = png_get_color_type(pp, pi); + PNG_CONST png_byte out_bd = png_get_bit_depth(pp, pi); + PNG_CONST unsigned int outmax = (1U<= + PNG_GAMMA_THRESHOLD && !threshold_test && !speed && colour_type != 3) + || bit_depth != out_bd; + PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U; + PNG_CONST double gamma = 1/(file_gamma*screen_gamma); /* Overall */ + + for (y=0; y> (bit_depth-sbit); + double i, sample, encoded_sample, output, encoded_error, error; + double es_lo, es_hi; + + /* First check on the 'perfect' result obtained from the digitized + * input value, id, and compare this against the actual digitized + * result, 'od'. 'i' is the input result in the range 0..1: + * + * NOTE: sbit should be taken into account here but isn't, as + * described above. + */ + i = isbit; i /= (1U< maxerrout) + maxerrout = encoded_error; + + if (encoded_error < .5+maxout) + continue; + + /* There may be an error, calculate the actual sample values - + * unencoded light intensity values. Note that in practice these + * are not unencoded because they include a 'viewing correction' to + * decrease or (normally) increase the perceptual contrast of the + * image. There's nothing we can do about this - we don't know what + * it is - so assume the unencoded value is perceptually linear. + */ + sample = pow(i, 1/file_gamma); /* In range 0..1 */ + output = od; + output /= outmax; + output = pow(output, screen_gamma); + + /* Now we have the numbers for real errors, both absolute values as + * as a percentage of the correct value (output): + */ + error = fabs(sample-output); + if (error > maxerrabs) + maxerrabs = error; + /* The following is an attempt to ignore the tendency of + * quantization to dominate the percentage errors for low output + * sample values: + */ + if (sample*maxpc > .5+maxabs) + { + double pcerr = error/sample; + if (pcerr > maxerrpc) maxerrpc = pcerr; + } + + /* Now calculate the digitization limits for 'encoded_sample' using + * the 'max' values. Note that maxout is in the encoded space but + * maxpc and maxabs are in linear light space. + * + * First find the maximum error in linear light space, range 0..1: + */ + { + double tmp = sample * maxpc; + if (tmp < maxabs) tmp = maxabs; + + /* Low bound - the minimum of the three: */ + es_lo = encoded_sample - maxout; + if (es_lo > 0 && sample-tmp > 0) + { + double l = outmax * pow(sample-tmp, 1/screen_gamma); + if (l < es_lo) es_lo = l; + } + else + es_lo = 0; + + es_hi = encoded_sample + maxout; + if (es_hi < outmax && sample+tmp < 1) + { + double h = outmax * pow(sample+tmp, 1/screen_gamma); + if (h > es_hi) es_hi = h; + } + else + es_hi = outmax; + } + + /* The primary test is that the final encoded value returned by the + * library should be between the two limits (inclusive) that were + * calculated above. At this point quantization of the output must + * be taken into account. + */ + if (od+.5 < es_lo || od-.5 > es_hi) + { + /* Thee has been an error in processing. */ + double is_lo, is_hi; + + if (use_input_precision) + { + /* Ok, something is wrong - this actually happens in current + * libpng sbit processing. Assume that the input value (id, + * adjusted for sbit) can be anywhere between value-.5 and + * value+.5 - quite a large range if sbit is low. + */ + double tmp = (isbit - .5)/((1U< 0) + { + is_lo = outmax * pow(tmp, gamma) - maxout; + if (is_lo < 0) is_lo = 0; + } + else + is_lo = 0; + + tmp = (isbit + .5)/((1U< outmax) is_hi = outmax; + } + else + is_hi = outmax; + + if (!(od+.5 < is_lo || od-.5 > is_hi)) + continue; + } + + { + char msg[256]; + sprintf(msg, + "error: %.3f; %u{%u;%u} -> %u not %.2f (%.1f-%.1f)", + od-encoded_sample, id, sbit, isbit, od, encoded_sample, + use_input_precision ? is_lo : es_lo, + use_input_precision ? is_hi : es_hi); + png_warning(pp, msg); + } + } + } + else if (!speed && memcmp(std, display, cb) != 0) + { + char msg[64]; + /* No transform is expected on the threshold tests. */ + sprintf(msg, "gamma: below threshold row %d (of %d) changed", y, h); + png_error(pp, msg); + } + } + } + + png_read_end(pp, pi); + modifier_reset(pm); + + if (pm->log && !threshold_test && !speed) + fprintf(stderr, "%d bit %s %s: max error %f (%.2g, %2g%%)\n", bit_depth, + colour_types[colour_type], name, maxerrout, maxerrabs, 100*maxerrpc); + + /* Log the summary values too. */ + if (colour_type == 0 || colour_type == 4) switch (bit_depth) + { + case 2: + if (maxerrout > pm->error_gray_2) pm->error_gray_2 = maxerrout; break; + case 4: + if (maxerrout > pm->error_gray_4) pm->error_gray_4 = maxerrout; break; + case 8: + if (maxerrout > pm->error_gray_8) pm->error_gray_8 = maxerrout; break; + case 16: + if (maxerrout > pm->error_gray_16) pm->error_gray_16 = maxerrout; break; + } + else if (colour_type == 2 || colour_type == 6) switch (bit_depth) + { + case 8: + if (maxerrout > pm->error_color_8) pm->error_color_8 = maxerrout; break; + case 16: + if (maxerrout > pm->error_color_16) pm->error_color_16 = maxerrout; break; + } +} + +static void gamma_threshold_test(png_modifier *pm, png_byte colour_type, + png_byte bit_depth, double file_gamma, double screen_gamma) +{ + size_t pos = 0; + char name[64]; + pos = safecat(name, sizeof name, pos, "threshold "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "/"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + (void)gamma_test(pm, colour_type, bit_depth, file_gamma, screen_gamma, + bit_depth, 1, name, 0/*speed*/, 0/*no input precision*/, 0/*no strip16*/); +} + +static void +perform_gamma_threshold_tests(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + + while (next_format(&colour_type, &bit_depth)) + { + double gamma = 1.0; + while (gamma >= .4) + { + gamma_threshold_test(pm, colour_type, bit_depth, gamma, 1/gamma); + gamma *= .95; + } + + /* And a special test for sRGB */ + gamma_threshold_test(pm, colour_type, bit_depth, .45455, 2.2); + if (fail(pm)) return; + } +} + +static void gamma_transform_test(png_modifier *pm, + PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth, + PNG_CONST double file_gamma, PNG_CONST double screen_gamma, + PNG_CONST png_byte sbit, PNG_CONST int speed, + PNG_CONST int use_input_precision, PNG_CONST int strip16) +{ + size_t pos = 0; + char name[64]; + if (sbit != bit_depth) + { + pos = safecat(name, sizeof name, pos, "sbit("); + pos = safecatn(name, sizeof name, pos, sbit); + pos = safecat(name, sizeof name, pos, ") "); + } + else + pos = safecat(name, sizeof name, pos, "gamma "); + if (strip16) + pos = safecat(name, sizeof name, pos, "16to8 "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "->"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + gamma_test(pm, colour_type, bit_depth, file_gamma, screen_gamma, sbit, 0, + name, speed, use_input_precision, strip16); +} + +static void perform_gamma_transform_tests(png_modifier *pm, int speed) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + + /* Ignore palette images - the gamma correction happens on the palette entry, + * haven't got the tests for this yet. + */ + while (next_format(&colour_type, &bit_depth)) if (colour_type != 3) + { + unsigned int i, j; + + for (i=0; ingammas; ++i) for (j=0; jngammas; ++j) if (i != j) + { + gamma_transform_test(pm, colour_type, bit_depth, 1/pm->gammas[i], + pm->gammas[j], bit_depth, speed, pm->use_input_precision, + 0/*do not strip16*/); + if (fail(pm)) return; + } + } +} + +static void perform_gamma_sbit_tests(png_modifier *pm, int speed) +{ + png_byte sbit; + + /* The only interesting cases are colour and grayscale, alpha is ignored here + * for overall speed. Only bit depths 8 and 16 are tested. + */ + for (sbit=pm->sbitlow; sbit<16; ++sbit) + { + unsigned int i, j; + for (i=0; ingammas; ++i) for (j=0; jngammas; ++j) + if (i != j) + { + if (sbit < 8) + { + gamma_transform_test(pm, 0, 8, 1/pm->gammas[i], pm->gammas[j], sbit, + speed, pm->use_input_precision_sbit, 0/*strip16*/); + if (fail(pm)) return; + gamma_transform_test(pm, 2, 8, 1/pm->gammas[i], pm->gammas[j], sbit, + speed, pm->use_input_precision_sbit, 0/*strip16*/); + if (fail(pm)) return; + } + gamma_transform_test(pm, 0, 16, 1/pm->gammas[i], pm->gammas[j], sbit, + speed, pm->use_input_precision_sbit, 0/*strip16*/); + if (fail(pm)) return; + gamma_transform_test(pm, 2, 16, 1/pm->gammas[i], pm->gammas[j], sbit, + speed, pm->use_input_precision_sbit, 0/*strip16*/); + if (fail(pm)) return; + } + } +} + +static void perform_gamma_strip16_tests(png_modifier *pm, int speed) +{ +# ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +# endif + /* Include the alpha cases here, not that sbit matches the internal value + * used by the library - otherwise we will get spurious errors from the + * internal sbit style approximation. + * + * The threshold test is here because otherwise the 16 to 8 conversion will + * proceed *without* gamma correction, and the tests above will fail (but not + * by much) - this could be fixed, it only appears with the -g option. + */ + unsigned int i, j; + for (i=0; ingammas; ++i) for (j=0; jngammas; ++j) + if (i != j && fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD) + { + gamma_transform_test(pm, 0, 16, 1/pm->gammas[i], pm->gammas[j], + PNG_MAX_GAMMA_8, speed, pm->use_input_precision_16to8, 1/*strip16*/); + if (fail(pm)) return; + gamma_transform_test(pm, 2, 16, 1/pm->gammas[i], pm->gammas[j], + PNG_MAX_GAMMA_8, speed, pm->use_input_precision_16to8, 1/*strip16*/); + if (fail(pm)) return; + gamma_transform_test(pm, 4, 16, 1/pm->gammas[i], pm->gammas[j], + PNG_MAX_GAMMA_8, speed, pm->use_input_precision_16to8, 1/*strip16*/); + if (fail(pm)) return; + gamma_transform_test(pm, 6, 16, 1/pm->gammas[i], pm->gammas[j], + PNG_MAX_GAMMA_8, speed, pm->use_input_precision_16to8, 1/*strip16*/); + if (fail(pm)) return; + } +} + +static void +perform_gamma_test(png_modifier *pm, int speed, int summary) +{ + /* First some arbitrary no-transform tests: */ + if (!speed) + { + perform_gamma_threshold_tests(pm); + if (fail(pm)) return; + } + + /* Now some real transforms. */ + perform_gamma_transform_tests(pm, speed); + if (summary) + { + printf("Gamma correction error summary (output value error):\n"); + printf(" 2 bit gray: %.5f\n", pm->error_gray_2); + printf(" 4 bit gray: %.5f\n", pm->error_gray_4); + printf(" 8 bit gray: %.5f\n", pm->error_gray_8); + printf(" 16 bit gray: %.5f\n", pm->error_gray_16); + printf(" 8 bit color: %.5f\n", pm->error_color_8); + printf(" 16 bit color: %.5f\n", pm->error_color_16); + } + + /* The sbit tests produce much larger errors: */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = pm->error_gray_16 = + pm->error_color_8 = pm->error_color_16 = 0; + perform_gamma_sbit_tests(pm, speed); + if (summary) + { + printf("Gamma correction with sBIT:\n"); + if (pm->sbitlow < 8U) + { + printf(" 2 bit gray: %.5f\n", pm->error_gray_2); + printf(" 4 bit gray: %.5f\n", pm->error_gray_4); + printf(" 8 bit gray: %.5f\n", pm->error_gray_8); + } + printf(" 16 bit gray: %.5f\n", pm->error_gray_16); + if (pm->sbitlow < 8U) + printf(" 8 bit color: %.5f\n", pm->error_color_8); + printf(" 16 bit color: %.5f\n", pm->error_color_16); + } + + /* The 16 to 8 bit strip operations: */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = pm->error_gray_16 = + pm->error_color_8 = pm->error_color_16 = 0; + perform_gamma_strip16_tests(pm, speed); + if (summary) + { + printf("Gamma correction with 16 to 8 bit reduction:\n"); + printf(" 16 bit gray: %.5f\n", pm->error_gray_16); + printf(" 16 bit color: %.5f\n", pm->error_color_16); + } +} + +/* main program */ +int main(int argc, PNG_CONST char **argv) +{ + int summary = 1; /* Print the error sumamry at the end */ + int speed = 0; /* Speed test only (for gamma stuff) */ + PNG_CONST char *touch = NULL; /* Create the given output file on success. */ + + /* This is an array of standard gamma values (believe it or not I've seen + * every one of these mentioned somewhere.) + * + * In the following list the most useful values are first! + */ + static double gammas[]={2.2, 1.0, 2.2/1.45, 1.8, 1.5, 2.4, 2.5, 2.62, 2.9}; + + png_modifier pm; + modifier_init(&pm); + + /* Default to error on warning: */ + pm.this.treat_warnings_as_errors = 1; + + /* Store the test gammas */ + pm.gammas = gammas; + pm.ngammas = 3U; /* for speed */ + pm.sbitlow = 8U; /* because libpng doesn't do sbit below 8! */ + pm.use_input_precision_16to8 = 1U; /* Because of the way libpng does it */ + + /* Some default values (set the behavior for 'make check' here) */ + pm.maxout8 = .1; /* Arithmetic error in *encoded* value */ + pm.maxabs8 = .00005; /* 1/20000 */ + pm.maxpc8 = .499; /* I.e. .499% fractional error */ + pm.maxout16 = .499; /* Error in *encoded* value */ + pm.maxabs16 = .00005;/* 1/20000 */ + /* NOTE: this is a reasonable perceptual limit, we assume that humans can + * perceive light level differences of 1% over a 100:1 range, so we need to + * maintain 1 in 10000 accuracy (in linear light space), this is what the + * following guarantees. It also allows significantly higher errors at + * higher 16 bit values, which is important for performance. The actual + * maximum 16 bit error is about +/-1.9 in the fixed point implementation but + * this is only allowed for values >38149 by the following: + */ + pm.maxpc16 = .005; /* I.e. 1/200% - 1/20000 */ + + /* Now parse the command line options. */ + while (--argc >= 1) + if (strcmp(*++argv, "-v") == 0) + pm.this.verbose = 1; + else if (strcmp(*argv, "-l") == 0) + pm.log = 1; + else if (strcmp(*argv, "-q") == 0) + pm.this.verbose = pm.log = summary = 0; + else if (strcmp(*argv, "-g") == 0) + pm.ngammas = (sizeof gammas)/(sizeof gammas[0]); + else if (strcmp(*argv, "-w") == 0) + pm.this.treat_warnings_as_errors = 0; + else if (strcmp(*argv, "--speed") == 0) + speed = 1, pm.ngammas = (sizeof gammas)/(sizeof gammas[0]); + else if (argc >= 1 && strcmp(*argv, "--sbitlow") == 0) + --argc, pm.sbitlow = (png_byte)atoi(*++argv); + else if (argc >= 1 && strcmp(*argv, "--touch") == 0) + --argc, touch = *++argv; + else if (argc >= 1 && strncmp(*argv, "--max", 4) == 0) + { + --argc; + if (strcmp(4+*argv, "abs8") == 0) + pm.maxabs8 = atof(*++argv); + else if (strcmp(4+*argv, "abs16") == 0) + pm.maxabs16 = atof(*++argv); + else if (strcmp(4+*argv, "out8") == 0) + pm.maxout8 = atof(*++argv); + else if (strcmp(4+*argv, "out16") == 0) + pm.maxout16 = atof(*++argv); + else if (strcmp(4+*argv, "pc8") == 0) + pm.maxpc8 = atof(*++argv); + else if (strcmp(4+*argv, "pc16") == 0) + pm.maxpc16 = atof(*++argv); + else + { + fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv); + exit(1); + } + } + else + { + fprintf(stderr, "pngvalid: %s: unknown argument\n", *argv); + exit(1); + } + + /* Make useful base images */ + make_standard_images(&pm.this); + + /* Perform the standard and gamma tests. */ + if (!speed) + perform_standard_test(&pm); + perform_gamma_test(&pm, speed, summary && !speed); + if (summary && !speed) + printf("Results using %s point arithmetic %s\n", +#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || PNG_LIBPNG_VER < 10500 + "floating", +#else + "fixed", +#endif + (pm.this.nerrors || (pm.this.treat_warnings_as_errors && + pm.this.nwarnings)) ? "(errors)" : (pm.this.nwarnings ? + "(warnings)" : "(no errors or warnings)") + ); + + /* Error exit if there are any errors, and maybe if there are any + * warnings. + */ + if (pm.this.nerrors || (pm.this.treat_warnings_as_errors && + pm.this.nwarnings)) + { + if (!pm.this.verbose) + fprintf(stderr, "pngvalid: %s\n", pm.this.error); + fprintf(stderr, "pngvalid: %d errors, %d warnings\n", pm.this.nerrors, + pm.this.nwarnings); + exit(1); + } + + /* Success case. */ + if (touch != NULL) + { + FILE *fsuccess = fopen(touch, "wt"); + if (fsuccess != NULL) + { + int error = 0; + fprintf(fsuccess, "PNG validation succeeded\n"); + fflush(fsuccess); + error = ferror(fsuccess); + if (fclose(fsuccess) || error) + { + fprintf(stderr, "%s: write failed\n", touch); + exit(1); + } + } + } + + return 0; +} diff -ru4NwbB libpng-1.4.3/pngwio.c libpng-1.5.0beta42/pngwio.c --- libpng-1.4.3/pngwio.c 2010-06-25 19:32:26.124848494 -0500 +++ libpng-1.5.0beta42/pngwio.c 2010-08-18 08:12:21.425676043 -0500 @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.4.0 [January 3, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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.) * @@ -17,25 +17,26 @@ * functions, but rather write replacement functions and then change * them at run time with png_set_write_fn(...). */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED #include "pngpriv.h" +#ifdef PNG_WRITE_SUPPORTED + /* 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. */ void /* PRIVATE */ -png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length) { + /* NOTE: write_data_fn must not change the buffer! */ if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, data, length); + (*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length); + else png_error(png_ptr, "Call to NULL write function"); } @@ -45,9 +46,9 @@ * 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 +void PNGCBAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_uint_32 check; @@ -65,9 +68,9 @@ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) -void PNGAPI +void PNGCBAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_uint_32 check; png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ @@ -123,14 +132,16 @@ (*(png_ptr->output_flush_fn))(png_ptr); } #ifdef PNG_STDIO_SUPPORTED -void PNGAPI +void PNGCBAPI png_default_flush(png_structp png_ptr) { png_FILE_p io_ptr; + if (png_ptr == NULL) return; + io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); fflush(io_ptr); } #endif @@ -199,12 +212,12 @@ /* It is an error to read while writing a png file */ if (png_ptr->read_data_fn != NULL) { 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"); + "Can't set both read_data_fn and write_data_fn in the" + " same structure"); } } #ifdef USE_FAR_KEYWORD diff -ru4NwbB libpng-1.4.3/pngwrite.c libpng-1.5.0beta42/pngwrite.c --- libpng-1.4.3/pngwrite.c 2010-06-25 19:32:26.133513514 -0500 +++ libpng-1.5.0beta42/pngwrite.c 2010-08-18 08:12:21.434242208 -0500 @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.4.0 [January 3, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,14 +10,12 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -/* Get internal access to png.h */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED #include "pngpriv.h" +#ifdef PNG_WRITE_SUPPORTED + /* 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 * after the image data, put it in png_write_end(). I strongly encourage @@ -58,17 +59,9 @@ * flag set, and if it does, writes the chunk. */ #ifdef PNG_WRITE_gAMA_SUPPORTED if (info_ptr->valid & PNG_INFO_gAMA) - { -# ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_gAMA(png_ptr, info_ptr->gamma); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma); -# endif -#endif - } + png_write_gAMA_fixed(png_ptr, info_ptr->gamma); #endif #ifdef PNG_WRITE_sRGB_SUPPORTED if (info_ptr->valid & PNG_INFO_sRGB) png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); @@ -72,37 +65,27 @@ #ifdef PNG_WRITE_sRGB_SUPPORTED if (info_ptr->valid & PNG_INFO_sRGB) png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent); #endif + #ifdef PNG_WRITE_iCCP_SUPPORTED if (info_ptr->valid & PNG_INFO_iCCP) png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE, - info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); + (png_charp)info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); #endif #ifdef PNG_WRITE_sBIT_SUPPORTED if (info_ptr->valid & PNG_INFO_sBIT) png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); #endif #ifdef PNG_WRITE_cHRM_SUPPORTED if (info_ptr->valid & PNG_INFO_cHRM) - { -#ifdef PNG_FLOATING_POINT_SUPPORTED - png_write_cHRM(png_ptr, + png_write_cHRM_fixed(png_ptr, info_ptr->x_white, info_ptr->y_white, info_ptr->x_red, info_ptr->y_red, info_ptr->x_green, info_ptr->y_green, info_ptr->x_blue, info_ptr->y_blue); -#else -# ifdef PNG_FIXED_POINT_SUPPORTED - png_write_cHRM_fixed(png_ptr, - info_ptr->int_x_white, info_ptr->int_y_white, - info_ptr->int_x_red, info_ptr->int_y_red, - info_ptr->int_x_green, info_ptr->int_y_green, - info_ptr->int_x_blue, info_ptr->int_y_blue); -# endif -#endif - } #endif + #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; @@ -160,9 +146,10 @@ info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { int j; for (j = 0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans_alpha[j] = (png_byte)(255 - info_ptr->trans_alpha[j]); + info_ptr->trans_alpha[j] = + (png_byte)(255 - info_ptr->trans_alpha[j]); } #endif png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color), info_ptr->num_trans, info_ptr->color_type); @@ -187,24 +177,12 @@ info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, info_ptr->pcal_units, info_ptr->pcal_params); #endif -#ifdef PNG_sCAL_SUPPORTED - if (info_ptr->valid & PNG_INFO_sCAL) #ifdef PNG_WRITE_sCAL_SUPPORTED -#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) - png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else /* !FLOATING_POINT */ -#ifdef PNG_FIXED_POINT_SUPPORTED + if (info_ptr->valid & PNG_INFO_sCAL) png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_s_width, info_ptr->scal_s_height); -#endif /* FIXED_POINT */ -#endif /* FLOATING_POINT */ -#else /* !WRITE_sCAL */ - png_warning(png_ptr, - "png_write_sCAL not supported; sCAL chunk not written"); -#endif /* WRITE_sCAL */ #endif /* sCAL */ #ifdef PNG_WRITE_pHYs_SUPPORTED if (info_ptr->valid & PNG_INFO_pHYs) @@ -427,9 +411,9 @@ #ifdef PNG_CONVERT_tIME_SUPPORTED /* "tm" structure is not supported on WindowsCE */ void PNGAPI -png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) +png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm FAR * ttime) { png_debug(1, "in png_convert_from_struct_tm"); ptime->year = (png_uint_16)(1900 + ttime->tm_year); @@ -452,22 +436,24 @@ } #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) +PNG_FUNCTION(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),PNG_ALLOCATED) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, warn_fn, NULL, NULL, NULL)); } /* Alternate initialize png_ptr structure, and allocate any memory needed */ -png_structp PNGAPI -png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, +static void png_reset_filter_heuristics(png_structp png_ptr); /* forward decl */ + +PNG_FUNCTION(png_structp,PNGAPI +png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn) + png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { #endif /* PNG_USER_MEM_SUPPORTED */ volatile int png_cleanup_needed = 0; #ifdef PNG_SETJMP_SUPPORTED @@ -475,9 +461,9 @@ #endif png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD - jmp_buf jmpbuf; + jmp_buf png_jmpbuf; #endif #endif int i; @@ -502,14 +488,14 @@ /* 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)) + if (setjmp(png_jmpbuf)) #else if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */ #endif #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(png_ptr), jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf)); #endif PNG_ABORT(); #endif @@ -538,27 +524,27 @@ if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || (user_png_ver[0] == '0' && user_png_ver[2] < '9')) { -#ifdef PNG_STDIO_SUPPORTED +#ifdef PNG_CONSOLE_IO_SUPPORTED char msg[80]; + 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_snprintf2(msg, 80, + "Application built with libpng-%.20s" + " but running with %.20s", + user_png_ver, png_libpng_ver); png_warning(png_ptr, msg); + } +#else + png_warning(png_ptr, + "Incompatible libpng version in application and library"); #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags = 0; #endif - png_warning(png_ptr, - "Incompatible libpng version in application and library"); png_cleanup_needed = 1; } } @@ -587,10 +575,9 @@ png_set_write_fn(png_ptr, NULL, NULL, NULL); #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, - 1, NULL, NULL); + png_reset_filter_heuristics(png_ptr); #endif return (png_ptr); } @@ -655,14 +642,14 @@ } /* Called by user to write a row of image data */ void PNGAPI -png_write_row(png_structp png_ptr, png_bytep row) +png_write_row(png_structp png_ptr, png_const_bytep row) { if (png_ptr == NULL) return; - png_debug2(1, "in png_write_row (row %ld, pass %d)", + png_debug2(1, "in png_write_row (row %u, pass %d)", png_ptr->row_number, png_ptr->pass); /* Initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) @@ -777,13 +769,13 @@ png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width); + png_debug1(3, "row_info->width = %u", png_ptr->row_info.width); png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels); png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth); 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); + png_debug1(3, "row_info->rowbytes = %u", png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes); @@ -877,10 +872,9 @@ if (!(png_ptr->zstream.avail_out)) { /* Write the IDAT and reset the zlib output buffer */ - png_write_IDAT(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size); + 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; wrote_IDAT = 1; } @@ -1005,18 +999,17 @@ png_free(png_ptr, png_ptr->time_buffer); #endif #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED - png_free(png_ptr, png_ptr->prev_filters); - png_free(png_ptr, png_ptr->filter_weights); - png_free(png_ptr, png_ptr->inv_filter_weights); + /* Use this to save a little code space, it doesn't free the filter_costs */ + png_reset_filter_heuristics(png_ptr); png_free(png_ptr, png_ptr->filter_costs); png_free(png_ptr, png_ptr->inv_filter_costs); #endif #ifdef PNG_SETJMP_SUPPORTED /* Reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); + png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf)); #endif error_fn = png_ptr->error_fn; warning_fn = png_ptr->warning_fn; @@ -1034,9 +1027,9 @@ png_ptr->free_fn = free_fn; #endif #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); + png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif } /* Allow the application to select one or more row filters to use. */ @@ -1062,20 +1057,27 @@ case 7: png_warning(png_ptr, "Unknown row filter for method 0"); #endif /* PNG_WRITE_FILTER_SUPPORTED */ case PNG_FILTER_VALUE_NONE: png_ptr->do_filter = PNG_FILTER_NONE; break; + #ifdef PNG_WRITE_FILTER_SUPPORTED case PNG_FILTER_VALUE_SUB: png_ptr->do_filter = PNG_FILTER_SUB; break; + case PNG_FILTER_VALUE_UP: png_ptr->do_filter = PNG_FILTER_UP; break; + case PNG_FILTER_VALUE_AVG: png_ptr->do_filter = PNG_FILTER_AVG; break; + case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter = PNG_FILTER_PAETH; break; - default: png_ptr->do_filter = (png_byte)filters; break; + + default: + png_ptr->do_filter = (png_byte)filters; break; #else - default: png_warning(png_ptr, "Unknown row filter for method 0"); + default: + png_warning(png_ptr, "Unknown row filter for method 0"); #endif /* PNG_WRITE_FILTER_SUPPORTED */ } /* If we have allocated the row_buf, this means we have already started @@ -1159,42 +1164,61 @@ * filtered data going to zlib more consistent, hopefully resulting in * better compression. */ #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */ -void PNGAPI -png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, - int num_weights, png_doublep filter_weights, - png_doublep filter_costs) +/* Conveneince reset API. */ +static void +png_reset_filter_heuristics(png_structp png_ptr) +{ + /* Clear out any old values in the 'weights' - this must be done because if + * the app calls set_filter_heuristics multiple times with different + * 'num_weights' values we would otherwise potentially have wrong sized + * arrays. + */ + png_ptr->num_prev_filters = 0; + png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; + if (png_ptr->prev_filters != NULL) { - int i; - - png_debug(1, "in png_set_filter_heuristics"); - - if (png_ptr == NULL) - return; - if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) + png_bytep old = png_ptr->prev_filters; + png_ptr->prev_filters = NULL; + png_free(png_ptr, old); + } + if (png_ptr->filter_weights != NULL) { - png_warning(png_ptr, "Unknown filter heuristic method"); - return; + png_uint_16p old = png_ptr->filter_weights; + png_ptr->filter_weights = NULL; + png_free(png_ptr, old); } - if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT) + if (png_ptr->inv_filter_weights != NULL) { - heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; + png_uint_16p old = png_ptr->inv_filter_weights; + png_ptr->inv_filter_weights = NULL; + png_free(png_ptr, old); } - if (num_weights < 0 || filter_weights == NULL || - heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) - { - num_weights = 0; + /* Leave the filter_costs - this array is fixed size. */ } - png_ptr->num_prev_filters = (png_byte)num_weights; - png_ptr->heuristic_method = (png_byte)heuristic_method; +static int +png_init_filter_heuristics(png_structp png_ptr, int heuristic_method, + int num_weights) +{ + if (png_ptr == NULL) + return 0; - if (num_weights > 0) + /* Clear out the arrays */ + png_reset_filter_heuristics(png_ptr); + + /* Check arguments; the 'reset' function makes the correct settings for the + * unweighted case, but we must handle the weight case by initializing the + * arrays for the caller. + */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) { - if (png_ptr->prev_filters == NULL) + int i; + + if (num_weights > 0) { png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, (png_uint_32)(png_sizeof(png_byte) * num_weights)); @@ -1202,39 +1226,23 @@ for (i = 0; i < num_weights; i++) { png_ptr->prev_filters[i] = 255; } - } - if (png_ptr->filter_weights == NULL) - { png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } - } for (i = 0; i < num_weights; i++) { - if (filter_weights[i] < 0.0) - { png_ptr->inv_filter_weights[i] = png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR*filter_weights[i]+0.5); - png_ptr->filter_weights[i] = - (png_uint_16)((double)PNG_WEIGHT_FACTOR/filter_weights[i]+0.5); - } - } + + /* Safe to set this now */ + png_ptr->num_prev_filters = (png_byte)num_weights; } /* If, in the future, there are other filter methods, this would * need to be based on png_ptr->filter. @@ -1245,14 +1253,69 @@ (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + } for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) { png_ptr->inv_filter_costs[i] = png_ptr->filter_costs[i] = PNG_COST_FACTOR; } + + /* All the arrays are inited, safe to set this: */ + png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED; + + /* Return the 'ok' code. */ + return 1; + } + else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT || + heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) + { + return 1; + } + else + { + png_warning(png_ptr, "Unknown filter heuristic method"); + return 0; + } +} + +/* Provide floating and fixed point APIs */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, + int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs) +{ + png_debug(1, "in png_set_filter_heuristics"); + + /* The internal API allocates all the arrays and ensures that the elements of + * those arrays are set to the default value. + */ + if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) + return; + + /* If using the weighted method copy in the weights. */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int i; + for (i = 0; i < num_weights; i++) + { + if (filter_weights[i] <= 0.0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } + + else + { + png_ptr->inv_filter_weights[i] = + (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); + + png_ptr->filter_weights[i] = + (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); + } } /* Here is where we set the relative costs of the different filters. We * should take the desired compression level into account when setting @@ -1260,24 +1323,75 @@ * compression levels, while it has a lower relative cost at higher * compression settings. The filter types are in order of increasing * relative cost, so it would be possible to do this with an algorithm. */ - for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) - { - if (filter_costs == NULL || filter_costs[i] < 0.0) + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0) { png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; + (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); + + png_ptr->filter_costs[i] = + (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); + } } - else if (filter_costs[i] >= 1.0) +} +#endif /* FLOATING_POINT */ + +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method, + int num_weights, png_const_fixed_point_p filter_weights, + png_const_fixed_point_p filter_costs) { - png_ptr->inv_filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR / filter_costs[i] + 0.5); - png_ptr->filter_costs[i] = - (png_uint_16)((double)PNG_COST_FACTOR * filter_costs[i] + 0.5); + png_debug(1, "in png_set_filter_heuristics_fixed"); + + /* The internal API allocates all the arrays and ensures that the elements of + * those arrays are set to the default value. + */ + if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights)) + return; + + /* If using the weighted method copy in the weights. */ + if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) + { + int i; + for (i = 0; i < num_weights; i++) + { + if (filter_weights[i] <= 0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; } + + else + { + png_ptr->inv_filter_weights[i] = (png_uint_16) + ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); + + png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* + PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); } } + + /* Here is where we set the relative costs of the different filters. We + * should take the desired compression level into account when setting + * the costs, so that Paeth, for instance, has a high relative cost at low + * compression levels, while it has a lower relative cost at higher + * compression settings. The filter types are in order of increasing + * relative cost, so it would be possible to do this with an algorithm. + */ + for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) + if (filter_costs[i] >= PNG_FP_1) + { + png_ptr->inv_filter_costs[i] = (png_uint_16)((PNG_COST_FACTOR* + PNG_FP_1+(filter_costs[i]/2)) / filter_costs[i]); + + png_ptr->filter_costs[i] = (png_uint_16) + ((PNG_COST_FACTOR * filter_costs[i] +PNG_FP_HALF)/PNG_FP_1); + } + } +} +#endif /* FIXED_POINT */ #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ void PNGAPI png_set_compression_level(png_structp png_ptr, int level) diff -ru4NwbB libpng-1.4.3/pngwtran.c libpng-1.5.0beta42/pngwtran.c --- libpng-1.4.3/pngwtran.c 2010-06-25 19:32:26.139873927 -0500 +++ libpng-1.5.0beta42/pngwtran.c 2010-08-18 08:12:21.440545134 -0500 @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,13 +10,12 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED #include "pngpriv.h" +#ifdef PNG_WRITE_SUPPORTED + /* Transform the data according to the user's wishes. The order of * transformations is significant. */ void /* PRIVATE */ @@ -212,14 +235,14 @@ * would pass 3 as bit_depth, and this routine would translate the * data to 0 to 15. */ void /* PRIVATE */ -png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) +png_do_shift(png_row_infop row_info, png_bytep row, + png_const_color_8p bit_depth) { png_debug(1, "in png_do_shift"); - if ( - row_info->color_type != PNG_COLOR_TYPE_PALETTE) + if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; int channels = 0; @@ -340,14 +375,15 @@ { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - /* This converts from ARGB to RGBA */ if (row_info->bit_depth == 8) { + /* This converts from ARGB to RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) { png_byte save = *(sp++); *(dp++) = *(sp++); @@ -355,11 +391,12 @@ *(dp++) = *(sp++); *(dp++) = save; } } - /* This converts from AARRGGBB to RRGGBBAA */ + else { + /* This converts from AARRGGBB to RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -378,13 +415,14 @@ *(dp++) = save[1]; } } } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - /* This converts from AG to GA */ if (row_info->bit_depth == 8) { + /* This converts from AG to GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -394,11 +432,12 @@ *(dp++) = *(sp++); *(dp++) = save; } } - /* This converts from AAGG to GGAA */ + else { + /* This converts from AAGG to GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -426,14 +465,15 @@ { if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in RGBA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; + for (i = 0, sp = dp = row; i < row_width; i++) { /* Does nothing *(dp++) = *(sp++); @@ -443,11 +483,12 @@ sp+=3; dp = sp; *(dp++) = (png_byte)(255 - *(sp++)); } } - /* This inverts the alpha channel in RRGGBBAA */ + else { + /* This inverts the alpha channel in RRGGBBAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -466,13 +507,14 @@ *(dp++) = (png_byte)(255 - *(sp++)); } } } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { + /* This inverts the alpha channel in GA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -481,11 +523,12 @@ *(dp++) = *(sp++); *(dp++) = (png_byte)(255 - *(sp++)); } } - /* This inverts the alpha channel in GGAA */ + else { + /* This inverts the alpha channel in GGAA */ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width = row_info->width; @@ -511,10 +554,9 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_write_intrapixel"); - if ( - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + if ((row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) diff -ru4NwbB libpng-1.4.3/pngwutil.c libpng-1.5.0beta42/pngwutil.c --- libpng-1.4.3/pngwutil.c 2010-06-25 19:32:26.151727158 -0500 +++ libpng-1.5.0beta42/pngwutil.c 2010-08-18 08:12:21.451571693 -0500 @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.4.1 [February 25, 2010] + * Last changed in libpng 1.5.0 [August 11, 2010] * Copyright (c) 1998-2010 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,13 +10,13 @@ * For conditions of distribution and use, see the disclaimer * and license in png.h */ -#define PNG_NO_PEDANTIC_WARNINGS -#include "png.h" -#ifdef PNG_WRITE_SUPPORTED #include "pngpriv.h" +#ifdef PNG_WRITE_SUPPORTED + +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED /* 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. */ @@ -31,9 +31,11 @@ #ifdef 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. + * be modified to write data in two's complement format. Note that, + * the following works correctly even if png_int_32 has more than 32 bits + * (compare the more complex code required on read for sign extention.) */ void PNGAPI png_save_int_32(png_bytep buf, png_int_32 i) { @@ -53,8 +55,9 @@ { buf[0] = (png_byte)((i >> 8) & 0xff); buf[1] = (png_byte)(i & 0xff); } +#endif /* Simple function to write the signature. If we have already written * the magic bytes of the signature, or more likely, the PNG stream is * being embedded into another stream and doesn't need its own signature, @@ -87,10 +91,10 @@ * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() * functions instead. */ void PNGAPI -png_write_chunk(png_structp png_ptr, png_bytep chunk_name, - png_bytep data, png_size_t length) +png_write_chunk(png_structp png_ptr, png_const_bytep chunk_name, + png_const_bytep data, png_size_t length) { if (png_ptr == NULL) return; png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); @@ -102,9 +106,9 @@ * The total_length is the sum of the lengths of all the data you will be * passing in png_write_chunk_data(). */ void PNGAPI -png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, +png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_name, png_uint_32 length) { png_byte buf[8]; @@ -144,9 +148,10 @@ * sum of the lengths from these calls *must* add up to the total_length * given to png_write_chunk_start(). */ void PNGAPI -png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) +png_write_chunk_data(png_structp png_ptr, png_const_bytep data, + png_size_t length) { /* Write the data, and run the CRC over it */ if (png_ptr == NULL) return; @@ -189,19 +195,19 @@ */ typedef struct { - char *input; /* The uncompressed input data */ + png_const_bytep input; /* The uncompressed input data */ int input_len; /* Its length */ int num_output_ptr; /* Number of output pointers used */ int max_output_ptr; /* Size of output_ptr */ - png_charpp output_ptr; /* Array of pointers to output */ + png_bytep *output_ptr; /* Array of pointers to output */ } compression_state; /* Compress given text into storage in the png_ptr structure */ static int /* PRIVATE */ png_text_compress(png_structp png_ptr, - png_charp text, png_size_t text_len, int compression, + png_const_charp text, png_size_t text_len, int compression, compression_state *comp) { int ret; @@ -213,16 +219,16 @@ /* We may just want to pass the text right through */ if (compression == PNG_TEXT_COMPRESSION_NONE) { - comp->input = text; + comp->input = (png_const_bytep)text; comp->input_len = text_len; return((int)text_len); } if (compression >= PNG_TEXT_COMPRESSION_LAST) { -#ifdef PNG_STDIO_SUPPORTED +#ifdef PNG_CONSOLE_IO_SUPPORTED char msg[50]; png_snprintf(msg, 50, "Unknown compression type %d", compression); png_warning(png_ptr, msg); #else @@ -275,27 +283,27 @@ old_max = comp->max_output_ptr; comp->max_output_ptr = comp->num_output_ptr + 4; if (comp->output_ptr != NULL) { - png_charpp old_ptr; + png_bytepp old_ptr; old_ptr = comp->output_ptr; - comp->output_ptr = (png_charpp)png_malloc(png_ptr, + comp->output_ptr = (png_bytepp)png_malloc(png_ptr, (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, + comp->output_ptr = (png_bytepp)png_malloc(png_ptr, (png_alloc_size_t) (comp->max_output_ptr * png_sizeof(png_charp))); } /* Save the data */ comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, + (png_bytep)png_malloc(png_ptr, (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++; @@ -326,13 +334,13 @@ old_max = comp->max_output_ptr; comp->max_output_ptr = comp->num_output_ptr + 4; if (comp->output_ptr != NULL) { - png_charpp old_ptr; + png_bytepp old_ptr; old_ptr = comp->output_ptr; /* This could be optimized to realloc() */ - comp->output_ptr = (png_charpp)png_malloc(png_ptr, + comp->output_ptr = (png_bytepp)png_malloc(png_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)); @@ -337,20 +345,23 @@ 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, + comp->output_ptr = (png_bytepp)png_malloc(png_ptr, (png_alloc_size_t)(comp->max_output_ptr * png_sizeof(png_charp))); } /* Save the data */ comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, + (png_bytep)png_malloc(png_ptr, (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 pointers */ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; @@ -383,18 +395,19 @@ /* Handle the no-compression case */ if (comp->input) { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, - (png_size_t)comp->input_len); + png_write_chunk_data(png_ptr, comp->input, (png_size_t)comp->input_len); + return; } /* 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_write_chunk_data(png_ptr, comp->output_ptr[i], (png_size_t)png_ptr->zbuf_size); + png_free(png_ptr, comp->output_ptr[i]); } if (comp->max_output_ptr != 0) png_free(png_ptr, comp->output_ptr); @@ -434,18 +448,23 @@ case 1: case 2: case 4: case 8: - case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr, + case 16: + png_ptr->channels = 1; break; + default: + png_error(png_ptr, "Invalid bit depth for grayscale image"); } break; + case PNG_COLOR_TYPE_RGB: if (bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth for RGB image"); + png_ptr->channels = 3; break; + case PNG_COLOR_TYPE_PALETTE: switch (bit_depth) { case 1: @@ -450,22 +469,30 @@ { case 1: case 2: case 4: - case 8: png_ptr->channels = 1; break; - default: png_error(png_ptr, "Invalid bit depth for paletted image"); + case 8: + png_ptr->channels = 1; + break; + default: + png_error(png_ptr, "Invalid bit depth for paletted image"); } break; + case PNG_COLOR_TYPE_GRAY_ALPHA: if (bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); + png_ptr->channels = 2; break; + case PNG_COLOR_TYPE_RGB_ALPHA: if (bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth for RGBA image"); + png_ptr->channels = 4; break; + default: png_error(png_ptr, "Invalid image color type specified"); } @@ -536,9 +563,9 @@ buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; /* Write the chunk */ - png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); + png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); /* Initialize zlib with PNG info */ png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; @@ -559,27 +589,39 @@ png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY; } if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL)) png_ptr->zlib_level = Z_DEFAULT_COMPRESSION; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL)) png_ptr->zlib_mem_level = 8; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS)) png_ptr->zlib_window_bits = 15; + if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD)) png_ptr->zlib_method = 8; + ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level, png_ptr->zlib_method, png_ptr->zlib_window_bits, png_ptr->zlib_mem_level, png_ptr->zlib_strategy); + if (ret != Z_OK) { - if (ret == Z_VERSION_ERROR) png_error(png_ptr, + if (ret == Z_VERSION_ERROR) + png_error(png_ptr, "zlib failed to initialize compressor -- version error"); - if (ret == Z_STREAM_ERROR) png_error(png_ptr, + + if (ret == Z_STREAM_ERROR) + png_error(png_ptr, "zlib failed to initialize compressor -- stream error"); - if (ret == Z_MEM_ERROR) png_error(png_ptr, + + if (ret == Z_MEM_ERROR) + png_error(png_ptr, "zlib failed to initialize compressor -- mem error"); + png_error(png_ptr, "zlib failed to initialize compressor"); } + png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; /* libpng is not interested in zstream.data_type */ /* Set it to a predefined value, to avoid its evaluation inside zlib */ @@ -592,13 +634,14 @@ * correct order for PNG, so people can redefine it to any convenient * structure. */ void /* PRIVATE */ -png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) +png_write_PLTE(png_structp png_ptr, png_const_colorp palette, + png_uint_32 num_pal) { PNG_PLTE; png_uint_32 i; - png_colorp pal_ptr; + png_const_colorp pal_ptr; png_byte buf[3]; png_debug(1, "in png_write_PLTE"); @@ -628,11 +673,11 @@ png_ptr->num_palette = (png_uint_16)num_pal; png_debug1(3, "num_palette = %d", png_ptr->num_palette); - png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, - (png_uint_32)(num_pal * 3)); + png_write_chunk_start(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); #ifdef PNG_POINTER_INDEXING_SUPPORTED + for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) { buf[0] = pal_ptr->red; buf[1] = pal_ptr->green; @@ -704,9 +753,9 @@ png_error(png_ptr, "Invalid zlib compression method or flags in IDAT"); } - png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); + png_write_chunk(png_ptr, png_IDAT, data, length); png_ptr->mode |= PNG_HAVE_IDAT; } /* Write an IEND chunk */ @@ -716,32 +765,14 @@ PNG_IEND; png_debug(1, "in png_write_IEND"); - png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, - (png_size_t)0); + png_write_chunk(png_ptr, png_IEND, NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } #ifdef PNG_WRITE_gAMA_SUPPORTED /* Write a gAMA chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_gAMA(png_structp png_ptr, double file_gamma) -{ - PNG_gAMA; - png_uint_32 igamma; - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA"); - - /* file_gamma is saved in 1/100,000ths */ - igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); - png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) { PNG_gAMA; @@ -750,12 +781,11 @@ png_debug(1, "in png_write_gAMA"); /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); } #endif -#endif #ifdef PNG_WRITE_sRGB_SUPPORTED /* Write a sRGB chunk */ void /* PRIVATE */ @@ -768,18 +798,19 @@ if (srgb_intent >= PNG_sRGB_INTENT_LAST) png_warning(png_ptr, "Invalid sRGB rendering intent specified"); + buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); + png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); } #endif #ifdef PNG_WRITE_iCCP_SUPPORTED /* 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) +png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type, + png_const_charp profile, int profile_len) { PNG_iCCP; png_size_t name_len; png_charp new_name; @@ -793,10 +824,9 @@ comp.output_ptr = NULL; comp.input = NULL; comp.input_len = 0; - if ((name_len = png_check_keyword(png_ptr, name, - &new_name)) == 0) + if ((name_len = png_check_keyword(png_ptr, name, &new_name)) == 0) return; if (compression_type != PNG_COMPRESSION_TYPE_BASE) png_warning(png_ptr, "Unknown compression type in iCCP chunk"); @@ -805,12 +835,12 @@ profile_len = 0; if (profile_len > 3) embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile + 1))<<16) | - ((*( (png_bytep)profile + 2))<< 8) | - ((*( (png_bytep)profile + 3)) ); + ((*( (png_const_bytep)profile ))<<24) | + ((*( (png_const_bytep)profile + 1))<<16) | + ((*( (png_const_bytep)profile + 2))<< 8) | + ((*( (png_const_bytep)profile + 3)) ); if (embedded_profile_len < 0) { png_warning(png_ptr, @@ -838,11 +868,13 @@ profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp); /* Make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, + png_write_chunk_start(png_ptr, png_iCCP, (png_uint_32)(name_len + profile_len + 2)); + new_name[name_len + 1] = 0x00; + png_write_chunk_data(png_ptr, (png_bytep)new_name, (png_size_t)(name_len + 2)); if (profile_len) @@ -855,9 +887,9 @@ #ifdef PNG_WRITE_sPLT_SUPPORTED /* Write a sPLT chunk */ void /* PRIVATE */ -png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) +png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette) { PNG_sPLT; png_size_t name_len; png_charp new_name; @@ -874,13 +906,15 @@ if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0) return; /* Make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, + png_write_chunk_start(png_ptr, 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); + + png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1); /* Loop through each palette entry, writing appropriately */ #ifdef PNG_POINTER_INDEXING_SUPPORTED for (ep = spalette->entries; epentries + spalette->nentries; ep++) @@ -934,9 +970,9 @@ #ifdef PNG_WRITE_sBIT_SUPPORTED /* Write the sBIT chunk */ void /* PRIVATE */ -png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) +png_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type) { PNG_sBIT; png_byte buf[4]; png_size_t size; @@ -982,61 +1021,14 @@ } buf[size++] = sbit->alpha; } - png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); + png_write_chunk(png_ptr, png_sBIT, buf, size); } #endif #ifdef PNG_WRITE_cHRM_SUPPORTED /* Write the cHRM chunk */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void /* PRIVATE */ -png_write_cHRM(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) -{ - PNG_cHRM; - png_byte buf[32]; - - png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, - int_green_x, int_green_y, int_blue_x, int_blue_y; - - png_debug(1, "in png_write_cHRM"); - - int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5); - int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5); - int_red_x = (png_uint_32)(red_x * 100000.0 + 0.5); - int_red_y = (png_uint_32)(red_y * 100000.0 + 0.5); - int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5); - int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5); - int_blue_x = (png_uint_32)(blue_x * 100000.0 + 0.5); - int_blue_y = (png_uint_32)(blue_y * 100000.0 + 0.5); - -#ifdef PNG_CHECK_cHRM_SUPPORTED - if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y, - int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)) -#endif - { - /* Each value is saved in 1/100,000ths */ - - png_save_uint_32(buf, int_white_x); - png_save_uint_32(buf + 4, int_white_y); - - png_save_uint_32(buf + 8, int_red_x); - png_save_uint_32(buf + 12, int_red_y); - - png_save_uint_32(buf + 16, int_green_x); - png_save_uint_32(buf + 20, int_green_y); - - png_save_uint_32(buf + 24, int_blue_x); - png_save_uint_32(buf + 28, int_blue_y); - - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); - } -} -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, @@ -1064,19 +1056,18 @@ png_save_uint_32(buf + 24, (png_uint_32)blue_x); png_save_uint_32(buf + 28, (png_uint_32)blue_y); - png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); + png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); } } #endif -#endif #ifdef PNG_WRITE_tRNS_SUPPORTED /* Write the tRNS chunk */ void /* PRIVATE */ -png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran, - int num_trans, int color_type) +png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha, + png_const_color_16p tran, int num_trans, int color_type) { PNG_tRNS; png_byte buf[6]; @@ -1088,12 +1079,13 @@ { png_warning(png_ptr, "Invalid number of transparent colors specified"); return; } + /* Write the chunk out as it is */ - png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans_alpha, - (png_size_t)num_trans); + png_write_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans); } + else if (color_type == PNG_COLOR_TYPE_GRAY) { /* One 16 bit value */ if (tran->gray >= (1 << png_ptr->bit_depth)) @@ -1102,10 +1094,11 @@ "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); return; } png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); + png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); } + else if (color_type == PNG_COLOR_TYPE_RGB) { /* Three 16 bit values */ png_save_uint_16(buf, tran->red); @@ -1116,10 +1109,11 @@ png_warning(png_ptr, "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); return; } - png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); + png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); } + else { png_warning(png_ptr, "Can't write tRNS with an alpha channel"); } @@ -1128,9 +1122,9 @@ #ifdef PNG_WRITE_bKGD_SUPPORTED /* Write the background chunk */ void /* PRIVATE */ -png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) +png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type) { PNG_bKGD; png_byte buf[6]; @@ -1147,11 +1141,13 @@ { png_warning(png_ptr, "Invalid background palette index"); return; } + buf[0] = back->index; - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); + png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); } + else if (color_type & PNG_COLOR_MASK_COLOR) { png_save_uint_16(buf, back->red); png_save_uint_16(buf + 2, back->green); @@ -1159,12 +1155,14 @@ if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) { png_warning(png_ptr, "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + return; } - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); + png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); } + else { if (back->gray >= (1 << png_ptr->bit_depth)) { @@ -1169,20 +1167,21 @@ if (back->gray >= (1 << png_ptr->bit_depth)) { png_warning(png_ptr, "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); + return; } png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); + png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); } } #endif #ifdef PNG_WRITE_hIST_SUPPORTED /* Write the histogram */ void /* PRIVATE */ -png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) +png_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist) { PNG_hIST; int i; png_byte buf[3]; @@ -1196,10 +1196,9 @@ png_warning(png_ptr, "Invalid number of histogram entries specified"); return; } - png_write_chunk_start(png_ptr, (png_bytep)png_hIST, - (png_uint_32)(num_hist * 2)); + png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); for (i = 0; i < num_hist; i++) { png_save_uint_16(buf, hist[i]); png_write_chunk_data(png_ptr, buf, (png_size_t)2); @@ -1220,11 +1219,12 @@ * by the calling routine. This avoids problems with trying to write to * static keywords without having to have duplicate copies of the strings. */ png_size_t /* PRIVATE */ -png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) +png_check_keyword(png_structp png_ptr, png_const_charp key, png_charpp new_key) { png_size_t key_len; + png_const_charp ikp; png_charp kp, dp; int kflag; int kwarn=0; @@ -1247,18 +1248,18 @@ return ((png_size_t)0); } /* Replace non-printing characters with a blank and print a warning */ - for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) + for (ikp = key, dp = *new_key; *ikp != '\0'; ikp++, dp++) { - if ((png_byte)*kp < 0x20 || - ((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1)) + if ((png_byte)*ikp < 0x20 || + ((png_byte)*ikp > 0x7E && (png_byte)*ikp < 0xA1)) { -#ifdef PNG_STDIO_SUPPORTED +#ifdef PNG_CONSOLE_IO_SUPPORTED char msg[40]; png_snprintf(msg, 40, - "invalid keyword character 0x%02X", (png_byte)*kp); + "invalid keyword character 0x%02X", (png_byte)*ikp); png_warning(png_ptr, msg); #else png_warning(png_ptr, "invalid character in keyword"); #endif @@ -1263,11 +1264,12 @@ png_warning(png_ptr, "invalid character in keyword"); #endif *dp = ' '; } + else { - *dp = *kp; + *dp = *ikp; } } *dp = '\0'; @@ -1341,9 +1345,9 @@ #ifdef PNG_WRITE_tEXt_SUPPORTED /* Write a tEXt chunk */ void /* PRIVATE */ -png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, +png_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len) { PNG_tEXt; png_size_t key_len; @@ -1359,9 +1364,9 @@ else text_len = png_strlen(text); /* Make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, + png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)(key_len + text_len + 1)); /* * 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 @@ -1369,10 +1374,12 @@ * 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)); + if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len); + png_write_chunk_data(png_ptr, (png_const_bytep)text, + (png_size_t)text_len); png_write_chunk_end(png_ptr); png_free(png_ptr, new_key); } @@ -1380,14 +1387,14 @@ #ifdef PNG_WRITE_zTXt_SUPPORTED /* Write a compressed text chunk */ void /* PRIVATE */ -png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, +png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text, png_size_t text_len, int compression) { PNG_zTXt; png_size_t key_len; - char buf[1]; + png_byte buf; png_charp new_key; compression_state comp; png_debug(1, "in png_write_zTXt"); @@ -1417,18 +1424,22 @@ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp); /* Write start of chunk */ - png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, + png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32)(key_len+text_len + 2)); + /* 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; + buf = (png_byte)compression; + /* Write compression */ - png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); + png_write_chunk_data(png_ptr, &buf, (png_size_t)1); + /* Write the compressed data */ png_write_compressed_data_out(png_ptr, &comp); /* Close the chunk */ @@ -1438,10 +1449,10 @@ #ifdef PNG_WRITE_iTXt_SUPPORTED /* 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) +png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key, + png_const_charp lang, png_const_charp lang_key, png_const_charp text) { PNG_iTXt; png_size_t lang_len, key_len, lang_key_len, text_len; png_charp new_lang; @@ -1483,10 +1496,9 @@ /* 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)( + png_write_chunk_start(png_ptr, png_iTXt, (png_uint_32)( 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ + key_len + lang_len + lang_key_len @@ -1496,29 +1508,34 @@ * 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)); + png_write_chunk_data(png_ptr, (png_bytep)new_key, (png_size_t)(key_len + 1)); /* Set the compression flag */ - if (compression == PNG_ITXT_COMPRESSION_NONE || \ + 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 */ cbuf[1] = 0; + png_write_chunk_data(png_ptr, cbuf, (png_size_t)2); cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), + png_write_chunk_data(png_ptr, (new_lang ? (png_const_bytep)new_lang : cbuf), (png_size_t)(lang_len + 1)); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), + + png_write_chunk_data(png_ptr, (lang_key ? (png_const_bytep)lang_key : cbuf), (png_size_t)(lang_key_len + 1)); + png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); + png_free(png_ptr, new_key); png_free(png_ptr, new_lang); } #endif @@ -1540,16 +1557,17 @@ png_save_int_32(buf, x_offset); png_save_int_32(buf + 4, y_offset); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); + png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); } #endif #ifdef PNG_WRITE_pCAL_SUPPORTED /* 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) + png_int_32 X1, int type, int nparams, png_const_charp units, + png_charpp params) { PNG_pCAL; png_size_t purpose_len, units_len, total_len; png_uint_32p params_len; @@ -1571,9 +1589,10 @@ params_len = (png_uint_32p)png_malloc(png_ptr, (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. */ + * null terminator for the last parameter. + */ for (i = 0; i < nparams; i++) { params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); png_debug2(3, "pCAL parameter %d length = %lu", i, @@ -1581,23 +1600,23 @@ total_len += (png_size_t)params_len[i]; } png_debug1(3, "pCAL total length = %d", (int)total_len); - png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, + png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_const_bytep)new_purpose, (png_size_t)purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf + 4, X1); buf[8] = (png_byte)type; buf[9] = (png_byte)nparams; png_write_chunk_data(png_ptr, buf, (png_size_t)10); - png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len); + png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len); png_free(png_ptr, new_purpose); for (i = 0; i < nparams; i++) { - png_write_chunk_data(png_ptr, (png_bytep)params[i], + png_write_chunk_data(png_ptr, (png_const_bytep)params[i], (png_size_t)params_len[i]); } png_free(png_ptr, params_len); @@ -1606,32 +1625,11 @@ #endif #ifdef PNG_WRITE_sCAL_SUPPORTED /* Write the sCAL chunk */ -#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) -void /* PRIVATE */ -png_write_sCAL(png_structp png_ptr, int unit, double width, double height) -{ - PNG_sCAL; - char buf[64]; - png_size_t total_len; - - png_debug(1, "in png_write_sCAL"); - - buf[0] = (char)unit; - 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); - - 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); -} -#else -#ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ -png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, - png_charp height) +png_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width, + png_const_charp height) { PNG_sCAL; png_byte buf[64]; png_size_t wlen, hlen, total_len; @@ -1651,13 +1650,11 @@ png_memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ png_memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); - png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); + png_write_chunk(png_ptr, png_sCAL, buf, total_len); } #endif -#endif -#endif #ifdef PNG_WRITE_pHYs_SUPPORTED /* Write the pHYs chunk */ void /* PRIVATE */ @@ -1676,18 +1673,18 @@ png_save_uint_32(buf, x_pixels_per_unit); png_save_uint_32(buf + 4, y_pixels_per_unit); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); + png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); } #endif #ifdef PNG_WRITE_tIME_SUPPORTED /* Write the tIME chunk. Use either png_convert_from_struct_tm() * or png_convert_from_time_t(), or fill in the structure yourself. */ void /* PRIVATE */ -png_write_tIME(png_structp png_ptr, png_timep mod_time) +png_write_tIME(png_structp png_ptr, png_const_timep mod_time) { PNG_tIME; png_byte buf[7]; @@ -1707,9 +1704,9 @@ buf[4] = mod_time->hour; buf[5] = mod_time->minute; buf[6] = mod_time->second; - png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); + png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7); } #endif /* Initializes the row writing capability of libpng */ @@ -2059,10 +2079,10 @@ /* Start at the beginning */ dp = row; /* 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 - matter */ + + /* 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 */ @@ -2152,10 +2174,9 @@ /* We don't need to test the 'no filter' case if this is the only filter * that has been chosen, as it doesn't actually do anything to the data. */ - if ((filter_to_do & PNG_FILTER_NONE) && - filter_to_do != PNG_FILTER_NONE) + if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE) { png_bytep rp; png_uint_32 sum = 0; png_uint_32 i; diff -ru4NwbB libpng-1.4.3/projects/visualc6/README.txt libpng-1.5.0beta42/projects/visualc6/README.txt --- libpng-1.4.3/projects/visualc6/README.txt 2010-06-25 19:32:28.317645029 -0500 +++ libpng-1.5.0beta42/projects/visualc6/README.txt 1969-12-31 18:00:00.000000000 -0600 @@ -1,57 +0,0 @@ -Microsoft Developer Studio Project File, Format Version 6.00 for libpng. - -Copyright (C) 2000-2004 Simon-Pierre Cadieux. -Copyright (C) 2004 Cosmin Truta. - -This code is released under the libpng license. -For conditions of distribution and use, see copyright notice in png.h - -NOTE: This project will be removed from libpng-1.5.0. It has -been replaced with the "vstudio" project. - -Assumptions: -* The libpng source files are in ..\.. -* The zlib source files are in ..\..\..\zlib -* The zlib project files are in ..\..\..\zlib\projects\visualc6 - - -To use: - -1) On the main menu, select "File | Open Workspace". - Open "libpng.dsw". - -2) Select "Build | Set Active Configuration". - Choose the configuration you wish to build. - (Choose libpng or pngtest; zlib will be built automatically.) - -3) Select "Build | Clean". - -4) Select "Build | Build ... (F7)". Ignore warning messages about - not being able to find certain include files (e.g. alloc.h). - -5) If you built the sample program (pngtest), - select "Build | Execute ... (Ctrl+F5)". - - -This project builds the libpng binaries as follows: - -* Win32_DLL_Release\libpng14.dll DLL build -* Win32_DLL_Debug\libpng14d.dll DLL build (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) - - -Notes: - -If you change anything in the source files, or select different compiler -settings, please change the DLL name to something different than any of -the above names. Also, make sure that in your "pngusr.h" you define -PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the -instructions provided in "pngconf.h". - -All DLLs built by this project use the Microsoft dynamic C runtime library -MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the -above mentioned libraries you should also include this DLL in your package. -For a list of files that are redistributable in Visual C++ 6.0, see -Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. diff -ru4NwbB libpng-1.4.3/projects/visualc6/libpng.dsp libpng-1.5.0beta42/projects/visualc6/libpng.dsp --- libpng-1.4.3/projects/visualc6/libpng.dsp 2010-06-25 19:32:28.327786662 -0500 +++ libpng-1.5.0beta42/projects/visualc6/libpng.dsp 1969-12-31 18:00:00.000000000 -0600 @@ -1,328 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libpng - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpng - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 DLL VB" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpng - Win32 LIB Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# 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" /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 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" -BSC32=bscmake.exe -# 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\libpng14.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# 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_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 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "_DEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "PNG_NO_PEDANTIC_WARNINGS" /d "_DEBUG" /d PNG_DEBUG=1 -BSC32=bscmake.exe -# 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\libpng14d.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_DLL_VB" -# PROP BASE Intermediate_Dir "libpng___Win32_DLL_VB" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_VB" -# PROP Intermediate_Dir "Win32_DLL_VB" -# PROP Ignore_Export_Lib 0 -# 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" /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 -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" /dPNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /dPNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions"""" -BSC32=bscmake.exe -# 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\libpng14vb.dll" /libpath:"..\..\..\zlib\projects\visualc6\Win32_DLL_Release" -# Begin Special Build Tool -OutDir=.\Win32_DLL_VB -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 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpng___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# 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" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" -# ADD RSC /l 0x409 /i "..\.." /d "PNG_NO_PEDANTIC_WARNINGS" /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "libpng___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# 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 /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -RSC=rc.exe -# ADD BASE RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "_DEBUG" -# ADD RSC /l 0x409 /d "PNG_NO_PEDANTIC_WARNINGS" /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"Win32_LIB_Debug\libpngd.lib" - -!ENDIF - -# Begin Target - -# Name "libpng - Win32 DLL Release" -# Name "libpng - Win32 DLL Debug" -# Name "libpng - Win32 DLL VB" -# Name "libpng - Win32 LIB Release" -# Name "libpng - Win32 LIB Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\png.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngerror.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngget.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngmem.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngpread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngread.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngrutil.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngset.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngtrans.c -# End Source File -# Begin Source File - -SOURCE=..\..\scripts\pngwin.def - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL 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 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\..\pngwio.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwrite.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwtran.c -# End Source File -# Begin Source File - -SOURCE=..\..\pngwutil.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\png.h -# End Source File -# 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\pngwin.rc - -!IF "$(CFG)" == "libpng - Win32 DLL Release" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" - -!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB" - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release" - -# PROP Exclude_From_Build 1 - -!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# End Group -# Begin Source File - -SOURCE=.\README.txt -# End Source File -# End Target -# End Project diff -ru4NwbB libpng-1.4.3/projects/visualc6/libpng.dsw libpng-1.5.0beta42/projects/visualc6/libpng.dsw --- libpng-1.4.3/projects/visualc6/libpng.dsw 2006-02-21 13:32:54.000000000 -0600 +++ libpng-1.5.0beta42/projects/visualc6/libpng.dsw 1969-12-31 18:00:00.000000000 -0600 @@ -1,59 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libpng"=".\libpng.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "pngtest"=".\pngtest.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libpng - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"="..\..\..\zlib\projects\visualc6\zlib.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff -ru4NwbB libpng-1.4.3/projects/visualc6/pngtest.dsp libpng-1.5.0beta42/projects/visualc6/pngtest.dsp --- libpng-1.4.3/projects/visualc6/pngtest.dsp 2010-06-25 19:32:28.337140486 -0500 +++ libpng-1.5.0beta42/projects/visualc6/pngtest.dsp 1969-12-31 18:00:00.000000000 -0600 @@ -1,178 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=pngtest - Win32 DLL Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 DLL Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pngtest - Win32 DLL Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 DLL Debug" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Release" (based on "Win32 (x86) Console Application") -!MESSAGE "pngtest - Win32 LIB Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pngtest - Win32 DLL Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_DLL_Release" -# PROP Intermediate_Dir "Win32_DLL_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /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] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Release; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 DLL Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_DLL_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_DLL_Debug" -# PROP Intermediate_Dir "Win32_DLL_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "PNG_DLL" /D "PNG_NO_STDIO" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# 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\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] -PostBuild_Cmds=set path=$(outdir);..\..\..\zlib\projects\visualc6\Win32_DLL_Debug; $(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Win32_LIB_Release" -# PROP Intermediate_Dir "Win32_LIB_Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 -# ADD LINK32 Win32_LIB_Release\libpng.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Release\zlib.lib /nologo /subsystem:console /machine:I386 -# Begin Special Build Tool -OutDir=.\Win32_LIB_Release -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ELSEIF "$(CFG)" == "pngtest - Win32 LIB Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Intermediate_Dir "pngtest___Win32_LIB_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Win32_LIB_Debug" -# PROP Intermediate_Dir "Win32_LIB_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT BASE CPP /YX -# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Win32_LIB_Debug\libpngd.lib ..\..\..\zlib\projects\visualc6\Win32_LIB_Debug\zlibd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -OutDir=.\Win32_LIB_Debug -SOURCE="$(InputPath)" -PostBuild_Desc=[Run Test] -PostBuild_Cmds=$(outdir)\pngtest.exe ..\..\pngtest.png -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "pngtest - Win32 DLL Release" -# Name "pngtest - Win32 DLL Debug" -# Name "pngtest - Win32 LIB Release" -# Name "pngtest - Win32 LIB Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\pngtest.c -# End Source File -# End Group -# End Target -# End Project diff -ru4NwbB libpng-1.4.3/projects/visualc71/README.txt libpng-1.5.0beta42/projects/visualc71/README.txt --- libpng-1.4.3/projects/visualc71/README.txt 2010-04-26 16:13:45.383523000 -0500 +++ libpng-1.5.0beta42/projects/visualc71/README.txt 2010-07-31 07:52:59.036528000 -0500 @@ -36,11 +36,11 @@ 6) Select "Build | Build Solution (Ctrl-Shift-B)" This project builds the libpng binaries as follows: -* Win32_DLL_Release\libpng%DLLNUM%.dll DLL build -* Win32_DLL_Debug\libpng%DLLNUM%d.dll DLL build (debug version) -* Win32_DLL_VB\libpng%DLLNUM%vb.dll DLL build for Visual Basic, using stdcall +* Win32_DLL_Release\libpng%NN%.dll DLL build +* Win32_DLL_Debug\libpng%NN%d.dll DLL build (debug version) +* Win32_DLL_VB\libpng%NN%vb.dll DLL build for Visual Basic, using stdcall * Win32_LIB_Release\libpng.lib static build * Win32_LIB_Debug\libpngd.lib static build (debug version) Notes: diff -ru4NwbB libpng-1.4.3/projects/visualc71/libpng.vcproj libpng-1.5.0beta42/projects/visualc71/libpng.vcproj --- libpng-1.4.3/projects/visualc71/libpng.vcproj 2009-12-04 07:53:56.000000000 -0600 +++ libpng-1.5.0beta42/projects/visualc71/libpng.vcproj 2010-07-30 23:23:56.000000000 -0500 @@ -16,22 +16,22 @@ ConfigurationType="2"> @@ -44,9 +44,9 @@ + AdditionalIncludeDirectories="..\..;..\..\scripts;..\..\..\zlib;$(IntDir)"/> @@ -64,22 +64,22 @@ ConfigurationType="2"> @@ -92,9 +92,9 @@ + AdditionalIncludeDirectories="..\..;..\..\scripts;..\..\..\zlib;$(IntDir)"/> @@ -112,22 +112,22 @@ ConfigurationType="2"> + AdditionalIncludeDirectories="..\..;..\..\scripts;..\..\..\zlib;$(IntDir)"/> @@ -160,15 +160,15 @@ ConfigurationType="4"> @@ -201,14 +201,14 @@ ConfigurationType="4"> @@ -161,12 +161,12 @@ ConfigurationType="1"> + RelativePath="..\..\..\zlib\gzlib.c"> + + + + + + diff -ru4NwbB libpng-1.4.3/projects/vstudio/libpng/libpng.vcxproj libpng-1.5.0beta42/projects/vstudio/libpng/libpng.vcxproj --- libpng-1.4.3/projects/vstudio/libpng/libpng.vcxproj 2010-04-26 16:12:01.929524000 -0500 +++ libpng-1.5.0beta42/projects/vstudio/libpng/libpng.vcxproj 2010-08-18 08:12:23.719781608 -0500 @@ -62,40 +62,39 @@ false - $(ProjectName)14 + $(ProjectName)15 false - $(ProjectName)14 + $(ProjectName)15 false - $(ProjectName)14 + $(ProjectName)15 false - $(ProjectName)14 + $(ProjectName)15 - NotUsing + Use Level4 false ProgramDatabase EnableFastChecks - MultiThreadedDebugDLL - WIN32;PNG_BUILD_DLL;PNG_NO_MODULEDEF;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true false false - png.h + pngpriv.h true CompileAsC true 4996;4127 @@ -105,35 +104,34 @@ Windows true - zlib.lib;msvcrtd.lib;kernel32.lib - true - 14 + zlib.lib + 15 $(OutDir) - NotUsing + Use Level4 false ProgramDatabase Disabled EnableFastChecks - MultiThreadedDebugDLL WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true false false - png.h + pngpriv.h true CompileAsC true 4996;4127 $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) true + MultiThreadedDebug Windows true @@ -141,64 +139,66 @@ Level4 - NotUsing + Use ProgramDatabase - MultiThreadedDLL true true - WIN32;PNG_BUILD_DLL;PNG_NO_MODULEDEF;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) false false - png.h + pngpriv.h true CompileAsC true false 4996;4127 - $(ZLib1Dir);..\..\..\scripts;%(AdditionalIncludeDirectories) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) true Full Windows true true true - zdll.lib;msvcrt.lib;kernel32.lib - true - 14 - $(ZLib1Dir) + zlib.lib + 15 + $(OutDir) Level4 - NotUsing + Use ProgramDatabase - MultiThreadedDLL + MultiThreaded true true WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) false false - png.h + pngpriv.h true CompileAsC true false 4996;4127 - $(ZLib1Dir);..\..\..\scripts;%(AdditionalIncludeDirectories) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) true Full + true Windows true true true + + true + Create diff -ru4NwbB libpng-1.4.3/projects/vstudio/pngtest/pngtest.vcxproj libpng-1.5.0beta42/projects/vstudio/pngtest/pngtest.vcxproj --- libpng-1.4.3/projects/vstudio/pngtest/pngtest.vcxproj 2010-04-26 11:42:27.000000000 -0500 +++ libpng-1.5.0beta42/projects/vstudio/pngtest/pngtest.vcxproj 2010-08-18 08:12:23.730027646 -0500 @@ -80,9 +80,8 @@ false ProgramDatabase Disabled EnableFastChecks - MultiThreadedDebugDLL WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996 false @@ -90,14 +89,14 @@ true true false true + false Console true - libpng14.lib;zlib.lib;msvcrtd.lib;kernel32.lib - true + libpng15.lib $(OutDir) Executing PNG test program @@ -113,9 +112,9 @@ false ProgramDatabase Disabled EnableFastChecks - MultiThreadedDebugDLL + MultiThreadedDebug WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996 false @@ -123,14 +122,14 @@ true true false true + false Console true - libpng14.lib;zlib.lib;msvcrtd.lib;kernel32.lib - true + libpng15.lib;zlib.lib $(OutDir) Executing PNG test program @@ -144,27 +143,28 @@ Level4 NotUsing ProgramDatabase Full - MultiThreadedDLL false true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(ZLib1Dir);..\..\..\scripts;%(AdditionalIncludeDirectories) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996 false true true false true + true + false Console true true true - libpng14.lib;msvcrt.lib;kernel32.lib - true + UseLinkTimeCodeGeneration + libpng15.lib $(OutDir) Executing PNG test program @@ -178,28 +178,30 @@ Level4 NotUsing ProgramDatabase Full - MultiThreadedDLL + MultiThreaded false true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(ZLib1Dir);..\..\..\scripts;%(AdditionalIncludeDirectories) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996 false true true false true + true + false Console true true true - libpng14.lib;zlib.lib;msvcrt.lib;kernel32.lib - true - $(OutDir);$(ZLib1Dir) + libpng15.lib;zlib.lib + UseLinkTimeCodeGeneration + $(OutDir) Executing PNG test program $(OutDir)pngtest.exe ..\..\..\pngtest.png $(IntDir)pngout.png diff -ru4NwbB libpng-1.4.3/projects/vstudio/pngvalid/pngvalid.vcxproj libpng-1.5.0beta42/projects/vstudio/pngvalid/pngvalid.vcxproj --- libpng-1.4.3/projects/vstudio/pngvalid/pngvalid.vcxproj 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/projects/vstudio/pngvalid/pngvalid.vcxproj 2010-08-02 07:13:20.439242000 -0500 @@ -0,0 +1,219 @@ + + + + + Debug Library + Win32 + + + Debug + Win32 + + + Release Library + Win32 + + + Release + Win32 + + + + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8} + Win32Proj + pngvalid + + + + + Application + Unicode + + + Application + Unicode + + + Application + Unicode + + + Application + Unicode + + + + + + + + + + + + + + + + + + + false + + + + false + + + + false + + + + false + + + + + NotUsing + Level4 + false + ProgramDatabase + Disabled + EnableFastChecks + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) + 4996 + false + true + true + true + false + true + false + + + Console + true + libpng15.lib;zlib.lib + $(OutDir) + + + Executing PNG validation program + "$(OutDir)pngvalid.exe" --touch "$(IntDir)pngvalid.out" + $(IntDir)pngvalid.out + $(OutDir)pngvalid.exe + + + + + NotUsing + Level4 + false + ProgramDatabase + Disabled + EnableFastChecks + MultiThreadedDebug + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) + 4996 + false + true + true + true + false + true + false + + + Console + true + libpng15.lib;zlib.lib + $(OutDir) + + + Executing PNG validation program + "$(OutDir)pngvalid.exe" --touch "$(IntDir)pngvalid.out" + $(IntDir)pngvalid.out + $(OutDir)pngvalid.exe + + + + + Level4 + NotUsing + ProgramDatabase + Full + false + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) + 4996 + false + true + true + false + true + true + false + + + Console + true + true + true + libpng15.lib;zlib.lib + $(OutDir) + UseLinkTimeCodeGeneration + + + Executing PNG validation program + "$(OutDir)pngvalid.exe" --touch "$(IntDir)pngvalid.out" + $(IntDir)pngvalid.out + $(OutDir)pngvalid.exe + + + + + Level4 + NotUsing + ProgramDatabase + Full + MultiThreaded + false + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) + 4996 + false + true + true + false + true + true + false + + + Console + true + true + true + libpng15.lib;zlib.lib + $(OutDir) + UseLinkTimeCodeGeneration + + + Executing PNG validation program + $(OutDir)pngvalid.exe ..\..\..\pngvalid.png $(IntDir)pngout.png + "$(OutDir)pngvalid.exe" --touch "$(IntDir)pngvalid.out" + $(IntDir)pngvalid.out + $(OutDir)pngvalid.exe + + + + + + + + + diff -ru4NwbB libpng-1.4.3/projects/vstudio/readme.txt libpng-1.5.0beta42/projects/vstudio/readme.txt --- libpng-1.4.3/projects/vstudio/readme.txt 2010-06-25 19:32:28.293894611 -0500 +++ libpng-1.5.0beta42/projects/vstudio/readme.txt 2010-08-18 08:12:23.700767912 -0500 @@ -12,31 +12,15 @@ This directory contains support for building libpng under MicroSoft VisualStudio 2010. It may also work under later versions of VisualStudio. You should be familiar with VisualStudio before using this directory. -This is a slightly modified copy of the 'vstudio' solution from libpng -1.5; it is intended to provide compatibility for libpng 1.4 with later -releases of zlib (from 1.2.4) and to provide a migration aid for 1.5. - -A 'VB' DLL is no longer produced - use the standard 'Release' DLL. - Initial preparations ==================== -You should install the 'official' build of zlib on your system - follow the -instructions provided on http://www.zlib.net. When a new release is being -made of zlib the instructions disappear for a while until the new official -build is available. You will have to wait. - You must enter some information in zlib.props before attempting to build with this 'solution'. Please read and edit zlib.props first. You will probably not be familiar with the contents of zlib.props - do not worry, it is mostly harmless. -Make sure that your official build layout matches the requirements listed -in zlib.props. Prior to zlib-1.2.4 the official build (1.2.3) placed -include and library files in different directories - if you find this -has happened just put them all in the same directory. - This is all you need to do to build the 'release' and 'release library' configurations. Debugging @@ -45,8 +29,27 @@ information is produced (in the .pdb), but if you encounter a problem the optimization may make it difficult to debug. Simply rebuild with a lower optimization level (e.g. /Od.) +Linking your application +======================== +Normally you should link against the 'release' configuration. This builds a +DLL for libpng 1.5 with the default runtime options used by Visual Studio +2010. In particular the runtime library is the "MultiThreaded DLL" version. +If you use Visual Studio defaults to build your application you will have no +problems. + +If you don't use the Visual Studio defaults your application must still be built +with the default runtime option (/MD). If, for some reason, it is not then your +application will crash inside libpng15.dll as soon as libpng tries to read +from a file handle you pass in. + +If you do not want to use the DLL, for example for a very small application, +the 'release library' configuration may be more appropriate. This is built +with a non-standard runtime library - the "MultiThreaded" version. When you +build your application it must be compiled with this option (/MT), otherwise +it will not build (if you are lucky) or crash (if you are not.) + Stop reading here ================= You have enough information to build a working application. @@ -56,38 +59,6 @@ do not need these unless your own solution itself uses debug builds (it is far more effective to debug on the release builds, there is no point building a special debug build.) -If, despite the previous paragraph, you still feel you need a debug build you -will have to download the zlib source as well (http://www.zlib.net) and include -the directory where you unpack it in zlib.props. This solution will then be -able to build a minimal zlib sufficient for libpng. This build is only -suitable for making a debug libpng. - The debug build of libpng is minimally supported. Support for debug builds of zlib is also minimal. You really don't want to do this. - -This solution only supports the Multi-Threaded DLL C Runtime -============================================================ -If you examine the solution you will find that it very deliberately lists -exactly which MicroSoft DLLs it is linking against. It explicitly links -against msvcrt.lib. The debug version links against msvcrtd.lib (this is -why it is a debug version - it's nothing to do with having any special -debug support, it doesn't). - -These versions of the MicroSoft C runtime correspond to the compiler flags -/MD (release) and /MDd (debug) - the "Multi-Threaded DLL" implementation of the -C runtime library. - -If you need to change this then you will have to make sure that both the -compiler flags and the ".lib" in the linker dependences match up. Fortunately -neither zlib nor libpng require libraries other than a C runtime and -kernel32. - -You cannot pass (FILE*) objects from a different runtime (including msvcrtd -to msvcrt) to libpng. If you do then your program will crash within libpng -when it first makes a file read or write call. - -It is likely if you have read this far that you have found you can't avoid -having multiple C runtimes in your program. This is OK, it does work, but -you will have to implement the libpng file read/write callbacks rather than -using the internal libpng default. This is easy. diff -ru4NwbB libpng-1.4.3/projects/vstudio/vstudio.sln libpng-1.5.0beta42/projects/vstudio/vstudio.sln --- libpng-1.4.3/projects/vstudio/vstudio.sln 2010-04-26 11:42:27.000000000 -0500 +++ libpng-1.5.0beta42/projects/vstudio/vstudio.sln 2010-08-02 07:13:20.467619000 -0500 @@ -1,17 +1,24 @@ Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 +# Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "libpng\libpng.vcxproj", "{D6973076-9317-4EF2-A0B8-B7A18AC0713E}" ProjectSection(ProjectDependencies) = postProject - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C} = {18040998-CC22-2BAE-FE7A-C0A3038F1D5C} + {64CE4900-97EA-2DD5-4226-F2E36FFF2867} = {64CE4900-97EA-2DD5-4226-F2E36FFF2867} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngtest", "pngtest\pngtest.vcxproj", "{228BA965-50D5-42B2-8BCF-AFCC227E3C1D}" ProjectSection(ProjectDependencies) = postProject + {64CE4900-97EA-2DD5-4226-F2E36FFF2867} = {64CE4900-97EA-2DD5-4226-F2E36FFF2867} {D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{18040998-CC22-2BAE-FE7A-C0A3038F1D5C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{64CE4900-97EA-2DD5-4226-F2E36FFF2867}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngvalid", "pngvalid\pngvalid.vcxproj", "{9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}" + ProjectSection(ProjectDependencies) = postProject + {64CE4900-97EA-2DD5-4226-F2E36FFF2867} = {64CE4900-97EA-2DD5-4226-F2E36FFF2867} + {D6973076-9317-4EF2-A0B8-B7A18AC0713E} = {D6973076-9317-4EF2-A0B8-B7A18AC0713E} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Library|Win32 = Debug Library|Win32 @@ -35,14 +42,24 @@ {228BA965-50D5-42B2-8BCF-AFCC227E3C1D}.Release Library|Win32.ActiveCfg = Release Library|Win32 {228BA965-50D5-42B2-8BCF-AFCC227E3C1D}.Release Library|Win32.Build.0 = Release Library|Win32 {228BA965-50D5-42B2-8BCF-AFCC227E3C1D}.Release|Win32.ActiveCfg = Release|Win32 {228BA965-50D5-42B2-8BCF-AFCC227E3C1D}.Release|Win32.Build.0 = Release|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Debug Library|Win32.ActiveCfg = Debug Library|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Debug Library|Win32.Build.0 = Debug Library|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Debug|Win32.ActiveCfg = Debug|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Debug|Win32.Build.0 = Debug|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Release Library|Win32.ActiveCfg = Debug|Win32 - {18040998-CC22-2BAE-FE7A-C0A3038F1D5C}.Release|Win32.ActiveCfg = Debug|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Debug Library|Win32.ActiveCfg = Debug Library|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Debug Library|Win32.Build.0 = Debug Library|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Debug|Win32.ActiveCfg = Debug|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Debug|Win32.Build.0 = Debug|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Release Library|Win32.ActiveCfg = Release Library|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Release Library|Win32.Build.0 = Release Library|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Release|Win32.ActiveCfg = Release|Win32 + {64CE4900-97EA-2DD5-4226-F2E36FFF2867}.Release|Win32.Build.0 = Release|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Debug Library|Win32.ActiveCfg = Debug Library|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Debug Library|Win32.Build.0 = Debug Library|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Debug|Win32.ActiveCfg = Debug|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Debug|Win32.Build.0 = Debug|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Release Library|Win32.ActiveCfg = Release Library|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Release Library|Win32.Build.0 = Release Library|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Release|Win32.ActiveCfg = Release|Win32 + {9B36B6FE-7FC0-434F-A71F-BBEF8099F1D8}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection diff -ru4NwbB libpng-1.4.3/projects/vstudio/zlib/zlib.vcxproj libpng-1.5.0beta42/projects/vstudio/zlib/zlib.vcxproj --- libpng-1.4.3/projects/vstudio/zlib/zlib.vcxproj 2010-04-26 11:42:26.000000000 -0500 +++ libpng-1.5.0beta42/projects/vstudio/zlib/zlib.vcxproj 2010-08-02 07:13:20.490220000 -0500 @@ -8,8 +8,16 @@ Debug Win32 + + Release Library + Win32 + + + Release + Win32 + @@ -27,75 +35,132 @@ Win32Proj + + StaticLibrary + - DynamicLibrary - true + StaticLibrary - + + StaticLibrary + + StaticLibrary - DynamicLibrary + StaticLibrary - - - + + + + + + + + + + + true + - false + true - + true true + + true + + + + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreadedDebug + TurnOffAllWarnings + ProgramDatabase + Disabled + true + + + MachineX86 + true + Windows + + - WIN32;ZLIB_DLL;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - Level3 + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + TurnOffAllWarnings ProgramDatabase Disabled + true + + + MachineX86 + true + Windows + + + + + Level3 + ProgramDatabase + Full true + true + false + true + true + true + MultiThreaded + MachineX86 true Windows - 1 - msvcrtd.lib;kernel32.lib - true + + true + - + - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - MultiThreadedDebugDLL Level3 ProgramDatabase - Disabled + Full + true + true + false + true + true + true MachineX86 true Windows + + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;DEBUGZLIB_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDLL Level3 ProgramDatabase diff -ru4NwbB libpng-1.4.3/projects/vstudio/zlib.props libpng-1.5.0beta42/projects/vstudio/zlib.props --- libpng-1.4.3/projects/vstudio/zlib.props 2010-06-25 19:32:28.302890901 -0500 +++ libpng-1.5.0beta42/projects/vstudio/zlib.props 2010-08-18 08:12:23.709455230 -0500 @@ -1,7 +1,7 @@ - + - - ..\..\..\..\zlib124-dll\zlib-1.2.4 - - ..\..\..\..\zlib-1.2.4 diff -ru4NwbB libpng-1.4.3/projects/xcode/Info.plist libpng-1.5.0beta42/projects/xcode/Info.plist --- libpng-1.4.3/projects/xcode/Info.plist 2009-07-05 13:05:07.000000000 -0500 +++ libpng-1.5.0beta42/projects/xcode/Info.plist 1969-12-31 18:00:00.000000000 -0600 @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - libpng - CFBundleIconFile - - CFBundleIdentifier - com.apple.carbonframeworktemplate - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleVersion - 1.0 - CFBundleShortVersionString - 1.0 - CSResourcesFileMapped - - - diff -ru4NwbB libpng-1.4.3/projects/xcode/README.txt libpng-1.5.0beta42/projects/xcode/README.txt --- libpng-1.4.3/projects/xcode/README.txt 2009-12-04 07:54:02.000000000 -0600 +++ libpng-1.5.0beta42/projects/xcode/README.txt 1969-12-31 18:00:00.000000000 -0600 @@ -1,9 +0,0 @@ -The xcode project has not been entirely updated to libpng-1.4.0. - -It needs to *not* depend on pnggccrd.c or pngvcrd.c - -It needs to PNG_NO_PEDANTIC_WARNINGS in the CFLAGS while building -the library, but not while building an application. - -If an updated version is not received, this project will -be removed when libpng-1.4.0 is released. diff -ru4NwbB libpng-1.4.3/projects/xcode/libpng.xcodeproj/.gitignore libpng-1.5.0beta42/projects/xcode/libpng.xcodeproj/.gitignore --- libpng-1.4.3/projects/xcode/libpng.xcodeproj/.gitignore 2009-10-05 12:08:58.000000000 -0500 +++ libpng-1.5.0beta42/projects/xcode/libpng.xcodeproj/.gitignore 1969-12-31 18:00:00.000000000 -0600 @@ -1,2 +0,0 @@ -*.mode1* -*.pbxuser diff -ru4NwbB libpng-1.4.3/projects/xcode/libpng.xcodeproj/project.pbxproj libpng-1.5.0beta42/projects/xcode/libpng.xcodeproj/project.pbxproj --- libpng-1.4.3/projects/xcode/libpng.xcodeproj/project.pbxproj 2010-06-25 19:32:27.287348886 -0500 +++ libpng-1.5.0beta42/projects/xcode/libpng.xcodeproj/project.pbxproj 1969-12-31 18:00:00.000000000 -0600 @@ -1,353 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXBuildFile section */ - 14461C7109C3C37F005840C0 /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C5D09C3C37F005840C0 /* png.c */; }; - 14461C7209C3C37F005840C0 /* png.h in Headers */ = {isa = PBXBuildFile; fileRef = 14461C5E09C3C37F005840C0 /* png.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 14461C7309C3C37F005840C0 /* pngconf.h in Headers */ = {isa = PBXBuildFile; fileRef = 14461C5F09C3C37F005840C0 /* pngconf.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 14461C7409C3C37F005840C0 /* pngerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6009C3C37F005840C0 /* pngerror.c */; }; - 14461C7509C3C37F005840C0 /* pnggccrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6109C3C37F005840C0 /* pnggccrd.c */; }; - 14461C7609C3C37F005840C0 /* pngget.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6209C3C37F005840C0 /* pngget.c */; }; - 14461C7709C3C37F005840C0 /* pngmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6309C3C37F005840C0 /* pngmem.c */; }; - 14461C7809C3C37F005840C0 /* pngpread.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6409C3C37F005840C0 /* pngpread.c */; }; - 14461C7909C3C37F005840C0 /* pngread.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6509C3C37F005840C0 /* pngread.c */; }; - 14461C7A09C3C37F005840C0 /* pngrio.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6609C3C37F005840C0 /* pngrio.c */; }; - 14461C7B09C3C37F005840C0 /* pngrtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6709C3C37F005840C0 /* pngrtran.c */; }; - 14461C7C09C3C37F005840C0 /* pngrutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6809C3C37F005840C0 /* pngrutil.c */; }; - 14461C7D09C3C37F005840C0 /* pngset.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6909C3C37F005840C0 /* pngset.c */; }; - 14461C7F09C3C37F005840C0 /* pngtrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6B09C3C37F005840C0 /* pngtrans.c */; }; - 14461C8009C3C37F005840C0 /* pngvcrd.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6C09C3C37F005840C0 /* pngvcrd.c */; }; - 14461C8109C3C37F005840C0 /* pngwio.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6D09C3C37F005840C0 /* pngwio.c */; }; - 14461C8209C3C37F005840C0 /* pngwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6E09C3C37F005840C0 /* pngwrite.c */; }; - 14461C8309C3C37F005840C0 /* pngwtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C6F09C3C37F005840C0 /* pngwtran.c */; }; - 14461C8409C3C37F005840C0 /* pngwutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 14461C7009C3C37F005840C0 /* pngwutil.c */; }; - 67FA470510693F6B0078FB9E /* pngpriv.h in Headers */ = {isa = PBXBuildFile; fileRef = 67FA470410693F6B0078FB9E /* pngpriv.h */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 14461C5D09C3C37F005840C0 /* png.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = png.c; path = ../../png.c; sourceTree = SOURCE_ROOT; }; - 14461C5E09C3C37F005840C0 /* png.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = png.h; path = ../../png.h; sourceTree = SOURCE_ROOT; }; - 14461C5F09C3C37F005840C0 /* pngconf.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pngconf.h; path = ../../pngconf.h; sourceTree = SOURCE_ROOT; }; - 14461C6009C3C37F005840C0 /* pngerror.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngerror.c; path = ../../pngerror.c; sourceTree = SOURCE_ROOT; }; - 14461C6109C3C37F005840C0 /* pnggccrd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pnggccrd.c; path = ../../pnggccrd.c; sourceTree = SOURCE_ROOT; }; - 14461C6209C3C37F005840C0 /* pngget.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngget.c; path = ../../pngget.c; sourceTree = SOURCE_ROOT; }; - 14461C6309C3C37F005840C0 /* pngmem.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngmem.c; path = ../../pngmem.c; sourceTree = SOURCE_ROOT; }; - 14461C6409C3C37F005840C0 /* pngpread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngpread.c; path = ../../pngpread.c; sourceTree = SOURCE_ROOT; }; - 14461C6509C3C37F005840C0 /* pngread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngread.c; path = ../../pngread.c; sourceTree = SOURCE_ROOT; }; - 14461C6609C3C37F005840C0 /* pngrio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrio.c; path = ../../pngrio.c; sourceTree = SOURCE_ROOT; }; - 14461C6709C3C37F005840C0 /* pngrtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrtran.c; path = ../../pngrtran.c; sourceTree = SOURCE_ROOT; }; - 14461C6809C3C37F005840C0 /* pngrutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngrutil.c; path = ../../pngrutil.c; sourceTree = SOURCE_ROOT; }; - 14461C6909C3C37F005840C0 /* pngset.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngset.c; path = ../../pngset.c; sourceTree = SOURCE_ROOT; }; - 14461C6B09C3C37F005840C0 /* pngtrans.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngtrans.c; path = ../../pngtrans.c; sourceTree = SOURCE_ROOT; }; - 14461C6C09C3C37F005840C0 /* pngvcrd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngvcrd.c; path = ../../pngvcrd.c; sourceTree = SOURCE_ROOT; }; - 14461C6D09C3C37F005840C0 /* pngwio.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwio.c; path = ../../pngwio.c; sourceTree = SOURCE_ROOT; }; - 14461C6E09C3C37F005840C0 /* pngwrite.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwrite.c; path = ../../pngwrite.c; sourceTree = SOURCE_ROOT; }; - 14461C6F09C3C37F005840C0 /* pngwtran.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwtran.c; path = ../../pngwtran.c; sourceTree = SOURCE_ROOT; }; - 14461C7009C3C37F005840C0 /* pngwutil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = pngwutil.c; path = ../../pngwutil.c; sourceTree = SOURCE_ROOT; }; - 67FA470410693F6B0078FB9E /* pngpriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pngpriv.h; path = ../../pngpriv.h; sourceTree = SOURCE_ROOT; }; - 8D07F2C70486CC7A007CD1D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; - 8D07F2C80486CC7A007CD1D0 /* libpng.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = libpng.framework; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D07F2C30486CC7A007CD1D0 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 034768DDFF38A45A11DB9C8B /* Products */ = { - isa = PBXGroup; - children = ( - 8D07F2C80486CC7A007CD1D0 /* libpng.framework */, - ); - name = Products; - sourceTree = ""; - }; - 0867D691FE84028FC02AAC07 /* libpng */ = { - isa = PBXGroup; - children = ( - 08FB77ACFE841707C02AAC07 /* Source */, - 089C1665FE841158C02AAC07 /* Resources */, - 034768DDFF38A45A11DB9C8B /* Products */, - ); - name = libpng; - sourceTree = ""; - }; - 089C1665FE841158C02AAC07 /* Resources */ = { - isa = PBXGroup; - children = ( - 8D07F2C70486CC7A007CD1D0 /* Info.plist */, - ); - name = Resources; - sourceTree = ""; - }; - 08FB77ACFE841707C02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - 67FA470410693F6B0078FB9E /* pngpriv.h */, - 14461C5D09C3C37F005840C0 /* png.c */, - 14461C5E09C3C37F005840C0 /* png.h */, - 14461C5F09C3C37F005840C0 /* pngconf.h */, - 14461C6009C3C37F005840C0 /* pngerror.c */, - 14461C6109C3C37F005840C0 /* pnggccrd.c */, - 14461C6209C3C37F005840C0 /* pngget.c */, - 14461C6309C3C37F005840C0 /* pngmem.c */, - 14461C6409C3C37F005840C0 /* pngpread.c */, - 14461C6509C3C37F005840C0 /* pngread.c */, - 14461C6609C3C37F005840C0 /* pngrio.c */, - 14461C6709C3C37F005840C0 /* pngrtran.c */, - 14461C6809C3C37F005840C0 /* pngrutil.c */, - 14461C6909C3C37F005840C0 /* pngset.c */, - 14461C6B09C3C37F005840C0 /* pngtrans.c */, - 14461C6C09C3C37F005840C0 /* pngvcrd.c */, - 14461C6D09C3C37F005840C0 /* pngwio.c */, - 14461C6E09C3C37F005840C0 /* pngwrite.c */, - 14461C6F09C3C37F005840C0 /* pngwtran.c */, - 14461C7009C3C37F005840C0 /* pngwutil.c */, - ); - name = Source; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 8D07F2BD0486CC7A007CD1D0 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 14461C7209C3C37F005840C0 /* png.h in Headers */, - 14461C7309C3C37F005840C0 /* pngconf.h in Headers */, - 67FA470510693F6B0078FB9E /* pngpriv.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 8D07F2BC0486CC7A007CD1D0 /* libpng */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget "libpng" */; - buildPhases = ( - 8D07F2BD0486CC7A007CD1D0 /* Headers */, - 8D07F2BF0486CC7A007CD1D0 /* Resources */, - 8D07F2C10486CC7A007CD1D0 /* Sources */, - 8D07F2C30486CC7A007CD1D0 /* Frameworks */, - 8D07F2C50486CC7A007CD1D0 /* Rez */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = libpng; - productInstallPath = "$(HOME)/Library/Frameworks"; - productName = libpng; - productReference = 8D07F2C80486CC7A007CD1D0 /* libpng.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 0867D690FE84028FC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "libpng" */; - compatibilityVersion = "Xcode 2.4"; - hasScannedForEncodings = 1; - mainGroup = 0867D691FE84028FC02AAC07 /* libpng */; - productRefGroup = 034768DDFF38A45A11DB9C8B /* Products */; - projectDirPath = ""; - projectRoot = ../..; - targets = ( - 8D07F2BC0486CC7A007CD1D0 /* libpng */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8D07F2BF0486CC7A007CD1D0 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXRezBuildPhase section */ - 8D07F2C50486CC7A007CD1D0 /* Rez */ = { - isa = PBXRezBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXRezBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D07F2C10486CC7A007CD1D0 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 14461C7109C3C37F005840C0 /* png.c in Sources */, - 14461C7409C3C37F005840C0 /* pngerror.c in Sources */, - 14461C7509C3C37F005840C0 /* pnggccrd.c in Sources */, - 14461C7609C3C37F005840C0 /* pngget.c in Sources */, - 14461C7709C3C37F005840C0 /* pngmem.c in Sources */, - 14461C7809C3C37F005840C0 /* pngpread.c in Sources */, - 14461C7909C3C37F005840C0 /* pngread.c in Sources */, - 14461C7A09C3C37F005840C0 /* pngrio.c in Sources */, - 14461C7B09C3C37F005840C0 /* pngrtran.c in Sources */, - 14461C7C09C3C37F005840C0 /* pngrutil.c in Sources */, - 14461C7D09C3C37F005840C0 /* pngset.c in Sources */, - 14461C7F09C3C37F005840C0 /* pngtrans.c in Sources */, - 14461C8009C3C37F005840C0 /* pngvcrd.c in Sources */, - 14461C8109C3C37F005840C0 /* pngwio.c in Sources */, - 14461C8209C3C37F005840C0 /* pngwrite.c in Sources */, - 14461C8309C3C37F005840C0 /* pngwtran.c in Sources */, - 14461C8409C3C37F005840C0 /* pngwutil.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 4FADC24308B4156D00ABE55E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 14; - DYLIB_CURRENT_VERSION = 14; - FRAMEWORK_VERSION = 1.4.3; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "@executable_path/../Frameworks"; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = "-lz"; - PRODUCT_NAME = libpng; - WRAPPER_EXTENSION = framework; - }; - name = Debug; - }; - 4FADC24408B4156D00ABE55E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 14; - DYLIB_CURRENT_VERSION = 14; - FRAMEWORK_VERSION = 1.4.3; - GCC_PRECOMPILE_PREFIX_HEADER = NO; - GCC_PREFIX_HEADER = ""; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "@executable_path/../Frameworks"; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = "-lz"; - PRODUCT_NAME = libpng; - WRAPPER_EXTENSION = framework; - }; - name = Release; - }; - 4FADC24708B4156D00ABE55E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - ppc64, - x86_64, - ); - DEPLOYMENT_POSTPROCESSING = YES; - GCC_ENABLE_CPP_EXCEPTIONS = NO; - GCC_ENABLE_CPP_RTTI = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_VERSION_i386 = 4.0; - GCC_VERSION_ppc = 3.3; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; - "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; - MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; - MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; - "SDKROOT[arch=i386]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - ZERO_LINK = NO; - }; - name = Debug; - }; - 4FADC24808B4156D00ABE55E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - ppc64, - x86_64, - ); - GCC_ENABLE_CPP_EXCEPTIONS = NO; - GCC_ENABLE_CPP_RTTI = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 2; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_VERSION_i386 = 4.0; - GCC_VERSION_ppc = 3.3; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; - "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; - MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; - MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; - "SDKROOT[arch=i386]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget "libpng" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4FADC24308B4156D00ABE55E /* Debug */, - 4FADC24408B4156D00ABE55E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "libpng" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4FADC24708B4156D00ABE55E /* Debug */, - 4FADC24808B4156D00ABE55E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 0867D690FE84028FC02AAC07 /* Project object */; -} diff -ru4NwbB libpng-1.4.3/scripts/README.txt libpng-1.5.0beta42/scripts/README.txt --- libpng-1.4.3/scripts/README.txt 2010-06-25 19:32:27.811195781 -0500 +++ libpng-1.5.0beta42/scripts/README.txt 2010-08-18 08:12:23.169523410 -0500 @@ -1,7 +1,8 @@ Makefiles for libpng version 1.5.0beta42 - August 11, 2010 +pnglibconf.h => Stores configuration settings makefile.linux => Linux/ELF makefile (gcc, creates libpng%SONAME%.so.%SONUM%.1.5.0beta42) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -14,27 +15,25 @@ makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) makefile.beos => beos makefile makefile.bor => Borland makefile (uses bcc) makefile.cegcc => minge32ce for Windows CE makefile - makefile.cygwin => Cygwin/gcc makefile makefile.darwin => Darwin makefile, can use on MacosX makefile.dec => DEC Alpha UNIX makefile makefile.dj2 => DJGPP 2 makefile makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng%SONAME%.so.%SONUM%.1.5.0beta42) + (gcc, creates libpng%SONAME%.so.%SONUM%.1.5.0beta42) makefile.freebsd => FreeBSD makefile makefile.gcc => Generic gcc makefile makefile.hpgcc => HPUX makefile using gcc makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) makefile.intel => Intel C/C++ version 4.0 and later - makefile.mingw => Mingw makefile makefile.mips => MIPS makefile makefile.msc => Microsoft C makefile makefile.netbsd => NetBSD/cc makefile, makes libpng.so. makefile.openbsd => OpenBSD makefile - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) + makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def) makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sggcc => Silicon Graphics (gcc, creates libpng%SONAME%.so.%SONUM%.1.5.0beta42) makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) @@ -53,15 +52,26 @@ smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler (Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc) Other supporting scripts: + README.txt => This file descrip.mms => VMS makefile for MMS or MMK libpng-config-body.in => used by several makefiles to create libpng-config libpng-config-head.in => used by several makefiles to create libpng-config libpng.pc.in => Used by several makefiles to create libpng.pc - pngos2.def => OS/2 module definition file used by makefile.os2 - pngwin.def => Module definitions for makefile.cygwin and mingw - png32ce.def => Module definition file used by makefile.cegcc pngwin.rc => Used by the visualc6 and visualc71 projects. + pngwin.def => Used by makefile.os2 + pngwin.dfn => Used to maintain pngwin.def SCOPTIONS.ppc => Used with smakefile.ppc +checksym.awk => Used for maintaining pnglibconf.h +def.dfn => Used for maintaining pnglibconf.h +options.awk => Used for maintaining pnglibconf.h +pnglibconf.dfa => Used for maintaining pnglibconf.h +pnglibconf.mak => Used for maintaining pnglibconf.h +sym.dfn => Used for symbol versioning +symbols.def => Used for symbol versioning +symbols.dfn => Used for symbol versioning +vers.dfn => Used for symbol versioning + + Further information can be found in comments in the individual makefiles. diff -ru4NwbB libpng-1.4.3/scripts/checksym.awk libpng-1.5.0beta42/scripts/checksym.awk --- libpng-1.4.3/scripts/checksym.awk 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/scripts/checksym.awk 2010-04-28 06:25:21.025701000 -0500 @@ -0,0 +1,155 @@ +#!/bin/awk -f +# Check a list of symbols against the master definition +# (official) list. Arguments: +# +# awk -f checksym.awk official-def list-to-check +# +# Output is a file in the current directory called 'symbols.new', +# stdout holds error messages. Error code indicates success or +# failure. +# +# NOTE: this is a pure, old fashioned, awk script. It will +# work with any awk + +BEGIN{ + err=0 + master="" # master file + official[1] = "" # defined symbols from master file + symbol[1] = "" # defined symbols from png.h + removed[1] = "" # removed symbols from png.h + lasto = 0 # last ordinal value from png.h + mastero = 0 # highest ordinal in master file + symbolo = 0 # highest ordinal in png.h +} + +# Read existing definitions from the master file (the first +# file on the command line.) This must be a def file and it +# has definition lines (others are ignored) of the form: +# +# symbol @ordinal +# +master == "" { + master = FILENAME; +} +FILENAME==master && NF==2 && $2~/^@/ && $1!~/^;/ { + o=0+substr($2,2) + if (o > 0) { + if (official[o] == "") { + official[o] = $1 + if (o > mastero) mastero = o + next + } else + print master ": duplicated symbol:", official[o] ":", $0 + } else + print master ": bad export line format:", $0 + err = 1 +} +FILENAME==master { + next +} + +# Read new definitions, these are free form but the lines must +# just be symbol definitions. Lines will be commented out for +# 'removed' symbols, introduced in png.h using PNG_REMOVED rather +# than PNG_EXPORT. Use symbols.dfn or pngwin.dfn to generate the +# input file. +# +# symbol @ordinal # two fields, exported symbol +# ; symbol @ordinal # three fields, removed symbol +# ; @ordinal # two fields, the last ordinal +NF==2 && $1 == ";" && $2 ~ /^@[1-9][0-9]*$/ { # last ordinal + o=0+substr($2,2) + if (lasto == 0 || lasto == o) + lasto=o + else { + print "png.h: duplicated last ordinal:", lasto, o + err = 1 + } + next +} +NF==3 && $1 == ";" && $3 ~ /^@[1-9][0-9]*$/ { # removed symbol + o=0+substr($3,2) + if (removed[o] == "" || removed[o] == $2) { + removed[o] = $2 + if (o > symbolo) symbolo = o + } else { + print "png.h: duplicated removed symbol", + o ": '" removed[o] "' != '" $2 "'" + err = 1 + } + next +} +NF==2 && $2 ~ /^@[1-9][0-9]*$/ { # exported symbol + o=0+substr($2,2) + if (symbol[o] == "" || symbol[o] == $1) { + symbol[o] = $1 + if (o > symbolo) symbolo = o + } else { + print "png.h: duplicated symbol", + o ": '" symbol[o] "' != '" $1 "'" + err = 1 + } +} +{ + next # skip all other lines +} + +# At the end check for symbols marked as both duplicated and removed +END{ + if (symbolo > lasto) { + print "highest symbol ordinal in png.h,", + symbolo ", exceeds last ordinal from png.h", lasto + err = 1 + } + if (mastero > lasto) { + print "highest symbol ordinal in", master ",", + mastero ", exceeds last ordinal from png.h", lasto + err = 1 + } + unexported=0 + for (o=1; o<=lasto; ++o) { + if (symbol[o] == "" && removed[o] == "") { + if (unexported == 0) unexported = o + if (official[o] == "") { + # missing in export list too, so ok + if (o < lasto) continue + } + } + if (unexported != 0) { + # Symbols in the .def but not in the new file are errors + if (o-1 > unexported) + print "png.h: warning: unexported symbol definitions:", + unexported "-" o-1 + else + print "png.h: warning: unexported symbol definition:", + unexported + unexported = 0 + } + if (symbol[o] != "" && removed[o] != "") { + print "png.h: symbol", o, + "both exported as '" symbol[o] "' and removed as '" removed[o] "'" + err = 1 + } else if (symbol[o] != official[o]) { + # either the symbol is missing somewhere or it changed + err = 1 + if (symbol[o] == "") + print "png.h: symbol", o, + "is exported as '" official[o] "' in", master + else if (official[o] == "") + print "png.h: exported symbol", o, + "'" symbol[o] "' not present in", master + else + print "png.h: exported symbol", o, + "'" symbol[o] "' exists as '" official[o] "' in", master + } + + # Finally generate symbols.new + if (symbol[o] != "") + print " " symbol[o], "@" o > "symbols.new" + } + + if (err != 0) { + print "*** A new list is in symbols.new ***" + exit 1 + } +} diff -ru4NwbB libpng-1.4.3/scripts/makefile.32sunu libpng-1.5.0beta42/scripts/makefile.32sunu --- libpng-1.4.3/scripts/makefile.32sunu 2010-06-25 19:32:27.849139546 -0500 +++ libpng-1.5.0beta42/scripts/makefile.32sunu 2010-08-18 08:12:23.207606136 -0500 @@ -81,8 +81,12 @@ $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +include scripts/pnglibconf.mak +DELETE = $(RM_F) +DFNFLAGS = $(DEFS) $(CPPFLAGS) + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -130,14 +134,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -233,5 +237,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.64sunu libpng-1.5.0beta42/scripts/makefile.64sunu --- libpng-1.4.3/scripts/makefile.64sunu 2010-06-25 19:32:27.859908981 -0500 +++ libpng-1.5.0beta42/scripts/makefile.64sunu 2010-08-18 08:12:23.218471749 -0500 @@ -81,8 +81,12 @@ $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +include scripts/pnglibconf.mak +DELETE = $(RM_F) +DFNFLAGS = $(DEFS) $(CPPFLAGS) + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -133,11 +137,11 @@ 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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -233,5 +237,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.acorn libpng-1.5.0beta42/scripts/makefile.acorn --- libpng-1.4.3/scripts/makefile.acorn 2009-11-25 08:20:24.000000000 -0600 +++ libpng-1.5.0beta42/scripts/makefile.acorn 2010-04-16 22:31:54.118614000 -0500 @@ -42,9 +42,16 @@ MemCheck.CC cc $(ccflags) -o $@ LibPng:$< .c.o: cc $(ccflags) -o $@ $< +# See scripts.mak.libpngconf for how to generate this: +@.h.libpngconf: @.scripts.h.libpngconf + copy @.scripts.h.libpngconf $@ # Static dependencies: +@.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ +@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ +@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil \ +@.o.pngtest: @.h.libpngconf # Dynamic dependencies: diff -ru4NwbB libpng-1.4.3/scripts/makefile.aix libpng-1.5.0beta42/scripts/makefile.aix --- libpng-1.4.3/scripts/makefile.aix 2010-06-25 19:32:27.869556361 -0500 +++ libpng-1.5.0beta42/scripts/makefile.aix 2010-08-18 08:12:23.228104879 -0500 @@ -45,9 +45,9 @@ LDDEBUG = CRELEASE = -O2 LDRELEASE = -s WARNMORE=-W -Wall -CFLAGS = -D_ALL_SOURCE -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) +CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) LDFLAGS = -L. -L$(ZLIBLIB) -lpng%N% -lz -lm $(LDRELEASE) # File extensions O=.o @@ -61,8 +61,12 @@ # Targets all: $(LIBNAME)$(A) pngtest$(E) +include scripts/pnglibconf.mak +REMOVE = $(RM_F) +DFNFLAGS = $(DEFS) $(CPPFLAGS) + $(LIBNAME)$(A): $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -77,13 +81,16 @@ -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi -@$(RM_F) $(DI)/$(LIBNAME)/png.h -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h + -@$(RM_F) $(DI)/$(LIBNAME)/pnglibconf.h -@$(RM_F) $(DI)/png.h -@$(RM_F) $(DI)/pngconf.h - cp png.h pngconf.h $(DI)/$(LIBNAME) + -@$(RM_F) $(DI)/pnglibconf.h + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) chmod 644 $(DI)/$(LIBNAME)/png.h \ - $(DI)/$(LIBNAME)/pngconf.h + $(DI)/$(LIBNAME)/pngconf.h \ + $(DI)/$(LIBNAME)/pnglibconf.h -@$(RM_F) -r $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) -@$(RM_F) $(DL)/$(LIBNAME)$(A) -@$(RM_F) $(DL)/libpng$(A) @@ -92,9 +99,9 @@ (cd $(DL); $(LN_SF) $(LIBNAME)$(A) libpng$(A)) (cd $(DI); $(LN_SF) libpng/* .;) clean: - $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png + $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png pnglibconf.h png$(O): %HEADERS% pngerror$(O): %HEADERS% pngget$(O): %HEADERS% @@ -110,5 +117,5 @@ pngwrite$(O): %HEADERS% pngwtran$(O): %HEADERS% pngwutil$(O): %HEADERS% -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.amiga libpng-1.5.0beta42/scripts/makefile.amiga --- libpng-1.4.3/scripts/makefile.amiga 2009-11-25 08:20:34.000000000 -0600 +++ libpng-1.5.0beta42/scripts/makefile.amiga 2010-04-16 22:31:54.180613000 -0500 @@ -5,10 +5,8 @@ # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h # -# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h -# # Location/path of zlib include files ZLIB=/zlib #compiler CC=sc @@ -25,8 +23,10 @@ # linker LN= slink # file deletion command RM= delete quiet +# file copy command? +CP= copy # library (.lib) file creation command AR= oml # make directory command MKDIR= makedir @@ -40,8 +40,13 @@ libpng.lib: $(OBJS) -$(RM) libpng.lib $(AR) libpng.lib r $(OBJS) +$(OBJS): pngpriv.h png.h pngconf.h pnglibconf.h pnginfo.h pngstruct.h pngdebug.h + +pnglibconf.h: scripts/pnglibconf.h +$(CP) scripts/pnglibconf.h pnglibconf.h + pngtest: pngtest.o libpng.lib $(LN) libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(CYGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -$(STATLIB): $(OBJS) - ar rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngwin.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest.pic.o: pngtest.c - $(CC) $(CFLAGS) -c $< -o $@ - -pngtest.o: pngtest.c png.h pngconf.h - $(CC) $(CFLAGS) -c $< -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -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) $(CFLAGS) \ - `$(BINPATH)/libpng%N%-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng%N%-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng%N%-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng%N%-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.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: %HEADERS% png.c -pngerror.o pngerror.pic.o: %HEADERS% pngerror.c -pngrio.o pngrio.pic.o: %HEADERS% pngrio.c -pngwio.o pngwio.pic.o: %HEADERS% pngwio.c -pngmem.o pngmem.pic.o: %HEADERS% pngmem.c -pngset.o pngset.pic.o: %HEADERS% pngset.c -pngget.o pngget.pic.o: %HEADERS% pngget.c -pngread.o pngread.pic.o: %HEADERS% pngread.c -pngrtran.o pngrtran.pic.o: %HEADERS% pngrtran.c -pngrutil.o pngrutil.pic.o: %HEADERS% pngrutil.c -pngtrans.o pngtrans.pic.o: %HEADERS% pngtrans.c -pngwrite.o pngwrite.pic.o: %HEADERS% pngwrite.c -pngwtran.o pngwtran.pic.o: %HEADERS% pngwtran.c -pngwutil.o pngwutil.pic.o: %HEADERS% pngwutil.c -pngpread.o pngpread.pic.o: %HEADERS% pngpread.c - -pngtest.o: png.h pngconf.h pngtest.c -pngtest-stat.o: png.h pngconf.h pngtest.c - - - diff -ru4NwbB libpng-1.4.3/scripts/makefile.darwin libpng-1.5.0beta42/scripts/makefile.darwin --- libpng-1.4.3/scripts/makefile.darwin 2010-06-25 19:32:27.930060870 -0500 +++ libpng-1.5.0beta42/scripts/makefile.darwin 2010-08-18 08:12:23.278630633 -0500 @@ -8,9 +8,10 @@ # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h -# where "make install" puts libpng.a, libpng%NN%.dylib, png.h and pngconf.h +# where "make install" puts libpng.a, libpng%NN%.dylib, png.h, pngconf.h, +# and pnglibconf.h prefix=/usr/local exec_prefix=$(prefix) # Where the zlib library and include files are located @@ -73,8 +74,12 @@ $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -109,14 +114,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -186,9 +191,9 @@ ./pngtesti pngtest.png clean: $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ - libpng.pc $(LIBNAME).*dylib pngtesti + libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -210,5 +215,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.dec libpng-1.5.0beta42/scripts/makefile.dec --- libpng-1.4.3/scripts/makefile.dec 2010-06-25 19:32:27.940227490 -0500 +++ libpng-1.5.0beta42/scripts/makefile.dec 2010-08-18 08:12:23.289196313 -0500 @@ -61,8 +61,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: $(LIBSO) libpng.a pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -95,14 +99,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 - -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@/bin/rm -f $(DI)/libpng (cd $(DI); $(LN_SF)(LIBNAME) libpng; $(LN_SF)(LIBNAME)/* .) install-static: install-headers libpng.a @@ -174,9 +178,9 @@ clean: /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h # DO NOT DELETE THIS LINE -- make depend depends on it. png.o: %HEADERS% @@ -194,5 +198,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.dj2 libpng-1.5.0beta42/scripts/makefile.dj2 --- libpng-1.4.3/scripts/makefile.dj2 2010-06-25 19:32:27.949505280 -0500 +++ libpng-1.5.0beta42/scripts/makefile.dj2 2010-08-18 08:12:23.298781266 -0500 @@ -1,6 +1,6 @@ # DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2009-2010 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -12,9 +12,9 @@ INCPATH=$(prefix)/include LIBPATH=$(prefix)/lib CC=gcc -CFLAGS=-I../zlib -O +CFLAGS=-I../zlib -O -DPNG_NO_SNPRINTF LDFLAGS=-L. -L../zlib/ -lpng -lz -lm RANLIB=ranlib @@ -23,8 +23,12 @@ pngmem.o pngerror.o pngpread.o all: libpng.a pngtest +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) ar rc $@ $(OBJS) $(RANLIB) $@ @@ -34,9 +38,9 @@ test: pngtest ./pngtest clean: - rm -f *.o libpng.a pngtest pngout.png + rm -f *.o libpng.a pngtest pngout.png pnglibconf.h # DO NOT DELETE THIS LINE -- make depend depends on it. png.o: %HEADERS% @@ -54,5 +58,5 @@ pngwrite.o: %HEADERS% pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.elf libpng-1.5.0beta42/scripts/makefile.elf --- libpng-1.4.3/scripts/makefile.elf 2010-06-25 19:32:27.960128434 -0500 +++ libpng-1.5.0beta42/scripts/makefile.elf 2010-08-18 08:12:23.309697676 -0500 @@ -32,9 +32,9 @@ 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 +# libpng%N%/png.h, libpng%N%/pngconf.h, and libpng%N%/pnglibconf.h # Prefix must be a full pathname. prefix=/usr/local exec_prefix=$(prefix) @@ -94,8 +94,12 @@ $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -105,9 +109,9 @@ -e s!@libdir@!$(LIBPATH)! \ -e s!@includedir@!$(INCPATH)! \ -e s!-lpng%N%!-lpng%N%\ -lz\ -lm! > libpng.pc -libpng.syms: png.h pngconf.h +libpng.syms: png.h pngconf.h pnglibconf.h $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\ awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG%N%_%s {global:\n",PNGMAJ)}\ { for (i=1;i+2<=NF;++i)\ if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ @@ -154,14 +158,14 @@ @echo " Running pngtest statically linked with libpng.a:" @echo "" ./pngtest-static -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -231,9 +235,9 @@ clean: $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \ $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -255,5 +259,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.freebsd libpng-1.5.0beta42/scripts/makefile.freebsd --- libpng-1.4.3/scripts/makefile.freebsd 2010-06-25 19:32:27.969249069 -0500 +++ libpng-1.5.0beta42/scripts/makefile.freebsd 2010-08-18 08:12:23.318941883 -0500 @@ -22,9 +22,10 @@ INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk MAN= libpng.3 libpngpf.3 png.5 MANDIR= /man/man SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \ - libpng/pngconf.h ${INCSDIR}/../pngconf.h + libpng/pngconf.h ${INCSDIR}/../pngconf.h \ + libpng/pnglibconf.h ${INCSDIR}/../pnglibconf.h LDADD+= -lm -lz DPADD+= ${LIBM} ${LIBZ} CFLAGS+= -I. @@ -40,8 +41,12 @@ test: pngtest ./pngtest +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* diff -ru4NwbB libpng-1.4.3/scripts/makefile.gcc libpng-1.5.0beta42/scripts/makefile.gcc --- libpng-1.4.3/scripts/makefile.gcc 2010-06-25 19:32:27.978649322 -0500 +++ libpng-1.5.0beta42/scripts/makefile.gcc 2010-08-18 08:12:23.328584189 -0500 @@ -40,8 +40,12 @@ # Targets all: static +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + .c$(O): $(CC) -c $(CFLAGS) -I$(ZLIBINC) $< static: libpng$(A) pngtest$(EXE) @@ -61,9 +65,9 @@ pngtest$(EXE): pngtest$(O) libpng$(A) $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS) clean: - $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png + $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png pnglibconf.h png$(O): %HEADERS% pngerror$(O): %HEADERS% pngget$(O): %HEADERS% @@ -79,5 +83,5 @@ pngwrite$(O): %HEADERS% pngwtran$(O): %HEADERS% pngwutil$(O): %HEADERS% -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.hp64 libpng-1.5.0beta42/scripts/makefile.hp64 --- libpng-1.4.3/scripts/makefile.hp64 2010-06-25 19:32:27.988873008 -0500 +++ libpng-1.5.0beta42/scripts/makefile.hp64 2010-08-18 08:12:23.339067185 -0500 @@ -79,8 +79,12 @@ $(CC) -c $(CFLAGS) +z -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -113,14 +117,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -192,9 +196,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -216,5 +220,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.hpgcc libpng-1.5.0beta42/scripts/makefile.hpgcc --- libpng-1.4.3/scripts/makefile.hpgcc 2010-06-25 19:32:27.999383196 -0500 +++ libpng-1.5.0beta42/scripts/makefile.hpgcc 2010-08-18 08:12:23.349588484 -0500 @@ -26,9 +26,10 @@ LN_SF=ln -sf RANLIB=ranlib RM_F=/bin/rm -f -# where "make install" puts libpng.a, $(OLDSO)*, png.h and pngconf.h +# where "make install" puts libpng.a, $(OLDSO)*, png.h, pngconf.h +# and pnglibconf.h prefix=/usr/local exec_prefix=$(prefix) # Where the zlib library and include files are located @@ -122,14 +123,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -201,9 +202,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -225,5 +226,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.hpux libpng-1.5.0beta42/scripts/makefile.hpux --- libpng-1.4.3/scripts/makefile.hpux 2010-06-25 19:32:28.011272631 -0500 +++ libpng-1.5.0beta42/scripts/makefile.hpux 2010-08-18 08:12:23.360224194 -0500 @@ -76,8 +76,12 @@ $(CC) -c $(CFLAGS) +z -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -110,14 +114,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -189,9 +193,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -213,5 +217,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.ibmc libpng-1.5.0beta42/scripts/makefile.ibmc --- libpng-1.4.3/scripts/makefile.ibmc 2010-06-25 19:32:28.020723566 -0500 +++ libpng-1.5.0beta42/scripts/makefile.ibmc 2010-08-18 08:12:23.369658004 -0500 @@ -40,8 +40,12 @@ # Targets all: libpng$(A) pngtest$(E) +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng$(A): $(OBJS) $(AR) -out:$@ $(OBJS) test: pngtest$(E) @@ -54,8 +58,9 @@ clean: $(RM) *$(O) $(RM) libpng$(A) + $(RM) pnglibconf.h $(RM) pngtest$(E) $(RM) pngout.png png$(O): %HEADERS% @@ -73,5 +78,5 @@ pngwrite$(O): %HEADERS% pngwtran$(O): %HEADERS% pngwutil$(O): %HEADERS% -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.intel libpng-1.5.0beta42/scripts/makefile.intel --- libpng-1.4.3/scripts/makefile.intel 2010-06-25 19:32:28.030277720 -0500 +++ libpng-1.5.0beta42/scripts/makefile.intel 2010-08-18 08:12:23.379226945 -0500 @@ -43,8 +43,12 @@ pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) all: test +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + png$(O): %HEADERS% $(CC) $(CFLAGS) $*.c $(ERRFILE) pngset$(O): %HEADERS% @@ -95,9 +99,9 @@ pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h $(CC) $(CFLAGS) $*.c $(ERRFILE) test: pngtest.exe pngtest.exe diff -ru4NwbB libpng-1.4.3/scripts/makefile.knr libpng-1.5.0beta42/scripts/makefile.knr --- libpng-1.4.3/scripts/makefile.knr 2010-06-25 19:32:28.039912213 -0500 +++ libpng-1.5.0beta42/scripts/makefile.knr 2010-08-18 08:12:23.389009457 -0500 @@ -40,8 +40,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: ansi2knr libpng.a pngtest +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + # general rule to allow ansi2knr to work .c.o: ./ansi2knr $*.c T$*.c $(CC) $(CFLAGS) -c T$*.c @@ -60,24 +64,26 @@ test: pngtest ./pngtest -install: libpng.a png.h pngconf.h +install: libpng.a png.h pngconf.h pnglibconf.h -@mkdir $(DESTDIR)$(INCPATH) -@mkdir $(DESTDIR)$(INCPATH)/libpng -@mkdir $(DESTDIR)$(LIBPATH) -@rm -f $(DESTDIR)$(INCPATH)/png.h -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) cp libpng.a $(DESTDIR)$(LIBPATH) chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a clean: - rm -f *.o libpng.a pngtest pngout.png ansi2knr + rm -f *.o libpng.a pngtest pngout.png ansi2knr pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -99,5 +105,5 @@ pngwrite.o: %HEADERS% pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.linux libpng-1.5.0beta42/scripts/makefile.linux --- libpng-1.4.3/scripts/makefile.linux 2010-06-25 19:32:28.050538963 -0500 +++ libpng-1.5.0beta42/scripts/makefile.linux 2010-08-18 08:12:23.399596787 -0500 @@ -26,9 +26,9 @@ 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 +# libpng%N%/png.h, libpng%N%/pngconf.h, and libpng%N%/pnglibconf.h # Prefix must be a full pathname. prefix=/usr/local exec_prefix=$(prefix) @@ -86,8 +86,12 @@ $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -129,14 +133,14 @@ @echo " Running pngtest statically linked with libpng.a:" @echo "" ./pngtest-static -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -207,9 +211,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* diff -ru4NwbB libpng-1.4.3/scripts/makefile.mingw libpng-1.5.0beta42/scripts/makefile.mingw --- libpng-1.4.3/scripts/makefile.mingw 2010-06-25 19:32:28.061725791 -0500 +++ libpng-1.5.0beta42/scripts/makefile.mingw 1969-12-31 18:00:00.000000000 -0600 @@ -1,282 +0,0 @@ -# makefile for mingw on x86 -# Builds both dll (with import lib) and static lib versions -# of the library, and builds two copies of pngtest: one -# statically linked and one dynamically linked. -# -# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson, -# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: -# Copyright (C) 1998-2000, 2007 Greg Roelofs -# Copyright (C) 1996, 1997 Andreas Dilger -# -# This code is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h - -# Built from makefile.cygwin - -# This makefile expects to be run under the MSYS shell (part of -# the MINGW project) and not under CMD.EXE which does not provide -# "cat" or "sed". - -# This makefile intends to support building outside the src directory -# if desired. When invoking it, specify an argument to SRCDIR on the -# command line that points to the top of the directory where your source -# is located. -ifdef SRCDIR -VPATH = $(SRCDIR) -else -SRCDIR = . -endif - -# 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= - -# If you're using a cross-compiler, add the appropriate prefix (e.g., -# "i386-mingw32msvc-") to the following three commands: -CC=gcc -AR=ar -RANLIB=ranlib - -MKDIR_P=/bin/mkdir -pv - -# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h -ifndef prefix -prefix=/usr -$(warning "You haven't specified a 'prefix=' location. Defaulting to '/usr'") -endif -exec_prefix=$(prefix) - -# Where the zlib library and include files are located -ZLIBLIB= /usr/lib -ZLIBINC= - -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 - -CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -W -Wall -O3 $(ALIGN) -funroll-loops \ - -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 - -LIBNAME = libpng%NN% -PNGMAJ = %SONUM% -MINGDLL = %NN% - -SHAREDLIB=libpng$(MINGDLL).dll -STATLIB=libpng.a -IMPLIB=libpng.dll.a -SHAREDDEF=libpng.def -LIBS=$(SHAREDLIB) $(STATLIB) -EXE=.exe - -LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) -LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS)) -LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz - -INCPATH=$(prefix)/include -LIBPATH=$(exec_prefix)/lib - -BINPATH=$(exec_prefix)/bin -MANPATH=$(prefix)/man -MAN3PATH=$(MANPATH)/man3 -MAN5PATH=$(MANPATH)/man5 - -# cosmetic: shortened strings: -S =$(SRCDIR) -D =$(DESTDIR) -DB =$(D)$(BINPATH) -DI =$(D)$(INCPATH) -DL =$(D)$(LIBPATH) - -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 - -%.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< -%.pic.o : CFLAGS += -DPNG_BUILD_DLL -%.pic.o : %.c - $(CC) -c $(CFLAGS) -o $@ $< - -all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config - -# Make this to verify that "make [...] install" will do what you want. -buildsetup-tell: - @echo VPATH is set to: \"$(VPATH)\" - @echo prefix is set to: \"$(prefix)\" - @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ - $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \ - $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n' - -libpng.pc: scripts/libpng.pc.in - @echo -e Making pkg-config file for this libpng installation..'\n' \ - using PREFIX=\"$(prefix)\"'\n' - 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!@includedir@!$(INCPATH)! \ - -e s!-lpng%NN%!-lpng%NN%\ -lz\ -lm! > libpng.pc - -libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in - @echo -e Making $(LIBNAME) libpng-config file for this libpng \ - installation..'\n' using PREFIX=\"$(prefix)\"'\n' - ( cat $(S)/scripts/libpng-config-head.in; \ - echo prefix=\"$(prefix)\"; \ - echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ - echo L_opts=\"-L$(LIBPATH)\"; \ - echo libs=\"-lpng$(MINGDLL) -lz\"; \ - cat $(S)/scripts/libpng-config-body.in ) > libpng-config - chmod +x libpng-config - -static: all-static -shared: all-shared -all-static: $(STATLIB) pngtest-stat$(EXE) -all-shared: $(SHAREDLIB) pngtest$(EXE) - -$(STATLIB): $(OBJS) - $(AR) rc $@ $(OBJS) - $(RANLIB) $@ - -$(SHAREDDEF): scripts/pngwin.def - cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \ - sed -e 's/\([^;]*\);/;/' > $@ - -$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) - $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA) - -pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) - $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ - -pngtest-stat$(EXE): pngtest.o $(STATLIB) - $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ - -test: test-static test-shared - -test-static: pngtest-stat$(EXE) - ./pngtest-stat $(S)/pngtest.png - -test-shared: pngtest$(EXE) - ./pngtest $(S)/pngtest.png - -install-static: $(STATLIB) install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a - -@rm -f $(DL)/$(STATLIB) - (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB)) - -install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man - -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi - -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc - -@/bin/rm -f $(DL)/pkgconfig/libpng.pc - install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a - -@rm -f $(DL)/$(IMPLIB) - (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB)) - install -s -m 755 $(SHAREDLIB) $(DB) - install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc - (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) - -install-headers: - -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi - -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi - -@rm -f $(DI)/png.h - -@rm -f $(DI)/pngconf.h - install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME) - -@rm -f $(DI)/libpng - (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) - -install-man: - -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi - -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi - install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) - install -m 644 $(S)/png.5 $(D)$(MAN5PATH) - -install-config: libpng-config - -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi - -@/bin/rm -f $(DB)/libpng-config - -@/bin/rm -f $(DB)/$(LIBNAME)-config - cp libpng-config $(DB)/$(LIBNAME)-config - chmod 755 $(DB)/$(LIBNAME)-config - (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) - -# Run this to verify that a future `configure' run will pick up the settings -# you want. -test-config-install: SHELL=/bin/bash -test-config-install: $(DB)/libpng-config - @echo -e Testing libpng-config functions...'\n' - @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ - do \ - printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ - "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ - gytiu=$$(( $$gytiu + 1 )); \ - done - -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) $(CFLAGS) \ - `$(BINPATH)/libpng%NN%-config --cflags` pngtest.c \ - -L$(DL) -L$(ZLIBLIB) \ - -o pngtestd `$(BINPATH)/libpng%NN%-config --ldflags` - ./pngtestd pngtest.png - -test-installed: - $(CC) $(CFLAGS) \ - `$(BINPATH)/libpng%NN%-config --cflags` pngtest.c \ - -L$(ZLIBLIB) \ - -o pngtesti$(EXE) `$(BINPATH)/libpng%NN%-config --ldflags` - ./pngtesti$(EXE) pngtest.png - -clean: - /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ - pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \ - libpng-config libpng.pc pngtesti$(EXE) - -DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -writelock: - chmod a-w *.[ch35] $(DOCS) scripts/* - -.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: %HEADERS% png.c -pngerror.o pngerror.pic.o: %HEADERS% pngerror.c -pngrio.o pngrio.pic.o: %HEADERS% pngrio.c -pngwio.o pngwio.pic.o: %HEADERS% pngwio.c -pngmem.o pngmem.pic.o: %HEADERS% pngmem.c -pngset.o pngset.pic.o: %HEADERS% pngset.c -pngget.o pngget.pic.o: %HEADERS% pngget.c -pngread.o pngread.pic.o: %HEADERS% pngread.c -pngrtran.o pngrtran.pic.o: %HEADERS% pngrtran.c -pngrutil.o pngrutil.pic.o: %HEADERS% pngrutil.c -pngtrans.o pngtrans.pic.o: %HEADERS% pngtrans.c -pngwrite.o pngwrite.pic.o: %HEADERS% pngwrite.c -pngwtran.o pngwtran.pic.o: %HEADERS% pngwtran.c -pngwutil.o pngwutil.pic.o: %HEADERS% pngwutil.c -pngpread.o pngpread.pic.o: %HEADERS% pngpread.c - -pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c diff -ru4NwbB libpng-1.4.3/scripts/makefile.mips libpng-1.5.0beta42/scripts/makefile.mips --- libpng-1.4.3/scripts/makefile.mips 2010-06-25 19:32:28.070969985 -0500 +++ libpng-1.5.0beta42/scripts/makefile.mips 2010-08-18 08:12:23.409056917 -0500 @@ -34,8 +34,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: libpng.a pngtest +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) ar rc $@ $(OBJS) $(RANLIB) $@ @@ -50,18 +54,21 @@ -@mkdir $(DESTDIR)$(INCPATH)/libpng -@mkdir $(DESTDIR)$(LIBPATH) -@rm -f $(DESTDIR)$(INCPATH)/png.h -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h + -@rm -f $(DESTDIR)$(INCPATH)/pnglibconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) cp libpng.a $(DESTDIR)$(LIBPATH) chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a clean: - rm -f *.o libpng.a pngtest pngout.png + rm -f *.o libpng.a pngtest pngout.png pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -83,5 +90,5 @@ pngwrite.o: %HEADERS% pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.msc libpng-1.5.0beta42/scripts/makefile.msc --- libpng-1.4.3/scripts/makefile.msc 2010-06-25 19:32:28.080358904 -0500 +++ libpng-1.5.0beta42/scripts/makefile.msc 2010-08-18 08:12:23.418676400 -0500 @@ -26,8 +26,12 @@ OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) all: libpng.lib +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + png$(O): %HEADERS% $(CC) -c $(CFLAGS) $*.c $(ERRFILE) pngset$(O): %HEADERS% @@ -77,9 +81,9 @@ lib libpng $(OBJS1); lib libpng $(OBJS2); lib libpng $(OBJS3); -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; diff -ru4NwbB libpng-1.4.3/scripts/makefile.ne12bsd libpng-1.5.0beta42/scripts/makefile.ne12bsd --- libpng-1.4.3/scripts/makefile.ne12bsd 2010-06-25 19:32:28.089530868 -0500 +++ libpng-1.5.0beta42/scripts/makefile.ne12bsd 2010-08-18 08:12:23.428240062 -0500 @@ -20,9 +20,9 @@ SHLIB_MINOR= 1.5.0beta42 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 -INCS= png.h pngconf.h +INCS= png.h pngconf.h pnglibconf.h MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} @@ -31,9 +31,13 @@ # .if ${MACHINE_ARCH} == "i386" # MKLINT= no # .endif -CLEANFILES+=pngtest.o pngtest +CLEANFILES+=pngtest.o pngtest pnglibconf.h + +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ pngtest.o: pngtest.c ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} diff -ru4NwbB libpng-1.4.3/scripts/makefile.netbsd libpng-1.5.0beta42/scripts/makefile.netbsd --- libpng-1.4.3/scripts/makefile.netbsd 2010-06-25 19:32:28.098943090 -0500 +++ libpng-1.5.0beta42/scripts/makefile.netbsd 2010-08-18 08:12:23.437602033 -0500 @@ -20,9 +20,9 @@ SHLIB_MINOR= 1.5.0beta42 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 -INCS= png.h pngconf.h +INCS= png.h pngconf.h pnglibconf.h MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} @@ -31,9 +31,13 @@ # .if ${MACHINE_ARCH} == "i386" # MKLINT= no # .endif -CLEANFILES+=pngtest.o pngtest +CLEANFILES+=pngtest.o pngtest pnglibconf.h + +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ pngtest.o: pngtest.c ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET} diff -ru4NwbB libpng-1.4.3/scripts/makefile.openbsd libpng-1.5.0beta42/scripts/makefile.openbsd --- libpng-1.4.3/scripts/makefile.openbsd 2010-06-25 19:32:28.108403757 -0500 +++ libpng-1.5.0beta42/scripts/makefile.openbsd 2010-08-18 08:12:23.447312863 -0500 @@ -17,20 +17,24 @@ SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \ pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \ pngwio.c pngwrite.c pngwtran.c pngwutil.c -HDRS= png.h pngconf.h +HDRS= png.h pngconf.h pnglibconf.h CFLAGS+= -W -Wall CPPFLAGS+= -I${.CURDIR} NOPROFILE= Yes -CLEANFILES+= pngtest.o pngtest +CLEANFILES+= pngtest.o pngtest pnglibconf.h MAN= libpng.3 libpngpf.3 png.5 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO libpng.txt +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + pngtest.o: pngtest.c ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET} pngtest: pngtest.o @@ -64,8 +68,9 @@ @rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a @rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a @rm -f ${DESTDIR}${PREFIX}/include/png.h @rm -f ${DESTDIR}${PREFIX}/include/pngconf.h + @rm -f ${DESTDIR}${PREFIX}/include/pnglibconf.h @rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ -m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include ${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \ diff -ru4NwbB libpng-1.4.3/scripts/makefile.os2 libpng-1.5.0beta42/scripts/makefile.os2 --- libpng-1.4.3/scripts/makefile.os2 2010-06-25 19:32:28.117921277 -0500 +++ libpng-1.5.0beta42/scripts/makefile.os2 2010-08-18 08:12:23.456876202 -0500 @@ -3,9 +3,9 @@ # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h -# Related files: pngos2.def +# Related files: scripts/pngwin.def CC=gcc -Zomf -s # Where the zlib library and include files are located @@ -32,15 +32,19 @@ .SUFFIXES: .c .o all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP) +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + $(PNGLIB): $(OBJS) $(AR) rc $@ $(OBJS) -$(SHAREDLIB): $(OBJS) pngos2.def +$(SHAREDLIB): $(OBJS) scripts/pngwin.def $(CC) $(LDFLAGS) -Zdll -o $@ $^ -$(SHAREDLIBIMP): pngos2.def +$(SHAREDLIBIMP): scripts/pngwin.def $(IMPLIB) -o $@ $^ pngtest.exe: pngtest.o png.dll pngdll.lib $(CC) -o $@ $(CFLAGS) $< $(LDFLAGS) @@ -48,9 +52,10 @@ test: pngtest.exe ./pngtest.exe clean: - rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png + rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png \ + pnglibconf.h # DO NOT DELETE THIS LINE -- make depend depends on it. png.o png.pic.o: %HEADERS% @@ -68,5 +73,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.sco libpng-1.5.0beta42/scripts/makefile.sco --- libpng-1.4.3/scripts/makefile.sco 2010-06-25 19:32:28.128176687 -0500 +++ libpng-1.5.0beta42/scripts/makefile.sco 2010-08-18 08:12:23.467519240 -0500 @@ -72,8 +72,12 @@ $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -106,16 +110,17 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.h -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi -@$(RM_F) $(DI)/png.h -@$(RM_F) $(DI)/pngconf.h - 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)/pnglibconf.h + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -185,9 +190,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ - libpng.pc + pnglibconf.h libpng.pc DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -209,5 +214,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.sggcc libpng-1.5.0beta42/scripts/makefile.sggcc --- libpng-1.4.3/scripts/makefile.sggcc 2010-06-25 19:32:28.138704375 -0500 +++ libpng-1.5.0beta42/scripts/makefile.sggcc 2010-08-18 08:12:23.478294899 -0500 @@ -75,8 +75,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: libpng.a pngtest shared libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -116,14 +120,14 @@ echo echo Testing local static library. ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -196,9 +200,9 @@ ./pngtesti pngtest.png clean: $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc \ - so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* + so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -220,5 +224,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.sgi libpng-1.5.0beta42/scripts/makefile.sgi --- libpng-1.4.3/scripts/makefile.sgi 2010-06-25 19:32:28.149215154 -0500 +++ libpng-1.5.0beta42/scripts/makefile.sgi 2010-08-18 08:12:23.489146024 -0500 @@ -78,8 +78,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: libpng.a pngtest shared libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -116,14 +120,14 @@ echo echo Testing local static library. ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -197,9 +201,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ $(LIBSO) $(LIBSOMAJ)* \ - so_locations + so_locations pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -221,5 +225,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.so9 libpng-1.5.0beta42/scripts/makefile.so9 --- libpng-1.4.3/scripts/makefile.so9 2010-06-25 19:32:28.159856712 -0500 +++ libpng-1.5.0beta42/scripts/makefile.so9 2010-08-18 08:12:23.500020160 -0500 @@ -82,8 +82,12 @@ $(CC) -c $(CFLAGS) -KPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -128,14 +132,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -207,9 +211,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -231,5 +235,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.solaris libpng-1.5.0beta42/scripts/makefile.solaris --- libpng-1.4.3/scripts/makefile.solaris 2010-06-25 19:32:28.170797213 -0500 +++ libpng-1.5.0beta42/scripts/makefile.solaris 2010-08-18 08:12:23.510905950 -0500 @@ -78,8 +78,12 @@ $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -125,14 +129,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -204,9 +208,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -228,5 +232,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.solaris-x86 libpng-1.5.0beta42/scripts/makefile.solaris-x86 --- libpng-1.4.3/scripts/makefile.solaris-x86 2010-06-25 19:32:28.181717948 -0500 +++ libpng-1.5.0beta42/scripts/makefile.solaris-x86 2010-08-18 08:12:23.521771147 -0500 @@ -78,8 +78,12 @@ $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -125,14 +129,14 @@ test: pngtest ./pngtest -install-headers: png.h pngconf.h +install-headers: png.h pngconf.h pnglibconf.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 + cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) + chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h + -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h -@$(RM_F) $(DI)/libpng (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) install-static: install-headers libpng.a @@ -204,9 +208,9 @@ clean: $(RM_F) *.o libpng.a pngtest pngtesti pngout.png \ libpng-config $(LIBSO) $(LIBSOMAJ)* \ - libpng.pc + libpng.pc pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -228,5 +232,5 @@ pngwtran.o pngwtran.pic.o: %HEADERS% pngwutil.o pngwutil.pic.o: %HEADERS% pngpread.o pngpread.pic.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.std libpng-1.5.0beta42/scripts/makefile.std --- libpng-1.4.3/scripts/makefile.std 2010-06-25 19:32:28.191346070 -0500 +++ libpng-1.5.0beta42/scripts/makefile.std 2010-08-18 08:12:23.531699314 -0500 @@ -32,9 +32,14 @@ MKDIR_P=mkdir LN_SF=ln -sf RANLIB=ranlib RM_F=rm -f +AWK = awk +SED = sed +CPP = $(CC) -E +ECHO = echo +DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ @@ -42,8 +47,28 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: libpng.a pngtest +# The standard pnglibconf.h exists as scripts/pnglibconf.h, +# copy this if the following doesn't work. +pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk + $(RM_F) $@ dfn?.out + $(AWK) -f scripts/options.awk out=dfn1.out\ + scripts/pnglibconf.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f scripts/options.awk out=dfn2.out dfn1.out 1>&2 + cp dfn2.out $@ + $(RM_F) dfn?.out + +pnglibconf.h: pnglibconf.dfn + $(RM_F) $@ dfn.c dfn?.out + $(ECHO) '#include "pnglibconf.dfn"' >dfn.c + $(CPP) $(DFNFLAGS) dfn.c >dfn1.out + $(SED) -n -e 's|^.*PNG_DEFN_MAGIC-\(.*\)-PNG_DEFN_END.*$$|\1|p'\ + dfn1.out >dfn2.out + $(SED) -e 's| *@@@ *||g' -e 's| *$$||' dfn2.out >dfn3.out + cp dfn3.out $@ + $(RM_F) dfn.c dfn?.out + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -52,24 +77,27 @@ test: pngtest ./pngtest -install: libpng.a +install: libpng.a pnglibconf.h -@$(MKDIR_P) $(DESTDIR)$(INCPATH) -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h + -@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) cp libpng.a $(DESTDIR)$(LIBPATH) chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a clean: - $(RM_F) *.o libpng.a pngtest pngout.png + $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.* dfn.c dfn?.out DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -91,5 +119,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.sunos libpng-1.5.0beta42/scripts/makefile.sunos --- libpng-1.4.3/scripts/makefile.sunos 2010-06-25 19:32:28.200927496 -0500 +++ libpng-1.5.0beta42/scripts/makefile.sunos 2010-08-18 08:12:23.541392288 -0500 @@ -47,8 +47,12 @@ pngwtran.o pngmem.o pngerror.o pngpread.o all: libpng.a pngtest +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + libpng.a: $(OBJS) $(AR_RC) $@ $(OBJS) $(RANLIB) $@ @@ -63,18 +67,21 @@ -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h + -@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng cp pngconf.h $(DESTDIR)$(INCPATH)/libpng + cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h + chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h (cd $(DESTDIR)$(INCPATH); $(LN_SF) libpng/* .) cp libpng.a $(DESTDIR)$(LIBPATH) chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a clean: - $(RM_F) *.o libpng.a pngtest pngout.png + $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: chmod a-w *.[ch35] $(DOCS) scripts/* @@ -96,5 +103,5 @@ pngwtran.o: %HEADERS% pngwutil.o: %HEADERS% pngpread.o: %HEADERS% -pngtest.o: png.h pngconf.h +pngtest.o: png.h pngconf.h pnglibconf.h diff -ru4NwbB libpng-1.4.3/scripts/makefile.tc3 libpng-1.5.0beta42/scripts/makefile.tc3 --- libpng-1.4.3/scripts/makefile.tc3 2010-06-25 19:32:28.210536495 -0500 +++ libpng-1.5.0beta42/scripts/makefile.tc3 2010-08-18 08:12:23.551072113 -0500 @@ -24,8 +24,12 @@ OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O) all: libpng$(MODEL).lib pngtest$(E) +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + pngtest: pngtest$(E) test: pngtest$(E) pngtest$(E) @@ -62,9 +66,9 @@ pngwio$(O): %HEADERS% $(CC) -c $(CFLAGS) $*.c -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h $(CC) -c $(CFLAGS) $*.c pngtrans$(O): %HEADERS% $(CC) -c $(CFLAGS) $*.c diff -ru4NwbB libpng-1.4.3/scripts/makefile.vcwin32 libpng-1.5.0beta42/scripts/makefile.vcwin32 --- libpng-1.4.3/scripts/makefile.vcwin32 2010-06-25 19:32:28.220180569 -0500 +++ libpng-1.5.0beta42/scripts/makefile.vcwin32 2010-08-18 08:12:23.560754124 -0500 @@ -34,8 +34,12 @@ # Targets all: libpng.lib +# see scripts/pnglibconf.mak for more options +pnglibconf.h: scripts/pnglibconf.h + cp scripts/pnglibconf.h $@ + png$(O): %HEADERS% $(CC) -c $(CFLAGS) $*.c $(ERRFILE) pngset$(O): %HEADERS% @@ -83,9 +87,9 @@ libpng.lib: $(OBJS) -$(RM) $@ $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) pngtest.exe: pngtest$(O) libpng.lib $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) @@ -95,8 +99,9 @@ clean: -$(RM) *$(O) -$(RM) libpng.lib + -$(RM) pnglibconf.h -$(RM) pngtest.exe -$(RM) pngout.png # End of makefile for libpng diff -ru4NwbB libpng-1.4.3/scripts/makefile.watcom libpng-1.5.0beta42/scripts/makefile.watcom --- libpng-1.4.3/scripts/makefile.watcom 2010-06-25 19:32:28.229937587 -0500 +++ libpng-1.5.0beta42/scripts/makefile.watcom 2010-08-18 08:12:23.570774758 -0500 @@ -48,8 +48,18 @@ all: test +# see scripts/pnglibconf.mak for more options +# to support watcom calling conventions it is necessary to set PNG_API_RULE to 2 +# in pnglibconf.h - copy scripts/pnglibconf.h, delete the first line and change +# the definition of PNG_API_RULE from 0 to 2. +# +# If you know how to do this with the Watcom build system please supply a patch +# for this makefile to the PNG implementation list. +pnglibconf.h: scripts/pnglibconf.h + @echo please copy scripts/pnglibconf.h and change PNG_API_RULE to 2 + png$(O): %HEADERS% $(CC) $(CFLAGS) $*.c $(ERRFILE) pngset$(O): %HEADERS% @@ -81,9 +91,9 @@ pngwio$(O): %HEADERS% $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h pnglibconf.h $(CC) $(CFLAGS) $*.c $(ERRFILE) pngtrans$(O): %HEADERS% $(CC) $(CFLAGS) $*.c $(ERRFILE) diff -ru4NwbB libpng-1.4.3/scripts/makevms.com libpng-1.5.0beta42/scripts/makevms.com --- libpng-1.4.3/scripts/makevms.com 2010-06-25 19:32:28.239861456 -0500 +++ libpng-1.5.0beta42/scripts/makevms.com 2010-08-18 08:12:23.580819618 -0500 @@ -86,9 +86,9 @@ $ 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" - - pngtest.c png.h pngconf.h + pngtest.c png.h pngconf.h pnglibconf.h $ call make pngtest.exe - "LINK pngtest,libpng.olb/lib,''zlibsrc'libz.olb/lib" - pngtest.obj libpng.olb $ write sys$output "Testing Libpng..." diff -ru4NwbB libpng-1.4.3/scripts/options.awk libpng-1.5.0beta42/scripts/options.awk --- libpng-1.4.3/scripts/options.awk 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/scripts/options.awk 2010-08-18 08:12:23.595444459 -0500 @@ -0,0 +1,734 @@ +#!/bin/awk -f +# scripts/options.awk - library build configuration control +# +# last changed in libpng version 1.5.0 - August 11, 2010 +# +# Copyright (c) 1998-2010 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# The output of this script is written to the file given by +# the variable 'out'. The script is run twice, once with +# an intermediate output file, 'options.tmp' then again on +# that file to produce the final output: +# +# awk -f scripts/options.awk out=options.tmp scripts/options.dfa 1>&2 +# awk -f scripts/options.awk out=options.dfn options.tmp 1>&2 +# +# Some options may be specified on the command line: +# +# deb=1 Causes debugging to be output +# logunsupported=1 Causes all options to be recorded in the output +# everything=off Causes all options to be disabled by default +# everything=on Causes all options to be enabled by default +# +# If awk fails on your platform, try nawk instead. +# +# These options may also be specified in the original input file (and +# are copied to the preprocessed file). + +BEGIN{ + out="/dev/null" # intermediate, preprocessed, file + pre=-1 # preprocess (first line) + err=0 # in-line exit sets this + start="PNG_DEFN_MAGIC-" # Arbitrary start + end="-PNG_DEFN_END" # Arbitrary end + cx= "/@@@*" # Open C comment for output file + comment=start cx # Comment start + cend="*/" end # Comment end + def=start "#define PNG_@@@" # Arbitrary define + sup="@@@_SUPPORTED" end # end supported option + und=comment "#undef PNG_@@@" # Unsupported option + une="@@@_SUPPORTED" cend # end unsupported option + error=start "ERROR:" # error message + + # Variables + deb=0 # debug - set on command line + everything="" # do not override defaults + logunsupported=0 # write unsupported options too + + # Precreate arrays + option[""] = "" # list of all options: default enabled/disabled + done[""] = 1 # marks option as having been output + requires[""] = "" # requires by option + iffs[""] = "" # if by option + enabledby[""] = "" # options that enable it by option + setting[""] = "" # requires by setting + defaults[""] = "" # used for a defaulted value + doneset[""] = 1 # marks setting as having been output + r[""] = "" # Temporary array + + # For decorating the output file + protect = "" +} + +# The output file must be specified before any input: +out == "/dev/null" { + print "out=output.file must be given on the command line" + err = 1 + exit 1 +} + +# The very first line indicates whether we are reading pre-processed +# input or not, this must come *first* because 'PREPROCESSED' needs +# to be the very first line in the temporary file. +pre == -1{ + if ($0 == "PREPROCESSED") { + pre = 0 + next + } else { + pre = 1 + print "PREPROCESSED" >out + # And fall through to continue processing + } +} + +# variable=value +# Sets the given variable to the given value (the syntax is fairly +# free form, except for deb (you are expected to understand how to +# set the debug variable...) +# +# This happens before the check on 'pre' below skips most of the +# rest of the actions, so the variable settings happen during +# preprocessing but are recorded in the END action too. This +# allows them to be set on the command line too. +$0 ~ /^[ ]*everything[ =]*off[ ]*$/{ + everything = "off" + next +} +$0 ~ /^[ ]*everything[ =]*on[ ]*$/{ + everything = "on" + next +} +$0 ~ /^[ ]*logunsupported[ =]*0[ ]*$/{ + logunsupported = 0 + next +} +$0 ~ /^[ ]*logunsupported[ =]*1[ ]*$/{ + logunsupported = 1 + next +} +$1 == "deb" && $2 == "=" && NF == 3{ + deb = $3 + next +} + +# Preprocessing - this just copies the input file with lines +# that need preprocessing (just chunk at present) expanded +# The bare "pre" instead of "pre != 0" crashes under Sunos awk +pre && $1 != "chunk"{ + print >out + next +} + +# The first characters of the line determine how it is processed, +# leading spaces are ignored. In general tokens that are not +# keywords are the names of options. An option 'name' is +# controlled by the definition of the corresponding macros: +# +# PNG_name_SUPPORTED The option is turned on +# PNG_NO_name +# PNG_NO_name_SUPPORTED If the first macro is not defined +# either of these will turn the option off +# +# If none of these macros are defined the option is turned on, unless +# the keyword 'off' is given in a line relating to the option. The +# keyword 'on' can also be given, but it will be ignored (since it is +# the default.) +# +# In the syntax below a 'name' is indicated by "NAME", other macro +# values are indicated by "MACRO", as with "NAME" the leading "PNG_" +# is omitted, but in this case the "NO_" prefix and the "_SUPPORTED" +# suffix are never used. +# +# Each line is introduced by a keyword - the first non-space characters +# on the line. A line starting with a '#' is a comment - it is totally +# ignored. Keywords are as follows, a NAME, is simply a macro name +# without the leading PNG_, PNG_NO_ or the trailing _SUPPORTED. + +$1 ~ /^#/ || $0 ~ /^[ ]*$/{ + next +} + +# com +# The whole line is placed in the output file as a comment with +# the preceding 'com' removed +$1 == "com"{ + if (NF > 1) { + # sub(/^[ ]*com[ ]*/, "") + $1 = "" + print comment, $0, cend >out + } else + print start end >out + next +} + +# file output input protect +# Informational: the official name of the input file (without +# make generated local directories), the official name of the +# output file and, if required, a name to use in a protection +# macro for the contents. +$1 == "file" && NF >= 2{ + print comment, $2, cend >out + print comment, "Machine generated file: DO NOT EDIT", cend >out + if (NF >= 3) + print comment, "Derived from:", $3, cend >out + protect = $4 + if (protect != "") { + print start "#ifndef", protect end >out + print start "#define", protect end >out + } + next +} + +# option NAME ( (requires|enables|if) NAME* | on | off | disabled )* +# Declares an option 'NAME' and describes its default setting (disabled) +# and its relationship to other options. The option is disabled +# unless *all* the options listed after 'requires' are set and at +# least one of the options listed after 'if' is set. If the +# option is set then it turns on all the options listed after 'enables'. +# +# Note that "enables" takes priority over the required/if/disabled/off +# setting of the target option. +# +# The definition file may list an option as 'disabled': off by default, +# otherwise the option is enabled: on by default. A later (and it must +# be later) entry may turn an option on or off explicitly. + +$1 == "option" && NF >= 2{ + onoff = option[$2] # records current (and the default is "", enabled) + key = "" + for (i=3; i<=NF; ++i) { + if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") { + key = "" + if (onoff != $(i)) { + # on or off can zap disabled or enabled: + if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) { + # It's easy to mis-spell the option when turning it + # on or off, so warn about it here: + if (onoff == "" && ($(i) == "on" || $(i) == "off")) { + print $2 ": ERROR: turning unrecognized option", $(i) + # For the moment error out - it is safer + err = 1 # prevent END{} running + exit 1 + } + onoff = $(i) + } else { + # Print a message, otherwise the error + # below is incomprehensible + print $2 ": currently", onoff ": attempt to turn", $(i) + break + } + } + } else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") { + key = $(i) + } else if (key == "requires") { + requires[$2] = requires[$2] " " $(i) + } else if (key == "if") { + iffs[$2] = iffs[$2] " " $(i) + } else if (key == "enables") { + enabledby[$(i)] = enabledby[$(i)] " " $2 + } else + break # bad line format + } + + if (i > NF) { + # Set the option, defaulting to 'enabled' + if (onoff == "") onoff = "enabled" + option[$2] = onoff + next + } + # Else fall through to the error handler +} + +# chunk NAME [requires OPT] [on|off|disabled] +# Expands to the 'option' settings appropriate to the reading and +# writing of an ancilliary PNG chunk 'NAME': +# +# option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT] +# option READ_NAME enables NAME +# [option READ_NAME off] +# option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT] +# option WRITE_NAME enables NAME +# [option WRITE_NAME off] + +pre != 0 && $1 == "chunk" && NF >= 2{ + # 'chunk' is handled on the first pass by writing appropriate + # 'option' lines into the intermediate file. + onoff = "" + reqread = "" + reqwrite = "" + i = 3 # indicates format error + if (NF > 2) { + # read the keywords/additional OPTS + req = 0 + for (i=3; i<=NF; ++i) { + if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") { + if (onoff != $(i)) { + if (onoff == "") + onoff = $(i) + else + break # on/off conflict + } + } else if ($(i) == "requires") + req = 1 + else if (req != 1) + break # bad line: handled below + else { + reqread = reqread " READ_" $(i) + reqwrite = reqwrite " WRITE_" $(i) + } + } + } + + if (i > NF) { + # Output new 'option' lines to the intermediate file (out) + print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2, onoff >out + print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2, onoff >out + next + } + # Else hit the error handler below - bad line format! +} + +# setting MACRO ( requires MACRO* )* [ default VALUE ] +# Behaves in a similar way to 'option' without looking for NO_ or +# _SUPPORTED; the macro is enabled if it is defined so long as all +# the 'requires' macros are also defined. The definitions may be +# empty, an error will be issued if the 'requires' macros are +# *not* defined. If given the 'default' value is used if the +# macro is not defined. The default value will be re-tokenised. +# (BTW: this is somewhat restrictive, it mainly exists for the +# support of non-standard configurations and numeric parameters, +# see the uses in scripts/options.dat + +$1 == "setting" && (NF == 2 || NF >= 3 && ($3 == "requires" || $3 == "default")){ + reqs = "" + deflt = "" + isdef = 0 + key = "" + for (i=3; i<=NF; ++i) + if ($(i) == "requires" || $(i) == "default") { + key = $(i) + if (key == "default") isdef = 1 + } else if (key == "requires") + reqs = reqs " " $(i) + else if (key == "default") + deflt = deflt " " $(i) + else + break # Format error, handled below + + setting[$2] = reqs + # NOTE: this overwrites a previous value silently + if (isdef && deflt == "") + deflt = " " # as a flag to force output + defaults[$2] = deflt + next +} + +# The order of the dependency lines (option, chunk, setting) is irrelevant +# - the 'enables', 'requires' and 'if' settings will be used to determine +# the correct order in the output and the final values in pnglibconf.h are +# not order dependent. 'requires' and 'if' entries take precedence over +# 'enables' from other options; if an option requires another option it +# won't be set regardless of any options that enable it unless the other +# option is also enabled. +# +# Similarly 'enables' trumps a NO_ definition in CFLAGS or pngusr.h +# +# For simplicity cycles in the definitions are regarded as errors, +# even if they are not ambiguous. +# A given NAME can be specified in as many 'option' lines as required, the +# definitions are additive. + +# For backwards compatibility equivalent macros may be listed thus: +# +# = [NO_]NAME MACRO +# Makes -DMACRO equivalent to -DPNG_NO_NAME or -DPNG_NAME_SUPPORTED +# as appropriate. +# +# The definition is injected into the C compiler input when encountered +# in the second pass (so all these definitions appear *after* the @ +# lines!) +# +# 'NAME' is as above, but 'MACRO' is the full text of the equivalent +# old, deprecated, macro. + +$1 == "=" && NF == 3{ + print "#ifdef PNG_" $3 >out + if ($2 ~ /^NO_/) + print "# define PNG_" $2 >out + else + print "# define PNG_" $2 "_SUPPORTED" >out + print "#endif" >out + next +} + +# Lines may be injected into the C compiler input by preceding them +# with an "@" character. The line is copied with just the leading +# @ removed. + +$1 ~ /^@/{ + # sub(/^[ ]*@/, "") + $1 = substr($1, 2) + print >out + next +} + +# Check for unreognized lines, because of the preprocessing chunk +# format errors will be detected on the first pass independent of +# any other format errors. +{ + print "options.awk: bad line (" NR "):", $0 + err = 1 # prevent END{} running + exit 1 +} + +# For checking purposes names that start with "ok_" or "fail_" are +# not output to pnglibconf.h and must be either enabled or disabled +# respectively for the build to succeed. This allows interdependencies +# between options of the form "at least one of" or "at most one of" +# to be checked. For example: +# +# option FLOATING_POINT enables ok_math +# option FIXED_POINT enables ok_math +# This ensures that at least one of FLOATING_POINT and FIXED_POINT +# must be set for the build to succeed. +# +# option fail_math requires FLOATING_POINT FIXED_POINT +# This means the build will fail if *both* FLOATING_POINT and +# FIXED_POINT are set (this is an example; in fact both are allowed.) +# +# If all these options were given the build would require exactly one +# of the names to be enabled. + +END{ + # END{} gets run on an exit (a traditional awk feature) + if (err) exit 1 + + if (pre) { + # Record the final value of the variables + print "deb =", deb >out + if (everything != "") { + print "everything =", everything >out + } + print "logunsupported =", logunsupported >out + exit 0 + } + + # Do the 'setting' values first, the algorithm the standard + # tree walk (O(1)) done in an O(2) while/for loop; interations + # settings x depth, outputing the deepest required macros + # first. + print "" >out + print "/* SETTINGS */" >out + print comment, "settings", cend >out + finished = 0 + while (!finished) { + finished = 1 + movement = 0 # done nothing + for (i in setting) if (!doneset[i]) { + nreqs = split(setting[i], r) + if (nreqs > 0) { + for (j=1; j<=nreqs; ++j) if (!doneset[r[j]]) { + break + } + if (j<=nreqs) { + finished = 0 + continue # try a different setting + } + } + + # All the requirements have been processed, output + # this setting. + if (deb) print "setting", i + print "" >out + print "/* setting: ", i >out + print " * requires:" setting[i] >out + print " * default: ", defaults[i], "*/" >out + if (defaults[i] == "") { # no default, only check if defined + print "#ifdef PNG_" i >out + } + for (j=1; j<=nreqs; ++j) { + print "# ifndef PNG_" r[j] >out + print error, i, "requires", r[j] end >out + print "# endif" >out + } + if (defaults[i] != "") { # default handling + print "#ifdef PNG_" i >out + } + print def i, "PNG_" i end >out + if (defaults[i] != "") { + print "#else /*default*/" >out + # And add the default definition for the benefit + # of later settings an options test: + print "# define PNG_" i defaults[i] >out + print def i defaults[i] end >out + } + print "#endif" >out + + doneset[i] = 1 + ++movement + } + + if (!finished && !movement) { + print "setting: loop or missing setting in 'requires', cannot process:" + for (i in setting) if (!doneset[i]) { + print " setting", i, "requires" setting[i] + } + exit 1 + } + } + print comment, "end of settings", cend >out + + # Now do the options - somewhat more complex. The dependency + # tree is thus: + # + # name > name + # name requires name + # name if name + # name enabledby name + # + # First build a list 'tree' by option of all the things on which + # it depends. + print "" >out + print "/* OPTIONS */" >out + print comment, "options", cend >out + for (opt in enabledby) tree[opt] = 1 # may not be explicit options + for (opt in option) if (opt != "") { + o = option[opt] + # option should always be one of the following values + if (o != "on" && o != "off" && o != "disabled" && o != "enabled") { + print "internal option error (" o ")" + exit 1 + } + tree[opt] = "" # so unlisted options marked + } + for (opt in tree) if (opt != "") { + if (tree[opt] == 1) { + tree[opt] = "" + if (option[opt] != "") { + print "internal error (1)" + exit 1 + } + # Macros only listed in 'enables' remain off unless + # one of the enabling macros is on. + option[opt] = "disabled" + } + + split("", list) # clear 'list' + # Now add every requires, iffs or enabledby entry to 'list' + # so that we can add a unique list of requirements to tree[i] + split(requires[opt] iffs[opt] enabledby[opt], r) + for (i in r) list[r[i]] = 1 + for (i in list) tree[opt] = tree[opt] " " i + } + + # print the tree for extreme debugging + if (deb > 2) for (i in tree) if (i != "") print i, "depends-on" tree[i] + + # Ok, now check all options marked explicitly 'on' or 'off': + # + # If an option[opt] is 'on' then turn on all requires[opt] + # If an option[opt] is 'off' then turn off all enabledby[opt] + # + # Error out if we have to turn 'on' an 'off' option or vice versa. + npending = 0 + for (opt in option) if (opt != "") { + if (option[opt] == "on" || option[opt] == "off") { + pending[++npending] = opt + } + } + + err = 0 # set on error + while (npending > 0) { + opt = pending[npending--] + if (option[opt] == "on") { + nreqs = split(requires[opt], r) + for (j=1; j<=nreqs; ++j) { + if (option[r[j]] == "off") { + print "option", opt, "turned on, but requirement", r[j], "is turned off" + err = 1 + } else if (option[r[j]] != "on") { + option[r[j]] = "on" + pending[++npending] = r[j] + } + } + } else { + if (option[opt] != "off") { + print "internal error (2)" + exit 1 + } + nreqs = split(enabledby[opt], r) + for (j=1; j<=nreqs; ++j) { + if (option[r[j]] == "on") { + print "option", opt, "turned off, but enabled by", r[j], "which is turned on" + err = 1 + } else if (option[r[j]] != "off") { + option[r[j]] = "off" + pending[++npending] = r[j] + } + } + } + } + if (err) exit 1 + + # option[i] is now the complete list of all the tokens we may + # need to output, go through it as above, depth first. + finished = 0 + while (!finished) { + finished = 1 + movement = 0 # done nothing + for (i in option) if (!done[i]) { + nreqs = split(tree[i], r) + if (nreqs > 0) { + for (j=1; j<=nreqs; ++j) if (!done[r[j]]) { + break + } + if (j<=nreqs) { + finished = 0 + continue # next option + } + } + + # All the requirements have been processed, output + # this option. An option is _SUPPORTED if: + # + # all 'requires' are _SUPPORTED AND + # at least one of the 'if' options are _SUPPORTED AND + # EITHER: + # The name is _SUPPORTED (on the command line) + # OR: + # an 'enabledby' is _SUPPORTED + # OR: + # NO_name is not defined AND + # the option is not disabled; an option is disabled if: + # option == off + # option == disabled && everything != on + # option == "" && everything == off + if (deb) print "option", i + print "" >out + print "/* option:", i, option[i] >out + print " * requires: " requires[i] >out + print " * if: " iffs[i] >out + print " * enabled-by:" enabledby[i], "*/" >out + print "#undef PNG_on" >out + print "#define PNG_on 1" >out + + # requires + nreqs = split(requires[i], r) + for (j=1; j<=nreqs; ++j) { + print "#ifndef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_on /*!" r[j] "*/" >out + # this error appears in the final output if something + # was switched 'on' but the processing above to force + # the requires did not work + if (option[i] == "on") { + print error, i, "requires", r[j] end >out + } + print "#endif" >out + } + + # if + nreqs = split(iffs[i], r) + print "#undef PNG_no_if" >out + if (nreqs > 0) { + print "/* if" iffs[i], "*/" >out + print "#define PNG_no_if 1" >out + for (j=1; j<=nreqs; ++j) { + print "#ifdef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_no_if /*" r[j] "*/" >out + print "#endif" >out + } + print "#ifdef PNG_no_if /*missing if*/" >out + print "# undef PNG_on" >out + # There is no checking above for this, because we + # don't know which 'if' to choose, so whine about + # it here: + if (option[i] == "on") { + print error, i, "needs one of:", iffs[i] end >out + } + print "#endif" >out + } + + print "#ifdef PNG_on /*requires, if*/" >out + # enables + print "# undef PNG_not_enabled" >out + print "# define PNG_not_enabled 1" >out + print " /* enabled by" enabledby[i], "*/" >out + nreqs = split(enabledby[i], r) + for (j=1; j<=nreqs; ++j) { + print "#ifdef PNG_" r[j] "_SUPPORTED" >out + print "# undef PNG_not_enabled /*" r[j] "*/" >out + # Oops, probably not intended (should be factored + # out by the checks above). + if (option[i] == "off") { + print error, i, "enabled by:", r[j] end >out + } + print "#endif" >out + } + + print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out + print "# ifdef PNG_not_enabled /*!enabled*/" >out + if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off") { + print "# undef PNG_on /*default off*/" >out + } else { + print "# ifdef PNG_NO_" i >out + print "# undef PNG_on /*turned off*/" >out + print "# endif" >out + print "# ifdef PNG_NO_" i "_SUPPORTED" >out + print "# undef PNG_on /*turned off*/" >out + print "# endif" >out + } + print "# endif /*!enabled*/" >out + print "# ifdef PNG_on" >out + # The _SUPPORTED macro must be defined so that dependent + # options output later work. + print "# define PNG_" i "_SUPPORTED" >out + print "# endif" >out + print "# endif /*!command line*/" >out + # If PNG_on is still set the option should be defined in + # pnglibconf.h + print "# ifdef PNG_on" >out + if (i ~ /^fail_/) { + print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out + } else if (i !~ /^ok_/) { + print def i sup >out + } + print "# endif /* definition */" >out + print "#endif /*requires, if*/" >out + if (logunsupported || i ~ /^ok_/) { + print "#ifndef PNG_on" >out + if (logunsupported) { + print und i une >out + } + if (i ~ /^ok_/) { + print error, i, "not enabled: requires:" requires[i] ", enabled by:" iffs[i] enabledby[i] end >out + } + print "#endif" >out + } + + done[i] = 1 + ++movement + } + + if (!finished && !movement) { + print "option: loop or missing option in dependency tree, cannot process:" + for (i in option) if (!done[i]) { + print " option", i, "depends on" tree[i], "needs:" + nreqs = split(tree[i], r) + if (nreqs > 0) for (j=1; j<=nreqs; ++j) if (!done[r[j]]) { + print " " r[j] + } + } + exit 1 + } + } + print comment, "end of options", cend >out + + # Regular end - everything looks ok + if (protect != "") { + print start "#endif", cx, protect, "*/" end >out + } +} diff -ru4NwbB libpng-1.4.3/scripts/png32ce.def libpng-1.5.0beta42/scripts/png32ce.def --- libpng-1.4.3/scripts/png32ce.def 2010-06-25 19:32:28.250427777 -0500 +++ libpng-1.5.0beta42/scripts/png32ce.def 1969-12-31 18:00:00.000000000 -0600 @@ -1,259 +0,0 @@ -;------------------------------------------ -; LIBPNG module definition file for Windows -;------------------------------------------ - -LIBRARY lpngce - - png_memcpy_check - png_memset_check - png_set_quantize - png_read_init_3 - png_write_init_3 - png_set_strip_error_numbers - png_get_uint_32 - png_get_uint_16 - png_get_int_32 - -EXPORTS -;Version 1.5.0beta42 - 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 @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_quantize @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 @107 ; deprecated - 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 -; png_libpng_ver @170 - png_init_io @171 - png_convert_to_rfc1123 @172 - png_set_invalid @173 -; Added at version 1.0.12 -; For compatiblity 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 @179 - png_zalloc @180 - png_zfree @181 -; png_handle_as_unknown @194 -; png_zalloc @195 -; png_zfree @196 -; 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 -; Added at version 1.2.41 - png_write_sig @208 - png_benign_error @209 - png_benign_chunk_error @210 - png_set_benign_error @211 - png_get_io_chunk_name @212 - png_get_io_state @213 - png_get_chunk_cache_max @215 - png_set_chunk_cache_max @216 - png_check_cHRM_fixed @217 - png_calloc @218 - png_set_longjmp_fn @219 -; Added at version 1.4.1 - png_get_chunk_malloc_max @220 - png_set_chunk_malloc_max @221 diff -ru4NwbB libpng-1.4.3/scripts/pnglibconf.dfa libpng-1.5.0beta42/scripts/pnglibconf.dfa --- libpng-1.4.3/scripts/pnglibconf.dfa 1969-12-31 18:00:00.000000000 -0600 +++ libpng-1.5.0beta42/scripts/pnglibconf.dfa 2010-08-18 08:12:23.608631674 -0500 @@ -0,0 +1,493 @@ +# scripts/pnglibconf.dfa - library build configuration control +# +@/*- pnglibconf.dfn intermediate file +@ * generated from scripts/pnglibconf.dfa +@ */ +# +com pnglibconf.h - library build configuration +com +com libpng version PNGLIB_VERSION - last changed on August 11, 2010 +com +com Copyright (c) 1998-2010 Glenn Randers-Pehrson +com +com This code is released under the libpng license. +com For conditions of distribution and use, see the disclaimer +com and license in png.h +com +file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H + +# This file is preprocessed by scripts/options.awk and the +# C compiler to generate 'pnglibconf.h' - a list of all the +# configuration options. The file lists the various options +# that can *only* be specified during the libpng build; +# pnglibconf.h freezes the definitons selected for the specific +# build. +# +# The syntax is detailed in scripts/options.awk, this is a summary +# only: +# +# setting [requires ...] [default] +# #define PNG_ /* value comes from current setting */ +# option [requires ...] [if ...] [enables ...] [disabled] +# #define PNG__SUPPORTED if the requirements are met and +# enable the other options listed +# chunk [requires ...] [disabled] +# Enable chunk processing for the given ancillary chunk +# +# Note that the 'on' and 'off' keywords, while valid on both option +# and chunk, should not be used in this file because they force the +# relevant options on or off. + +#---------------------------------------------------------------------- + +# The following setting, option and chunk values can all be changed +# while building libpng: +# +# setting: change 'setting' lines to fine tune library performance, +# changes to the settings don't affect the libpng API functionally +# +# option: change 'option' lines to remove or add capabilities from +# or to the library; options change the library API +# +# chunk: change 'chunk' lines to remove capabilities to process +# optional ('ancillary') chunks. This does not prevent PNG +# decoding but does change the libpng API because some chunks +# will be ignored. +# +# There are three ways of disabling features, in no particular order: +# +# 1) Create 'pngusr.h', enter the required private build information +# detailed below and #define PNG_NO_