Compare commits

...

99 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
0f820b1a70 [libpng10] Imported from libpng-1.0.62.tar 2014-11-20 10:54:25 -06:00
Glenn Randers-Pehrson
9d6ff2c566 [libpng10] Imported from libpng-1.0.61.tar 2014-02-05 22:13:50 -06:00
Glenn Randers-Pehrson
0fc7d58632 [libpng10] Imported from libpng-1.0.60.tar 2012-07-10 20:52:01 -05:00
Glenn Randers-Pehrson
4761085af8 [libpng10] Imported from libpng-1.0.59.tar 2012-03-29 06:28:47 -05:00
Glenn Randers-Pehrson
e4e87743af [libpng10] Update version numbers in ANNOUNCE 2012-03-08 07:53:19 -06:00
Glenn Randers-Pehrson
8d15fc29b0 [libpng10] Imported from libpng-1.0.58.tar 2012-03-08 07:30:37 -06:00
Glenn Randers-Pehrson
ddda5f01c7 [libpng10] Imported from libpng-1.0.57.tar 2012-02-19 00:02:08 -06:00
Glenn Randers-Pehrson
83a7187a28 [libpng10] Imported from libpng-1.0.56.tar 2011-09-03 12:29:00 -05:00
Glenn Randers-Pehrson
8d3449ca03 [libpng10] Imported from libpng-1.0.56rc01.tar 2011-09-03 12:27:21 -05:00
Glenn Randers-Pehrson
62095d5f03 [libpng10] Imported from libpng-1.0.55.tar 2011-09-03 12:27:19 -05:00
Glenn Randers-Pehrson
8b1b797f87 [libpng10] Imported from libpng-1.0.55rc01.tar 2011-09-03 12:27:16 -05:00
Glenn Randers-Pehrson
b7f5fe1430 [libpng10] Imported from libpng-1.0.54.tar 2011-09-03 12:27:14 -05:00
Glenn Randers-Pehrson
9b0cc95bb7 [libpng10] Imported from libpng-1.0.53.tar 2011-09-03 12:27:11 -05:00
Glenn Randers-Pehrson
c76174bdf5 [libpng10] Imported from libpng-1.0.53rc02.tar 2011-09-03 12:27:08 -05:00
Glenn Randers-Pehrson
52f70cca54 [libpng10] Imported from libpng-1.0.53rc01.tar 2011-09-03 12:27:06 -05:00
Glenn Randers-Pehrson
a4ad250d5a [libpng10] Imported from libpng-1.0.53beta02.tar 2011-09-03 12:27:03 -05:00
Glenn Randers-Pehrson
9c9662527e [libpng10] Imported from libpng-1.0.53beta01.tar 2011-09-03 12:27:00 -05:00
Glenn Randers-Pehrson
73176b9030 [libpng10] Imported from libpng-1.0.52.tar 2011-09-03 12:26:58 -05:00
Glenn Randers-Pehrson
d7e43f93ff [libpng10] Imported from libpng-1.0.52rc02.tar 2011-09-03 12:26:55 -05:00
Glenn Randers-Pehrson
74caee01a4 [libpng10] Imported from libpng-1.0.52rc01.tar 2011-09-03 12:26:52 -05:00
Glenn Randers-Pehrson
7836e21894 [libpng10] Imported from libpng-1.0.51.tar 2011-09-03 12:26:50 -05:00
Glenn Randers-Pehrson
270a623b90 [libpng10] Imported from libpng-1.0.51rc01.tar 2011-09-03 12:26:47 -05:00
Glenn Randers-Pehrson
afbb32433c [libpng10] Imported from libpng-1.0.50.tar 2011-09-03 12:26:45 -05:00
Glenn Randers-Pehrson
e058ce14ea [libpng10] Imported from libpng-1.0.48.tar 2011-09-03 12:26:42 -05:00
Glenn Randers-Pehrson
1e73a532f5 [libpng10] Imported from libpng-1.0.47.tar 2011-09-03 12:26:39 -05:00
Glenn Randers-Pehrson
073070791a [libpng10] Imported from libpng-1.0.46.tar 2011-09-03 12:26:37 -05:00
Glenn Randers-Pehrson
4049c1ac2a [libpng10] Imported from libpng-1.0.45.tar 2011-09-03 12:26:34 -05:00
Glenn Randers-Pehrson
4fa097d58b [libpng10] Imported from libpng-1.0.44.tar 2011-09-03 12:26:31 -05:00
Glenn Randers-Pehrson
bceda5f9d6 [libpng10] Imported from libpng-1.0.43.tar 2011-09-03 12:26:29 -05:00
Glenn Randers-Pehrson
53ab12bb91 [libpng10] Imported from libpng-1.0.43rc02.tar 2011-09-03 12:26:26 -05:00
Glenn Randers-Pehrson
1f6c3eb4e0 [libpng10] Imported from libpng-1.0.43rc01.tar 2011-09-03 12:26:24 -05:00
Glenn Randers-Pehrson
c802480614 [libpng10] Imported from libpng-1.0.42.tar 2011-09-03 12:26:21 -05:00
Glenn Randers-Pehrson
0b86d89622 [libpng10] Imported from libpng-1.0.42rc01.tar 2011-09-03 12:26:18 -05:00
Glenn Randers-Pehrson
ebfd716fc4 [libpng10] Imported from libpng-1.0.41.tar 2011-09-03 12:26:15 -05:00
Glenn Randers-Pehrson
19a2ee7a55 [libpng10] Imported from libpng-1.0.41rc01.tar 2011-09-03 12:26:13 -05:00
Glenn Randers-Pehrson
5314d4afa8 [libpng10] Imported from libpng-1.0.40.tar 2011-09-03 12:26:10 -05:00
Glenn Randers-Pehrson
196d964a5c [libpng10] Imported from libpng-1.0.40rc01.tar 2011-09-03 12:26:07 -05:00
Glenn Randers-Pehrson
d061149ae8 [libpng10] Imported from libpng-1.0.39.tar 2011-09-03 12:26:05 -05:00
Glenn Randers-Pehrson
62fef7d0ca [libpng10] Imported from libpng-1.0.39rc03.tar 2011-09-03 12:26:02 -05:00
Glenn Randers-Pehrson
a22f977a29 [libpng10] Imported from libpng-1.0.39rc02.tar 2011-09-03 12:26:00 -05:00
Glenn Randers-Pehrson
e8c732dffb [libpng10] Imported from libpng-1.0.39rc01.tar 2011-09-03 12:25:57 -05:00
Glenn Randers-Pehrson
212ff60146 [libpng10] Imported from libpng-1.0.38.tar 2011-09-03 12:25:55 -05:00
Glenn Randers-Pehrson
fb4edffd05 [libpng10] Imported from libpng-1.0.38rc08.tar 2011-09-03 12:25:52 -05:00
Glenn Randers-Pehrson
ab85e8f491 [libpng10] Imported from libpng-1.0.38rc07.tar 2011-09-03 12:25:49 -05:00
Glenn Randers-Pehrson
ac9a0378fd [libpng10] Imported from libpng-1.0.38rc06.tar 2011-09-03 12:25:47 -05:00
Glenn Randers-Pehrson
cf77d0d594 [libpng10] Imported from libpng-1.0.38rc05.tar 2011-09-03 12:25:44 -05:00
Glenn Randers-Pehrson
6b0bf2742b [libpng10] Imported from libpng-1.0.38rc04.tar 2011-09-03 12:25:41 -05:00
Glenn Randers-Pehrson
49838313fc [libpng10] Imported from libpng-1.0.38rc03.tar 2011-09-03 12:25:38 -05:00
Glenn Randers-Pehrson
881e55a189 [libpng10] Imported from libpng-1.0.38rc02.tar 2011-09-03 12:25:36 -05:00
Glenn Randers-Pehrson
0303ee804d [libpng10] Imported from libpng-1.0.38rc01.tar 2011-09-03 12:25:33 -05:00
Glenn Randers-Pehrson
3f6e7d5e64 [libpng10] Imported from libpng-1.0.37.tar 2011-09-03 12:25:31 -05:00
Glenn Randers-Pehrson
ac278cc06a [libpng10] Imported from libpng-1.0.35.tar 2011-09-03 12:25:28 -05:00
Glenn Randers-Pehrson
dc2e72f1a2 [libpng10] Imported from libpng-1.0.34.tar 2011-09-03 12:25:25 -05:00
Glenn Randers-Pehrson
38f0418ee7 [libpng10] Imported from libpng-1.0.33.tar 2011-09-03 12:25:22 -05:00
Glenn Randers-Pehrson
4f66bef47f [libpng10] Imported from libpng-1.0.32.tar 2011-09-03 12:25:20 -05:00
Glenn Randers-Pehrson
80d4e25c9d [libpng10] Imported from libpng-1.0.31.tar 2011-09-03 12:25:17 -05:00
Glenn Randers-Pehrson
be5217de8c [libpng10] Imported from libpng-1.0.31rc01.tar 2011-09-03 12:25:15 -05:00
Glenn Randers-Pehrson
f9b9775253 [libpng10] Imported from libpng-1.0.30.tar 2011-09-03 12:25:12 -05:00
Glenn Randers-Pehrson
b007817932 [libpng10] Imported from libpng-1.0.30rc1.tar 2011-09-03 12:25:09 -05:00
Glenn Randers-Pehrson
fd4078cb1b [libpng10] Imported from libpng-1.0.29.tar 2011-09-03 12:25:07 -05:00
Glenn Randers-Pehrson
ad57dbb530 [libpng10] Imported from libpng-1.0.29rc3.tar 2011-09-03 12:25:04 -05:00
Glenn Randers-Pehrson
39acfab5bc [libpng10] Imported from libpng-1.0.29rc2.tar 2011-09-03 12:25:01 -05:00
Glenn Randers-Pehrson
43a349ae4a [libpng10] Imported from libpng-1.0.29rc1.tar 2011-09-03 12:24:58 -05:00
Glenn Randers-Pehrson
02f800dbd6 [libpng10] Imported from libpng-1.0.29beta1.tar 2011-09-03 12:24:56 -05:00
Glenn Randers-Pehrson
f9d6ce301d [libpng10] Imported from libpng-1.0.28.tar 2011-09-03 12:24:53 -05:00
Glenn Randers-Pehrson
725c747abe [libpng10] Imported from libpng-1.0.28rc6.tar 2011-09-03 12:24:51 -05:00
Glenn Randers-Pehrson
3f7bcb635e [libpng10] Imported from libpng-1.0.28rc5.tar 2011-09-03 12:24:48 -05:00
Glenn Randers-Pehrson
cb15afd5ce [libpng10] Imported from libpng-1.0.28rc4.tar 2011-09-03 12:24:45 -05:00
Glenn Randers-Pehrson
0e0798b796 [libpng10] Imported from libpng-1.0.28rc3.tar 2011-09-03 12:24:43 -05:00
Glenn Randers-Pehrson
a41eecbdd4 [libpng10] Imported from libpng-1.0.28rc2.tar 2011-09-03 12:24:40 -05:00
Glenn Randers-Pehrson
01f17eee9e [libpng10] Imported from libpng-1.0.27.tar 2011-09-03 12:24:37 -05:00
Glenn Randers-Pehrson
430d11ea06 [libpng10] Imported from libpng-1.0.27rc6.tar 2011-09-03 12:24:34 -05:00
Glenn Randers-Pehrson
bfb1ddd2c9 [libpng10] Imported from libpng-1.0.27rc5.tar 2011-09-03 12:24:31 -05:00
Glenn Randers-Pehrson
0a7bbf8697 [libpng10] Imported from libpng-1.0.27rc4.tar 2011-09-03 12:24:29 -05:00
Glenn Randers-Pehrson
59e559b2a2 [libpng10] Imported from libpng-1.0.27rc3.tar 2011-09-03 12:24:26 -05:00
Glenn Randers-Pehrson
9bc3a1fdd4 [libpng10] Imported from libpng-1.0.27rc2.tar 2011-09-03 12:24:23 -05:00
Glenn Randers-Pehrson
14ae6c1d94 [libpng10] Imported from libpng-1.0.27rc1.tar 2011-09-03 12:24:21 -05:00
Glenn Randers-Pehrson
1719fac606 [libpng10] Imported from libpng-1.0.26.tar 2011-09-03 12:24:18 -05:00
Glenn Randers-Pehrson
c79c23c0d5 [libpng10] Imported from libpng-1.0.25.tar 2011-09-03 12:24:15 -05:00
Glenn Randers-Pehrson
918dc976d5 [libpng10] Imported from libpng-1.0.25rc2.tar 2011-09-03 12:24:13 -05:00
Glenn Randers-Pehrson
928d84e713 [libpng10] Imported from libpng-1.0.25rc1.tar 2011-09-03 12:24:10 -05:00
Glenn Randers-Pehrson
764b52ad45 [libpng10] Imported from libpng-1.0.24.tar 2011-09-03 12:24:07 -05:00
Glenn Randers-Pehrson
551892bb60 [libpng10] Imported from libpng-1.0.24rc1.tar 2011-09-03 12:24:05 -05:00
Glenn Randers-Pehrson
1a2e75ccf1 [libpng10] Imported from libpng-1.0.23.tar 2011-09-03 12:24:02 -05:00
Glenn Randers-Pehrson
fb088b9cca [libpng10] Imported from libpng-1.0.23rc5.tar 2011-09-03 12:23:59 -05:00
Glenn Randers-Pehrson
a3a5d7c172 [libpng10] Imported from libpng-1.0.23rc4.tar 2011-09-03 12:23:57 -05:00
Glenn Randers-Pehrson
295e9df783 [libpng10] Imported from libpng-1.0.23rc3.tar 2011-09-03 12:23:54 -05:00
Glenn Randers-Pehrson
ef860dab8f [libpng10] Imported from libpng-1.0.23rc2.tar 2011-09-03 12:23:51 -05:00
Glenn Randers-Pehrson
e696c7205a [libpng10] Imported from libpng-1.0.23rc1.tar 2011-09-03 12:23:49 -05:00
Glenn Randers-Pehrson
1ff473f3fd [libpng10] Imported from libpng-1.0.22.tar 2011-09-03 12:23:46 -05:00
Glenn Randers-Pehrson
b88935a8b2 [libpng10] Imported from libpng-1.0.22rc1.tar 2011-09-03 12:23:43 -05:00
Glenn Randers-Pehrson
64b481e714 [libpng10] Imported from libpng-1.0.21.tar 2011-09-03 12:23:41 -05:00
Glenn Randers-Pehrson
0f5e1e5a39 [libpng10] Imported from libpng-1.0.21rc2.tar 2011-09-03 12:23:38 -05:00
Glenn Randers-Pehrson
6fbb54d253 [libpng10] Imported from libpng-1.0.21rc1.tar 2011-09-03 12:23:36 -05:00
Glenn Randers-Pehrson
fba872492b [libpng10] Imported from libpng-1.0.20.tar 2011-09-03 12:23:33 -05:00
Glenn Randers-Pehrson
82282113b9 [libpng10] Imported from libpng-1.0.19.tar 2011-09-03 12:23:31 -05:00
Glenn Randers-Pehrson
a095d92224 [libpng10] Imported from libpng-1.0.19rc5.tar 2011-09-03 12:23:28 -05:00
Glenn Randers-Pehrson
ff518067c3 [libpng10] Imported from libpng-1.0.19rc2.tar 2011-09-03 12:23:26 -05:00
Glenn Randers-Pehrson
db576fa76b [libpng10] Imported from libpng-1.0.19rc1.tar 2011-09-03 12:23:23 -05:00
169 changed files with 61680 additions and 22347 deletions

View File

@@ -1,31 +1,55 @@
Libpng 1.0.18 - December 3, 2004 Libpng 1.0.62 - February 6, 2014
This is a public release of libpng, intended for use in production codes. This is a public release of libpng, intended for use in production codes.
Changes since the last public release (1.0.17): Files available for download:
Fixed bug in png_text_compress() that would fail to complete a large block. Source files with LF line endings (for Unix/Linux) and with a
Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during "configure" script
strip alpha operation in png_do_strip_filler().
#ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0)
Reduce color_type to a nonalpha type after strip alpha operation in
png_do_strip_filler().
Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM
Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin).
Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin).
Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection
of data type in deflate (Cosmin).
Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of
PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
Despammed mailing addresses by masking "@" with "at".
Added scripts/makefile.elf with supporting code in pngconf.h for symbol
versioning (John Bowler).
Added projects/visualc71 (Simon-pierre).
Send comments/corrections/commendations to libpng-1.0.62.tar.xz (LZMA-compressed, recommended)
png-implement at ccrc.wustl.edu (subscription required; write to libpng-1.0.62.tar.gz
majordomo at ccrc.wustl.edu with "subscribe png-implement" in the message) libpng-1.0.62.tar.bz2
Source files with LF line endings (for Unix/Linux) without the
"configure" script
libpng-1.0.62-no-config.tar.xz (LZMA-compressed, recommended)
libpng-1.0.62-no-config.tar.gz
libpng-1.0.62-no-config.tar.bz2
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1062.zip
lpng1062.7z
lpng1062.tar.bz2
Project files
libpng-1.0.62-project-netware.zip
libpng-1.0.62-project-wince.zip
Other information:
libpng-1.0.62-README.txt
libpng-1.0.62-KNOWNBUGS.txt
libpng-1.0.62-LICENSE.txt
libpng-1.0.62-Y2K-compliance.txt
libpng-1.0.62-*.asc (armored detached GPG signatures)
Changes since the last public release (1.0.61):
Avoid out-of-bounds memory access while checking version string in
pngread.c and pngwrite.c
Added "-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS" to
CFLAGS in scripts/makefile.vcwin32
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe)
or to glennrp at users.sourceforge.net or to glennrp at users.sourceforge.net
Glenn R-P Glenn R-P
#endif

1448
CHANGES

File diff suppressed because it is too large Load Diff

176
INSTALL
View File

@@ -1,17 +1,53 @@
Installing libpng version 1.0.18 - December 3, 2004 Installing libpng version 1.0.62 - February 6, 2014
Before installing libpng, you must first install zlib. zlib On Unix/Linux and similar systems, you can simply type
can usually be found wherever you got libpng. zlib can be
placed in another directory, at the same level as libpng. ./configure [--prefix=/path]
Note that your system might already have a preinstalled make check
zlib, but you will still need to have access to the make install
zlib.h and zconf.h include files that correspond to the
version of zlib that's installed. and ignore the rest of this document.
If configure does not work on your system and you have a reasonably
up-to-date set of tools, running ./autogen.sh before running ./configure
may fix the problem. You can also run the individual commands in
autogen.sh with the --force option, if supported by your version of
the tools. If you run 'libtoolize --force', though, this will replace
the distributed, patched, version of ltmain.sh with an unpatched version
and your shared library builds may fail to produce libraries with the
correct version numbers.
Instead, you can use one of the custom-built makefiles in the
"scripts" directory
cp scripts/makefile.system makefile
make test
make install
The files that are presently available in the scripts directory
are listed and described in scripts/README.txt.
Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng. zlib can be placed in another directory,
at the same level as libpng.
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
correspond to the version of zlib that's installed.
You can rename the directories that you downloaded (they You can rename the directories that you downloaded (they
might be called "libpng-1.0.18" or "lpng109" and "zlib-1.2.1" might be called "libpng-1.0.62" or "libpng10" and "zlib-1.2.3"
or "zlib121") so that you have directories called "zlib" and "libpng". or "zlib123") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this: Your directory structure should look like this:
@@ -21,19 +57,26 @@ Your directory structure should look like this:
README README
*.h *.h
*.c *.c
CMakeLists.txt => "cmake" script
configuration files:
configure.ac, configure, Makefile.am, Makefile.in,
autogen.sh, config.guess, ltmain.sh, missing,
aclocal.m4, config.h.in, config.sub,
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
contrib contrib
gregbook gregbook
pngminim
pngminus pngminus
pngsuite pngsuite
visupng visupng
projects projects
beos cbuilder5 (Borland)
c5builder (Borland)
visualc6 (msvc) visualc6 (msvc)
netware.txt visualc71
wince.txt xcode
scripts scripts
makefile.* makefile.*
*.def (module definition files)
pngtest.png pngtest.png
etc. etc.
zlib zlib
@@ -47,84 +90,13 @@ If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats. endings) and zip (DOS style line endings) formats.
If you are building libpng with MSVC, you can enter the If you are building libpng with MSVC, you can enter the
libpng projects\visualc6 directory and follow the instructions in libpng projects\visualc6 or visualc71 directory and follow the instructions
projects\visualc6\README.txt. in README.txt.
You can build libpng for WindowsCE by downloading and installing Otherwise enter the zlib directory and follow the instructions in zlib/README,
the projects\wince directory as instructed in the projects\wince.txt file, and then come back here and run "configure" or choose the appropriate
then following the instructions in the README* files. Similarly, you can makefile.sys in the scripts directory.
build libpng for Netware or Beos as instructed in projects\netware.txt
or projects\beos.
Else enter the zlib directory and follow the instructions in zlib/README,
then come back here and choose the appropriate makefile.sys in the scripts
directory.
The files that are presently available in the scripts directory
include
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng10.so.0.1.0.18)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng10.so.0.1.0.18)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng10.so.0.1.0.18,
uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX/gcc makefile
makefile.cygwin => Cygwin/gcc makefile
makefile.darwin => Darwin makefile, can use on MacosX
makefile.dec => DEC Alpha UNIX makefile
makefile.freebsd => FreeBSD 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
libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later
makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so.
makefile.ne10bsd => NetBSD/cc makefile, uses PNGGCCRD,
makes libpng10.so
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc,
creates libpng10.so.0.1.0.18)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng10.so.0.1.0.18)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng10.so.0.1.0.18)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
makefile.amiga => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.bor => Borland makefile (uses bcc)
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
makefile.tc3 => Turbo C 3.0 makefile
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
assembler code tuned for Intel MMX platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does
not use assembler code)
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
descrip.mms => VMS makefile for MMS or MMK
SCOPTIONS.ppc => Used with smakefile.ppc
Copy the file (or files) that you need from the Copy the file (or files) that you need from the
scripts directory into this directory, for example scripts directory into this directory, for example
@@ -155,9 +127,11 @@ run "make install".
If you encounter a compiler error message complaining about the If you encounter a compiler error message complaining about the
lines lines
__png.h__ already includes setjmp.h; __png.h__ already includes setjmp.h;
__dont__ include it again.; __dont__ include it again.;
This means you have compiled another module that includes setjmp.h,
this means you have compiled another module that includes setjmp.h,
which is hazardous because the two modules might not include exactly which is hazardous because the two modules might not include exactly
the same setjmp.h. If you are sure that you know what you are doing the same setjmp.h. If you are sure that you know what you are doing
and that they are exactly the same, then you can comment out or and that they are exactly the same, then you can comment out or
@@ -167,3 +141,23 @@ instead, as demonstrated in contrib/visupng of the libpng distribution.
Further information can be found in the README and libpng.txt Further information can be found in the README and libpng.txt
files, in the individual makefiles, in png.h, and the manual pages files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5. libpng.3 and png.5.
Using the ./configure script -- 16 December 2002.
=================================================
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you need to add to configure explicitly,
which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/png12, or whatever.

View File

@@ -1,11 +1,22 @@
Known bugs in libpng version 1.0.18 Known bugs in libpng version 1.0.62
1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when 1. February 23, 2006: The custom makefiles don't build libpng with -lz.
reading interlaced PNG files, when assembler code is enabled but running
on a non-MMX i386 platform.
STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1 STATUS: This is a subject of debate. The change will probably be made
fixed a problem under FreeBSD but not the problem with NetBSD, which as a part of a major overhaul of the makefiles in libpng version 1.4.0.
still fails as of libpng-1.2.2rc1.
2. February 24, 2006: The Makefile generated by the "configure" script
fails to install symbolic links
libpng12.so => libpng12.so.0.1.2.9betaN
that are generated by the custom makefiles.
3. September 4, 2007: There is a report that pngtest crashes on MacOS 10.
STATUS: workarounds are
1) Compile without optimization (crashes are observed with
-arch i386 and -O2 or -O3, using gcc-4.0.1).
2) Compile pngtest.c with PNG_DEBUG defined (the bug goes away if
you try to look at it).
3) Ignore the crash. The library itself seems to be OK.

View File

@@ -8,8 +8,10 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following If you modify libpng you may insert additional notices immediately following
this sentence. this sentence.
libpng version 1.2.6, December 3, 2004, is This code is released under the libpng license.
Copyright (c) 2004 Glenn Randers-Pehrson, and is
libpng versions 1.2.6, August 15, 2004, through 1.0.62, February 6, 2014, are
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5 distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors with the following individual added to the list of Contributing Authors
@@ -106,4 +108,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
December 3, 2004 February 6, 2014

155
Makefile.am Normal file
View File

@@ -0,0 +1,155 @@
# Makefile.am:
# Source file for Makefile.in (and hence Makefile)
#
# Makefile.am need only be changed on a major version number
# change (e.g. libpng12 --> libpng14). In that case seach
# this file for every instance of the old base name (libpng12)
# and change to the new one (libpng14), then change the
# -version-number settings below so that the new values have
# the correct major part (first field).
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
# libpng does not follow GNU file name conventions
AUTOMAKE_OPTIONS = foreign
# test programs - run on make check, make distcheck
check_PROGRAMS= pngtest
pngtest_SOURCES = pngtest.c
pngtest_LDADD = libpng10.la
TESTS = test-pngtest.sh
TESTS_ENVIRONMENT= srcdir=$(srcdir)
# man pages
dist_man_MANS= libpng.3 libpngpf.3 png.5
# generate the -config scripts if required
binconfigs= libpng10-config
EXTRA_SCRIPTS= libpng-config libpng10-config
bin_SCRIPTS= @binconfigs@
# rules to build libpng, only build the old library on request
lib_LTLIBRARIES=libpng10.la @compatlib@
EXTRA_LTLIBRARIES= libpng.la
libpng10_la_SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c \
png.h pngconf.h
libpng_la_SOURCES = $(libpng10_la_SOURCES)
libpng_la_CPPFLAGS = @LIBPNG_DEFINES@
libpng10_la_CPPFLAGS = @LIBPNG_DEFINES@
# MAJOR UPGRADE: the version-number settings below must be changed.
libpng10_la_LDFLAGS = -no-undefined -export-dynamic \
-version-number 0:@PNGLIB_RELEASE@:0
# -rpath is needed as automake doesn't know the directory
libpng_la_LDFLAGS = -rpath '$(libdir)' -no-undefined -export-dynamic \
-version-number 2:@PNGLIB_RELEASE@:0
if HAVE_LD_VERSION_SCRIPT
# Versioned symbols and restricted exports
libpng10_la_LDFLAGS += -Wl,--version-script=libpng.vers
libpng10_la_DEPENDENCIES = libpng.vers
else
# Only restricted exports when possible
libpng10_la_LDFLAGS += -export-symbols libpng.sym
libpng10_la_DEPENDENCIES = libpng.sym
endif
libpng_la_DEPENDENCIES = $(libpng10_la_DEPENDENCIES)
# Avoid depending upon Character Ranges.
AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
#distribute headers in /usr/include/libpng/*
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
pkginclude_HEADERS= png.h pngconf.h
# pkg-config stuff, note that libpng.pc is always required in order
# to get the correct library
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libpng10.pc
#extra source distribution files.
EXTRA_DIST= \
ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
CMakeLists.txt \
${srcdir}/projects/cbuilder5/* \
${srcdir}/projects/beos/* \
${srcdir}/projects/visualc6/* \
${srcdir}/projects/visualc71/* \
${srcdir}/projects/wince.txt \
${srcdir}/projects/netware.txt \
${srcdir}/projects/xcode/* \
${srcdir}/scripts/* \
${srcdir}/contrib/gregbook/* \
${srcdir}/contrib/pngminim/* \
${srcdir}/contrib/pngminus/* \
${srcdir}/contrib/pngsuite/* \
${srcdir}/contrib/visupng/* \
$(TESTS) \
example.c libpng-1.0.62.txt pnggccrd.c pngvcrd.c
CLEANFILES= pngout.png libpng10.pc libpng10-config libpng.vers \
libpng.sym
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
config.sub configure depcomp install-sh ltmain.sh missing
$(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 $@
test: check
# install the .../include headers as links to the new ones
install-data-hook:
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h pngconf.h
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
# do evil things to libpng to cause libpng10 to be used
install-exec-hook:
cd $(DESTDIR)$(bindir); rm -f libpng-config
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
@set -x;\
cd $(DESTDIR)$(libdir);\
for ext in a la so sl dylib; 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
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
rm -f $(DESTDIR)$(bindir)/libpng-config
@if test -n "@compatlib@"; then\
set -x;\
cd $(DESTDIR)$(libdir);\
for ext in a la so sl dylib; do\
rm -f libpng.$$ext;\
done;\
fi

1804
Makefile.in Normal file

File diff suppressed because it is too large Load Diff

133
README
View File

@@ -1,11 +1,15 @@
README for libpng version 1.0.18 - December 3, 2004 (shared library 10.0) README for libpng version 1.0.62 - February 6, 2014 (shared library 10.0)
See the note about version numbers near the top of png.h See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng. See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz Libpng comes in several distribution formats. Get libpng-*.tar.gz,
or libpng-*.tar.bz2 if you want UNIX-style line endings in the text libpng-*.tar.xz, or libpng-*.tar.bz2 if you want UNIX-style line
files, or lpng*.zip if you want DOS-style line endings. endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style
line endings. You can get UNIX-style line endings from the *.zip file
by using "unzip -a" but there seems to be no simple way to recover
UNIX-style line endings from the *.7z file. The *.tar.xz file is
recommended for *NIX users instead.
Version 0.89 was the first official release of libpng. Don't let the Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in fact that it's the first release fool you. The libpng library has been in
@@ -54,9 +58,9 @@ to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk. critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions The changes made to the library, and bugs fixed are based on discussions
on the PNG-implement mailing list on the png-mng-implement mailing list and not on material submitted
and not on material submitted privately to Guy, Andreas, or Glenn. They will privately to Guy, Andreas, or Glenn. They will forward any good
forward any good suggestions to the list. suggestions to the list.
For a detailed description on using libpng, read libpng.txt. For For a detailed description on using libpng, read libpng.txt. For
examples of libpng in a program, see example.c and pngtest.c. For usage examples of libpng in a program, see example.c and pngtest.c. For usage
@@ -77,18 +81,24 @@ compression library that is useful for more things than just PNG files.
You can use zlib as a drop-in replacement for fread() and fwrite() if You can use zlib as a drop-in replacement for fread() and fwrite() if
you are so inclined. you are so inclined.
zlib should be available at the same place that libpng is, or at. zlib should be available at the same place that libpng is, or at
ftp://ftp.info-zip.org/pub/infozip/zlib ftp://ftp.simplesystems.org/pub/png/src/
You may also want a copy of the PNG specification. It is available You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/ these at http://www.libpng.org/pub/png/pngdocs.html
This code is currently being archived at libpng.sf.net in the This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) [DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
at GO GRAPHSUP. If you can't find it in any of those places, at GO GRAPHSUP. If you can't find it in any of those places,
e-mail me, and I'll help you find it. e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because it
is open source, publicly available software, that does not contain any
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
If you have any code changes, requests, problems, etc., please e-mail If you have any code changes, requests, problems, etc., please e-mail
them to me. Also, I'd appreciate any make files or project files, them to me. Also, I'd appreciate any make files or project files,
and any modifications you needed to make to get libpng to compile, and any modifications you needed to make to get libpng to compile,
@@ -101,22 +111,23 @@ Finally, if you get any warning messages when compiling libpng
fix. Please mention "libpng" somewhere in the subject line. Thanks. fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG group. based in a large way on Guy's and Andreas' earlier work), and the PNG
development group.
glennrp at users.sourceforge.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
png-implement at ccrc.wustl.edu (subscription required; write to (subscription required; visit
majordomo at ccrc.wustl.edu with "subscribe png-implement" in the message). https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
You can't reach Guy, the original libpng author, at the addresses You can't reach Guy, the original libpng author, at the addresses
given in previous versions of this document. He and Andreas will read mail given in previous versions of this document. He and Andreas will
addressed to the png-implement list, however. read mail addressed to the png-mng-implement list, however.
Please do not send general questions about PNG. Send them to Please do not send general questions about PNG. Send them to
the (png-list at ccrc.wustl.edu, subscription required, write to the (png-mng-misc at lists.sourceforge.net, subscription required, visit
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message). https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
On the other hand, subscribe). On the other hand, please do not send libpng questions to
please do not send libpng questions to that address, send them to me that address, send them to me or to the png-mng-implement list. I'll
or to the png-implement list. I'll
get them in the end anyway. If you have a question about something get them in the end anyway. If you have a question about something
in the PNG specification that is related to using libpng, send it in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng, to me. Send me any questions that start with "I was using libpng,
@@ -124,7 +135,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary. to others, if necessary.
Please do not send suggestions on how to change PNG. We have Please do not send suggestions on how to change PNG. We have
been discussing PNG for nine years now, and it is official and been discussing PNG for nineteen years now, and it is official and
finished. If you have suggestions for libpng, however, I'll finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately, gladly listen. Even if your suggestion is not used immediately,
it may be used later. it may be used later.
@@ -139,6 +150,7 @@ Files in this distribution:
TODO => Things not implemented in the current library TODO => Things not implemented in the current library
Y2KINFO => Statement of Y2K compliance Y2KINFO => Statement of Y2K compliance
example.c => Example code for using libpng functions example.c => Example code for using libpng functions
libpng-*-*-diff.txt => Diff from previous release
libpng.3 => manual page for libpng (includes libpng.txt) libpng.3 => manual page for libpng (includes libpng.txt)
libpng.txt => Description of libpng and its functions libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions libpngpf.3 => manual page for libpng's private functions
@@ -146,7 +158,6 @@ Files in this distribution:
png.c => Basic interface functions common to library png.c => Basic interface functions common to library
png.h => Library function and interface declarations png.h => Library function and interface declarations
pngconf.h => System specific library configuration pngconf.h => System specific library configuration
pngasmrd.h => Header file for assembler-coded functions
pngerror.c => Error/warning message I/O functions pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions pngmem.c => Memory handling functions
@@ -169,35 +180,44 @@ Files in this distribution:
gregbook => source code for PNG reading and writing, from gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide", Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999 O'Reilly, 1999
msvctest => Builds and runs pngtest using a MSVC workspace pngminim => Minimal pnm2pngm and png2pnmm programs
pngminus => Simple pnm2png and png2pnm programs pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images pngsuite => Test images
visupng => Contains a MSVC workspace for VisualPng visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for building DLL projects => Contains project files and workspaces for
building a DLL
beos => Contains a Beos workspace for building libpng beos => Contains a Beos workspace for building libpng
c5builder => Contains a Borland workspace for building libpng c5builder => Contains a Borland workspace for building
and zlib libpng and zlib
visualc6 => Contains a Microsoft Visual C++ (MSVC) workspace MacOSX => Contains a MacOSX workspace for building libpng
for building libpng and zlib netware.txt => Contains instructions for downloading a set
netware.txt => Contains instructions for downloading a set of of project files for building libpng and
project files for building libpng and zlib on zlib on Netware.
Netware. visualc6 => Contains a Microsoft Visual C++ (MSVC)
wince.txt => Contains instructions for downloading a Microsoft workspace for building libpng and zlib
Visual C++ (Windows CD Toolkit) workspace for visualc71 => Contains a Microsoft Visual C++ (MSVC)
building libpng and zlib on WindowsCE workspace for building libpng and zlib
wince.txt => Contains instructions for downloading a
Microsoft Visual C++ (Windows CD Toolkit)
workspace for building libpng and zlib on
WindowsCE
xcode => Contains xcode project files
scripts => Directory containing scripts for building libpng: scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.std => Generic UNIX makefile (cc, creates static
makefile.elf => Linux/ELF makefile symbol versioning, libpng.a)
gcc, creates libpng10.so.0.1.0.18) makefile.elf => Linux/ELF gcc makefile symbol versioning,
makefile.linux => Linux/ELF makefile creates libpng10.so.0.1.0.62)
(gcc, creates libpng10.so.0.1.0.18) makefile.linux => Linux/ELF makefile (gcc, creates
makefile.gcmmx => Linux/ELF makefile libpng10.so.0.1.0.62)
(gcc, creates libpng10.so.0.1.0.18, makefile.gcmmx => Linux/ELF makefile (gcc, creates
uses assembler code tuned for Intel MMX platform) libpng10.so.0.1.0.62, previously
makefile.gcc => Generic makefile (gcc, creates static libpng.a) used assembler code tuned for Intel MMX
makefile.knr => Archaic UNIX Makefile that converts files with platform)
ansi2knr (Requires ansi2knr.c from makefile.gcc => Generic makefile (gcc, creates static
libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files
with ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost) ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile makefile.cygwin => Cygwin/gcc makefile
@@ -207,20 +227,21 @@ Files in this distribution:
makefile.hpgcc => HPUX makefile using gcc makefile.hpgcc => HPUX makefile using gcc
makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit 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.ibmc => IBM C/C++ version 3.x for Win32 and OS/2
(static)
makefile.intel => Intel C/C++ version 4.0 and later makefile.intel => Intel C/C++ version 4.0 and later
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so. makefile.netbsd => NetBSD/cc makefile, makes libpng.so.
makefile.ne10bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng10.so makefile.ne10bsd => NetBSD/cc makefile, makes libpng10.so
makefile.openbsd => OpenBSD makefile makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics makefile.sggcc => Silicon Graphics
(gcc, creates libpng10.so.0.1.0.18) (gcc, creates libpng10.so.0.1.0.62)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng10.so.0.1.0.18) (gcc, creates libpng10.so.0.1.0.62)
makefile.so9 => Solaris 9 makefile makefile.so9 => Solaris 9 makefile
(gcc, creates libpng10.so.0.1.0.18) (gcc, creates libpng10.so.0.1.0.62)
makefile.32sunu => Sun Ultra 32-bit makefile makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile makefile.64sunu => Sun Ultra 64-bit makefile
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
@@ -238,8 +259,8 @@ Files in this distribution:
makefile.dj2 => DJGPP 2 makefile makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile makefile.msc => Microsoft C makefile
makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and
later (uses assembler code tuned for Intel MMX later (previously used assembler code tuned
platform) for Intel MMX platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
later (does not use assembler code) later (does not use assembler code)
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
@@ -250,12 +271,12 @@ Files in this distribution:
Good luck, and happy coding. Good luck, and happy coding.
-Glenn Randers-Pehrson (current maintainer) -Glenn Randers-Pehrson (current maintainer, since 1998)
Internet: glennrp at users.sourceforge.net Internet: glennrp at users.sourceforge.net
-Andreas Eric Dilger (former maintainer, 1996-1997) -Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca Internet: adilger at enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ Web: http://members.shaw.ca/adilger/
-Guy Eric Schalnat (original author and former maintainer, 1995-1996) -Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc) (formerly of Group 42, Inc)

1
TODO
View File

@@ -22,3 +22,4 @@ Build gamma tables using fixed point (and do away with floating point entirely).
Use greater precision when changing to linear gamma for compositing against Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation. background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions. Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.

View File

@@ -1,13 +1,13 @@
Y2K compliance in libpng: Y2K compliance in libpng:
========================= =========================
December 3, 2004 February 6, 2014
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.18 are Y2K compliant. It is my belief that earlier upward through 1.0.62 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer Libpng only has three year fields. One is a 2-byte unsigned integer

9772
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

25
autogen.sh Executable file
View File

@@ -0,0 +1,25 @@
#! /bin/sh
# a quick hack script to generate necessary files from
# auto* tools.
#
# WARNING: if you run this you will change the versions
# of the tools which are used and, maybe, required!
touch Makefile.am configure.ac
{
echo "running libtoolize" >&2
libtoolize --force --copy --automake
} && {
echo "running aclocal" >&2
aclocal
} && {
echo "running autoheader [ignore the warnings]" >&2
autoheader
} && {
echo "running automake" >&2
automake --force-missing --foreign -a -c
} && {
echo "running autoconf" >&2
autoconf
} &&
echo "autogen complete" >&2 ||
echo "ERROR: autogen.sh failed, autogen is incomplete" >&2

347
compile Normal file
View File

@@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

1568
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

86
config.h.in Normal file
View File

@@ -0,0 +1,86 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the `pow' function. */
#undef HAVE_POW
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

1793
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

14970
configure vendored

File diff suppressed because it is too large Load Diff

153
configure.ac Normal file
View File

@@ -0,0 +1,153 @@
# configure.ac
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
dnl (third field in two places below) and set the PNGLIB_RELEASE
dnl variable.
dnl
dnl Major upgrades (incompatible ABI): increment the package major
dnl version (second field, or first if desired), set the minor
dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
dnl Makefile.am to upgrade the package name.
dnl This is here to prevent earlier autoconf from being used, it
dnl should not be necessary to regenerate configure if the time
dnl stamps are correct
AC_PREREQ(2.59)
dnl Version number stuff here:
AC_INIT([libpng], [1.0.62], [png-mng-implement@lists.sourceforge.net])
AM_INIT_AUTOMAKE
dnl stop configure from automagically running automake
AM_MAINTAINER_MODE
PNGLIB_VERSION=1.0.62
PNGLIB_MAJOR=1
PNGLIB_MINOR=0
PNGLIB_RELEASE=62
dnl End of version number stuff
AC_CONFIG_SRCDIR([pngget.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
AC_PROG_LD
AC_PROG_CPP
AC_CHECK_TOOL(SED, sed, :)
AC_LIBTOOL_WIN32_DLL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_STRTOD
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
AC_MSG_CHECKING(
[if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE])
AC_TRY_COMPILE(
[#include "$srcdir/pnggccrd.c"],
[return 0;],
AC_MSG_RESULT(yes)
LIBPNG_NO_MMX="",
AC_MSG_RESULT(no)
LIBPNG_NO_MMX=-DPNG_NO_MMX_CODE)
LIBPNG_DEFINES=$LIBPNG_DEFINES\ $LIBPNG_NO_MMX
AC_SUBST(LIBPNG_DEFINES)
AC_SUBST(LIBPNG_NO_MMX)
AC_MSG_CHECKING([if libraries can be versioned])
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
if test "$GLD"; then
have_ld_version_script=yes
AC_MSG_RESULT(yes)
else
have_ld_version_script=no
AC_MSG_RESULT(no)
AC_MSG_WARN(*** You have not enabled versioned symbols.)
fi
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])
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
| ${CPP-${CC-gcc} -E} - 2>&1 \
| ${EGREP-grep} "^PREFIX=" \
| ${SED-sed} "s:^PREFIX=::"`
AC_SUBST(SYMBOL_PREFIX)
AC_MSG_RESULT($SYMBOL_PREFIX)
fi
# Substitutions for .in files
AC_SUBST(PNGLIB_VERSION)
AC_SUBST(PNGLIB_MAJOR)
AC_SUBST(PNGLIB_MINOR)
AC_SUBST(PNGLIB_RELEASE)
# Additional arguments (and substitutions)
# Allow the pkg-config directory to be set
AC_ARG_WITH(pkgconfigdir,
AC_HELP_STRING([--with-pkgconfigdir],
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
[pkgconfigdir=${withval}],
[pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
# Make the *-config binary config scripts optional
AC_ARG_WITH(binconfigs,
AC_HELP_STRING([--with-binconfigs],
[Generate shell libpng-config scripts as well as pkg-config data]
[@<:@default=yes@:>@]),
[if test "${withval}" = no; then
binconfigs=
AC_MSG_NOTICE([libpng-config scripts will not be built])
else
binconfigs='${binconfigs}'
fi],
[binconfigs='${binconfigs}'])
AC_SUBST([binconfigs])
# Allow the old version number library, libpng.so, to be removed from
# the build
AC_ARG_WITH(libpng-compat,
AC_HELP_STRING([--with-libpng-compat],
[Generate the obsolete libpng.so library @<:@default=yes@:>@]),
[if test "${withval}" = no; then
compatlib=
AC_MSG_NOTICE([libpng.so will not be built])
else
compatlib=libpng.la
fi],
[compatlib=libpng.la])
AC_SUBST([compatlib])
# Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc:scripts/libpng.pc-configure.in])
AC_CONFIG_FILES([libpng-config:scripts/libpng-config.in],
[chmod +x libpng-config])
AC_OUTPUT

340
contrib/gregbook/COPYING Normal file
View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -1,12 +1,19 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -23,4 +30,21 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@@ -0,0 +1,130 @@
# Sample makefile for rpng-win / rpng2-win / wpng using mingw32-gcc and make.
# Greg Roelofs
# Last modified: 2 June 2007
#
# The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
# Associates, 1999). Go buy a copy, eh? Well, OK, it's not
# generally for sale anymore, but it's the thought that counts,
# right? (Hint: http://www.libpng.org/pub/png/book/ )
#
# Invoke this makefile from a DOS-prompt window via:
#
# make -f Makefile.mingw32
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are in subdirectories at the same level as the current subdirectory
# (as indicated by the PNGDIR and ZDIR macros below). It makes no assumptions
# at all about the mingw32 installation tree (W32DIR). Edit as appropriate.
#
# Note that the names of the dynamic and static libpng and zlib libraries
# used below may change in later releases of the libraries. This makefile
# builds both statically and dynamically linked executables by default.
# (You need only one set, but for testing it can be handy to have both.)
# macros --------------------------------------------------------------------
#PNGDIR = ../..# for libpng-x.y.z/contrib/gregbook builds
PNGDIR = ../libpng-win32
PNGINC = -I$(PNGDIR)
PNGLIBd = $(PNGDIR)/libpng.dll.a # dynamically linked
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
#ZDIR = ../../../zlib-win32# for libpng-x.y.z/contrib/gregbook builds
ZDIR = ../zlib-win32
ZINC = -I$(ZDIR)
ZLIBd = $(ZDIR)/libzdll.a
ZLIBs = $(ZDIR)/libz.a
# change this to be the path where mingw32 installs its stuff:
W32DIR =
#W32DIR = /usr/local/cross-tools/i386-mingw32msvc
W32INC = -I$(W32DIR)/include
W32LIB = $(W32DIR)/lib/libuser32.a $(W32DIR)/lib/libgdi32.a
CC = gcc
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
LD = $(CC)
RM = rm -f
CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
LDFLAGS = $(MINGW_LDFLAGS)
O = .o
E = .exe
INCS = $(PNGINC) $(ZINC) $(W32INC)
RLIBSd = $(PNGLIBd) $(ZLIBd) $(W32LIB) -lm
RLIBSs = $(PNGLIBs) $(ZLIBs) $(W32LIB) -lm
WLIBSd = $(PNGLIBd) $(ZLIBd)
WLIBSs = $(PNGLIBs) $(ZLIBs)
RPNG = rpng-win
RPNG2 = rpng2-win
WPNG = wpng
ROBJSd = $(RPNG)$(O) readpng.pic$(O)
ROBJS2d = $(RPNG2)$(O) readpng2.pic$(O)
WOBJSd = $(WPNG)$(O) writepng.pic$(O)
RPNGs = $(RPNG)-static
RPNG2s = $(RPNG2)-static
WPNGs = $(WPNG)-static
ROBJSs = $(RPNG)$(O) readpng$(O)
ROBJS2s = $(RPNG2)$(O) readpng2$(O)
WOBJSs = $(WPNG)$(O) writepng$(O)
STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
%.pic$(O): %.c
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
# dependencies --------------------------------------------------------------
all: $(EXES)
$(RPNGs)$(E): $(ROBJSs)
$(LD) $(LDFLAGS) -o $@ $(ROBJSs) $(RLIBSs)
$(RPNG)$(E): $(ROBJSd)
$(LD) $(LDFLAGS) -o $@ $(ROBJSd) $(RLIBSd)
$(RPNG2s)$(E): $(ROBJS2s)
$(LD) $(LDFLAGS) -o $@ $(ROBJS2s) $(RLIBSs)
$(RPNG2)$(E): $(ROBJS2d)
$(LD) $(LDFLAGS) -o $@ $(ROBJS2d) $(RLIBSd)
$(WPNGs)$(E): $(WOBJSs)
$(LD) $(LDFLAGS) -o $@ $(WOBJSs) $(WLIBSs)
$(WPNG)$(E): $(WOBJSd)
$(LD) $(LDFLAGS) -o $@ $(WOBJSd) $(WLIBSd)
$(RPNG)$(O): $(RPNG).c readpng.h
$(RPNG2)$(O): $(RPNG2).c readpng2.h
$(WPNG)$(O): $(WPNG).c writepng.h
readpng$(O) readpng.pic$(O): readpng.c readpng.h
readpng2$(O) readpng2.pic$(O): readpng2.c readpng2.h
writepng$(O) writepng.pic$(O): writepng.c writepng.h
# maintenance ---------------------------------------------------------------
clean:
$(RM) $(EXES)
$(RM) $(ROBJSs) $(ROBJS2s) $(WOBJSs)
$(RM) $(ROBJSd) $(ROBJS2d) $(WOBJSd)

View File

@@ -1,73 +1,92 @@
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. # Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
# Greg Roelofs # Greg Roelofs
# Last modified: 7 March 2002 # Last modified: 2 June 2007
# #
# The programs built by this makefile are described in the book, # The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
# Associates, 1999). Go buy a copy, eh? Buy some for friends # Associates, 1999). Go buy a copy, eh? Well, OK, it's not
# and family, too. (Not that this is a blatant plug or anything.) # generally for sale anymore, but it's the thought that counts,
# right? (Hint: http://www.libpng.org/pub/png/book/ )
# #
# Invoke this makefile from a shell prompt in the usual way; for example: # Invoke this makefile from a shell prompt in the usual way; for example:
# #
# make -f Makefile.unx # make -f Makefile.unx
# #
# This makefile assumes libpng and zlib have already been built or downloaded # This makefile assumes libpng and zlib have already been built or downloaded
# and are both installed in /usr/local/{include,lib} (as indicated by the # and are installed in /usr/local/{include,lib} or as otherwise indicated by
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of # the PNG* and Z* macros below. Edit as appropriate--choose only ONE each of
# the PNGINC, PNGLIB, ZINC and ZLIB lines. # the PNGINC, PNGLIBd, PNGLIBs, ZINC, ZLIBd and ZLIBs lines.
# #
# This makefile builds statically linked executables (against libpng and zlib, # This makefile builds both dynamically and statically linked executables
# that is), but that can be changed by uncommenting the appropriate PNGLIB and # (against libpng and zlib, that is), but that can be changed by modifying
# ZLIB lines. # the "EXES =" line. (You need only one set, but for testing it can be handy
# to have both.)
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include/libpng12 #PNGDIR = /usr/local/lib
#PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng #PNGINC = -I/usr/local/include/libpng12
PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng #PNGLIBd = -L$(PNGDIR) -lpng12 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng12.a # statically linked, installed libpng
# or: # or:
#PNGINC = -I../libpng PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
#PNGLIB = -L../libpng -lpng #PNGDIR = ../libpng
#PNGLIB = ../libpng/libpng.a PNGINC = -I$(PNGDIR)
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng12 # dynamically linked
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
ZDIR = /usr/local/lib
#ZDIR = /usr/lib64
ZINC = -I/usr/local/include ZINC = -I/usr/local/include
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib ZLIBd = -L$(ZDIR) -lz # dynamically linked against zlib
ZLIB = /usr/local/lib/libz.a # statically linked against zlib ZLIBs = $(ZDIR)/libz.a # statically linked against zlib
#ZINC = -I../zlib # or:
#ZLIB = -L../zlib -lz #ZDIR = ../zlib
#ZLIB = ../zlib/libz.a #ZINC = -I$(ZDIR)
#ZLIBd = -Wl,-rpath,$(ZDIR) -L$(ZDIR) -lz # -rpath allows in-place testing
#ZLIBs = $(ZDIR)/libz.a
#XINC = -I/usr/include # old-style, stock X distributions #XINC = -I/usr/include # old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11 #XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows) #XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
#XLIB = -L/usr/openwin/lib -lX11 #XLIB = -L/usr/openwin/lib -lX11
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) XINC = -I/usr/X11R6/include # new X distributions (X.org, etc.)
XLIB = -L/usr/X11R6/lib -lX11 XLIB = -L/usr/X11R6/lib -lX11
#XLIB = -L/usr/X11R6/lib64 -lX11 # e.g., Red Hat on AMD64
INCS = $(PNGINC) $(ZINC) $(XINC) INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
WLIBS = $(PNGLIB) $(ZLIB) RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
WLIBSs = $(PNGLIBs) $(ZLIBs)
CC = gcc CC = gcc
LD = gcc LD = gcc
RM = rm -f RM = rm -f
CFLAGS = -O -Wall $(INCS) CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")] # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used] # [-ansi, -pedantic and -W can also be used]
LDFLAGS = LDFLAGS =
O = .o O = .o
E = E =
RPNG = rpng-x RPNG = rpng-x
RPNG2 = rpng2-x RPNG2 = rpng2-x
WPNG = wpng WPNG = wpng
RPNGs = $(RPNG)-static
RPNG2s = $(RPNG2)-static
WPNGs = $(WPNG)-static
ROBJS = $(RPNG)$(O) readpng$(O) ROBJS = $(RPNG)$(O) readpng$(O)
ROBJS2 = $(RPNG2)$(O) readpng2$(O) ROBJS2 = $(RPNG2)$(O) readpng2$(O)
WOBJS = $(WPNG)$(O) writepng$(O) WOBJS = $(WPNG)$(O) writepng$(O)
EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
# implicit make rules ------------------------------------------------------- # implicit make rules -------------------------------------------------------
@@ -80,14 +99,23 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
all: $(EXES) all: $(EXES)
$(RPNGs)$(E): $(ROBJS)
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSs)
$(RPNG)$(E): $(ROBJS) $(RPNG)$(E): $(ROBJS)
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS) $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSd)
$(RPNG2s)$(E): $(ROBJS2)
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSs)
$(RPNG2)$(E): $(ROBJS2) $(RPNG2)$(E): $(ROBJS2)
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS) $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSd)
$(WPNGs)$(E): $(WOBJS)
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSs)
$(WPNG)$(E): $(WOBJS) $(WPNG)$(E): $(WOBJS)
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS) $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSd)
$(RPNG)$(O): $(RPNG).c readpng.h $(RPNG)$(O): $(RPNG).c readpng.h
$(RPNG2)$(O): $(RPNG2).c readpng2.h $(RPNG2)$(O): $(RPNG2).c readpng2.h

View File

@@ -1,11 +1,12 @@
# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. # Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE.
# Greg Roelofs # Greg Roelofs
# Last modified: 16 February 1999 # Last modified: 2 June 2007
# #
# The programs built by this makefile are described in the book, # The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
# Associates, 1999). Go buy a copy, eh? Buy some for friends # Associates, 1999). Go buy a copy, eh? Well, OK, it's not
# and family, too. (Not that this is a blatant plug or anything.) # generally for sale anymore, but it's the thought that counts,
# right? (Hint: http://www.libpng.org/pub/png/book/ )
# #
# Invoke this makefile from a DOS prompt window via: # Invoke this makefile from a DOS prompt window via:
# #
@@ -53,7 +54,7 @@ CC = cl
LD = link LD = link
RM = del RM = del
CFLAGS = -nologo -O -W3 $(INCS) $(cvars) CFLAGS = -nologo -O -W3 $(INCS) $(cvars)
# [note that -Wall is an MSVC-specific compilation flag ("all warnings on")] # [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
# [see %devstudio%\vc\include\win32.mak for cvars macro definition] # [see %devstudio%\vc\include\win32.mak for cvars macro definition]
O = .obj O = .obj
E = .exe E = .exe

View File

@@ -22,7 +22,8 @@ below.
Files: Files:
README this file README this file
LICENSE terms of distribution and reuse (BSD-like) LICENSE terms of distribution and reuse (BSD-like or GNU GPL)
COPYING GNU General Public License (GPL)
Makefile.unx Unix makefile Makefile.unx Unix makefile
Makefile.w32 Windows (MSVC) makefile Makefile.w32 Windows (MSVC) makefile
@@ -54,15 +55,15 @@ mation and links to the latest version of the source code, and Chapters
13-15 of the book for detailed discussion of the three programs. 13-15 of the book for detailed discussion of the three programs.
Greg Roelofs Greg Roelofs
newt@pobox.com http://pobox.com/~newt/greg_contact.html
30 June 2001 16 March 2008
BUILD INSTRUCTIONS BUILD INSTRUCTIONS
- Prerequisites (in order of compilation): - Prerequisites (in order of compilation):
- zlib http://www.gzip.org/zlib/ - zlib http://zlib.net/
- libpng http://www.libpng.org/pub/png/libpng.html - libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.libpng.org/pub/png/book/sources.html - pngbook http://www.libpng.org/pub/png/book/sources.html
@@ -150,9 +151,9 @@ BUILD INSTRUCTIONS
To run the programs, they probably first need to be set up as "foreign To run the programs, they probably first need to be set up as "foreign
symbols," with "disk" and "dir" set appropriately: symbols," with "disk" and "dir" set appropriately:
$ rpng == "$disk:[dir]rpng-x.exe" $ rpng == "$disk:[dir]rpng-x.exe"
$ rpng2 == "$disk:[dir]rpng2-x.exe" $ rpng2 == "$disk:[dir]rpng2-x.exe"
$ wpng == "$disk:[dir]wpng.exe" $ wpng == "$disk:[dir]wpng.exe"
All three will print a basic usage screen when run without any command- All three will print a basic usage screen when run without any command-
line arguments; see the book for more details. Note that the options line arguments; see the book for more details. Note that the options
@@ -176,7 +177,7 @@ RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
format (.pgm or .ppm) to PNG; for example, format (.pgm or .ppm) to PNG; for example,
wpng -time < toucan.ppm > toucan.png wpng -time < toucan-notrans.ppm > toucan-notrans.png
would convert the specified PPM file (using redirection) to PNG, auto- would convert the specified PPM file (using redirection) to PNG, auto-
matically setting the PNG modification-time chunk. matically setting the PNG modification-time chunk.

View File

@@ -4,13 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -27,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
@@ -69,7 +93,7 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
* have used slightly more general png_sig_cmp() function instead */ * have used slightly more general png_sig_cmp() function instead */
fread(sig, 1, 8, infile); fread(sig, 1, 8, infile);
if (!png_check_sig(sig, 8)) if (png_sig_cmp(sig, 0, 8))
return 1; /* bad signature */ return 1; /* bad signature */
@@ -190,6 +214,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
* libpng function */ * libpng function */
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
free(image_data);
image_data = NULL;
free(row_pointers);
row_pointers = NULL;
png_destroy_read_struct(&png_ptr, &info_ptr, NULL); png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }

View File

@@ -4,13 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -27,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#ifndef TRUE #ifndef TRUE

View File

@@ -4,19 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Changelog: Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
- 1.01: initial public release
- 1.02: added code to skip unused chunks (GR-P)
---------------------------------------------------------------------------
Copyright (c) 1998-2002 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -33,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
@@ -56,7 +74,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
void readpng2_version_info(void) void readpng2_version_info(void)
{ {
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
(defined(__i386__) || defined(_M_IX86)) && \ (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
/* /*
* WARNING: This preprocessor approach means that the following code * WARNING: This preprocessor approach means that the following code
@@ -79,7 +97,12 @@ void readpng2_version_info(void)
"with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING,
png_libpng_ver, compilerID == 1? "MSVC++" : png_libpng_ver, compilerID == 1? "MSVC++" :
(compilerID == 2? "GNU C" : "unknown")); (compilerID == 2? "GNU C" : "unknown"));
fprintf(stderr, " Processor %s MMX instructions.\n", fprintf(stderr, " Processor (x86%s) %s MMX instructions.\n",
#if defined(__x86_64__)
"_64",
#else
"",
#endif
mmxsupport? "supports" : "does not support"); mmxsupport? "supports" : "does not support");
if (mmxsupport > 0) { if (mmxsupport > 0) {
int num_optims = 0; int num_optims = 0;
@@ -136,7 +159,7 @@ void readpng2_version_info(void)
int readpng2_check_sig(uch *sig, int num) int readpng2_check_sig(uch *sig, int num)
{ {
return png_check_sig(sig, num); return !png_sig_cmp(sig, 0, num);
} }
@@ -179,40 +202,38 @@ int readpng2_init(mainprog_info *mainprog_ptr)
return 2; return 2;
} }
/* prepare the reader to ignore all recognized chunks whose data isn't
* going to be used, i.e., all chunks recognized by libpng except for
* IHDR, PLTE, IDAT, IEND, tRNS, bKGD, gAMA, and sRGB : */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
/* prepare the reader to ignore all recognized chunks whose data won't be
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
{ {
#ifndef HANDLE_CHUNK_NEVER /* These byte strings were copied from png.h. If a future libpng
/* prior to libpng-1.2.5, this macro was internal, so we define it here. */ * version recognizes more chunks, add them to this list. If a
# define HANDLE_CHUNK_NEVER 1 * future version of readpng2.c recognizes more chunks, delete them
#endif * from this list. */
/* these byte strings were copied from png.h. static const png_byte chunks_to_ignore[] = {
* If a future libpng version recognizes more chunks, add them 99, 72, 82, 77, '\0', /* cHRM */
* to this list. If a future version of readpng2.c recognizes 104, 73, 83, 84, '\0', /* hIST */
* more chunks, delete them from this list. */ 105, 67, 67, 80, '\0', /* iCCP */
png_byte png_chunk_types_to_ignore[]= 105, 84, 88, 116, '\0', /* iTXt */
{ 99, 72, 82, 77, '\0', /* cHRM */ 111, 70, 70, 115, '\0', /* oFFs */
104, 73, 83, 84, '\0', /* hIST */ 112, 67, 65, 76, '\0', /* pCAL */
105, 67, 67, 80, '\0', /* iCCP */ 112, 72, 89, 115, '\0', /* pHYs */
105, 84, 88, 116, '\0', /* iTXt */ 115, 66, 73, 84, '\0', /* sBIT */
111, 70, 70, 115, '\0', /* oFFs */ 115, 67, 65, 76, '\0', /* sCAL */
112, 67, 65, 76, '\0', /* pCAL */ 115, 80, 76, 84, '\0', /* sPLT */
115, 67, 65, 76, '\0', /* sCAL */ 115, 84, 69, 82, '\0', /* sTER */
112, 72, 89, 115, '\0', /* pHYs */ 116, 69, 88, 116, '\0', /* tEXt */
115, 66, 73, 84, '\0', /* sBIT */ 116, 73, 77, 69, '\0', /* tIME */
115, 80, 76, 84, '\0', /* sPLT */ 122, 84, 88, 116, '\0' /* zTXt */
116, 69, 88, 116, '\0', /* tEXt */ };
116, 73, 77, 69, '\0', /* tIME */
122, 84, 88, 116, '\0'}; /* zTXt */
#define NUM_PNG_CHUNK_TYPES_TO_IGNORE 13
png_set_keep_unknown_chunks(png_ptr, HANDLE_CHUNK_NEVER, png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
png_chunk_types_to_ignore, NUM_PNG_CHUNK_TYPES_TO_IGNORE); chunks_to_ignore, sizeof(chunks_to_ignore)/5);
} }
#endif #endif /* PNG_UNKNOWN_CHUNKS_SUPPORTED */
/* instead of doing png_init_io() here, now we set up our callback /* instead of doing png_init_io() here, now we set up our callback
* functions for progressive decoding */ * functions for progressive decoding */
@@ -237,7 +258,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
* png_set_asm_flags (png_ptr, flags); * png_set_asm_flags (png_ptr, flags);
*/ */
#if (defined(__i386__) || defined(_M_IX86)) && \ #if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
/* /*
* WARNING: This preprocessor approach means that the following code * WARNING: This preprocessor approach means that the following code
@@ -358,6 +379,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
{ {
mainprog_info *mainprog_ptr; mainprog_info *mainprog_ptr;
int color_type, bit_depth; int color_type, bit_depth;
png_uint_32 width, height;
double gamma; double gamma;
@@ -393,8 +415,10 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
/* this is just like in the non-progressive case */ /* this is just like in the non-progressive case */
png_get_IHDR(png_ptr, info_ptr, &mainprog_ptr->width, png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&mainprog_ptr->height, &bit_depth, &color_type, NULL, NULL, NULL); NULL, NULL, NULL);
mainprog_ptr->width = (ulg)width;
mainprog_ptr->height = (ulg)height;
/* since we know we've read all of the PNG file's "header" (i.e., up /* since we know we've read all of the PNG file's "header" (i.e., up

View File

@@ -4,13 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -27,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#ifndef TRUE #ifndef TRUE
@@ -45,6 +69,12 @@
# define Trace(x) ; # define Trace(x) ;
#endif #endif
enum rpng2_states {
kPreInit = 0,
kWindowInit,
kDone
};
typedef unsigned char uch; typedef unsigned char uch;
typedef unsigned short ush; typedef unsigned short ush;
typedef unsigned long ulg; typedef unsigned long ulg;
@@ -66,12 +96,12 @@ typedef struct _mainprog_info {
int rowbytes; int rowbytes;
int channels; int channels;
int need_bgcolor; int need_bgcolor;
#if (defined(__i386__) || defined(_M_IX86)) #if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
int nommxfilters; int nommxfilters;
int nommxcombine; int nommxcombine;
int nommxinterlace; int nommxinterlace;
#endif #endif
int done; int state;
uch bg_red; uch bg_red;
uch bg_green; uch bg_green;
uch bg_blue; uch bg_blue;

179
contrib/gregbook/readppm.c Normal file
View File

@@ -0,0 +1,179 @@
/*---------------------------------------------------------------------------
rpng - simple PNG display program readppm.c
---------------------------------------------------------------------------
This is a special-purpose replacement for readpng.c that allows binary
PPM files to be used in place of PNG images.
---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of
this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. Redistributions of source code must retain the above copyright
notice, disclaimer, and this list of conditions.
2. Redistributions in binary form must reproduce the above copyright
notice, disclaimer, and this list of conditions in the documenta-
tion and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledgment:
This product includes software developed by Greg Roelofs
and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "readpng.h" /* typedefs, common macros, public prototypes */
ulg width, height;
int bit_depth, color_type, channels;
uch *image_data = NULL;
FILE *saved_infile;
void readpng_version_info()
{
fprintf(stderr, " Compiled without libpng, zlib or PBMPLUS/NetPBM.\n");
}
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
{
static uch ppmline[256];
int maxval;
saved_infile = infile;
fgets(ppmline, 256, infile);
if (ppmline[0] != 'P' || ppmline[1] != '6') {
fprintf(stderr, "ERROR: not a PPM file\n");
return 1;
}
/* possible color types: P5 = grayscale (0), P6 = RGB (2), P8 = RGBA (6) */
if (ppmline[1] == '6') {
color_type = 2;
channels = 3;
} else if (ppmline[1] == '8') {
color_type = 6;
channels = 4;
} else /* if (ppmline[1] == '5') */ {
color_type = 0;
channels = 1;
}
do {
fgets(ppmline, 256, infile);
} while (ppmline[0] == '#');
sscanf(ppmline, "%lu %lu", &width, &height);
do {
fgets(ppmline, 256, infile);
} while (ppmline[0] == '#');
sscanf(ppmline, "%d", &maxval);
if (maxval != 255) {
fprintf(stderr, "ERROR: maxval = %d\n", maxval);
return 2;
}
bit_depth = 8;
*pWidth = width;
*pHeight = height;
return 0;
}
/* returns 0 if succeeds, 1 if fails due to no bKGD chunk, 2 if libpng error;
* scales values to 8-bit if necessary */
int readpng_get_bgcolor(uch *red, uch *green, uch *blue)
{
return 1;
}
/* display_exponent == LUT_exponent * CRT_exponent */
uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
{
ulg rowbytes;
/* expand palette images to RGB, low-bit-depth grayscale images to 8 bits,
* transparency chunks to full alpha channel; strip 16-bit-per-sample
* images to 8 bits per sample; and convert grayscale to RGB[A] */
/* GRR WARNING: grayscale needs to be expanded and channels reset! */
*pRowbytes = rowbytes = channels*width;
*pChannels = channels;
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
return NULL;
}
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
/* now we can go ahead and just read the whole image */
fread(image_data, 1L, rowbytes*height, saved_infile);
return image_data;
}
void readpng_cleanup(int free_image_data)
{
if (free_image_data && image_data) {
free(image_data);
image_data = NULL;
}
}

View File

@@ -22,16 +22,25 @@
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug command-line parsing bug
- 1.10: enabled "message window"/console (thanks to David Geldreich) - 1.10: enabled "message window"/console (thanks to David Geldreich)
- 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed improper display of usage screen on PNG error(s)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -48,11 +57,28 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#define PROGNAME "rpng-win" #define PROGNAME "rpng-win"
#define LONGNAME "Simple PNG Viewer for Windows" #define LONGNAME "Simple PNG Viewer for Windows"
#define VERSION "1.20 of 28 May 2001" #define VERSION "2.01 of 16 March 2008"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -85,10 +111,9 @@ static void rpng_win_cleanup(void);
LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar; static char titlebar[1024];
static char *progname = PROGNAME; static char *progname = PROGNAME;
static char *appname = LONGNAME; static char *appname = LONGNAME;
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename; static char *filename;
static FILE *infile; static FILE *infile;
@@ -247,40 +272,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
} }
} }
if (!filename) { if (!filename)
++error; ++error;
} else if (!(infile = fopen(filename, "rb"))) {
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error;
} else {
if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
switch (rc) {
case 1:
fprintf(stderr, PROGNAME
": [%s] is not a PNG file: incorrect signature\n",
filename);
break;
case 2:
fprintf(stderr, PROGNAME
": [%s] has bad IHDR (libpng longjmp)\n",
filename);
break;
case 4:
fprintf(stderr, PROGNAME ": insufficient memory\n");
break;
default:
fprintf(stderr, PROGNAME
": unknown readpng_init() error\n");
break;
}
++error;
}
if (error)
fclose(infile);
}
/* usage screen */ /* print usage screen if any errors up to this point */
if (error) { if (error) {
int ch; int ch;
@@ -303,6 +299,47 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
ch = _getch(); ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B); while (ch != 'q' && ch != 'Q' && ch != 0x1B);
exit(1); exit(1);
}
if (!(infile = fopen(filename, "rb"))) {
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error;
} else {
if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
switch (rc) {
case 1:
fprintf(stderr, PROGNAME
": [%s] is not a PNG file: incorrect signature\n",
filename);
break;
case 2:
fprintf(stderr, PROGNAME
": [%s] has bad IHDR (libpng longjmp)\n", filename);
break;
case 4:
fprintf(stderr, PROGNAME ": insufficient memory\n");
break;
default:
fprintf(stderr, PROGNAME
": unknown readpng_init() error\n");
break;
}
++error;
}
if (error)
fclose(infile);
}
if (error) {
int ch;
fprintf(stderr, PROGNAME ": aborting.\n");
do
ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
exit(2);
} else { } else {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
fprintf(stderr, fprintf(stderr,
@@ -325,9 +362,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
* check for one in the PNG file--if not, the initialized values of 0 * check for one in the PNG file--if not, the initialized values of 0
* (black) will be used */ * (black) will be used */
if (have_bg) if (have_bg) {
sscanf(bgstr+1, "%2x%2x%2x", &bg_red, &bg_green, &bg_blue); unsigned r, g, b; /* this approach quiets compiler warnings */
else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) {
sscanf(bgstr+1, "%2x%2x%2x", &r, &g, &b);
bg_red = (uch)r;
bg_green = (uch)g;
bg_blue = (uch)b;
} else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) {
readpng_cleanup(TRUE); readpng_cleanup(TRUE);
fprintf(stderr, PROGNAME fprintf(stderr, PROGNAME
": libpng error while checking for background color\n"); ": libpng error while checking for background color\n");

View File

@@ -9,7 +9,7 @@
by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking). by Martin Zinser under OpenVMS; may work under OS/2 with some tweaking).
to do: to do:
- 8-bit support - 8-bit (colormapped) X support
- use %.1023s to simplify truncation of title-bar string? - use %.1023s to simplify truncation of title-bar string?
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -21,18 +21,28 @@
- 1.10: added support for non-default visuals; fixed X pixel-conversion - 1.10: added support for non-default visuals; fixed X pixel-conversion
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug command-line parsing bug
- 1.12: fixed small X memory leak (thanks to Francois Petitjean) - 1.12: fixed some small X memory leaks (thanks to Fran<EFBFBD>ois Petitjean)
- 1.13: fixed XFreeGC() crash bug - 1.13: fixed XFreeGC() crash bug (thanks to Patrick Welche)
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
- 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed improper display of usage screen on PNG error(s)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -49,11 +59,30 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#define PROGNAME "rpng-x" #define PROGNAME "rpng-x"
#define LONGNAME "Simple PNG Viewer for X" #define LONGNAME "Simple PNG Viewer for X"
#define VERSION "1.13 of 16 August 2001" #define VERSION "2.01 of 16 March 2008"
#define RESNAME "rpng" /* our X resource application name */
#define RESCLASS "Rpng" /* our X resource class name */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -91,6 +120,8 @@ static int rpng_x_msb(ulg u32val);
static char titlebar[1024], *window_name = titlebar; static char titlebar[1024], *window_name = titlebar;
static char *appname = LONGNAME; static char *appname = LONGNAME;
static char *icon_name = PROGNAME; static char *icon_name = PROGNAME;
static char *res_name = RESNAME;
static char *res_class = RESCLASS;
static char *filename; static char *filename;
static FILE *infile; static FILE *infile;
@@ -235,9 +266,33 @@ int main(int argc, char **argv)
} }
} }
if (!filename) { if (!filename)
++error; ++error;
} else if (!(infile = fopen(filename, "rb"))) {
/* print usage screen if any errors up to this point */
if (error) {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
readpng_version_info();
fprintf(stderr, "\n"
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" 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 (within image window, after image\n"
"is displayed) to quit.\n"
"\n", PROGNAME, default_display_exponent);
exit(1);
}
if (!(infile = fopen(filename, "rb"))) {
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error; ++error;
} else { } else {
@@ -250,8 +305,7 @@ int main(int argc, char **argv)
break; break;
case 2: case 2:
fprintf(stderr, PROGNAME fprintf(stderr, PROGNAME
": [%s] has bad IHDR (libpng longjmp)\n", ": [%s] has bad IHDR (libpng longjmp)\n", filename);
filename);
break; break;
case 4: case 4:
fprintf(stderr, PROGNAME ": insufficient memory\n"); fprintf(stderr, PROGNAME ": insufficient memory\n");
@@ -276,25 +330,9 @@ int main(int argc, char **argv)
} }
/* usage screen */
if (error) { if (error) {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); fprintf(stderr, PROGNAME ": aborting.\n");
readpng_version_info(); exit(2);
fprintf(stderr, "\n"
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" 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 (within image window, after image\n"
"is displayed) to quit.\n"
"\n", PROGNAME, default_display_exponent);
exit(1);
} }
@@ -399,11 +437,12 @@ static int rpng_x_create_window(void)
XEvent e; XEvent e;
XGCValues gcvalues; XGCValues gcvalues;
XSetWindowAttributes attr; XSetWindowAttributes attr;
XSizeHints *size_hints;
XTextProperty windowName, *pWindowName = &windowName; XTextProperty windowName, *pWindowName = &windowName;
XTextProperty iconName, *pIconName = &iconName; XTextProperty iconName, *pIconName = &iconName;
XVisualInfo visual_info; XVisualInfo visual_info;
XSizeHints *size_hints;
XWMHints *wm_hints; XWMHints *wm_hints;
XClassHint *class_hints;
screen = DefaultScreen(display); screen = DefaultScreen(display);
@@ -526,7 +565,7 @@ static int rpng_x_create_window(void)
if (!XStringListToTextProperty(&icon_name, 1, pIconName)) if (!XStringListToTextProperty(&icon_name, 1, pIconName))
pIconName = NULL; pIconName = NULL;
/* OK if either hints allocation fails; XSetWMProperties() allows NULLs */ /* OK if any hints allocation fails; XSetWMProperties() allows NULLs */
if ((size_hints = XAllocSizeHints()) != NULL) { if ((size_hints = XAllocSizeHints()) != NULL) {
/* window will not be resizable */ /* window will not be resizable */
@@ -542,8 +581,13 @@ static int rpng_x_create_window(void)
wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ; wm_hints->flags = StateHint | InputHint /* | IconPixmapHint */ ;
} }
if ((class_hints = XAllocClassHint()) != NULL) {
class_hints->res_name = res_name;
class_hints->res_class = res_class;
}
XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0,
size_hints, wm_hints, NULL); size_hints, wm_hints, class_hints);
/* various properties and hints no longer needed; free memory */ /* various properties and hints no longer needed; free memory */
if (pWindowName) if (pWindowName)
@@ -554,6 +598,8 @@ static int rpng_x_create_window(void)
XFree(size_hints); XFree(size_hints);
if (wm_hints) if (wm_hints)
XFree(wm_hints); XFree(wm_hints);
if (class_hints)
XFree(class_hints);
XMapWindow(display, window); XMapWindow(display, window);

View File

@@ -10,7 +10,7 @@
tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der tweaking (or maybe not). Thanks to Adam Costello and Pieter S. van der
Meulen for the "diamond" and "radial waves" patterns, respectively. Meulen for the "diamond" and "radial waves" patterns, respectively.
to do: to do (someday, maybe):
- handle quoted command-line args (especially filenames with spaces) - handle quoted command-line args (especially filenames with spaces)
- finish resizable checkerboard-gradient (sizes 4-128?) - finish resizable checkerboard-gradient (sizes 4-128?)
- use %.1023s to simplify truncation of title-bar string? - use %.1023s to simplify truncation of title-bar string?
@@ -27,16 +27,28 @@
- 1.10: enabled "message window"/console (thanks to David Geldreich) - 1.10: enabled "message window"/console (thanks to David Geldreich)
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options - 1.20: added runtime MMX-enabling/disabling and new -mmx* options
- 1.21: made minor tweak to usage screen to fit within 25-line console - 1.21: made minor tweak to usage screen to fit within 25-line console
- 1.22: added AMD64/EM64T support (__x86_64__)
- 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed 64-bit typo in readpng2.c
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
unexpected-EOF and file-read-error cases
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -53,11 +65,28 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#define PROGNAME "rpng2-win" #define PROGNAME "rpng2-win"
#define LONGNAME "Progressive PNG Viewer for Windows" #define LONGNAME "Progressive PNG Viewer for Windows"
#define VERSION "1.21 of 29 June 2001" #define VERSION "2.02 of 16 March 2008"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -119,10 +148,9 @@ static void rpng2_win_cleanup(void);
LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar; static char titlebar[1024];
static char *progname = PROGNAME; static char *progname = PROGNAME;
static char *appname = LONGNAME; static char *appname = LONGNAME;
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename; static char *filename;
static FILE *infile; static FILE *infile;
@@ -367,7 +395,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
} }
} else if (!strncmp(*argv, "-timing", 2)) { } else if (!strncmp(*argv, "-timing", 2)) {
timing = TRUE; timing = TRUE;
#if (defined(__i386__) || defined(_M_IX86)) #if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
} else if (!strncmp(*argv, "-nommxfilters", 7)) { } else if (!strncmp(*argv, "-nommxfilters", 7)) {
rpng2_info.nommxfilters = TRUE; rpng2_info.nommxfilters = TRUE;
} else if (!strncmp(*argv, "-nommxcombine", 7)) { } else if (!strncmp(*argv, "-nommxcombine", 7)) {
@@ -389,9 +417,54 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
} }
} }
if (!filename) { if (!filename)
++error; ++error;
} else if (!(infile = fopen(filename, "rb"))) {
/* print usage screen if any errors up to this point */
if (error) {
int ch;
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
readpng2_version_info();
fprintf(stderr, "\n"
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n"
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
#endif
" %*s file.png\n\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" 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; overrides -bgpat option\n"
" pat \tdesired background pattern number (1-%d); used with\n"
"\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"
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
"\t\t combining rows, and expanding interlacing, respectively\n"
#endif
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
"Press Q or Esc to quit this usage screen. ",
PROGNAME,
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
(int)strlen(PROGNAME), " ",
#endif
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
fflush(stderr);
do
ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
exit(1);
}
if (!(infile = fopen(filename, "rb"))) {
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error; ++error;
} else { } else {
@@ -405,8 +478,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
switch (rc) { switch (rc) {
case 2: case 2:
fprintf(stderr, PROGNAME fprintf(stderr, PROGNAME
": [%s] has bad IHDR (libpng longjmp)\n", ": [%s] has bad IHDR (libpng longjmp)\n", filename);
filename);
break; break;
case 4: case 4:
fprintf(stderr, PROGNAME ": insufficient memory\n"); fprintf(stderr, PROGNAME ": insufficient memory\n");
@@ -423,46 +495,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
} }
/* usage screen */
if (error) { if (error) {
int ch; int ch;
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); fprintf(stderr, PROGNAME ": aborting.\n");
readpng2_version_info();
fprintf(stderr, "\n"
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n"
#if (defined(__i386__) || defined(_M_IX86))
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
#endif
" %*s file.png\n\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" 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; overrides -bgpat option\n"
" pat \tdesired background pattern number (1-%d); used with\n"
"\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"
#if (defined(__i386__) || defined(_M_IX86))
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
"\t\t combining rows, and expanding interlacing, respectively\n"
#endif
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
"Press Q or Esc to quit this usage screen. ",
PROGNAME,
#if (defined(__i386__) || defined(_M_IX86))
strlen(PROGNAME), " ",
#endif
strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
fflush(stderr);
do do
ch = _getch(); ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B); while (ch != 'q' && ch != 'Q' && ch != 0x1B);
exit(1); exit(2);
} else { } else {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
fprintf(stderr, fprintf(stderr,
@@ -494,7 +534,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
} else } else
rpng2_info.need_bgcolor = TRUE; rpng2_info.need_bgcolor = TRUE;
rpng2_info.done = FALSE; rpng2_info.state = kPreInit;
rpng2_info.mainprog_init = rpng2_win_init; rpng2_info.mainprog_init = rpng2_win_init;
rpng2_info.mainprog_display_row = rpng2_win_display_row; rpng2_info.mainprog_display_row = rpng2_win_display_row;
rpng2_info.mainprog_finish_display = rpng2_win_finish_display; rpng2_info.mainprog_finish_display = rpng2_win_finish_display;
@@ -514,10 +554,27 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
if (readpng2_decode_data(&rpng2_info, inbuf, incount)) if (readpng2_decode_data(&rpng2_info, inbuf, incount))
++error; ++error;
Trace((stderr, "done with readpng2_decode_data()\n")) Trace((stderr, "done with readpng2_decode_data()\n"))
if (error || feof(infile) || rpng2_info.done)
if (error || incount != INBUFSIZE || rpng2_info.state == kDone) {
if (rpng2_info.state == kDone) {
Trace((stderr, "done decoding PNG image\n"))
} else if (ferror(infile)) {
fprintf(stderr, PROGNAME
": error while reading PNG image file\n");
exit(3);
} else if (feof(infile)) {
fprintf(stderr, PROGNAME ": end of file reached "
"(unexpectedly) while reading PNG image file\n");
exit(3);
} else /* if (error) */ {
// will print error message below
}
break; break;
}
if (timing) if (timing)
Sleep(1000L); Sleep(1000L);
incount = fread(inbuf, 1, INBUFSIZE, infile); incount = fread(inbuf, 1, INBUFSIZE, infile);
} }
@@ -564,7 +621,7 @@ static void rpng2_win_init()
ulg rowbytes = rpng2_info.rowbytes; ulg rowbytes = rpng2_info.rowbytes;
Trace((stderr, "beginning rpng2_win_init()\n")) Trace((stderr, "beginning rpng2_win_init()\n"))
Trace((stderr, " rowbytes = %ld\n", rpng2_info.rowbytes)) Trace((stderr, " rowbytes = %d\n", rpng2_info.rowbytes))
Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " width = %ld\n", rpng2_info.width))
Trace((stderr, " height = %ld\n", rpng2_info.height)) Trace((stderr, " height = %ld\n", rpng2_info.height))
@@ -594,6 +651,8 @@ static void rpng2_win_init()
readpng2_cleanup(&rpng2_info); readpng2_cleanup(&rpng2_info);
return; return;
} }
rpng2_info.state = kWindowInit;
} }
@@ -1089,7 +1148,7 @@ static void rpng2_win_finish_display()
* we have nothing to do here except set a flag and let the user know * we have nothing to do here except set a flag and let the user know
* that the image is done */ * that the image is done */
rpng2_info.done = TRUE; rpng2_info.state = kDone;
printf( printf(
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
fflush(stdout); fflush(stdout);

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,10 @@
This program converts certain NetPBM binary files (grayscale and RGB, This program converts certain NetPBM binary files (grayscale and RGB,
maxval = 255) to PNG. Non-interlaced PNGs are written progressively; maxval = 255) to PNG. Non-interlaced PNGs are written progressively;
interlaced PNGs are read and written in one memory-intensive blast. interlaced PNGs are read and written in one memory-intensive blast.
Thanks to Jean-loup Gailly for providing the necessary trick to read Thanks to Jean-loup Gailly for providing the necessary trick to read
interactive text from the keyboard while stdin is redirected. interactive text from the keyboard while stdin is redirected. Thanks
to Cosmin Truta for Cygwin fixes.
NOTE: includes provisional support for PNM type "8" (portable alphamap) NOTE: includes provisional support for PNM type "8" (portable alphamap)
images, presumed to be a 32-bit interleaved RGBA format; no pro- images, presumed to be a 32-bit interleaved RGBA format; no pro-
@@ -24,16 +26,32 @@
- 1.02: modified to allow abbreviated options - 1.02: modified to allow abbreviated options
- 1.03: removed extraneous character from usage screen; fixed bug in - 1.03: removed extraneous character from usage screen; fixed bug in
command-line parsing command-line parsing
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
- 2.00: dual-licensed (added GNU GPL)
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
dose not work! In order to do something useful I needed to redirect
both input and output, with cygwin and with bcc32 as well. Under
Linux, the same wpng appears to work fine. I don't know what is
the problem."]
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -50,16 +68,35 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#define PROGNAME "wpng" #define PROGNAME "wpng"
#define VERSION "1.03 of 19 March 2000" #define VERSION "2.00 of 2 June 2007"
#define APPNAME "Simple PGM/PPM/PAM to PNG Converter" #define APPNAME "Simple PGM/PPM/PAM to PNG Converter"
#if defined(__MSDOS__) || defined(__OS2__) #if defined(__MSDOS__) || defined(__OS2__)
# define DOS_OS2_W32 # define DOS_OS2_W32
#elif defined(_WIN32) || defined(__WIN32__) #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define DOS_OS2_W32 # ifndef __GNUC__ /* treat Win32 native ports of gcc as Unix environments */
# define DOS_OS2_W32
# endif
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@@ -4,13 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -27,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/

View File

@@ -4,13 +4,20 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of be held liable for any damages arising in any way from the use of
this software. this software.
The contents of this file are DUAL-LICENSED. You may modify and/or
redistribute this software according to the terms of one of the
following two licenses (at your option):
LICENSE 1 ("BSD-like with advertising clause"):
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions: it freely, subject to the following restrictions:
@@ -27,6 +34,23 @@
and contributors for the book, "PNG: The Definitive Guide," and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates. published by O'Reilly and Associates.
LICENSE 2 (GNU GPL v2 or later):
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#ifndef TRUE #ifndef TRUE

View File

@@ -20,7 +20,7 @@ Soon after the creation of PNG in 1995, the need was felt for a set of
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
(Willem van Schaik) started such a project. Luckily we discovered this (Willem van Schaik) started such a project. Luckily we discovered this
and merged the two together into pnmtopng.tar.gz, which is available and merged the two together into pnmtopng.tar.gz, which is available
from a/o ftp://swrinde.nde.swri.edu/pub/png/. from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
These two utilities have many, many options and make use of most of the These two utilities have many, many options and make use of most of the
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes

View File

@@ -8,9 +8,9 @@ LD=$(CC)
RM=rm -f RM=rm -f
#PNGPATH = /usr/local #PNGPATH = /usr/local
#PNGINC = -I$(PNGPATH)/include/libpng12 #PNGINC = -I$(PNGPATH)/include/libpng10
#PNGLIB = -L$(PNGPATH)/lib -lpng12 #PNGLIB = -L$(PNGPATH)/lib -lpng10
#PNGLIBS = $(PNGPATH)/lib/libpng12.a #PNGLIBS = $(PNGPATH)/lib/libpng10.a
PNGINC = -I../.. PNGINC = -I../..
PNGLIB = -L../.. -lpng PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a PNGLIBS = ../../libpng.a
@@ -23,9 +23,9 @@ ZINC = -I../../../zlib
ZLIB = -L../../../zlib -lz ZLIB = -L../../../zlib -lz
ZLIBS = ../../../zlib/libz.a ZLIBS = ../../../zlib/libz.a
CFLAGS=-O3 $(PNGINC) $(ZINC) CFLAGS=$(PNGINC) $(ZINC)
LDFLAGS=$(PNGLIB) $(ZLIB) LDLIBS=$(PNGLIB) $(ZLIB)
LDFLAGSS=$(PNGLIBS) $(ZLIBS) LDLIBSS=$(PNGLIBS) $(ZLIBS)
C=.c C=.c
O=.o O=.o
L=.a L=.a
@@ -40,19 +40,19 @@ png2pnm$(O): png2pnm$(C)
$(CC) -c $(CFLAGS) png2pnm$(C) $(CC) -c $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O) png2pnm$(E): png2pnm$(O)
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm $(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
png2pnm-static$(E): png2pnm$(O) png2pnm-static$(E): png2pnm$(O)
$(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm $(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
pnm2png$(O): pnm2png$(C) pnm2png$(O): pnm2png$(C)
$(CC) -c $(CFLAGS) pnm2png$(C) $(CC) -c $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O) pnm2png$(E): pnm2png$(O)
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm $(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
pnm2png-static$(E): pnm2png$(O) pnm2png-static$(E): pnm2png$(O)
$(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm $(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
clean: clean:
$(RM) png2pnm$(O) $(RM) png2pnm$(O)

View File

@@ -211,7 +211,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (ret != 8) if (ret != 8)
return FALSE; return FALSE;
ret = png_check_sig (buf, 8); ret = !png_sig_cmp (buf, 0, 8);
if (!ret) if (!ret)
return FALSE; return FALSE;

View File

@@ -1,3 +1,4 @@
#!/bin/sh
# -- grayscale # -- grayscale
./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm ./png2pnm -noraw ../pngsuite/basn0g01.png basn0g01.pgm
./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm ./png2pnm -noraw ../pngsuite/basn0g02.png basn0g02.pgm

View File

@@ -1,3 +1,4 @@
#!/bin/sh
make -f makefile.std make -f makefile.std
sh png2pnm.sh sh png2pnm.sh
sh pnm2png.sh sh pnm2png.sh

View File

@@ -1,3 +1,4 @@
#!/bin/sh
# -- grayscale # -- grayscale
./pnm2png basn0g01.pgm basn0g01.png ./pnm2png basn0g01.pgm basn0g01.png
./pnm2png basn0g02.pgm basn0g02.png ./pnm2png basn0g02.pgm basn0g02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -2,8 +2,11 @@
// PNGFILE.C -- Image File Functions // PNGFILE.C -- Image File Functions
//------------------------------------- //-------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and // Copyright 2000, Willem van Schaik.
// use, see the copyright/license/disclaimer notice in png.h //
// This code is released under the libpng license.
// For conditions of distribution and use, see the disclaimer
// and license in png.h
#include <windows.h> #include <windows.h>
#include <commdlg.h> #include <commdlg.h>
@@ -123,7 +126,7 @@ BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
// first check the eight byte PNG signature // first check the eight byte PNG signature
fread(pbSig, 1, 8, pfFile); fread(pbSig, 1, 8, pfFile);
if (!png_check_sig(pbSig, 8)) if (png_sig_cmp(pbSig, 0, 8))
{ {
*ppbImageData = pbImageData = NULL; *ppbImageData = pbImageData = NULL;
return FALSE; return FALSE;

View File

@@ -2,8 +2,11 @@
// PNGFILE.H -- Header File for pngfile.c // PNGFILE.H -- Header File for pngfile.c
//------------------------------------------ //------------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and // Copyright 2000, Willem van Schaik.
// use, see the copyright/license/disclaimer notice in png.h
// This code is released under the libpng license.
// For conditions of distribution and use, see the disclaimer
// and license in png.h
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@@ -1,8 +1,11 @@
Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng
------------------------------------------------------------------------ ------------------------------------------------------------------------
Copyright 2000, Willem van Schaik. For conditions of distribution and Copyright 2000, Willem van Schaik.
use, see the copyright/license/disclaimer notice in png.h
This code is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h
As a PNG .dll demo VisualPng is finished. More features would only hinder As a PNG .dll demo VisualPng is finished. More features would only hinder
the program's objective. However, further extensions (like support for other the program's objective. However, further extensions (like support for other

View File

@@ -2,8 +2,11 @@
// VisualPng.C -- Shows a PNG image // VisualPng.C -- Shows a PNG image
//------------------------------------ //------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and // Copyright 2000, Willem van Schaik.
// use, see the copyright/license/disclaimer notice in png.h
// This code is released under the libpng license.
// For conditions of distribution and use, see the disclaimer
// and license in png.h
// switches // switches

View File

@@ -1,25 +1,30 @@
/*=== /*===
cexcept.h 2.0.0 (2001-Jul-12-Thu) cexcept.h 2.0.1 (2008-Jul-19-Sat)
Adam M. Costello <amc@cs.berkeley.edu> http://www.nicemice.net/cexcept/
Adam M. Costello
http://www.nicemice.net/amc/
An interface for exception-handling in ANSI C (C89 and subsequent ISO An interface for exception-handling in ANSI C (C89 and subsequent ISO
standards), developed jointly with Cosmin Truta <cosmin@cs.toronto.edu>. standards), developed jointly with Cosmin Truta.
Copyright (c) 2001 Adam M. Costello and Cosmin Truta. Everyone Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta.
is hereby granted permission to do whatever they like with this This software may be modified only if its author and version
file, provided that if they modify it they take reasonable steps to information is updated accurately, and may be redistributed
avoid confusing or misleading people about the authors, version, only if accompanied by this unaltered notice. Subject to those
and terms of use of the derived file. The copyright holders make restrictions, permission is granted to anyone to do anything
no guarantees regarding this file, and are not responsible for any with this software. The copyright holders make no guarantees
damage resulting from its use. regarding this software, and are not responsible for any damage
resulting from its use.
Only user-defined exceptions are supported, not "real" exceptions like The cexcept interface is not compatible with and cannot interact
division by zero or memory segmentation violations. with system exceptions (like division by zero or memory segmentation
violation), compiler-generated exceptions (like C++ exceptions), or
other exception-handling interfaces.
If this interface is used by multiple .c files, they shouldn't include When using this interface across multiple .c files, do not include
this header file directly. Instead, create a wrapper header file that this header file directly. Instead, create a wrapper header file that
includes this header file and then invokes the define_exception_type includes this header file and then invokes the define_exception_type
macro (see below), and let your .c files include that header file. macro (see below). The .c files should then include that header file.
The interface consists of one type, one well-known name, and six macros. The interface consists of one type, one well-known name, and six macros.
@@ -164,7 +169,7 @@ Throw expression;
be compatible with the type passed to define_exception_type(). The be compatible with the type passed to define_exception_type(). The
exception must be caught, otherwise the program may crash. exception must be caught, otherwise the program may crash.
Slight limitation: If the expression is a comma-expression it must Slight limitation: If the expression is a comma-expression, it must
be enclosed in parentheses. be enclosed in parentheses.
@@ -209,11 +214,11 @@ struct exception_context { \
exception__prev = the_exception_context->penv; \ exception__prev = the_exception_context->penv; \
the_exception_context->penv = &exception__env; \ the_exception_context->penv = &exception__env; \
if (setjmp(exception__env) == 0) { \ if (setjmp(exception__env) == 0) { \
if (&exception__prev) do
#define exception__catch(action) \ #define exception__catch(action) \
else { } \ while (the_exception_context->caught = 0, \
the_exception_context->caught = 0; \ the_exception_context->caught); \
} \ } \
else { \ else { \
the_exception_context->caught = 1; \ the_exception_context->caught = 1; \
@@ -226,14 +231,14 @@ struct exception_context { \
#define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0)) #define Catch(e) exception__catch(((e) = the_exception_context->v.etmp, 0))
#define Catch_anonymous exception__catch(0) #define Catch_anonymous exception__catch(0)
/* Try ends with if(), and Catch begins and ends with else. This */ /* Try ends with do, and Catch begins with while(0) and ends with */
/* ensures that the Try/Catch syntax is really the same as the */ /* else, to ensure that Try/Catch syntax is similar to if/else */
/* if/else syntax. */ /* syntax. */
/* */ /* */
/* We use &exception__prev instead of 1 to appease compilers that */ /* The 0 in while(0) is expressed as x=0,x in order to appease */
/* warn about constant expressions inside if(). Most compilers */ /* compilers that warn about constant expressions inside while(). */
/* should still recognize that &exception__prev is never zero and */ /* Most compilers should still recognize that the condition is always */
/* avoid generating test code. */ /* false and avoid generating code for it. */
#define Throw \ #define Throw \
for (;; longjmp(*the_exception_context->penv, 1)) \ for (;; longjmp(*the_exception_context->penv, 1)) \

791
depcomp Executable file
View File

@@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

322
example.c
View File

@@ -1,7 +1,13 @@
#if 0 /* in case someone actually tries to compile this */ #if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng */ /* example.c - an example of using libpng
* Last changed in libpng 1.2.37 [June 4, 2009]
* 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.)
*/
/* This is an example of how to use libpng to read and write PNG files. /* This is an example of how to use libpng to read and write PNG files.
* The file libpng.txt is much more verbose then this. If you have not * The file libpng.txt is much more verbose then this. If you have not
@@ -85,14 +91,15 @@ void read_png(char *file_name) /* We need to open the file */
if ((fp = fopen(file_name, "rb")) == NULL) if ((fp = fopen(file_name, "rb")) == NULL)
return (ERROR); return (ERROR);
#else no_open_file /* prototype 2 */ #else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */
{ {
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
png_uint_32 width, height; png_uint_32 width, height;
int bit_depth, color_type, interlace_type; int bit_depth, color_type, interlace_type;
#endif no_open_file /* only use one prototype! */ #endif no_open_file /* Only use one prototype! */
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,
@@ -158,6 +165,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
* pixels) into the info structure with this call: * pixels) into the info structure with this call:
*/ */
png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else #else
/* OK, you're doing it the hard way, with the lower-level functions */ /* OK, you're doing it the hard way, with the lower-level functions */
@@ -169,13 +177,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, int_p_NULL, int_p_NULL); &interlace_type, int_p_NULL, int_p_NULL);
/* Set up the data transformations you want. Note that these are all /* Set up the data transformations you want. Note that these are all
* optional. Only call them if you want/need them. Many of the * optional. Only call them if you want/need them. Many of the
* transformations only work on specific types of images, and many * transformations only work on specific types of images, and many
* are mutually exclusive. * are mutually exclusive.
*/ */
/* tell libpng to strip 16 bit/color files down to 8 bits/color */ /* Tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with the /* Strip alpha bytes from the input data without combining with the
@@ -194,11 +202,11 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* Expand paletted colors into true RGB triplets */ /* Expand paletted colors into true RGB triplets */
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_rgb(png_ptr); png_set_palette_to_rgb(png_ptr);
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_gray_1_2_4_to_8(png_ptr); png_set_expand_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels /* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets. * so the data will be available as RGBA quartets.
@@ -222,10 +230,11 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_set_background(png_ptr, &my_background, png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
/* Some suggestions as to how to get a screen gamma value */ /* Some suggestions as to how to get a screen gamma value
*
/* Note that screen gamma is the display_exponent, which includes * Note that screen gamma is the display_exponent, which includes
* the CRT_exponent and any correction for viewing conditions */ * the CRT_exponent and any correction for viewing conditions
*/
if (/* We have a user-defined screen gamma value */) if (/* We have a user-defined screen gamma value */)
{ {
screen_gamma = user-defined screen_gamma; screen_gamma = user-defined screen_gamma;
@@ -238,7 +247,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* If we don't have another value */ /* If we don't have another value */
else else
{ {
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly
lit room */ lit room */
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
} }
@@ -271,7 +280,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_colorp palette; png_colorp palette;
/* This reduces the image to the application supplied palette */ /* This reduces the image to the application supplied palette */
if (/* we have our own palette */) if (/* We have our own palette */)
{ {
/* An array of colors to which the image should be dithered */ /* An array of colors to which the image should be dithered */
png_color std_color_cube[MAX_SCREEN_COLORS]; png_color std_color_cube[MAX_SCREEN_COLORS];
@@ -291,7 +300,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
} }
} }
/* invert monochrome files to have 0 as white and 1 as black */ /* Invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
/* If you want to shift the pixel values from the range [0,255] or /* If you want to shift the pixel values from the range [0,255] or
@@ -300,20 +309,20 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
*/ */
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{ {
png_color_8p sig_bit; png_color_8p sig_bit_p;
png_get_sBIT(png_ptr, info_ptr, &sig_bit); png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);
png_set_shift(png_ptr, sig_bit); png_set_shift(png_ptr, sig_bit_p);
} }
/* flip the RGB pixels to BGR (or RGBA to BGRA) */ /* Flip the RGB pixels to BGR (or RGBA to BGRA) */
if (color_type & PNG_COLOR_MASK_COLOR) if (color_type & PNG_COLOR_MASK_COLOR)
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
png_set_swap_alpha(png_ptr); png_set_swap_alpha(png_ptr);
/* swap bytes of 16 bit files to least significant byte first */ /* Swap bytes of 16 bit files to least significant byte first */
png_set_swap(png_ptr); png_set_swap(png_ptr);
/* Add filler (or alpha) byte (before/after each RGB triplet) */ /* Add filler (or alpha) byte (before/after each RGB triplet) */
@@ -336,11 +345,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* The easiest way to read the image: */ /* The easiest way to read the image: */
png_bytep row_pointers[height]; png_bytep row_pointers[height];
/* Clear the pointer array */
for (row = 0; row < height; row++)
row_pointers[row] = NULL;
for (row = 0; row < height; row++) for (row = 0; row < height; row++)
{
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr)); info_ptr));
}
/* Now it's time to read the image. One of these methods is REQUIRED */ /* Now it's time to read the image. One of these methods is REQUIRED */
#ifdef entire /* Read the entire image in one go */ #ifdef entire /* Read the entire image in one go */
@@ -366,32 +377,31 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
#else no_sparkle /* Read the image using the "rectangle" effect */ #else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y],
number_of_rows); number_of_rows);
#endif no_sparkle /* use only one of these two methods */ #endif no_sparkle /* Use only one of these two methods */
} }
/* if you want to display the image after every pass, do /* If you want to display the image after every pass, do so here */
so here */ #endif no_single /* Use only one of these two methods */
#endif no_single /* use only one of these two methods */
} }
#endif no_entire /* use only one of these two methods */ #endif no_entire /* Use only one of these two methods */
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */ /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr); png_read_end(png_ptr, info_ptr);
#endif hilevel #endif hilevel
/* At this point you have read the entire image */ /* At this point you have read the entire image */
/* clean up after the read, and free any memory allocated - REQUIRED */ /* Clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
/* close the file */ /* Close the file */
fclose(fp); fclose(fp);
/* that's it */ /* That's it */
return (OK); return (OK);
} }
/* progressively read a file */ /* Progressively read a file */
int int
initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
@@ -456,7 +466,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
/* This one's new also. Simply give it chunks of data as /* This one's new also. Simply give it chunks of data as
* they arrive from the data stream (in order, of course). * they arrive from the data stream (in order, of course).
* On Segmented machines, don't give it any more than 64K. * On segmented machines, don't give it any more than 64K.
* The library seems to run fine with sizes of 4K, although * The library seems to run fine with sizes of 4K, although
* you can give it much less if necessary (I assume you can * you can give it much less if necessary (I assume you can
* give it chunks of 1 byte, but I haven't tried with less * give it chunks of 1 byte, but I haven't tried with less
@@ -470,86 +480,84 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
info_callback(png_structp png_ptr, png_infop info) info_callback(png_structp png_ptr, png_infop info)
{ {
/* do any setup here, including setting any of the transformations /* Do any setup here, including setting any of the transformations
* mentioned in the Reading PNG files section. For now, you _must_ * mentioned in the Reading PNG files section. For now, you _must_
* call either png_start_read_image() or png_read_update_info() * call either png_start_read_image() or png_read_update_info()
* after all the transformations are set (even if you don't set * after all the transformations are set (even if you don't set
* any). You may start getting rows before png_process_data() * any). You may start getting rows before png_process_data()
* returns, so this is your last chance to prepare for that. * returns, so this is your last chance to prepare for that.
*/ */
} }
row_callback(png_structp png_ptr, png_bytep new_row, row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass) png_uint_32 row_num, int pass)
{ {
/* /*
* This function is called for every row in the image. If the * This function is called for every row in the image. If the
* image is interlaced, and you turned on the interlace handler, * image is interlaced, and you turned on the interlace handler,
* this function will be called for every row in every pass. * this function will be called for every row in every pass.
* *
* In this function you will receive a pointer to new row data from * In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of * libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application. * the same data format) in a buffer allocated by your application.
* *
* The new row data pointer new_row may be NULL, indicating there is * The new row data pointer "new_row" may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading). * no new data to be replaced (in cases of interlace loading).
* *
* If new_row is not NULL then you need to call * If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as * png_progressive_combine_row() to replace the corresponding row as
* shown below: * shown below:
*/ */
/* Check if row_num is in bounds. */
if((row_num >= 0) && (row_num < height))
{
/* Get pointer to corresponding row in our
* PNG read buffer.
*/
png_bytep old_row = ((png_bytep *)our_data)[row_num];
/* If both rows are allocated then copy the new row /* Get pointer to corresponding row in our
* data to the corresponding row data. * PNG read buffer.
*/ */
if((old_row != NULL) && (new_row != NULL)) png_bytep old_row = ((png_bytep *)our_data)[row_num];
png_progressive_combine_row(png_ptr, old_row, new_row);
} /* If both rows are allocated then copy the new row
/* * data to the corresponding row data.
* The rows and passes are called in order, so you don't really */
* need the row_num and pass, but I'm supplying them because it if ((old_row != NULL) && (new_row != NULL))
* may make your life easier. png_progressive_combine_row(png_ptr, old_row, new_row);
*
* For the non-NULL rows of interlaced images, you must call /*
* png_progressive_combine_row() passing in the new row and the * The rows and passes are called in order, so you don't really
* old row, as demonstrated above. You can call this function for * need the row_num and pass, but I'm supplying them because it
* NULL rows (it will just return) and for non-interlaced images * may make your life easier.
* (it just does the png_memcpy for you) if it will make the code *
* easier. Thus, you can just do this for all cases: * For the non-NULL rows of interlaced images, you must call
*/ * png_progressive_combine_row() passing in the new row and the
* old row, as demonstrated above. You can call this function for
* NULL rows (it will just return) and for non-interlaced images
* (it just does the png_memcpy for you) if it will make the code
* easier. Thus, you can just do this for all cases:
*/
png_progressive_combine_row(png_ptr, old_row, new_row); png_progressive_combine_row(png_ptr, old_row, new_row);
/* where old_row is what was displayed for previous rows. Note /* where old_row is what was displayed for previous rows. Note
* that the first pass (pass == 0 really) will completely cover * that the first pass (pass == 0 really) will completely cover
* the old row, so the rows do not have to be initialized. After * the old row, so the rows do not have to be initialized. After
* the first pass (and only for interlaced images), you will have * the first pass (and only for interlaced images), you will have
* to pass the current row as new_row, and the function will combine * to pass the current row as new_row, and the function will combine
* the old row and the new row. * the old row and the new row.
*/ */
} }
end_callback(png_structp png_ptr, png_infop info) end_callback(png_structp png_ptr, png_infop info)
{ {
/* this function is called when the whole image has been read, /* This function is called when the whole image has been read,
* including any chunks after the image (up to and including * including any chunks after the image (up to and including
* the IEND). You will usually have the same info chunk as you * the IEND). You will usually have the same info chunk as you
* had in the header, although some data may have been added * had in the header, although some data may have been added
* to the comments and time fields. * to the comments and time fields.
* *
* Most people won't do much here, perhaps setting a flag that * Most people won't do much here, perhaps setting a flag that
* marks the image as finished. * marks the image as finished.
*/ */
} }
/* write a png file */ /* Write a png file */
void write_png(char *file_name /* , ... other image information ... */) void write_png(char *file_name /* , ... other image information ... */)
{ {
FILE *fp; FILE *fp;
@@ -557,7 +565,7 @@ void write_png(char *file_name /* , ... other image information ... */)
png_infop info_ptr; png_infop info_ptr;
png_colorp palette; png_colorp palette;
/* open the file */ /* Open the file */
fp = fopen(file_name, "wb"); fp = fopen(file_name, "wb");
if (fp == NULL) if (fp == NULL)
return (ERROR); return (ERROR);
@@ -591,30 +599,34 @@ void write_png(char *file_name /* , ... other image information ... */)
*/ */
if (setjmp(png_jmpbuf(png_ptr))) if (setjmp(png_jmpbuf(png_ptr)))
{ {
/* If we get here, we had a problem reading the file */ /* If we get here, we had a problem writing the file */
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
return (ERROR); return (ERROR);
} }
/* One of the following I/O initialization functions is REQUIRED */ /* One of the following I/O initialization functions is REQUIRED */
#ifdef streams /* I/O initialization method 1 */ #ifdef streams /* I/O initialization method 1 */
/* set up the output control if you are using standard C streams */ /* Set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
#else no_streams /* I/O initialization method 2 */ #else no_streams /* I/O initialization method 2 */
/* If you are using replacement read functions, instead of calling /* If you are using replacement write functions, instead of calling
* png_init_io() here you would call */ * png_init_io() here you would call
*/
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function); user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */ /* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* only use one initialization method */ #endif no_streams /* Only use one initialization method */
#ifdef hilevel #ifdef hilevel
/* This is the easy way. Use it if you already have all the /* This is the easy way. Use it if you already have all the
* image info living info in the structure. You could "|" many * image info living in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here. * PNG_TRANSFORM flags into the png_transforms integer here.
*/ */
png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else #else
/* This is the hard way */ /* This is the hard way */
@@ -629,25 +641,27 @@ void write_png(char *file_name /* , ... other image information ... */)
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */ /* Set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* png_sizeof (png_color)); * png_sizeof(png_color));
/* ... set palette colors ... */ /* ... Set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to /* You must not free palette here, because png_set_PLTE only makes a link to
the palette that you malloced. Wait until you are about to destroy * the palette that you malloced. Wait until you are about to destroy
the png structure. */ * the png structure.
*/
/* optional significant bit chunk */ /* Optional significant bit (sBIT) chunk */
/* if we are dealing with a grayscale image then */ png_color_8 sig_bit;
/* If we are dealing with a grayscale image then */
sig_bit.gray = true_bit_depth; sig_bit.gray = true_bit_depth;
/* otherwise, if we are dealing with a color image then */ /* Otherwise, if we are dealing with a color image then */
sig_bit.red = true_red_bit_depth; sig_bit.red = true_red_bit_depth;
sig_bit.green = true_green_bit_depth; sig_bit.green = true_green_bit_depth;
sig_bit.blue = true_blue_bit_depth; sig_bit.blue = true_blue_bit_depth;
/* if the image has an alpha channel then */ /* If the image has an alpha channel then */
sig_bit.alpha = true_alpha_bit_depth; sig_bit.alpha = true_alpha_bit_depth;
png_set_sBIT(png_ptr, info_ptr, sig_bit); png_set_sBIT(png_ptr, info_ptr, &sig_bit);
/* Optional gamma chunk is strongly suggested if you have any guess /* Optional gamma chunk is strongly suggested if you have any guess
@@ -672,9 +686,12 @@ void write_png(char *file_name /* , ... other image information ... */)
#endif #endif
png_set_text(png_ptr, info_ptr, text_ptr, 3); png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
/* note that if sRGB is present the gAMA and cHRM chunks must be ignored
* on read and must be written in accordance with the sRGB profile */ /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored
* on read and, if your application chooses to write them, they must
* be written in accordance with the sRGB profile
*/
/* Write the file header information. REQUIRED */ /* Write the file header information. REQUIRED */
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);
@@ -686,7 +703,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* write_my_chunk(); * write_my_chunk();
* png_write_info(png_ptr, info_ptr); * png_write_info(png_ptr, info_ptr);
* *
* However, given the level of known- and unknown-chunk support in 1.1.0 * However, given the level of known- and unknown-chunk support in 1.2.0
* and up, this should no longer be necessary. * and up, this should no longer be necessary.
*/ */
@@ -696,11 +713,11 @@ void write_png(char *file_name /* , ... other image information ... */)
* at the end. * at the end.
*/ */
/* set up the transformations you want. Note that these are /* Set up the transformations you want. Note that these are
* all optional. Only call them if you want them. * all optional. Only call them if you want them.
*/ */
/* invert monochrome pixels */ /* Invert monochrome pixels */
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
/* Shift the pixels up to a legal bit depth and fill in /* Shift the pixels up to a legal bit depth and fill in
@@ -708,10 +725,10 @@ void write_png(char *file_name /* , ... other image information ... */)
*/ */
png_set_shift(png_ptr, &sig_bit); png_set_shift(png_ptr, &sig_bit);
/* pack pixels into bytes */ /* Pack pixels into bytes */
png_set_packing(png_ptr); png_set_packing(png_ptr);
/* swap location of alpha bytes from ARGB to RGBA */ /* Swap location of alpha bytes from ARGB to RGBA */
png_set_swap_alpha(png_ptr); png_set_swap_alpha(png_ptr);
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
@@ -719,16 +736,16 @@ void write_png(char *file_name /* , ... other image information ... */)
*/ */
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
/* flip BGR pixels to RGB */ /* Flip BGR pixels to RGB */
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
/* swap bytes of 16-bit files to most significant byte first */ /* Swap bytes of 16-bit files to most significant byte first */
png_set_swap(png_ptr); png_set_swap(png_ptr);
/* swap bits of 1, 2, 4 bit packed pixel formats */ /* Swap bits of 1, 2, 4 bit packed pixel formats */
png_set_packswap(png_ptr); png_set_packswap(png_ptr);
/* turn on interlace handling if you are not using png_write_image() */ /* Turn on interlace handling if you are not using png_write_image() */
if (interlacing) if (interlacing)
number_passes = png_set_interlace_handling(png_ptr); number_passes = png_set_interlace_handling(png_ptr);
else else
@@ -749,12 +766,14 @@ void write_png(char *file_name /* , ... other image information ... */)
row_pointers[k] = image + k*width*bytes_per_pixel; row_pointers[k] = image + k*width*bytes_per_pixel;
/* One of the following output methods is REQUIRED */ /* One of the following output methods is REQUIRED */
#ifdef entire /* write out the entire image data in one call */
#ifdef entire /* Write out the entire image data in one call */
png_write_image(png_ptr, row_pointers); png_write_image(png_ptr, row_pointers);
/* the other way to write the image - deal with interlacing */ /* The other way to write the image - deal with interlacing */
#else no_entire /* Write out the image data by one or more scanlines */
#else no_entire /* write out the image data by one or more scanlines */
/* The number of passes is either 1 for non-interlaced images, /* The number of passes is either 1 for non-interlaced images,
* or 7 for interlaced images. * or 7 for interlaced images.
*/ */
@@ -765,14 +784,12 @@ void write_png(char *file_name /* , ... other image information ... */)
/* If you are only writing one row at a time, this works */ /* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{
png_write_rows(png_ptr, &row_pointers[y], 1); png_write_rows(png_ptr, &row_pointers[y], 1);
}
} }
#endif no_entire /* use only one output method */ #endif no_entire /* Use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end /* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well. Shouldn't be necessary in 1.1.0 and up as all the public * as well. Shouldn't be necessary in 1.2.0 and up as all the public
* chunks are supported and you can use png_set_unknown_chunks() to * chunks are supported and you can use png_set_unknown_chunks() to
* register unknown chunks into the info structure to be written out. * register unknown chunks into the info structure to be written out.
*/ */
@@ -782,26 +799,33 @@ void write_png(char *file_name /* , ... other image information ... */)
#endif hilevel #endif hilevel
/* If you png_malloced a palette, free it here (don't free info_ptr->palette, /* If you png_malloced a palette, free it here (don't free info_ptr->palette,
as recommended in versions 1.0.5m and earlier of this example; if * as recommended in versions 1.0.5m and earlier of this example; if
libpng mallocs info_ptr->palette, libpng will free it). If you * libpng mallocs info_ptr->palette, libpng will free it). If you
allocated it with malloc() instead of png_malloc(), use free() instead * allocated it with malloc() instead of png_malloc(), use free() instead
of png_free(). */ * of png_free().
*/
png_free(png_ptr, palette); png_free(png_ptr, palette);
palette=NULL; palette = NULL;
/* Similarly, if you png_malloced any data that you passed in with /* Similarly, if you png_malloced any data that you passed in with
png_set_something(), such as a hist or trans array, free it here, * png_set_something(), such as a hist or trans array, free it here,
when you can be sure that libpng is through with it. */ * when you can be sure that libpng is through with it.
*/
png_free(png_ptr, trans); png_free(png_ptr, trans);
trans=NULL; trans = NULL;
/* Whenever you use png_free() it is a good idea to set the pointer to
* NULL in case your application inadvertently tries to png_free() it
* again. When png_free() sees a NULL it returns without action, thus
* avoiding the double-free security problem.
*/
/* clean up after the write, and free any memory allocated */ /* Clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
/* close the file */ /* Close the file */
fclose(fp); fclose(fp);
/* that's it */ /* That's it */
return (OK); return (OK);
} }

527
install-sh Executable file
View File

@@ -0,0 +1,527 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -1,13 +1,19 @@
libpng.txt - A description on how to use and modify libpng libpng.txt - A description on how to use and modify libpng
libpng version 1.0.18 - December 3, 2004 libpng version 1.0.62 - February 6, 2014
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2004 Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
based on: This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h
Based on:
libpng versions 0.97, January 1998, through 1.0.62 - February 6, 2014
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
libpng 1.0 beta 6 version 0.96 May 28, 1997 libpng 1.0 beta 6 version 0.96 May 28, 1997
Updated and distributed by Andreas Dilger Updated and distributed by Andreas Dilger
@@ -33,6 +39,10 @@ it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the will need. We assume that libpng is already installed; see the
INSTALL file for instructions on how to install libpng. INSTALL file for instructions on how to install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in
the libpng distribution.
Libpng was written as a companion to the PNG specification, as a way Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG of reducing the amount of time and effort it takes to support the PNG
file format in application programs. file format in application programs.
@@ -43,12 +53,14 @@ a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
The W3C and ISO documents have identical technical content. The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at The PNG-1.2 specification is available at
<http://www.libpng.org/pub/png/documents/> <http://www.libpng.org/pub/png/documents/>. It is technically equivalent
to the PNG specification (second edition) but has some additional material.
The PNG-1.0 specification is available The PNG-1.0 specification is available
as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
additional chunks are described in the special-purpose public chunks
Some additional chunks are described in the special-purpose public chunks
documents at <http://www.libpng.org/pub/png/documents/>. documents at <http://www.libpng.org/pub/png/documents/>.
Other information Other information
@@ -82,9 +94,7 @@ Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image. png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the Libpng does not protect itself against two threads using the
same instance of a structure. Note: thread safety may be defeated same instance of a structure.
by use of some of the MMX assembler code in pnggccrd.c, which is only
compiled when the user defines PNG_THREAD_UNSAFE_OK.
II. Structures II. Structures
@@ -133,9 +143,10 @@ so if it doesn't work, you don't have much to undo. Of course, you
will also want to insure that you are, in fact, dealing with a PNG will also want to insure that you are, in fact, dealing with a PNG
file. Libpng provides a simple check to see if a file is a PNG file. file. Libpng provides a simple check to see if a file is a PNG file.
To use it, pass in the first 1 to 8 bytes of the file to the function To use it, pass in the first 1 to 8 bytes of the file to the function
png_sig_cmp(), and it will return 0 if the bytes match the corresponding png_sig_cmp(), and it will return 0 (false) if the bytes match the
bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes corresponding bytes of the PNG signature, or nonzero (true) otherwise.
you pass in, the greater the accuracy of the prediction. Of course, the more bytes you pass in, the greater the accuracy of the
prediction.
If you are intending to keep the file pointer open for use in libpng, If you are intending to keep the file pointer open for use in libpng,
you must ensure you don't read more than 8 bytes from the beginning you must ensure you don't read more than 8 bytes from the beginning
@@ -258,15 +269,19 @@ input stream. You must supply the function
png_unknown_chunkp chunk); png_unknown_chunkp chunk);
{ {
/* The unknown chunk structure contains your /* The unknown chunk structure contains your
chunk data: */ chunk data, along with similar data for any other
unknown chunks: */
png_byte name[5]; png_byte name[5];
png_byte *data; png_byte *data;
png_size_t size; png_size_t size;
/* Note that libpng has already taken care of /* Note that libpng has already taken care of
the CRC handling */ the CRC handling */
/* put your code here. Return one of the /* put your code here. Search for your chunk in the
following: */ unknown chunk structure, process it, and return one
of the following: */
return (-n); /* chunk had an error */ return (-n); /* chunk had an error */
return (0); /* did not recognize */ return (0); /* did not recognize */
@@ -286,6 +301,11 @@ you can retrieve with
png_get_user_chunk_ptr(png_ptr); png_get_user_chunk_ptr(png_ptr);
If you call the png_set_read_user_chunk_fn() function, then all unknown
chunks will be saved when read, in case your callback function will need
one or more of them. This behavior can be changed with the
png_set_keep_unknown_chunks() function, described below.
At this point, you can set up a callback function that will be At this point, you can set up a callback function that will be
called after each row has been read, which you can use to control called after each row has been read, which you can use to control
a progress meter or the like. It's demonstrated in pngtest.c. a progress meter or the like. It's demonstrated in pngtest.c.
@@ -308,13 +328,14 @@ Unknown-chunk handling
Now you get to set the way the library processes unknown chunks in the Now you get to set the way the library processes unknown chunks in the
input PNG stream. Both known and unknown chunks will be read. Normal input PNG stream. Both known and unknown chunks will be read. Normal
behavior is that known chunks will be parsed into information in behavior is that known chunks will be parsed into information in
various info_ptr members; unknown chunks will be discarded. To change various info_ptr members while unknown chunks will be discarded. This
this, you can call: behavior can be wasteful if your application will never use some known
chunk types. To change this, you can call:
png_set_keep_unknown_chunks(png_ptr, keep, png_set_keep_unknown_chunks(png_ptr, keep,
chunk_list, num_chunks); chunk_list, num_chunks);
keep - 0: do not handle as unknown keep - 0: default unknown chunk handling
1: do not keep 1: ignore; do not keep
2: keep only if safe-to-copy 2: keep only if safe-to-copy
3: keep even if unsafe-to-copy 3: keep even if unsafe-to-copy
You can use these definitions: You can use these definitions:
@@ -337,6 +358,71 @@ instances of png_set_keep_unknown_chunks(), the final instance will
take precedence. The IHDR and IEND chunks should not be named in take precedence. The IHDR and IEND chunks should not be named in
chunk_list; if they are, libpng will process them normally anyway. chunk_list; if they are, libpng will process them normally anyway.
Here is an example of the usage of png_set_keep_unknown_chunks(),
where the private "vpAg" chunk will later be processed by a user chunk
callback function:
png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'};
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
png_byte unused_chunks[]=
{
104, 73, 83, 84, (png_byte) '\0', /* hIST */
105, 84, 88, 116, (png_byte) '\0', /* iTXt */
112, 67, 65, 76, (png_byte) '\0', /* pCAL */
115, 67, 65, 76, (png_byte) '\0', /* sCAL */
115, 80, 76, 84, (png_byte) '\0', /* sPLT */
116, 73, 77, 69, (png_byte) '\0', /* tIME */
};
#endif
...
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* ignore all unknown chunks: */
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
/* except for vpAg: */
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
/* also ignore unused known chunks: */
png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
(int)sizeof(unused_chunks)/5);
#endif
User limits
The PNG specification allows the width and height of an image to be as
large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
Since very few applications really need to process such large images,
we have imposed an arbitrary 1-million limit on rows and columns.
Larger images will be rejected immediately with a png_error() call. If
you wish to override this limit, you can use
png_set_user_limits(png_ptr, width_max, height_max);
to set your own limits, or use width_max = height_max = 0x7fffffffL
to allow all valid dimensions (libpng may reject some very large images
anyway because of potential buffer overflow conditions).
You should put this statement after you create the PNG structure and
before calling png_read_info(), png_read_png(), or png_process_data().
If you need to retrieve the limits that are being applied, use
width_max = png_get_user_width_max(png_ptr);
height_max = png_get_user_height_max(png_ptr);
The PNG specification sets no limit on the number of ancillary chunks
allowed in a PNG datastream. You can impose a limit on the total number
of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with
png_set_chunk_cache_max(png_ptr, user_chunk_cache_max);
where 0x7fffffffL means unlimited. You can retrieve this limit with
chunk_cache_max = png_get_chunk_cache_max(png_ptr);
This limit also applies to the number of buffers that can be allocated
by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
The high-level read interface The high-level read interface
At this point there are two ways to proceed; through the high-level At this point there are two ways to proceed; through the high-level
@@ -364,14 +450,16 @@ you want to do are limited to the following set:
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
PNG_TRANSFORM_GRAY_TO_RGB Expand grayscale samples
to RGB (or GA to RGBA)
(This excludes setting a background color, doing gamma transformation, (This excludes setting a background color, doing gamma transformation,
dithering, and setting filler.) If this is the case, simply do this: dithering, and setting filler.) If this is the case, simply do this:
png_read_png(png_ptr, info_ptr, png_transforms, NULL) png_read_png(png_ptr, info_ptr, png_transforms, NULL)
where png_transforms is an integer containing the logical OR of where png_transforms is an integer containing the bitwise OR of some
some set of transformation flags. This call is equivalent to png_read_info(), set of transformation flags. This call is equivalent to png_read_info(),
followed the set of transformations indicated by the transform mask, followed the set of transformations indicated by the transform mask,
then png_read_image(), and finally png_read_end(). then png_read_image(), and finally png_read_end().
@@ -401,6 +489,8 @@ row_pointers prior to calling png_read_png() with
"Image is too wide to process in memory"); "Image is too wide to process in memory");
row_pointers = png_malloc(png_ptr, row_pointers = png_malloc(png_ptr,
height*png_sizeof(png_bytep)); height*png_sizeof(png_bytep));
for (int i=0; i<height, i++)
row_pointers[i]=NULL; /* security precaution */
for (int i=0; i<height, i++) for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr, row_pointers[i]=png_malloc(png_ptr,
width*pixel_size); width*pixel_size);
@@ -470,10 +560,33 @@ in until png_read_end() has read the chunk data following the image.
for PNG 1.0) for PNG 1.0)
interlace_type - (PNG_INTERLACE_NONE or interlace_type - (PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7) PNG_INTERLACE_ADAM7)
Any or all of interlace_type, compression_type, of
Any or all of interlace_type, compression_type, or
filter_method can be NULL if you are filter_method can be NULL if you are
not interested in their values. not interested in their values.
Note that png_get_IHDR() returns 32-bit data into
the application's width and height variables.
This is an unsafe situation if these are 16-bit
variables. In such situations, the
png_get_image_width() and png_get_image_height()
functions described below are safer.
width = png_get_image_width(png_ptr,
info_ptr);
height = png_get_image_height(png_ptr,
info_ptr);
bit_depth = png_get_bit_depth(png_ptr,
info_ptr);
color_type = png_get_color_type(png_ptr,
info_ptr);
filter_method = png_get_filter_type(png_ptr,
info_ptr);
compression_type = png_get_compression_type(png_ptr,
info_ptr);
interlace_type = png_get_interlace_type(png_ptr,
info_ptr);
channels = png_get_channels(png_ptr, info_ptr); channels = png_get_channels(png_ptr, info_ptr);
channels - number of channels of info for the channels - number of channels of info for the
color type (valid values are 1 (GRAY, color type (valid values are 1 (GRAY,
@@ -493,29 +606,12 @@ in until png_read_end() has read the chunk data following the image.
be in signature[4] through signature[7] be in signature[4] through signature[7]
(see png_set_sig_bytes())). (see png_set_sig_bytes())).
width = png_get_image_width(png_ptr,
info_ptr);
height = png_get_image_height(png_ptr,
info_ptr);
bit_depth = png_get_bit_depth(png_ptr,
info_ptr);
color_type = png_get_color_type(png_ptr,
info_ptr);
filter_method = png_get_filter_type(png_ptr,
info_ptr);
compression_type = png_get_compression_type(png_ptr,
info_ptr);
interlace_type = png_get_interlace_type(png_ptr,
info_ptr);
These are also important, but their validity depends on whether the chunk These are also important, but their validity depends on whether the chunk
has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
data has been read, or zero if it is missing. The parameters to the data has been read, or zero if it is missing. The parameters to the
png_get_<chunk> are set directly if they are simple data types, or a pointer png_get_<chunk> are set directly if they are simple data types, or a
into the info_ptr is returned for any complex types. pointer into the info_ptr is returned for any complex types.
png_get_PLTE(png_ptr, info_ptr, &palette, png_get_PLTE(png_ptr, info_ptr, &palette,
&num_palette); &num_palette);
@@ -555,8 +651,8 @@ into the info_ptr is returned for any complex types.
png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
&trans_values); &trans_values);
trans - array of transparent entries for trans - array of transparent
palette (PNG_INFO_tRNS) entries for palette (PNG_INFO_tRNS)
trans_values - graylevel or color sample values of trans_values - graylevel or color sample values of
the single transparent color for the single transparent color for
non-paletted images (PNG_INFO_tRNS) non-paletted images (PNG_INFO_tRNS)
@@ -599,6 +695,10 @@ into the info_ptr is returned for any complex types.
string for unknown). string for unknown).
text_ptr[i].lang_key - keyword in UTF-8 text_ptr[i].lang_key - keyword in UTF-8
(empty string for unknown). (empty string for unknown).
Note that the itxt_length, lang, and lang_key
members of the text_ptr structure only exist
when the library is built with iTXt chunk support.
num_text - number of comments (same as num_text - number of comments (same as
num_comments; you can put NULL here num_comments; you can put NULL here
to avoid the duplication) to avoid the duplication)
@@ -775,6 +875,46 @@ in libpng version 1.0.4, with the function names expanded to improve code
readability. In some future version they may actually do different readability. In some future version they may actually do different
things. things.
As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
added. It expands the sample depth without changing tRNS to alpha.
As of libpng version 1.0.62, not all possible expansions are supported.
In the following table, the 01 means grayscale with depth<8, 31 means
indexed with depth<8, other numerals represent the color type, "T" means
the tRNS chunk is present, A means an alpha channel is present, and O
means tRNS or alpha is present but all pixels in the image are opaque.
FROM 01 31 0 0T 0O 2 2T 2O 3 3T 3O 4A 4O 6A 6O
TO
01 -
31 -
0 1 -
0T -
0O -
2 GX -
2T -
2O -
3 1 -
3T -
3O -
4A T -
4O -
6A GX TX TX -
6O GX TX -
Within the matrix,
"-" means the transformation is not supported.
"X" means the transformation is obtained by png_set_expand().
"1" means the transformation is obtained by
png_set_expand_gray_1_2_4_to_8
"G" means the transformation is obtained by
png_set_gray_to_rgb().
"P" means the transformation is obtained by
png_set_expand_palette_to_rgb().
"T" means the transformation is obtained by
png_set_tRNS_to_alpha().
PNG can have files with 16 bits per channel. If you only can handle PNG can have files with 16 bits per channel. If you only can handle
8 bits per channel, this will strip the pixels down to 8 bit. 8 bits per channel, this will strip the pixels down to 8 bit.
@@ -798,6 +938,15 @@ images) is fully transparent, with
png_set_invert_alpha(png_ptr); png_set_invert_alpha(png_ptr);
The PNG format only supports pixels with postmultiplied alpha.
If you want to replace the pixels, after reading them, with pixels
that have premultiplied color samples, you can do this with
png_set_premultiply_alpha(png_ptr);
If you do this, any input with a tRNS chunk will be expanded to
have an alpha channel.
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
they can, resulting in, for example, 8 pixels per byte for 1 bit they can, resulting in, for example, 8 pixels per byte for 1 bit
files. This code expands to 1 pixel per byte without changing the files. This code expands to 1 pixel per byte without changing the
@@ -808,10 +957,10 @@ values of the pixels:
PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
stored in a PNG image have been "scaled" or "shifted" up to the next stored in a PNG image have been "scaled" or "shifted" up to the next
higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to higher possible bit depth (e.g. from 5 bits/sample in the range [0,31]
8 bits/sample in the range [0, 255]). However, it is also possible to to 8 bits/sample in the range [0, 255]). However, it is also possible
convert the PNG pixel data back to the original bit depth of the image. to convert the PNG pixel data back to the original bit depth of the
This call reduces the pixels back down to the original bit depth: image. This call reduces the pixels back down to the original bit depth:
png_color_8p sig_bit; png_color_8p sig_bit;
@@ -1217,8 +1366,8 @@ the second parameter NULL.
Finishing a sequential read Finishing a sequential read
After you are finished reading the image through either the high- or After you are finished reading the image through the
low-level interfaces, you can finish reading the file. If you are low-level interface, you can finish reading the file. If you are
interested in comments or time, which may be stored either before or interested in comments or time, which may be stored either before or
after the image data, you should pass the separate png_info struct if after the image data, you should pass the separate png_info struct if
you want to keep the comments from before and after the image you want to keep the comments from before and after the image
@@ -1236,7 +1385,7 @@ point to libpng-allocated storage with the following function:
png_free_data(png_ptr, info_ptr, mask, seq) png_free_data(png_ptr, info_ptr, mask, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the bitwise OR of one or
more of more of
PNG_FREE_PLTE, PNG_FREE_TRNS, PNG_FREE_PLTE, PNG_FREE_TRNS,
PNG_FREE_HIST, PNG_FREE_ICCP, PNG_FREE_HIST, PNG_FREE_ICCP,
@@ -1249,12 +1398,11 @@ point to libpng-allocated storage with the following function:
This function may be safely called when the relevant storage has This function may be safely called when the relevant storage has
already been freed, or has not yet been allocated, or was allocated already been freed, or has not yet been allocated, or was allocated
by the user and not by libpng, and will in those by the user and not by libpng, and will in those cases do nothing.
cases do nothing. The "seq" parameter is ignored if only one item The "seq" parameter is ignored if only one item of the selected data
of the selected data type, such as PLTE, is allowed. If "seq" is not type, such as PLTE, is allowed. If "seq" is not -1, and multiple items
-1, and multiple items are allowed for the data type identified in are allowed for the data type identified in the mask, such as text or
the mask, such as text or sPLT, only the n'th item in the structure sPLT, only the n'th item in the structure is freed, where n is "seq".
is freed, where n is "seq".
The default behavior is only to free data that was allocated internally The default behavior is only to free data that was allocated internally
by libpng. This can be changed, so that libpng will not free the data, by libpng. This can be changed, so that libpng will not free the data,
@@ -1293,12 +1441,12 @@ if you transfer responsibility for free'ing text_ptr from libpng to your
application, your application must not separately free those members. application, your application must not separately free those members.
The png_free_data() function will turn off the "valid" flag for anything The png_free_data() function will turn off the "valid" flag for anything
it frees. If you need to turn the flag off for a chunk that was freed by your it frees. If you need to turn the flag off for a chunk that was freed by
application instead of by libpng, you can use your application instead of by libpng, you can use
png_set_invalid(png_ptr, info_ptr, mask); png_set_invalid(png_ptr, info_ptr, mask);
mask - identifies the chunks to be made invalid, mask - identifies the chunks to be made invalid,
containing the logical OR of one or containing the bitwise OR of one or
more of more of
PNG_INFO_gAMA, PNG_INFO_sBIT, PNG_INFO_gAMA, PNG_INFO_sBIT,
PNG_INFO_cHRM, PNG_INFO_PLTE, PNG_INFO_cHRM, PNG_INFO_PLTE,
@@ -1565,6 +1713,14 @@ Libpng section below.
png_init_io(png_ptr, fp); png_init_io(png_ptr, fp);
If you are embedding your PNG into a datastream such as MNG, and don't
want libpng to write the 8-byte signature, or if you have already
written the signature in your application, use
png_set_sig_bytes(png_ptr, 8);
to inform libpng that it should not write a signature.
Write callbacks Write callbacks
At this point, you can set up a callback function that will be At this point, you can set up a callback function that will be
@@ -1596,19 +1752,19 @@ the filter method, for which the only valid values are 0 (as of the
July 1999 PNG specification, version 1.2) or 64 (if you are writing July 1999 PNG specification, version 1.2) or 64 (if you are writing
a PNG datastream that is to be embedded in a MNG datastream). The third a PNG datastream that is to be embedded in a MNG datastream). The third
parameter is a flag that indicates which filter type(s) are to be tested parameter is a flag that indicates which filter type(s) are to be tested
for each scanline. See the PNG specification for details on the specific filter for each scanline. See the PNG specification for details on the specific
types. filter types.
/* turn on or off filtering, and/or choose /* turn on or off filtering, and/or choose
specific filters. You can use either a single specific filters. You can use either a single
PNG_FILTER_VALUE_NAME or the logical OR of one PNG_FILTER_VALUE_NAME or the bitwise OR of one
or more PNG_FILTER_NAME masks. */ or more PNG_FILTER_NAME masks. */
png_set_filter(png_ptr, 0, png_set_filter(png_ptr, 0,
PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
PNG_FILTER_UP | PNG_FILTER_VALUE_UP | PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS); PNG_ALL_FILTERS);
@@ -1697,6 +1853,15 @@ Some of the more important parts of the png_info are:
can also be can also be
PNG_INTRAPIXEL_DIFFERENCING) PNG_INTRAPIXEL_DIFFERENCING)
If you call png_set_IHDR(), the call must appear before any of the
other png_set_*() functions, because they might require access to some of
the IHDR settings. The remaining png_set_*() functions can be called
in any order.
If you wish, you can reset the compression_type, interlace_type, or
filter_method later by calling png_set_IHDR() again; if you do this, the
width, height, bit_depth, and color_type must be the same in each call.
png_set_PLTE(png_ptr, info_ptr, palette, png_set_PLTE(png_ptr, info_ptr, palette,
num_palette); num_palette);
palette - the palette for the file palette - the palette for the file
@@ -1756,10 +1921,11 @@ Some of the more important parts of the png_info are:
png_set_tRNS(png_ptr, info_ptr, trans, num_trans, png_set_tRNS(png_ptr, info_ptr, trans, num_trans,
trans_values); trans_values);
trans - array of transparent entries for trans - array of transparent
palette (PNG_INFO_tRNS) entries for palette (PNG_INFO_tRNS)
trans_values - graylevel or color sample values of trans_values - graylevel or color sample values
the single transparent color for (in order red, green, blue) of the
single transparent color for
non-paletted images (PNG_INFO_tRNS) non-paletted images (PNG_INFO_tRNS)
num_trans - number of transparent entries num_trans - number of transparent entries
(PNG_INFO_tRNS) (PNG_INFO_tRNS)
@@ -1796,6 +1962,10 @@ Some of the more important parts of the png_info are:
empty for unknown). empty for unknown).
text_ptr[i].translated_keyword - keyword in UTF-8 (NULL text_ptr[i].translated_keyword - keyword in UTF-8 (NULL
or empty for unknown). or empty for unknown).
Note that the itxt_length, lang, and lang_key
members of the text_ptr structure only exist
when the library is built with iTXt chunk support.
num_text - number of comments num_text - number of comments
png_set_sPLT(png_ptr, info_ptr, &palette_ptr, png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
@@ -1968,14 +2138,19 @@ transformations are permitted, enabled by the following masks.
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. PNG_TRANSFORM_STRIP_FILLER Strip out filler
bytes (deprecated).
PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
filler bytes
PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing
filler bytes
If you have valid image data in the info structure (you can use If you have valid image data in the info structure (you can use
png_set_rows() to put image data in the info structure), simply do this: png_set_rows() to put image data in the info structure), simply do this:
png_write_png(png_ptr, info_ptr, png_transforms, NULL) png_write_png(png_ptr, info_ptr, png_transforms, NULL)
where png_transforms is an integer containing the logical OR of some set of where png_transforms is an integer containing the bitwise OR of some set of
transformation flags. This call is equivalent to png_write_info(), transformation flags. This call is equivalent to png_write_info(),
followed the set of transformations indicated by the transform mask, followed the set of transformations indicated by the transform mask,
then png_write_image(), and finally png_write_end(). then png_write_image(), and finally png_write_end().
@@ -1996,10 +2171,10 @@ this with a call to png_write_info().
Note that there is one transformation you may need to do before Note that there is one transformation you may need to do before
png_write_info(). In PNG files, the alpha channel in an image is the png_write_info(). In PNG files, the alpha channel in an image is the
level of opacity. If your data is supplied as a level of level of opacity. If your data is supplied as a level of transparency,
transparency, you can invert the alpha channel before you write it, so you can invert the alpha channel before you write it, so that 0 is
that 0 is fully transparent and 255 (in 8-bit or paletted images) or fully transparent and 255 (in 8-bit or paletted images) or 65535
65535 (in 16-bit images) is fully opaque, with (in 16-bit images) is fully opaque, with
png_set_invert_alpha(png_ptr); png_set_invert_alpha(png_ptr);
@@ -2186,14 +2361,13 @@ a single row_pointer instead of an array of row_pointers:
png_write_row(png_ptr, row_pointer); png_write_row(png_ptr, row_pointer);
When the file is interlaced, things can get a good deal more When the file is interlaced, things can get a good deal more complicated.
complicated. The only currently (as of the PNG Specification The only currently (as of the PNG Specification version 1.2, dated July
version 1.2, dated July 1999) defined interlacing scheme for PNG files 1999) defined interlacing scheme for PNG files is the "Adam7" interlace
is the "Adam7" interlace scheme, that breaks down an scheme, that breaks down an image into seven smaller images of varying
image into seven smaller images of varying size. libpng will build size. libpng will build these images for you, or you can do them
these images for you, or you can do them yourself. If you want to yourself. If you want to build them yourself, see the PNG specification
build them yourself, see the PNG specification for details of which for details of which pixels to write when.
pixels to write when.
If you don't want libpng to handle the interlacing details, just If you don't want libpng to handle the interlacing details, just
use png_set_interlace_handling() and call png_write_rows() the use png_set_interlace_handling() and call png_write_rows() the
@@ -2205,17 +2379,17 @@ writing any rows:
number_of_passes = number_of_passes =
png_set_interlace_handling(png_ptr); png_set_interlace_handling(png_ptr);
This will return the number of passes needed. Currently, this This will return the number of passes needed. Currently, this is seven,
is seven, but may change if another interlace type is added. but may change if another interlace type is added.
Then write the complete image number_of_passes times. Then write the complete image number_of_passes times.
png_write_rows(png_ptr, row_pointers, png_write_rows(png_ptr, row_pointers,
number_of_rows); number_of_rows);
As some of these rows are not used, and thus return immediately, As some of these rows are not used, and thus return immediately, you may
you may want to read about interlacing in the PNG specification, want to read about interlacing in the PNG specification, and only update
and only update the rows that are actually used. the rows that are actually used.
Finishing a sequential write Finishing a sequential write
@@ -2235,7 +2409,7 @@ point to libpng-allocated storage with the following function:
png_free_data(png_ptr, info_ptr, mask, seq) png_free_data(png_ptr, info_ptr, mask, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the bitwise OR of one or
more of more of
PNG_FREE_PLTE, PNG_FREE_TRNS, PNG_FREE_PLTE, PNG_FREE_TRNS,
PNG_FREE_HIST, PNG_FREE_ICCP, PNG_FREE_HIST, PNG_FREE_ICCP,
@@ -2248,15 +2422,14 @@ point to libpng-allocated storage with the following function:
This function may be safely called when the relevant storage has This function may be safely called when the relevant storage has
already been freed, or has not yet been allocated, or was allocated already been freed, or has not yet been allocated, or was allocated
by the user and not by libpng, and will in those by the user and not by libpng, and will in those cases do nothing.
cases do nothing. The "seq" parameter is ignored if only one item The "seq" parameter is ignored if only one item of the selected data
of the selected data type, such as PLTE, is allowed. If "seq" is not type, such as PLTE, is allowed. If "seq" is not -1, and multiple items
-1, and multiple items are allowed for the data type identified in are allowed for the data type identified in the mask, such as text or
the mask, such as text or sPLT, only the n'th item in the structure sPLT, only the n'th item in the structure is freed, where n is "seq".
is freed, where n is "seq".
If you allocated data such as a palette that you passed If you allocated data such as a palette that you passed in to libpng
in to libpng with png_set_*, you must not free it until just before the call to with png_set_*, you must not free it until just before the call to
png_destroy_write_struct(). png_destroy_write_struct().
The default behavior is only to free data that was allocated internally The default behavior is only to free data that was allocated internally
@@ -2307,17 +2480,13 @@ For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng: V. Modifying/Customizing libpng:
There are three issues here. The first is changing how libpng does There are two issues here. The first is changing how libpng does
standard things like memory allocation, input/output, and error handling. standard things like memory allocation, input/output, and error handling.
The second deals with more complicated things like adding new chunks, The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works. adding new transformations, and generally changing how libpng works.
Both of those are compile-time issues; that is, they are generally Both of those are compile-time issues; that is, they are generally
determined at the time the code is written, and there is rarely a need determined at the time the code is written, and there is rarely a need
to provide the user with a means of changing them. The third is a to provide the user with a means of changing them.
run-time issue: choosing between and/or tuning one or more alternate
versions of computationally intensive routines; specifically, optimized
assembly-language (and therefore compiler- and platform-dependent)
versions.
Memory allocation, input/output, and error handling Memory allocation, input/output, and error handling
@@ -2326,16 +2495,18 @@ goes through callbacks that are user-settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
these functions, call the appropriate png_set_*_fn() function. these functions, call the appropriate png_set_*_fn() function.
Memory allocation is done through the functions png_malloc() Memory allocation is done through the functions png_malloc(), png_calloc(),
and png_free(). These currently just call the standard C functions. If and png_free(). These currently just call the standard C functions.
your pointers can't access more then 64K at a time, you will want to set png_calloc() calls png_malloc() and then png_memset() to clear the newly
MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling allocated memory to zero. If your pointers can't access more then 64K
memory allocation on a platform will change between applications, these at a time, you will want to set MAXSEG_64K in zlib.h. Since it is
functions must be modified in the library at compile time. If you prefer unlikely that the method of handling memory allocation on a platform
to use a different method of allocating and freeing data, you can use will change between applications, these functions must be modified in
png_create_read_struct_2() or png_create_write_struct_2() to register the library at compile time. If you prefer to use a different method
your own functions as described above. of allocating and freeing data, you can use png_create_read_struct_2() or
These functions also provide a void pointer that can be retrieved via png_create_write_struct_2() to register your own functions as described
above. These functions also provide a void pointer that can be retrieved
via
mem_ptr=png_get_mem_ptr(png_ptr); mem_ptr=png_get_mem_ptr(png_ptr);
@@ -2349,6 +2520,9 @@ Your malloc_fn() must return NULL in case of failure. The png_malloc()
function will normally call png_error() if it receives a NULL from the function will normally call png_error() if it receives a NULL from the
system memory allocator or from your replacement malloc_fn(). system memory allocator or from your replacement malloc_fn().
Your free_fn() will never be called with a NULL ptr, since libpng's
png_free() checks for NULL before calling free_fn().
Input/Output in libpng is done through png_read() and png_write(), Input/Output in libpng is done through png_read() and png_write(),
which currently just call fread() and fwrite(). The FILE * is stored in which currently just call fread() and fwrite(). The FILE * is stored in
png_struct and is initialized via png_init_io(). If you wish to change png_struct and is initialized via png_init_io(). If you wish to change
@@ -2376,9 +2550,15 @@ The replacement I/O functions must have prototypes as follows:
png_bytep data, png_size_t length); png_bytep data, png_size_t length);
void user_flush_data(png_structp png_ptr); void user_flush_data(png_structp png_ptr);
The user_read_data() function is responsible for detecting and
handling end-of-data errors.
Supplying NULL for the read, write, or flush functions sets them back Supplying NULL for the read, write, or flush functions sets them back
to using the default C stream functions. It is an error to read from to using the default C stream functions, which expect the io_ptr to
a write stream, and vice versa. point to a standard *FILE structure. It is probably a mistake
to use NULL for one of write_data_fn and output_flush_fn but not both
of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
It is an error to read from a write stream, and vice versa.
Error handling in libpng is done through png_error() and png_warning(). Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error() Errors handled through png_error() are fatal, meaning that png_error()
@@ -2418,30 +2598,29 @@ The motivation behind using setjmp() and longjmp() is the C++ throw and
catch exception handling methods. This makes the code much easier to write, catch exception handling methods. This makes the code much easier to write,
as there is no need to check every return code of every function call. as there is no need to check every return code of every function call.
However, there are some uncertainties about the status of local variables However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything after after a longjmp, so the user may want to be careful about doing anything
setjmp returns non-zero besides returning itself. Consult your compiler after setjmp returns non-zero besides returning itself. Consult your
documentation for more details. For an alternative approach, you may wish compiler documentation for more details. For an alternative approach, you
to use the "cexcept" facility (see http://cexcept.sourceforge.net). may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net).
Custom chunks Custom chunks
If you need to read or write custom chunks, you may need to get deeper If you need to read or write custom chunks, you may need to get deeper
into the libpng code. The library now has mechanisms for storing into the libpng code. The library now has mechanisms for storing
and writing chunks of unknown type; you can even declare callbacks and writing chunks of unknown type; you can even declare callbacks
for custom chunks. Hoewver, this may not be good enough if the for custom chunks. However, this may not be good enough if the
library code itself needs to know about interactions between your library code itself needs to know about interactions between your
chunk and existing `intrinsic' chunks. chunk and existing `intrinsic' chunks.
If you need to write a new intrinsic chunk, first read the PNG If you need to write a new intrinsic chunk, first read the PNG
specification. Acquire a first level of specification. Acquire a first level of understanding of how it works.
understanding of how it works. Pay particular attention to the Pay particular attention to the sections that describe chunk names,
sections that describe chunk names, and look at how other chunks were and look at how other chunks were designed, so you can do things
designed, so you can do things similarly. Second, check out the similarly. Second, check out the sections of libpng that read and
sections of libpng that read and write chunks. Try to find a chunk write chunks. Try to find a chunk that is similar to yours and use
that is similar to yours and use it as a template. More details can it as a template. More details can be found in the comments inside
be found in the comments inside the code. It is best to handle unknown the code. It is best to handle unknown chunks in a generic method,
chunks in a generic method, via callback functions, instead of by via callback functions, instead of by modifying libpng functions.
modifying libpng functions.
If you wish to write your own transformation for the data, look through If you wish to write your own transformation for the data, look through
the part of the code that does the transformations, and check out some of the part of the code that does the transformations, and check out some of
@@ -2483,11 +2662,12 @@ you may also have to change the memory allocators (png_malloc, etc.).
Configuring for compiler xxx: Configuring for compiler xxx:
All includes for libpng are in pngconf.h. If you need to add/change/delete All includes for libpng are in pngconf.h. If you need to add, change
an include, this is the place to do it. The includes that are not or delete an include, this is the place to do it.
needed outside libpng are protected by the PNG_INTERNAL definition, The includes that are not needed outside libpng are protected by the
which is only defined for those routines inside libpng itself. The PNG_INTERNAL definition, which is only defined for those routines inside
files in libpng proper only include png.h, which includes pngconf.h. libpng itself. The files in libpng proper only include png.h, which
includes pngconf.h.
Configuring zlib: Configuring zlib:
@@ -2556,7 +2736,7 @@ currently does not allocate the filter buffers until png_write_row()
is called for the first time.) is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB filters = PNG_FILTER_NONE | PNG_FILTER_SUB
PNG_FILTER_UP | PNG_FILTER_AVE | PNG_FILTER_UP | PNG_FILTER_AVG |
PNG_FILTER_PAETH | PNG_ALL_FILTERS; PNG_FILTER_PAETH | PNG_ALL_FILTERS;
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
@@ -2617,14 +2797,14 @@ off en masse with compiler directives that define
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
or all four, or all four,
along with directives to turn on any of the capabilities that you do along with directives to turn on any of the capabilities that you do
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
the extra transformations but still leave the library fully capable of reading transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks and writing PNG files with all known public chunks. Use of the
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
produces a library that is incapable of reading or writing ancillary chunks. that is incapable of reading or writing ancillary chunks. If you are
If you are not using the progressive reading capability, you can not using the progressive reading capability, you can turn that off
turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
this with the INTERLACING capability, which you'll still have). capability, which you'll still have).
All the reading and writing specific code are in separate files, so the All the reading and writing specific code are in separate files, so the
linker should only grab the files it needs. However, if you want to linker should only grab the files it needs. However, if you want to
@@ -2660,7 +2840,7 @@ the message, "message" is the formatted string to be printed,
and p1 and p2 are parameters that are to be embedded in the string and p1 and p2 are parameters that are to be embedded in the string
according to printf-style formatting directives. For example, according to printf-style formatting directives. For example,
png_debug1(2, "foo=%d\n", foo); png_debug1(2, "foo=%d", foo);
is expanded to is expanded to
@@ -2686,12 +2866,12 @@ Libpng can support some of these extensions. To enable them, use the
png_permit_mng_features() function: png_permit_mng_features() function:
feature_set = png_permit_mng_features(png_ptr, mask) feature_set = png_permit_mng_features(png_ptr, mask)
mask is a png_uint_32 containing the logical OR of the mask is a png_uint_32 containing the bitwise OR of the
features you want to enable. These include features you want to enable. These include
PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_EMPTY_PLTE
PNG_FLAG_MNG_FILTER_64 PNG_FLAG_MNG_FILTER_64
PNG_ALL_MNG_FEATURES PNG_ALL_MNG_FEATURES
feature_set is a png_uint_32 that is the logical AND of feature_set is a png_uint_32 that is the bitwise AND of
your mask with the set of MNG features that is your mask with the set of MNG features that is
supported by the version of libpng that you are using. supported by the version of libpng that you are using.
@@ -2738,6 +2918,9 @@ png_set_error_fn(), which is essentially the same function, but with a new
name to force compilation errors with applications that try to use the old name to force compilation errors with applications that try to use the old
method. method.
Support for the sCAL, iCCP, iTXt, and sPLT chunks was added at libpng-1.0.6;
however, iTXt support was not enabled by default.
Starting with version 1.0.7, you can find out which version of the library Starting with version 1.0.7, you can find out which version of the library
you are using at run-time: you are using at run-time:
@@ -2752,15 +2935,158 @@ application:
png_uint_32 application_vn = PNG_LIBPNG_VER; png_uint_32 application_vn = PNG_LIBPNG_VER;
VIII. Y2K Compliance in libpng VIII. (Omitted).
December 3, 2004
IX. (Omitted)
X. Detecting libpng
The png_get_io_ptr() function has been present since libpng-0.88, has never
changed, and is unaffected by conditional compilation macros. It is the
best choice for use in configure scripts for detecting the presence of any
libpng version since 0.88. In an autoconf "configure.in" you could use
AC_CHECK_LIB(png, png_get_io_ptr, ...
XI. Source code repository
Since about February 2009, version 1.2.34, libpng has been under "git" source
control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
git://git.code.sf.net/p/libpng/code
or you can browse it with a web browser by selecting the "code" button at
https://sourceforge.net/projects/libpng/
Patches can be sent to glennrp at users.sourceforge.net or to
png-mng-implement at lists.sourceforge.net or you can upload them to
the libpng bug tracker at
http://libpng.sourceforge.net
XII. Coding style
Our coding style is similar to the "Allman" style
(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
{
action;
}
else if (another condition)
{
another action;
}
The braces can be omitted from simple one-line actions:
if (condition)
return (0);
We use 3-space indentation, except for continued statements which
are usually indented the same as the first line of the statement
plus four more spaces.
For macro definitions we use 2-space indentation, always leaving the "#"
in the first column.
#ifndef PNG_NO_FEATURE
# ifndef PNG_FEATURE_SUPPORTED
# define PNG_FEATURE_SUPPORTED
# endif
#endif
Comments appear with the leading "/*" at the same indentation as
the statement that follows the comment:
/* Single-line comment */
statement;
/* Multiple-line
* comment
*/
statement;
Very short comments can be placed at the end of the statement
to which they pertain:
statement; /* comment */
We don't use C++ style ("//") comments. We have, however,
used them in the past in some now-abandoned MMX assembler
code.
Functions and their curly braces are not indented, and
exported functions are marked with PNGAPI:
/* This is a public function that is visible to
* application programers. It does thus-and-so.
*/
void PNGAPI
png_exported_function(png_ptr, png_info, foo)
{
body;
}
The prototypes for all exported functions appear in png.h,
above the comment that says
/* Maintainer: Put new public prototypes here ... */
We mark all non-exported functions with "/* PRIVATE */"":
void /* PRIVATE */
png_non_exported_function(png_ptr, png_info, foo)
{
body;
}
The prototypes for non-exported functions (except for those in
pngtest) appear in
the PNG_INTERNAL section of png.h
above the comment that says
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
The names of all exported functions and variables begin
with "png_", and all publicly visible C preprocessor
macros begin with "PNG".
We put a space after each comma and after each semicolon
in "for" statments, and we put spaces before and after each
C binary operator and after "for" or "while". We don't
put a space between a typecast and the expression being
cast, nor do we put one between a function name and the
left parenthesis that follows it:
for (i = 2; i > 0; --i)
y[i] = a(x) + (int)b;
We prefer #ifdef and #ifndef to #if defined() and if !defined()
when there is only one macro being tested.
We do not use the TAB character for indentation in the C sources.
Lines do not exceed 80 characters.
Other rules can be inferred by inspecting the libpng source.
XIII. Y2K Compliance in libpng
February 6, 2014
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.18 are Y2K compliant. It is my belief that earlier upward through 1.0.62 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that Libpng only has three year fields. One is a 2-byte unsigned integer that

1258
libpng.3

File diff suppressed because it is too large Load Diff

1084
libpngpf.3

File diff suppressed because it is too large Load Diff

9655
ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

215
missing Executable file
View File

@@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

162
mkinstalldirs Executable file
View File

@@ -0,0 +1,162 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2009-04-28.21; # UTC
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
IFS=" "" $nl"
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the 'mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because '.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp=$pathcomp/
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

8
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "December 3, 2004" .TH PNG 5 "February 6, 2014"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION
@@ -18,7 +18,7 @@ gamma and chromaticity data for improved color matching on heterogeneous
platforms. platforms.
.SH "SEE ALSO" .SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5) .IR libpng(3) ", " zlib(3) ", " deflate(5) ", and " zlib(5)
.LP .LP
PNG specification (second edition), November 2003: PNG specification (second edition), November 2003:
.IP .IP
@@ -35,7 +35,7 @@ PNG 1.0 specification, October 1996:
RFC 2083 RFC 2083
.IP .IP
.br .br
ftp://ds.internic.net/rfc/rfc2083.txt ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt
.br .br
or (as a W3C Recommendation) at or (as a W3C Recommendation) at
.br .br
@@ -58,7 +58,7 @@ Thomas Boutell and others (png-list).
.SH COPYRIGHT NOTICE .SH COPYRIGHT NOTICE
.LP .LP
This man page is Copyright (c) 1998-2004 Glenn Randers-Pehrson. See png.h This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
for conditions of use and distribution. for conditions of use and distribution.
.LP .LP
The PNG Specification (Second Edition) is The PNG Specification (Second Edition) is

970
png.c

File diff suppressed because it is too large Load Diff

1915
png.h

File diff suppressed because it is too large Load Diff

559
pngconf.h
View File

@@ -1,11 +1,14 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.0.18 - December 3, 2004 * libpng version 1.0.62 - February 6, 2014
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2013 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/ */
/* Any machine specific code is near the front of this file, so if you /* Any machine specific code is near the front of this file, so if you
@@ -24,6 +27,21 @@
* includes the resource compiler for Windows DLL configurations. * includes the resource compiler for Windows DLL configurations.
*/ */
/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
#ifdef PNG_CONFIGURE_LIBPNG
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#endif
#ifdef PNG_1_0_X
# ifndef PNG_iTXt_SUPPORTED
# ifndef PNG_NO_iTXt
# define PNG_NO_iTXt
# endif
# endif
#endif
/* /*
* Added at libpng-1.2.8 * Added at libpng-1.2.8
* *
@@ -52,8 +70,8 @@
#endif #endif
#ifdef PRIVATEBUILD #ifdef PRIVATEBUILD
# pragma message("PRIVATEBUILD is deprecated. Use\ # pragma message("PRIVATEBUILD is deprecated.\
PNG_USER_PRIVATEBUILD instead.") Use PNG_USER_PRIVATEBUILD instead.")
# define PNG_USER_PRIVATEBUILD PRIVATEBUILD # define PNG_USER_PRIVATEBUILD PRIVATEBUILD
#endif #endif
#endif /* __STDC__ */ #endif /* __STDC__ */
@@ -62,6 +80,26 @@
/* End of material added to libpng-1.2.8 */ /* End of material added to libpng-1.2.8 */
/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble
Restored at libpng-1.2.21 */
#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \
!defined(PNG_WARN_UNINITIALIZED_ROW)
# define PNG_WARN_UNINITIALIZED_ROW 1
#endif
/* End of material added at libpng-1.2.19/1.2.21 */
/* Added at libpng-1.2.51 (ported from 1.4.6) */
#ifndef PNG_UNUSED
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely). Note that if you replace
* it with something other than whitespace, you must include the terminating
* semicolon.
*/
# define PNG_UNUSED(param) (void)param;
#endif
/* End of material added to libpng-1.4.6 */
/* This is the size of the compression buffer, and thus the size of /* 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 * 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 * machine. One of these will be allocated per png_struct. When this
@@ -91,8 +129,33 @@
# define PNG_WRITE_SUPPORTED # define PNG_WRITE_SUPPORTED
#endif #endif
/* Enabled in 1.2.41. */
#ifdef PNG_ALLOW_BENIGN_ERRORS
# define png_benign_error png_warning
# define png_chunk_benign_error png_chunk_warning
#else
# ifndef PNG_BENIGN_ERRORS_SUPPORTED
# define png_benign_error png_error
# define png_chunk_benign_error png_chunk_error
# endif
#endif
/* Added in libpng-1.2.41 */
#if !defined(PNG_NO_WARNINGS) && !defined(PNG_WARNINGS_SUPPORTED)
# define PNG_WARNINGS_SUPPORTED
#endif
#if !defined(PNG_NO_ERROR_TEXT) && !defined(PNG_ERROR_TEXT_SUPPORTED)
# define PNG_ERROR_TEXT_SUPPORTED
#endif
#if !defined(PNG_NO_CHECK_cHRM) && !defined(PNG_CHECK_cHRM_SUPPORTED)
# define PNG_CHECK_cHRM_SUPPORTED
#endif
/* Enabled by default in 1.2.0. You can disable this if you don't need to /* 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 */ * support PNGs that are embedded in MNG datastreams
*/
#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) #if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES)
# ifndef PNG_MNG_FEATURES_SUPPORTED # ifndef PNG_MNG_FEATURES_SUPPORTED
# define PNG_MNG_FEATURES_SUPPORTED # define PNG_MNG_FEATURES_SUPPORTED
@@ -150,44 +213,44 @@
* PNG_BUILD_DLL and PNG_STATIC because those change some defaults * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
* such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
*/ */
#if defined(__CYGWIN__) #ifdef __CYGWIN__
# if defined(ALL_STATIC) # ifdef ALL_STATIC
# if defined(PNG_BUILD_DLL) # ifdef PNG_BUILD_DLL
# undef PNG_BUILD_DLL # undef PNG_BUILD_DLL
# endif # endif
# if defined(PNG_USE_DLL) # ifdef PNG_USE_DLL
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if defined(PNG_DLL) # ifdef PNG_DLL
# undef PNG_DLL # undef PNG_DLL
# endif # endif
# if !defined(PNG_STATIC) # ifndef PNG_STATIC
# define PNG_STATIC # define PNG_STATIC
# endif # endif
# else # else
# if defined (PNG_BUILD_DLL) # ifdef PNG_BUILD_DLL
# if defined(PNG_STATIC) # ifdef PNG_STATIC
# undef PNG_STATIC # undef PNG_STATIC
# endif # endif
# if defined(PNG_USE_DLL) # ifdef PNG_USE_DLL
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if !defined(PNG_DLL) # ifndef PNG_DLL
# define PNG_DLL # define PNG_DLL
# endif # endif
# else # else
# if defined(PNG_STATIC) # ifdef PNG_STATIC
# if defined(PNG_USE_DLL) # ifdef PNG_USE_DLL
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if defined(PNG_DLL) # ifdef PNG_DLL
# undef PNG_DLL # undef PNG_DLL
# endif # endif
# else # else
# if !defined(PNG_USE_DLL) # ifndef PNG_USE_DLL
# define PNG_USE_DLL # define PNG_USE_DLL
# endif # endif
# if !defined(PNG_DLL) # ifndef PNG_DLL
# define PNG_DLL # define PNG_DLL
# endif # endif
# endif # endif
@@ -208,10 +271,16 @@
* #define PNG_NO_STDIO * #define PNG_NO_STDIO
*/ */
#if defined(_WIN32_WCE) #if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
# define PNG_STDIO_SUPPORTED
#endif
#ifdef _WIN32_WCE
# include <windows.h> # include <windows.h>
/* Console I/O functions are not supported on WindowsCE */ /* Console I/O functions are not supported on WindowsCE */
# define PNG_NO_CONSOLE_IO # define PNG_NO_CONSOLE_IO
/* abort() may not be supported on some/all Windows CE platforms */
# define PNG_ABORT() exit(-1)
# ifdef PNG_DEBUG # ifdef PNG_DEBUG
# undef PNG_DEBUG # undef PNG_DEBUG
# endif # endif
@@ -235,12 +304,16 @@
# endif # endif
# endif # endif
# else # else
# if !defined(_WIN32_WCE) # ifndef _WIN32_WCE
/* "stdio.h" functions are not supported on WindowsCE */ /* "stdio.h" functions are not supported on WindowsCE */
# include <stdio.h> # include <stdio.h>
# endif # endif
# endif # 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 /* This macro protects us against machines that don't have function
* prototypes (ie K&R style headers). If your compiler does not handle * prototypes (ie K&R style headers). If your compiler does not handle
* function prototypes, define this macro and use the included ansi2knr. * function prototypes, define this macro and use the included ansi2knr.
@@ -263,6 +336,7 @@
# define PNGARG(arglist) arglist # define PNGARG(arglist) arglist
#endif /* _NO_PROTO */ #endif /* _NO_PROTO */
#endif /* OF */ #endif /* OF */
#endif /* PNGARG */ #endif /* PNGARG */
@@ -290,28 +364,38 @@
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* This is an attempt to force a single setjmp behaviour on Linux. If /* 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. * 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.
*/ */
# ifdef __linux__ # ifndef PNG_SKIP_SETJMP_CHECK
# ifdef _BSD_SOURCE # ifdef __linux__
# define PNG_SAVE_BSD_SOURCE # ifdef _BSD_SOURCE
# undef _BSD_SOURCE # define PNG_SAVE_BSD_SOURCE
# endif # undef _BSD_SOURCE
# ifdef _SETJMP_H # endif
/* If you encounter a compiler error here, see the explanation # ifdef _SETJMP_H
* near the end of INSTALL. /* If you encounter a compiler error here, see the explanation
*/ * near the end of INSTALL.
__png.h__ already includes setjmp.h; */
__dont__ include it again.; __pngconf.h__ in libpng already includes setjmp.h;
# endif __dont__ include it again.;
# endif /* __linux__ */ # endif
# endif /* __linux__ */
# endif /* PNG_SKIP_SETJMP_CHECK */
/* include setjmp.h for error handling */ /* include setjmp.h for error handling */
# include <setjmp.h> # include <setjmp.h>
# ifdef __linux__ # ifdef __linux__
# ifdef PNG_SAVE_BSD_SOURCE # ifdef PNG_SAVE_BSD_SOURCE
# define _BSD_SOURCE # ifndef _BSD_SOURCE
# define _BSD_SOURCE
# endif
# undef PNG_SAVE_BSD_SOURCE # undef PNG_SAVE_BSD_SOURCE
# endif # endif
# endif /* __linux__ */ # endif /* __linux__ */
@@ -341,8 +425,8 @@
* them inside an appropriate ifdef/endif pair for portability. * them inside an appropriate ifdef/endif pair for portability.
*/ */
#if defined(PNG_FLOATING_POINT_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED
# if defined(MACOS) # ifdef MACOS
/* We need to check that <math.h> hasn't already been included earlier /* We need to check that <math.h> hasn't already been included earlier
* as it seems it doesn't agree with <fp.h>, yet we should really use * as it seems it doesn't agree with <fp.h>, yet we should really use
* <fp.h> if possible. * <fp.h> if possible.
@@ -450,21 +534,33 @@
*/ */
/* The size of the png_text structure changed in libpng-1.0.6 when /* The size of the png_text structure changed in libpng-1.0.6 when
* iTXt is supported. It is turned off by default, to support old apps * iTXt support was added. iTXt support was turned off by default through
* that malloc the png_text structure instead of calling png_set_text() * libpng-1.2.x, to support old apps that malloc the png_text structure
* and letting libpng malloc it. It will be turned on by default in * instead of calling png_set_text() and letting libpng malloc it. It
* libpng-1.3.0. * will be turned on by default in libpng-1.4.0.
*/ */
#ifndef PNG_iTXt_SUPPORTED #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) # ifndef PNG_NO_iTXt_SUPPORTED
# define PNG_NO_iTXt_SUPPORTED
# endif
# ifndef PNG_NO_READ_iTXt
# define PNG_NO_READ_iTXt # define PNG_NO_READ_iTXt
# endif # endif
# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) # ifndef PNG_NO_WRITE_iTXt
# define PNG_NO_WRITE_iTXt # define PNG_NO_WRITE_iTXt
# endif # endif
#endif #endif
#if !defined(PNG_NO_iTXt_SUPPORTED)
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
# define PNG_READ_iTXt
# endif
# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
# define PNG_WRITE_iTXt
# endif
#endif
/* The following support, added after version 1.0.0, can be turned off here en /* The following support, added after version 1.0.0, can be turned off here en
* masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
* with old applications that require the length of png_struct and png_info * with old applications that require the length of png_struct and png_info
@@ -475,6 +571,7 @@
# define PNG_NO_FREE_ME # define PNG_NO_FREE_ME
# define PNG_NO_READ_UNKNOWN_CHUNKS # define PNG_NO_READ_UNKNOWN_CHUNKS
# define PNG_NO_WRITE_UNKNOWN_CHUNKS # define PNG_NO_WRITE_UNKNOWN_CHUNKS
# define PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_NO_READ_USER_CHUNKS # define PNG_NO_READ_USER_CHUNKS
# define PNG_NO_READ_iCCP # define PNG_NO_READ_iCCP
# define PNG_NO_WRITE_iCCP # define PNG_NO_WRITE_iCCP
@@ -504,7 +601,7 @@
# define PNG_FREE_ME_SUPPORTED # define PNG_FREE_ME_SUPPORTED
#endif #endif
#if defined(PNG_READ_SUPPORTED) #ifdef PNG_READ_SUPPORTED
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_TRANSFORMS) !defined(PNG_NO_READ_TRANSFORMS)
@@ -568,29 +665,40 @@
# endif # endif
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ #endif /* PNG_READ_TRANSFORMS_SUPPORTED */
/* PNG_PROGRESSIVE_READ_NOT_SUPPORTED is deprecated. */
#if !defined(PNG_NO_PROGRESSIVE_READ) && \ #if !defined(PNG_NO_PROGRESSIVE_READ) && \
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ # define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
#endif /* about interlacing capability! You'll */ #endif /* about interlacing capability! You'll */
/* still have interlacing unless you change the following line: */ /* still have interlacing unless you change the following define: */
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ #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
#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */
#ifndef PNG_NO_READ_COMPOSITE_NODIV #ifndef PNG_NO_READ_COMPOSITE_NODIV
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ # ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ # define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
# endif # endif
#endif #endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Deprecated, will be removed from version 2.0.0. /* Deprecated, will be removed from version 2.0.0.
Use PNG_MNG_FEATURES_SUPPORTED instead. */ Use PNG_MNG_FEATURES_SUPPORTED instead. */
#ifndef PNG_NO_READ_EMPTY_PLTE #ifndef PNG_NO_READ_EMPTY_PLTE
# define PNG_READ_EMPTY_PLTE_SUPPORTED # define PNG_READ_EMPTY_PLTE_SUPPORTED
#endif #endif
#endif
#endif /* PNG_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */
#if defined(PNG_WRITE_SUPPORTED) #ifdef PNG_WRITE_SUPPORTED
# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ # if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_TRANSFORMS) !defined(PNG_NO_WRITE_TRANSFORMS)
@@ -622,19 +730,25 @@
# ifndef PNG_NO_WRITE_SWAP_ALPHA # ifndef PNG_NO_WRITE_SWAP_ALPHA
# define PNG_WRITE_SWAP_ALPHA_SUPPORTED # define PNG_WRITE_SWAP_ALPHA_SUPPORTED
# endif # endif
#ifndef PNG_1_0_X
# ifndef PNG_NO_WRITE_INVERT_ALPHA # ifndef PNG_NO_WRITE_INVERT_ALPHA
# define PNG_WRITE_INVERT_ALPHA_SUPPORTED # define PNG_WRITE_INVERT_ALPHA_SUPPORTED
# endif # endif
#endif
# ifndef PNG_NO_WRITE_USER_TRANSFORM # ifndef PNG_NO_WRITE_USER_TRANSFORM
# define PNG_WRITE_USER_TRANSFORM_SUPPORTED # define PNG_WRITE_USER_TRANSFORM_SUPPORTED
# endif # endif
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ #endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
!defined(PNG_WRITE_INTERLACING_SUPPORTED)
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant #define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
encoders, but can cause trouble encoders, but can cause trouble
if left undefined */ if left undefined */
#endif
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ #if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
!defined(PNG_WRITE_WEIGHTED_FILTER) && \
defined(PNG_FLOATING_POINT_SUPPORTED) defined(PNG_FLOATING_POINT_SUPPORTED)
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED # define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif #endif
@@ -643,10 +757,12 @@
# define PNG_WRITE_FLUSH_SUPPORTED # define PNG_WRITE_FLUSH_SUPPORTED
#endif #endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ /* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
#ifndef PNG_NO_WRITE_EMPTY_PLTE #ifndef PNG_NO_WRITE_EMPTY_PLTE
# define PNG_WRITE_EMPTY_PLTE_SUPPORTED # define PNG_WRITE_EMPTY_PLTE_SUPPORTED
#endif #endif
#endif
#endif /* PNG_WRITE_SUPPORTED */ #endif /* PNG_WRITE_SUPPORTED */
@@ -688,37 +804,70 @@
#endif #endif
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ * and removed from version 1.2.20. The following will be removed
* from libpng-1.4.0
*/
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE)
# ifndef PNG_OPTIMIZED_CODE_SUPPORTED
# define PNG_OPTIMIZED_CODE_SUPPORTED
# endif
#endif
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED # ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNG_ASSEMBLER_CODE_SUPPORTED # define PNG_ASSEMBLER_CODE_SUPPORTED
# endif # endif
# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4)
/* work around 64-bit gcc compiler bugs in gcc-3.x */
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# ifdef __APPLE__
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh))
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_NO_MMX_CODE
# endif
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) # if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_MMX_CODE_SUPPORTED # define PNG_MMX_CODE_SUPPORTED
# endif # endif
#endif #endif
/* end of obsolete code to be removed from libpng-1.4.0 */
/* If you are sure that you don't need thread safety and you are compiling /* Added at libpng-1.2.0 */
with PNG_USE_PNGCCRD for an MMX application, you can define this for #ifndef PNG_1_0_X
faster execution. See pnggccrd.c.
#define PNG_THREAD_UNSAFE_OK
*/
#if !defined(PNG_1_0_X)
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) #if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
# define PNG_USER_MEM_SUPPORTED # define PNG_USER_MEM_SUPPORTED
#endif #endif
#endif /* PNG_1_0_X */ #endif /* PNG_1_0_X */
/* Added at libpng-1.2.6 */ /* Added at libpng-1.2.6 */
#if !defined(PNG_1_0_X) #ifndef PNG_1_0_X
#ifndef PNG_SET_USER_LIMITS_SUPPORTED # ifndef PNG_SET_USER_LIMITS_SUPPORTED
#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) # ifndef PNG_NO_SET_USER_LIMITS
# define PNG_SET_USER_LIMITS_SUPPORTED # define PNG_SET_USER_LIMITS_SUPPORTED
#endif # endif
#endif # endif
#endif /* PNG_1_0_X */ #endif /* PNG_1_0_X */
/* Added at libpng-1.0.53 and 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 /* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter
* how large, set these limits to 0x7fffffffL * how large, set these limits to 0x7fffffffL
*/ */
@@ -729,6 +878,33 @@
# define PNG_USER_HEIGHT_MAX 1000000L # define PNG_USER_HEIGHT_MAX 1000000L
#endif #endif
/* Added at libpng-1.2.43. To accept all valid PNGs no matter
* how large, set these two limits to 0.
*/
#ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 32765
#endif
/* Added at libpng-1.2.43 */
#ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 0
#endif
#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
/* Added at libpng-1.2.34 */
#ifndef PNG_STRING_NEWLINE
#define PNG_STRING_NEWLINE "\n"
#endif
/* These are currently experimental features, define them if you want */ /* These are currently experimental features, define them if you want */
/* very little testing */ /* very little testing */
@@ -753,6 +929,11 @@
#define PNG_NO_POINTER_INDEXING #define PNG_NO_POINTER_INDEXING
*/ */
#if !defined(PNG_NO_POINTER_INDEXING) && \
!defined(PNG_POINTER_INDEXING_SUPPORTED)
# define PNG_POINTER_INDEXING_SUPPORTED
#endif
/* These functions are turned off by default, as they will be phased out. */ /* These functions are turned off by default, as they will be phased out. */
/* /*
#define PNG_USELESS_TESTS_SUPPORTED #define PNG_USELESS_TESTS_SUPPORTED
@@ -856,14 +1037,22 @@
# define PNG_READ_zTXt_SUPPORTED # define PNG_READ_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED
#endif #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_NO_READ_UNKNOWN_CHUNKS
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED # define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif # endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif #endif
#if !defined(PNG_NO_READ_USER_CHUNKS) && \ #if !defined(PNG_NO_READ_USER_CHUNKS) && \
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@@ -876,17 +1065,14 @@
# undef PNG_NO_HANDLE_AS_UNKNOWN # undef PNG_NO_HANDLE_AS_UNKNOWN
# endif # endif
#endif #endif
#ifndef PNG_NO_READ_OPT_PLTE
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ #ifndef PNG_NO_HANDLE_AS_UNKNOWN
#endif /* optional PLTE chunk in RGB and RGBA images */ # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
defined(PNG_READ_zTXt_SUPPORTED) # endif
# define PNG_READ_TEXT_SUPPORTED
# define PNG_TEXT_SUPPORTED
#endif #endif
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ #ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#ifdef PNG_NO_WRITE_TEXT #ifdef PNG_NO_WRITE_TEXT
@@ -998,17 +1184,6 @@
# define PNG_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED
# endif # endif
#endif #endif
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
# endif
#endif
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ #if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_WRITE_zTXt_SUPPORTED) defined(PNG_WRITE_zTXt_SUPPORTED)
# define PNG_WRITE_TEXT_SUPPORTED # define PNG_WRITE_TEXT_SUPPORTED
@@ -1017,8 +1192,37 @@
# endif # endif
#endif #endif
#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
# endif
# endif
# endif
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ #endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
#if !defined(PNG_NO_WRITE_FILTER) && !defined(PNG_WRITE_FILTER_SUPPORTED)
# define PNG_WRITE_FILTER_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
#endif
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#endif /* PNG_WRITE_SUPPORTED */
/* Turn this off to disable png_read_png() and /* Turn this off to disable png_read_png() and
* png_write_png() and leave the row_pointers member * png_write_png() and leave the row_pointers member
* out of the info structure. * out of the info structure.
@@ -1027,12 +1231,10 @@
# define PNG_INFO_IMAGE_SUPPORTED # define PNG_INFO_IMAGE_SUPPORTED
#endif #endif
/* need the time information for reading tIME chunks */ /* Need the time information for converting tIME chunks */
#if defined(PNG_tIME_SUPPORTED) #ifdef PNG_CONVERT_tIME_SUPPORTED
# if !defined(_WIN32_WCE)
/* "time.h" functions are not supported on WindowsCE */ /* "time.h" functions are not supported on WindowsCE */
# include <time.h> # include <time.h>
# endif
#endif #endif
/* Some typedefs to get us started. These should be safe on most of the /* Some typedefs to get us started. These should be safe on most of the
@@ -1054,10 +1256,10 @@ typedef unsigned char png_byte;
change (I'm not sure if you will or not, so I thought I'd be safe) */ change (I'm not sure if you will or not, so I thought I'd be safe) */
#ifdef PNG_SIZE_T #ifdef PNG_SIZE_T
typedef PNG_SIZE_T png_size_t; typedef PNG_SIZE_T png_size_t;
# define png_sizeof(x) png_convert_size(sizeof (x)) # define png_sizeof(x) png_convert_size(sizeof(x))
#else #else
typedef size_t png_size_t; typedef size_t png_size_t;
# define png_sizeof(x) sizeof (x) # define png_sizeof(x) sizeof(x)
#endif #endif
/* The following is needed for medium model support. It cannot be in the /* The following is needed for medium model support. It cannot be in the
@@ -1101,8 +1303,8 @@ typedef unsigned char png_byte;
*/ */
/* MSC Medium model */ /* MSC Medium model */
#if defined(FAR) #ifdef FAR
# if defined(M_I86MM) # ifdef M_I86MM
# define USE_FAR_KEYWORD # define USE_FAR_KEYWORD
# define FARDATA FAR # define FARDATA FAR
# include <dos.h> # include <dos.h>
@@ -1135,7 +1337,7 @@ typedef char FAR * png_charp;
typedef png_fixed_point FAR * png_fixed_point_p; typedef png_fixed_point FAR * png_fixed_point_p;
#ifndef PNG_NO_STDIO #ifndef PNG_NO_STDIO
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
typedef HANDLE png_FILE_p; typedef HANDLE png_FILE_p;
#else #else
typedef FILE * png_FILE_p; typedef FILE * png_FILE_p;
@@ -1164,7 +1366,7 @@ typedef char FAR * FAR * FAR * png_charppp;
#if defined(PNG_1_0_X) || defined(PNG_1_2_X) #if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* SPC - Is this stuff deprecated? */ /* SPC - Is this stuff deprecated? */
/* It'll be removed as of libpng-1.3.0 - GR-P */ /* It'll be removed as of libpng-1.4.0 - GR-P */
/* libpng typedefs for types in zlib. If zlib changes /* libpng typedefs for types in zlib. If zlib changes
* or another compression library is used, then change these. * or another compression library is used, then change these.
* Eliminates need to change all the source files. * Eliminates need to change all the source files.
@@ -1199,17 +1401,17 @@ typedef z_stream FAR * png_zstreamp;
* When building a static lib, default to no GLOBAL ARRAYS, but allow * When building a static lib, default to no GLOBAL ARRAYS, but allow
* command-line override * command-line override
*/ */
#if defined(__CYGWIN__) #ifdef __CYGWIN__
# if !defined(PNG_STATIC) # ifndef PNG_STATIC
# if defined(PNG_USE_GLOBAL_ARRAYS) # ifdef PNG_USE_GLOBAL_ARRAYS
# undef PNG_USE_GLOBAL_ARRAYS # undef PNG_USE_GLOBAL_ARRAYS
# endif # endif
# if !defined(PNG_USE_LOCAL_ARRAYS) # ifndef PNG_USE_LOCAL_ARRAYS
# define PNG_USE_LOCAL_ARRAYS # define PNG_USE_LOCAL_ARRAYS
# endif # endif
# else # else
# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) # if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
# if defined(PNG_USE_GLOBAL_ARRAYS) # ifdef PNG_USE_GLOBAL_ARRAYS
# undef PNG_USE_GLOBAL_ARRAYS # undef PNG_USE_GLOBAL_ARRAYS
# endif # endif
# endif # endif
@@ -1224,14 +1426,15 @@ typedef z_stream FAR * png_zstreamp;
* but might be required for some pre-1.0.5c applications. * but might be required for some pre-1.0.5c applications.
*/ */
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) #if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) # if defined(PNG_NO_GLOBAL_ARRAYS) || \
(defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER)
# define PNG_USE_LOCAL_ARRAYS # define PNG_USE_LOCAL_ARRAYS
# else # else
# define PNG_USE_GLOBAL_ARRAYS # define PNG_USE_GLOBAL_ARRAYS
# endif # endif
#endif #endif
#if defined(__CYGWIN__) #ifdef __CYGWIN__
# undef PNGAPI # undef PNGAPI
# define PNGAPI __cdecl # define PNGAPI __cdecl
# undef PNG_IMPEXP # undef PNG_IMPEXP
@@ -1272,7 +1475,7 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_IMPEXP # define PNG_IMPEXP
# endif # endif
# if !defined(PNG_IMPEXP) # ifndef PNG_IMPEXP
# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol # define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol # define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
@@ -1283,7 +1486,7 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_EXPORT PNG_EXPORT_TYPE1 # define PNG_EXPORT PNG_EXPORT_TYPE1
# else # else
# define PNG_EXPORT PNG_EXPORT_TYPE2 # define PNG_EXPORT PNG_EXPORT_TYPE2
# if defined(PNG_BUILD_DLL) # ifdef PNG_BUILD_DLL
# define PNG_IMPEXP __export # define PNG_IMPEXP __export
# else # else
# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in # define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
@@ -1293,8 +1496,8 @@ typedef z_stream FAR * png_zstreamp;
# endif # endif
# endif # endif
# if !defined(PNG_IMPEXP) # ifndef PNG_IMPEXP
# if defined(PNG_BUILD_DLL) # ifdef PNG_BUILD_DLL
# define PNG_IMPEXP __declspec(dllexport) # define PNG_IMPEXP __declspec(dllexport)
# else # else
# define PNG_IMPEXP __declspec(dllimport) # define PNG_IMPEXP __declspec(dllimport)
@@ -1340,6 +1543,70 @@ typedef z_stream FAR * png_zstreamp;
# endif # endif
#endif #endif
#ifdef PNG_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
/* User may want to use these so they are not in PNG_INTERNAL. Any library /* User may want to use these so they are not in PNG_INTERNAL. Any library
* functions that are passed far data must be model independent. * functions that are passed far data must be model independent.
*/ */
@@ -1355,23 +1622,42 @@ typedef z_stream FAR * png_zstreamp;
(LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
#endif #endif
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ #ifdef USE_FAR_KEYWORD /* memory model independent fns */
/* use this to make far-to-near assignments */ /* Use this to make far-to-near assignments */
# define CHECK 1 # define CHECK 1
# define NOCHECK 0 # define NOCHECK 0
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) # 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 CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
# define png_strcpy _fstrcpy # define png_snprintf _fsnprintf /* Added to v 1.2.19 */
# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
# define png_strlen _fstrlen # define png_strlen _fstrlen
# define png_memcmp _fmemcmp /* SJT: added */ # define png_memcmp _fmemcmp /* SJT: added */
# define png_memcpy _fmemcpy # define png_memcpy _fmemcpy
# define png_memset _fmemset # define png_memset _fmemset
#else /* use the usual functions */ #else /* Use the usual functions */
# define CVT_PTR(ptr) (ptr) # define CVT_PTR(ptr) (ptr)
# define CVT_PTR_NOCHECK(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr)
# define png_strcpy strcpy # ifndef PNG_NO_SNPRINTF
# define png_strncpy strncpy /* Added to v 1.2.6 */ # 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
# define png_strlen strlen # define png_strlen strlen
# define png_memcmp memcmp /* SJT: added */ # define png_memcmp memcmp /* SJT: added */
# define png_memcpy memcpy # define png_memcpy memcpy
@@ -1387,47 +1673,6 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_ZBUF_SIZE 65536L # define PNG_ZBUF_SIZE 65536L
#endif #endif
#ifdef PNG_READ_SUPPORTED
/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
#if defined(PNG_INTERNAL)
/* These are the default thresholds before the MMX code kicks in; if either
* rowbytes or bitdepth is below the threshold, plain C code is used. These
* can be overridden at runtime via the png_set_mmx_thresholds() call in
* libpng 1.2.0 and later. The values below were chosen by Intel.
*/
#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
#endif
#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
#endif
/* Set this in the makefile for VC++ on Pentium, not here. */
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
* MMX will be detected at run time and used if present.
*/
#ifdef PNG_USE_PNGVCRD
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
/* Set this in the makefile for gcc/as on Pentium, not here. */
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
* MMX will be detected at run time and used if present.
*/
#ifdef PNG_USE_PNGGCCRD
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
/* - see pnggccrd.c for info about what is currently enabled */
#endif /* PNG_INTERNAL */
#endif /* PNG_READ_SUPPORTED */
/* Added at libpng-1.2.8 */ /* Added at libpng-1.2.8 */
#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNG_VERSION_INFO_ONLY */

View File

@@ -1,12 +1,15 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* libpng version 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.51 [February 6, 2014]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* This file provides a location for all error handling. Users who * This file provides a location for all error handling. Users who
* need special error handling are expected to write replacement functions * need special error handling are expected to write replacement functions
* and use png_set_error_fn() to use those functions. See the instructions * and use png_set_error_fn() to use those functions. See the instructions
@@ -14,52 +17,62 @@
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
static void /* PRIVATE */ static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr, png_default_error PNGARG((png_structp png_ptr,
png_const_charp error_message)); png_const_charp error_message)) PNG_NORETURN;
#ifdef PNG_WARNINGS_SUPPORTED
static void /* PRIVATE */ static void /* PRIVATE */
png_default_warning PNGARG((png_structp png_ptr, png_default_warning PNGARG((png_structp png_ptr,
png_const_charp warning_message)); png_const_charp warning_message));
#endif /* PNG_WARNINGS_SUPPORTED */
/* This function is called whenever there is a fatal error. This function /* This function is called whenever there is a fatal error. This function
* should not be changed. If there is a need to handle errors differently, * should not be changed. If there is a need to handle errors differently,
* you should supply a replacement error function and use png_set_error_fn() * you should supply a replacement error function and use png_set_error_fn()
* to replace the error function at run-time. * to replace the error function at run-time.
*/ */
#ifdef PNG_ERROR_TEXT_SUPPORTED
void PNGAPI void PNGAPI
png_error(png_structp png_ptr, png_const_charp error_message) png_error(png_structp png_ptr, png_const_charp error_message)
{ {
#ifdef PNG_ERROR_NUMBERS_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED
char msg[16]; char msg[16];
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) if (png_ptr != NULL)
{ {
if (*error_message == '#') if (png_ptr->flags&
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
{ {
int offset; if (*error_message == PNG_LITERAL_SHARP)
for (offset=1; offset<15; offset++) {
if (*(error_message+offset) == ' ') /* Strip "#nnnn " from beginning of error message. */
break; int offset;
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) for (offset = 1; offset<15; offset++)
{ if (error_message[offset] == ' ')
int i; break;
for (i=0; i<offset-1; i++) if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
msg[i]=error_message[i+1]; {
msg[i]='\0'; int i;
error_message=msg; for (i = 0; i < offset - 1; i++)
} msg[i] = error_message[i + 1];
else msg[i - 1] = '\0';
error_message+=offset; error_message = msg;
} }
else else
{ error_message += offset;
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) }
{ else
msg[0]='0'; {
msg[1]='\0'; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
error_message=msg; {
} msg[0] = '0';
msg[1] = '\0';
error_message = msg;
}
}
} }
} }
#endif #endif
@@ -70,7 +83,25 @@ png_error(png_structp png_ptr, png_const_charp error_message)
use the default handler, which will not return. */ use the default handler, which will not return. */
png_default_error(png_ptr, error_message); png_default_error(png_ptr, error_message);
} }
#else
void PNGAPI
png_err(png_structp png_ptr)
{
/* Prior to 1.2.45 the error_fn received a NULL pointer, expressed
* erroneously as '\0', instead of the empty string "". This was
* apparently an error, introduced in libpng-1.2.20, and png_default_error
* will crash in this case.
*/
if (png_ptr != NULL && png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_ptr, "");
/* If the custom handler doesn't exist, or if it returns,
use the default handler, which will not return. */
png_default_error(png_ptr, "");
}
#endif /* PNG_ERROR_TEXT_SUPPORTED */
#ifdef PNG_WARNINGS_SUPPORTED
/* This function is called whenever there is a non-fatal error. This function /* This function is called whenever there is a non-fatal error. This function
* should not be changed. If there is a need to handle warnings differently, * should not be changed. If there is a need to handle warnings differently,
* you should supply a replacement warning function and use * you should supply a replacement warning function and use
@@ -80,22 +111,38 @@ void PNGAPI
png_warning(png_structp png_ptr, png_const_charp warning_message) png_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
int offset = 0; int offset = 0;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED if (png_ptr != NULL)
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
#endif
{ {
if (*warning_message == '#') #ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (png_ptr->flags&
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
#endif
{ {
for (offset=1; offset<15; offset++) if (*warning_message == PNG_LITERAL_SHARP)
if (*(warning_message+offset) == ' ') {
break; for (offset = 1; offset < 15; offset++)
if (warning_message[offset] == ' ')
break;
}
} }
} }
if (png_ptr != NULL && png_ptr->warning_fn != NULL) if (png_ptr != NULL && png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_ptr, warning_message+offset); (*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
else else
png_default_warning(png_ptr, warning_message+offset); png_default_warning(png_ptr, warning_message + offset);
} }
#endif /* PNG_WARNINGS_SUPPORTED */
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
void PNGAPI
png_benign_error(png_structp png_ptr, png_const_charp error_message)
{
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
png_warning(png_ptr, error_message);
else
png_error(png_ptr, error_message);
}
#endif
/* These utilities are used internally to build an error message that relates /* These utilities are used internally to build an error message that relates
* to the current chunk. The chunk name comes from png_ptr->chunk_name, * to the current chunk. The chunk name comes from png_ptr->chunk_name,
@@ -109,6 +156,8 @@ static PNG_CONST char png_digit[16] = {
'A', 'B', 'C', 'D', 'E', 'F' 'A', 'B', 'C', 'D', 'E', 'F'
}; };
#define PNG_MAX_ERROR_TEXT 64
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
static void /* PRIVATE */ static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
error_message) error_message)
@@ -120,10 +169,10 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
int c = png_ptr->chunk_name[iin++]; int c = png_ptr->chunk_name[iin++];
if (isnonalpha(c)) if (isnonalpha(c))
{ {
buffer[iout++] = '['; buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
buffer[iout++] = png_digit[(c & 0xf0) >> 4]; buffer[iout++] = png_digit[(c & 0xf0) >> 4];
buffer[iout++] = png_digit[c & 0x0f]; buffer[iout++] = png_digit[c & 0x0f];
buffer[iout++] = ']'; buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;
} }
else else
{ {
@@ -132,31 +181,64 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
} }
if (error_message == NULL) if (error_message == NULL)
buffer[iout] = 0; buffer[iout] = '\0';
else else
{ {
buffer[iout++] = ':'; buffer[iout++] = ':';
buffer[iout++] = ' '; buffer[iout++] = ' ';
png_strncpy(buffer+iout, error_message, 63);
buffer[iout+63] = 0; iin = 0;
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
buffer[iout++] = error_message[iin++];
/* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
buffer[iout] = '\0';
} }
} }
#ifdef PNG_READ_SUPPORTED
void PNGAPI void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp error_message) png_chunk_error(png_structp png_ptr, png_const_charp error_message)
{ {
char msg[18+64]; char msg[18+PNG_MAX_ERROR_TEXT];
png_format_buffer(png_ptr, msg, error_message); if (png_ptr == NULL)
png_error(png_ptr, msg); png_error(png_ptr, error_message);
else
{
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 */
#ifdef PNG_WARNINGS_SUPPORTED
void PNGAPI void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
char msg[18+64]; char msg[18+PNG_MAX_ERROR_TEXT];
png_format_buffer(png_ptr, msg, warning_message); if (png_ptr == NULL)
png_warning(png_ptr, msg); png_warning(png_ptr, warning_message);
else
{
png_format_buffer(png_ptr, msg, warning_message);
png_warning(png_ptr, msg);
}
} }
#endif /* PNG_WARNINGS_SUPPORTED */
#ifdef PNG_READ_SUPPORTED
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
void PNGAPI
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
{
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
png_chunk_warning(png_ptr, error_message);
else
png_chunk_error(png_ptr, error_message);
}
#endif
#endif /* PNG_READ_SUPPORTED */
/* This is the default error handling function. Note that replacements for /* This is the default error handling function. Note that replacements for
* this function MUST NOT RETURN, or the program will likely crash. This * this function MUST NOT RETURN, or the program will likely crash. This
@@ -166,54 +248,63 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
static void /* PRIVATE */ static void /* PRIVATE */
png_default_error(png_structp png_ptr, png_const_charp error_message) png_default_error(png_structp png_ptr, png_const_charp error_message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifdef PNG_CONSOLE_IO_SUPPORTED
#ifdef PNG_ERROR_NUMBERS_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*error_message == '#') if (*error_message == PNG_LITERAL_SHARP)
{ {
/* Strip "#nnnn " from beginning of error message. */
int offset; int offset;
char error_number[16]; char error_number[16];
for (offset=0; offset<15; offset++) for (offset = 0; offset<15; offset++)
{ {
error_number[offset] = *(error_message+offset+1); error_number[offset] = error_message[offset + 1];
if (*(error_message+offset) == ' ') if (error_message[offset] == ' ')
break; break;
} }
if((offset > 1) && (offset < 15)) if ((offset > 1) && (offset < 15))
{ {
error_number[offset-1]='\0'; error_number[offset - 1] = '\0';
fprintf(stderr, "libpng error no. %s: %s\n", error_number, fprintf(stderr, "libpng error no. %s: %s",
error_message+offset); error_number, error_message + offset + 1);
fprintf(stderr, "\n");
} }
else else
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); {
fprintf(stderr, "libpng error: %s, offset=%d",
error_message, offset);
fprintf(stderr, "\n");
}
} }
else else
#endif #endif
fprintf(stderr, "libpng error: %s\n", error_message); {
fprintf(stderr, "libpng error: %s", error_message);
fprintf(stderr, "\n");
}
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
if (png_ptr)
{
# ifdef USE_FAR_KEYWORD # ifdef USE_FAR_KEYWORD
{ {
jmp_buf jmpbuf; jmp_buf jmpbuf;
png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf)); png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
longjmp(jmpbuf, 1); longjmp(jmpbuf,1);
} }
# else # else
longjmp(png_ptr->jmpbuf, 1); longjmp(png_ptr->jmpbuf, 1);
# endif # endif
#else }
/* make compiler happy */ ;
if (png_ptr)
PNG_ABORT();
#endif #endif
#ifdef PNG_NO_CONSOLE_IO /* Here if not setjmp support or if png_ptr is null. */
/* make compiler happy */ ; PNG_ABORT();
if (&error_message != NULL) #ifndef PNG_CONSOLE_IO_SUPPORTED
return; PNG_UNUSED(error_message) /* Make compiler happy */
#endif #endif
} }
#ifdef PNG_WARNINGS_SUPPORTED
/* This function is called when there is a warning, but the library thinks /* This function is called when there is a warning, but the library thinks
* it can continue anyway. Replacement functions don't have to do anything * it can continue anyway. Replacement functions don't have to do anything
* here if you don't want them to. In the default configuration, png_ptr is * here if you don't want them to. In the default configuration, png_ptr is
@@ -222,39 +313,44 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
static void /* PRIVATE */ static void /* PRIVATE */
png_default_warning(png_structp png_ptr, png_const_charp warning_message) png_default_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifdef PNG_CONSOLE_IO_SUPPORTED
# ifdef PNG_ERROR_NUMBERS_SUPPORTED # ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*warning_message == '#') if (*warning_message == PNG_LITERAL_SHARP)
{ {
int offset; int offset;
char warning_number[16]; char warning_number[16];
for (offset=0; offset<15; offset++) for (offset = 0; offset < 15; offset++)
{ {
warning_number[offset]=*(warning_message+offset+1); warning_number[offset] = warning_message[offset + 1];
if (*(warning_message+offset) == ' ') if (warning_message[offset] == ' ')
break; break;
} }
if((offset > 1) && (offset < 15)) if ((offset > 1) && (offset < 15))
{ {
warning_number[offset-1]='\0'; warning_number[offset + 1] = '\0';
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, fprintf(stderr, "libpng warning no. %s: %s",
warning_message+offset); warning_number, warning_message + offset);
fprintf(stderr, "\n");
} }
else else
fprintf(stderr, "libpng warning: %s\n", warning_message); {
fprintf(stderr, "libpng warning: %s",
warning_message);
fprintf(stderr, "\n");
}
} }
else else
# endif # endif
fprintf(stderr, "libpng warning: %s\n", warning_message); {
fprintf(stderr, "libpng warning: %s", warning_message);
fprintf(stderr, "\n");
}
#else #else
/* make compiler happy */ ; PNG_UNUSED(warning_message) /* Make compiler happy */
if (warning_message)
return;
#endif #endif
/* make compiler happy */ ; PNG_UNUSED(png_ptr) /* Make compiler happy */
if (png_ptr)
return;
} }
#endif /* PNG_WARNINGS_SUPPORTED */
/* This function is called when the application wants to use another method /* This function is called when the application wants to use another method
* of handling errors and warnings. Note that the error function MUST NOT * of handling errors and warnings. Note that the error function MUST NOT
@@ -265,6 +361,8 @@ void PNGAPI
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warning_fn) png_error_ptr error_fn, png_error_ptr warning_fn)
{ {
if (png_ptr == NULL)
return;
png_ptr->error_ptr = error_ptr; png_ptr->error_ptr = error_ptr;
png_ptr->error_fn = error_fn; png_ptr->error_fn = error_fn;
png_ptr->warning_fn = warning_fn; png_ptr->warning_fn = warning_fn;
@@ -278,6 +376,8 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
png_voidp PNGAPI png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr) png_get_error_ptr(png_structp png_ptr)
{ {
if (png_ptr == NULL)
return NULL;
return ((png_voidp)png_ptr->error_ptr); return ((png_voidp)png_ptr->error_ptr);
} }
@@ -286,10 +386,11 @@ png_get_error_ptr(png_structp png_ptr)
void PNGAPI void PNGAPI
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
{ {
if(png_ptr != NULL) if (png_ptr != NULL)
{ {
png_ptr->flags &= 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
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

5414
pnggccrd.c

File diff suppressed because it is too large Load Diff

412
pngget.c
View File

@@ -1,21 +1,28 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* libpng 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.51 [February 6, 2014]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->valid & flag); return(info_ptr->valid & flag);
else else
return(0); return(0);
} }
@@ -25,30 +32,31 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes); return(info_ptr->rowbytes);
else else
return(0); return(0);
} }
#if defined(PNG_INFO_IMAGE_SUPPORTED) #ifdef PNG_INFO_IMAGE_SUPPORTED
png_bytepp PNGAPI png_bytepp PNGAPI
png_get_rows(png_structp png_ptr, png_infop info_ptr) png_get_rows(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers); return(info_ptr->row_pointers);
else else
return(0); return(0);
} }
#endif #endif
#ifdef PNG_EASY_ACCESS_SUPPORTED #ifdef PNG_EASY_ACCESS_SUPPORTED
/* easy access to info, added in libpng-0.99 */ /* Easy access to info, added in libpng-0.99 */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_image_width(png_structp png_ptr, png_infop info_ptr) png_get_image_width(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->width; return info_ptr->width;
}
return (0); return (0);
} }
@@ -56,9 +64,8 @@ png_uint_32 PNGAPI
png_get_image_height(png_structp png_ptr, png_infop info_ptr) png_get_image_height(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->height; return info_ptr->height;
}
return (0); return (0);
} }
@@ -66,9 +73,8 @@ png_byte PNGAPI
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->bit_depth; return info_ptr->bit_depth;
}
return (0); return (0);
} }
@@ -76,9 +82,8 @@ png_byte PNGAPI
png_get_color_type(png_structp png_ptr, png_infop info_ptr) png_get_color_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->color_type; return info_ptr->color_type;
}
return (0); return (0);
} }
@@ -86,9 +91,8 @@ png_byte PNGAPI
png_get_filter_type(png_structp png_ptr, png_infop info_ptr) png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->filter_type; return info_ptr->filter_type;
}
return (0); return (0);
} }
@@ -96,9 +100,8 @@ png_byte PNGAPI
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->interlace_type; return info_ptr->interlace_type;
}
return (0); return (0);
} }
@@ -106,9 +109,8 @@ png_byte PNGAPI
png_get_compression_type(png_structp png_ptr, png_infop info_ptr) png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{
return info_ptr->compression_type; return info_ptr->compression_type;
}
return (0); return (0);
} }
@@ -116,13 +118,16 @@ png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
if (info_ptr->valid & PNG_INFO_pHYs) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0); return (0);
else return (info_ptr->x_pixels_per_unit);
else
return (info_ptr->x_pixels_per_unit);
} }
#else #else
return (0); return (0);
@@ -134,13 +139,16 @@ png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
if (info_ptr->valid & PNG_INFO_pHYs) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0); return (0);
else return (info_ptr->y_pixels_per_unit);
else
return (info_ptr->y_pixels_per_unit);
} }
#else #else
return (0); return (0);
@@ -152,14 +160,17 @@ png_uint_32 PNGAPI
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
if (info_ptr->valid & PNG_INFO_pHYs) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
return (0); return (0);
else return (info_ptr->x_pixels_per_unit);
else
return (info_ptr->x_pixels_per_unit);
} }
#else #else
return (0); return (0);
@@ -172,18 +183,21 @@ float PNGAPI
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
if (info_ptr->valid & PNG_INFO_pHYs) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0) if (info_ptr->x_pixels_per_unit == 0)
return ((float)0.0); return ((float)0.0);
else else
return ((float)((float)info_ptr->y_pixels_per_unit return ((float)((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit)); /(float)info_ptr->x_pixels_per_unit));
} }
#else #else
return (0.0); return (0.0);
#endif #endif
return ((float)0.0); return ((float)0.0);
} }
@@ -193,16 +207,20 @@ png_int_32 PNGAPI
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED) #ifdef PNG_oFFs_SUPPORTED
if (info_ptr->valid & PNG_INFO_oFFs) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0); return (0);
else return (info_ptr->x_offset);
else
return (info_ptr->x_offset);
} }
#else #else
return (0); return (0);
#endif #endif
return (0); return (0);
} }
@@ -211,13 +229,17 @@ png_int_32 PNGAPI
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED)
#ifdef PNG_oFFs_SUPPORTED
if (info_ptr->valid & PNG_INFO_oFFs) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0); return (0);
else return (info_ptr->y_offset);
else
return (info_ptr->y_offset);
} }
#else #else
return (0); return (0);
@@ -229,13 +251,17 @@ png_int_32 PNGAPI
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED)
#ifdef PNG_oFFs_SUPPORTED
if (info_ptr->valid & PNG_INFO_oFFs) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0); return (0);
else return (info_ptr->x_offset);
else
return (info_ptr->x_offset);
} }
#else #else
return (0); return (0);
@@ -247,13 +273,17 @@ png_int_32 PNGAPI
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED)
#ifdef PNG_oFFs_SUPPORTED
if (info_ptr->valid & PNG_INFO_oFFs) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0); return (0);
else return (info_ptr->y_offset);
else
return (info_ptr->y_offset);
} }
#else #else
return (0); return (0);
@@ -297,7 +327,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
*.00003937); *.00003937);
} }
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, 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) png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
@@ -306,7 +336,8 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{ {
png_debug1(1, "in %s retrieval function\n", "pHYs"); png_debug1(1, "in %s retrieval function", "pHYs");
if (res_x != NULL) if (res_x != NULL)
{ {
*res_x = info_ptr->x_pixels_per_unit; *res_x = info_ptr->x_pixels_per_unit;
@@ -321,7 +352,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
{ {
*unit_type = (int)info_ptr->phys_unit_type; *unit_type = (int)info_ptr->phys_unit_type;
retval |= PNG_INFO_pHYs; retval |= PNG_INFO_pHYs;
if(*unit_type == 1) if (*unit_type == 1)
{ {
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
@@ -355,7 +386,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
return (NULL); return (NULL);
} }
#if defined(PNG_bKGD_SUPPORTED) #ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_color_16p *background) png_color_16p *background)
@@ -363,7 +394,8 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
&& background != NULL) && background != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "bKGD"); png_debug1(1, "in %s retrieval function", "bKGD");
*background = &(info_ptr->background); *background = &(info_ptr->background);
return (PNG_INFO_bKGD); return (PNG_INFO_bKGD);
} }
@@ -371,7 +403,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_cHRM_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_cHRM(png_structp png_ptr, png_infop info_ptr, png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
@@ -380,7 +412,8 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
{ {
png_debug1(1, "in %s retrieval function\n", "cHRM"); png_debug1(1, "in %s retrieval function", "cHRM");
if (white_x != NULL) if (white_x != NULL)
*white_x = (double)info_ptr->x_white; *white_x = (double)info_ptr->x_white;
if (white_y != NULL) if (white_y != NULL)
@@ -409,9 +442,10 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, 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) png_fixed_point *blue_x, png_fixed_point *blue_y)
{ {
png_debug1(1, "in %s retrieval function", "cHRM");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
{ {
png_debug1(1, "in %s retrieval function\n", "cHRM");
if (white_x != NULL) if (white_x != NULL)
*white_x = info_ptr->int_x_white; *white_x = info_ptr->int_x_white;
if (white_y != NULL) if (white_y != NULL)
@@ -435,15 +469,16 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_gAMA_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
{ {
png_debug1(1, "in %s retrieval function", "gAMA");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& file_gamma != NULL) && file_gamma != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "gAMA");
*file_gamma = (double)info_ptr->gamma; *file_gamma = (double)info_ptr->gamma;
return (PNG_INFO_gAMA); return (PNG_INFO_gAMA);
} }
@@ -455,10 +490,11 @@ png_uint_32 PNGAPI
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point *int_file_gamma) 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) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& int_file_gamma != NULL) && int_file_gamma != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "gAMA");
*int_file_gamma = info_ptr->int_gamma; *int_file_gamma = info_ptr->int_gamma;
return (PNG_INFO_gAMA); return (PNG_INFO_gAMA);
} }
@@ -467,14 +503,15 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_sRGB_SUPPORTED) #ifdef PNG_sRGB_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
{ {
png_debug1(1, "in %s retrieval function", "sRGB");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
&& file_srgb_intent != NULL) && file_srgb_intent != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "sRGB");
*file_srgb_intent = (int)info_ptr->srgb_intent; *file_srgb_intent = (int)info_ptr->srgb_intent;
return (PNG_INFO_sRGB); return (PNG_INFO_sRGB);
} }
@@ -482,20 +519,22 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
} }
#endif #endif
#if defined(PNG_iCCP_SUPPORTED) #ifdef PNG_iCCP_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charpp name, int *compression_type, png_charpp name, int *compression_type,
png_charpp profile, png_uint_32 *proflen) png_charpp 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) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
&& name != NULL && profile != NULL && proflen != NULL) && name != NULL && profile != NULL && proflen != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "iCCP");
*name = info_ptr->iccp_name; *name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile; *profile = info_ptr->iccp_profile;
/* compression_type is a dummy so the API won't have to change /* Compression_type is a dummy so the API won't have to change
if we introduce multiple compression types later. */ * if we introduce multiple compression types later.
*/
*proflen = (int)info_ptr->iccp_proflen; *proflen = (int)info_ptr->iccp_proflen;
*compression_type = (int)info_ptr->iccp_compression; *compression_type = (int)info_ptr->iccp_compression;
return (PNG_INFO_iCCP); return (PNG_INFO_iCCP);
@@ -504,25 +543,29 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_sPLT_SUPPORTED) #ifdef PNG_sPLT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sPLT(png_structp png_ptr, png_infop info_ptr, png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_sPLT_tpp spalettes) png_sPLT_tpp spalettes)
{ {
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{
*spalettes = info_ptr->splt_palettes; *spalettes = info_ptr->splt_palettes;
return ((png_uint_32)info_ptr->splt_palettes_num); return ((png_uint_32)info_ptr->splt_palettes_num);
}
return (0);
} }
#endif #endif
#if defined(PNG_hIST_SUPPORTED) #ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
{ {
png_debug1(1, "in %s retrieval function", "hIST");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
&& hist != NULL) && hist != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "hIST");
*hist = info_ptr->hist; *hist = info_ptr->hist;
return (PNG_INFO_hIST); return (PNG_INFO_hIST);
} }
@@ -537,54 +580,48 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
int *filter_type) int *filter_type)
{ {
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && png_debug1(1, "in %s retrieval function", "IHDR");
bit_depth != NULL && color_type != NULL)
{
png_debug1(1, "in %s retrieval function\n", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
*bit_depth = info_ptr->bit_depth;
if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
png_error(png_ptr, "Invalid bit depth");
*color_type = info_ptr->color_type;
if (info_ptr->color_type > 6)
png_error(png_ptr, "Invalid color type");
if (compression_type != NULL)
*compression_type = info_ptr->compression_type;
if (filter_type != NULL)
*filter_type = info_ptr->filter_type;
if (interlace_type != NULL)
*interlace_type = info_ptr->interlace_type;
/* check for potential overflow of rowbytes */ if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
if (*width == 0 || *width > PNG_UINT_31_MAX) height == NULL || bit_depth == NULL || color_type == NULL)
png_error(png_ptr, "Invalid image width"); return (0);
if (*height == 0 || *height > PNG_UINT_31_MAX)
png_error(png_ptr, "Invalid image height"); *width = info_ptr->width;
if (info_ptr->width > (PNG_UINT_32_MAX *height = info_ptr->height;
>> 3) /* 8-byte RGBA pixels */ *bit_depth = info_ptr->bit_depth;
- 64 /* bigrowbuf hack */ *color_type = info_ptr->color_type;
- 1 /* filter byte */
- 7*8 /* rounding of width to multiple of 8 pixels */ if (compression_type != NULL)
- 8) /* extra max_pixel_depth pad */ *compression_type = info_ptr->compression_type;
{
png_warning(png_ptr, if (filter_type != NULL)
"Width too large for libpng to process image data."); *filter_type = info_ptr->filter_type;
}
return (1); if (interlace_type != NULL)
} *interlace_type = info_ptr->interlace_type;
return (0);
/* This is redundant if we can be sure that the info_ptr values were all
* assigned in png_set_IHDR(). We do the check anyhow in case an
* application has ignored our advice not to mess with the members
* of info_ptr directly.
*/
png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
info_ptr->compression_type, info_ptr->filter_type);
return (1);
} }
#if defined(PNG_oFFs_SUPPORTED) #ifdef PNG_oFFs_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{ {
png_debug1(1, "in %s retrieval function", "oFFs");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
&& offset_x != NULL && offset_y != NULL && unit_type != NULL) && offset_x != NULL && offset_y != NULL && unit_type != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "oFFs");
*offset_x = info_ptr->x_offset; *offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset; *offset_y = info_ptr->y_offset;
*unit_type = (int)info_ptr->offset_unit_type; *unit_type = (int)info_ptr->offset_unit_type;
@@ -594,17 +631,18 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_pCAL_SUPPORTED) #ifdef PNG_pCAL_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_pCAL(png_structp png_ptr, png_infop info_ptr, 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 *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params) png_charp *units, png_charpp *params)
{ {
png_debug1(1, "in %s retrieval function", "pCAL");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
nparams != NULL && units != NULL && params != NULL) nparams != NULL && units != NULL && params != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "pCAL");
*purpose = info_ptr->pcal_purpose; *purpose = info_ptr->pcal_purpose;
*X0 = info_ptr->pcal_X0; *X0 = info_ptr->pcal_X0;
*X1 = info_ptr->pcal_X1; *X1 = info_ptr->pcal_X1;
@@ -618,14 +656,14 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_sCAL_SUPPORTED) #ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sCAL(png_structp png_ptr, png_infop info_ptr, png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
int *unit, double *width, double *height) int *unit, double *width, double *height)
{ {
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL)) (info_ptr->valid & PNG_INFO_sCAL))
{ {
*unit = info_ptr->scal_unit; *unit = info_ptr->scal_unit;
*width = info_ptr->scal_pixel_width; *width = info_ptr->scal_pixel_width;
@@ -641,7 +679,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
int *unit, png_charpp width, png_charpp height) int *unit, png_charpp width, png_charpp height)
{ {
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL)) (info_ptr->valid & PNG_INFO_sCAL))
{ {
*unit = info_ptr->scal_unit; *unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width; *width = info_ptr->scal_s_width;
@@ -654,27 +692,30 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_pHYs_SUPPORTED) #ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{ {
png_uint_32 retval = 0; png_uint_32 retval = 0;
png_debug1(1, "in %s retrieval function", "pHYs");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs)) (info_ptr->valid & PNG_INFO_pHYs))
{ {
png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL) if (res_x != NULL)
{ {
*res_x = info_ptr->x_pixels_per_unit; *res_x = info_ptr->x_pixels_per_unit;
retval |= PNG_INFO_pHYs; retval |= PNG_INFO_pHYs;
} }
if (res_y != NULL) if (res_y != NULL)
{ {
*res_y = info_ptr->y_pixels_per_unit; *res_y = info_ptr->y_pixels_per_unit;
retval |= PNG_INFO_pHYs; retval |= PNG_INFO_pHYs;
} }
if (unit_type != NULL) if (unit_type != NULL)
{ {
*unit_type = (int)info_ptr->phys_unit_type; *unit_type = (int)info_ptr->phys_unit_type;
@@ -689,26 +730,28 @@ png_uint_32 PNGAPI
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
int *num_palette) int *num_palette)
{ {
png_debug1(1, "in %s retrieval function", "PLTE");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
&& palette != NULL) && palette != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "PLTE");
*palette = info_ptr->palette; *palette = info_ptr->palette;
*num_palette = info_ptr->num_palette; *num_palette = info_ptr->num_palette;
png_debug1(3, "num_palette = %d\n", *num_palette); png_debug1(3, "num_palette = %d", *num_palette);
return (PNG_INFO_PLTE); return (PNG_INFO_PLTE);
} }
return (0); return (0);
} }
#if defined(PNG_sBIT_SUPPORTED) #ifdef PNG_sBIT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
{ {
png_debug1(1, "in %s retrieval function", "sBIT");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
&& sig_bit != NULL) && sig_bit != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "sBIT");
*sig_bit = &(info_ptr->sig_bit); *sig_bit = &(info_ptr->sig_bit);
return (PNG_INFO_sBIT); return (PNG_INFO_sBIT);
} }
@@ -716,20 +759,23 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
} }
#endif #endif
#if defined(PNG_TEXT_SUPPORTED) #ifdef PNG_TEXT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text) int *num_text)
{ {
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{ {
png_debug1(1, "in %s retrieval function\n", png_debug1(1, "in %s retrieval function",
(png_ptr->chunk_name[0] == '\0' ? "text" (png_ptr->chunk_name[0] == '\0' ? "text"
: (png_const_charp)png_ptr->chunk_name)); : (png_const_charp)png_ptr->chunk_name));
if (text_ptr != NULL) if (text_ptr != NULL)
*text_ptr = info_ptr->text; *text_ptr = info_ptr->text;
if (num_text != NULL) if (num_text != NULL)
*num_text = info_ptr->num_text; *num_text = info_ptr->num_text;
return ((png_uint_32)info_ptr->num_text); return ((png_uint_32)info_ptr->num_text);
} }
if (num_text != NULL) if (num_text != NULL)
@@ -738,14 +784,15 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
} }
#endif #endif
#if defined(PNG_tIME_SUPPORTED) #ifdef PNG_tIME_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
{ {
png_debug1(1, "in %s retrieval function", "tIME");
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
&& mod_time != NULL) && mod_time != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "tIME");
*mod_time = &(info_ptr->mod_time); *mod_time = &(info_ptr->mod_time);
return (PNG_INFO_tIME); return (PNG_INFO_tIME);
} }
@@ -753,7 +800,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
} }
#endif #endif
#if defined(PNG_tRNS_SUPPORTED) #ifdef PNG_tRNS_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep *trans, int *num_trans, png_color_16p *trans_values) png_bytep *trans, int *num_trans, png_color_16p *trans_values)
@@ -761,7 +808,8 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_uint_32 retval = 0; png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
{ {
png_debug1(1, "in %s retrieval function\n", "tRNS"); png_debug1(1, "in %s retrieval function", "tRNS");
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if (trans != NULL) if (trans != NULL)
@@ -769,6 +817,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
*trans = info_ptr->trans; *trans = info_ptr->trans;
retval |= PNG_INFO_tRNS; retval |= PNG_INFO_tRNS;
} }
if (trans_values != NULL) if (trans_values != NULL)
*trans_values = &(info_ptr->trans_values); *trans_values = &(info_ptr->trans_values);
} }
@@ -779,10 +828,11 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
*trans_values = &(info_ptr->trans_values); *trans_values = &(info_ptr->trans_values);
retval |= PNG_INFO_tRNS; retval |= PNG_INFO_tRNS;
} }
if(trans != NULL)
if (trans != NULL)
*trans = NULL; *trans = NULL;
} }
if(num_trans != NULL) if (num_trans != NULL)
{ {
*num_trans = info_ptr->num_trans; *num_trans = info_ptr->num_trans;
retval |= PNG_INFO_tRNS; retval |= PNG_INFO_tRNS;
@@ -792,18 +842,21 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_unknown_chunkpp unknowns) png_unknown_chunkpp unknowns)
{ {
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
{
*unknowns = info_ptr->unknown_chunks; *unknowns = info_ptr->unknown_chunks;
return ((png_uint_32)info_ptr->unknown_chunks_num); return ((png_uint_32)info_ptr->unknown_chunks_num);
}
return (0);
} }
#endif #endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI png_byte PNGAPI
png_get_rgb_to_gray_status (png_structp png_ptr) png_get_rgb_to_gray_status (png_structp png_ptr)
{ {
@@ -811,7 +864,7 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
} }
#endif #endif
#if defined(PNG_USER_CHUNKS_SUPPORTED) #ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp PNGAPI png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr) png_get_user_chunk_ptr(png_structp png_ptr)
{ {
@@ -819,106 +872,63 @@ png_get_user_chunk_ptr(png_structp png_ptr)
} }
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_compression_buffer_size(png_structp png_ptr) png_get_compression_buffer_size(png_structp png_ptr)
{ {
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
} }
#endif
#ifndef PNG_1_0_X
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* this function was added to libpng 1.2.0 and should exist by default */ #ifndef PNG_1_0_X
/* This function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_asm_flags (png_structp png_ptr) png_get_asm_flags (png_structp png_ptr)
{ {
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L);
} }
/* this function was added to libpng 1.2.0 and should exist by default */ /* This function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_asm_flagmask (int flag_select) png_get_asm_flagmask (int flag_select)
{ {
png_uint_32 settable_asm_flags = 0; /* Obsolete, to be removed from libpng-1.4.0 */
PNG_UNUSED(flag_select)
if (flag_select & PNG_SELECT_READ) return 0L;
settable_asm_flags |=
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
/* no non-MMX flags yet */
#if 0
/* GRR: no write-flags yet, either, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_asm_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
return settable_asm_flags; /* _theoretically_ settable capabilities only */
} }
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */ /* This function was added to libpng 1.2.0 */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_mmx_flagmask (int flag_select, int *compilerID) png_get_mmx_flagmask (int flag_select, int *compilerID)
{ {
png_uint_32 settable_mmx_flags = 0; /* Obsolete, to be removed from libpng-1.4.0 */
PNG_UNUSED(flag_select)
if (flag_select & PNG_SELECT_READ) *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
settable_mmx_flags |= return 0L;
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
#if 0
/* GRR: no MMX write support yet, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_mmx_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
if (compilerID != NULL) {
#ifdef PNG_USE_PNGVCRD
*compilerID = 1; /* MSVC */
#else
#ifdef PNG_USE_PNGGCCRD
*compilerID = 2; /* gcc/gas */
#else
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
#endif
#endif
}
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
} }
/* this function was added to libpng 1.2.0 */ /* This function was added to libpng 1.2.0 */
png_byte PNGAPI png_byte PNGAPI
png_get_mmx_bitdepth_threshold (png_structp png_ptr) png_get_mmx_bitdepth_threshold (png_structp png_ptr)
{ {
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0: 0);
} }
/* this function was added to libpng 1.2.0 */ /* This function was added to libpng 1.2.0 */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_mmx_rowbytes_threshold (png_structp png_ptr) png_get_mmx_rowbytes_threshold (png_structp png_ptr)
{ {
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); /* Obsolete, to be removed from libpng-1.4.0 */
return (png_ptr? 0L: 0L);
} }
#endif /* ?PNG_1_0_X */
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED #ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* these functions were added to libpng 1.2.6 */ /* These functions were added to libpng 1.2.6 but not enabled
* by default. They will be enabled in libpng-1.4.0 */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_user_width_max (png_structp png_ptr) png_get_user_width_max (png_structp png_ptr)
{ {
@@ -931,4 +941,4 @@ png_get_user_height_max (png_structp png_ptr)
} }
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
#endif /* ?PNG_1_0_X */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

158
pngmem.c
View File

@@ -1,12 +1,15 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* libpng version 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.41 [February 25, 2010]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* This file provides a location for all memory allocation. Users who * This file provides a location for all memory allocation. Users who
* need special memory handling are expected to supply replacement * need special memory handling are expected to supply replacement
* functions for png_malloc() and png_free(), and to use * functions for png_malloc() and png_free(), and to use
@@ -15,11 +18,13 @@
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Borland DOS special memory handler */ /* Borland DOS special memory handler */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* if you change this, be sure to change the one in png.h also */ /* 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 /* 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. */ by a single call to calloc() if this is thought to improve performance. */
@@ -39,14 +44,14 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
png_voidp struct_ptr; png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO) if (type == PNG_STRUCT_INFO)
size = png_sizeof(png_info); size = png_sizeof(png_info);
else if (type == PNG_STRUCT_PNG) else if (type == PNG_STRUCT_PNG)
size = png_sizeof(png_struct); size = png_sizeof(png_struct);
else else
return (png_get_copyright(NULL)); return (png_get_copyright(NULL));
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if (malloc_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
@@ -55,7 +60,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
} }
else else
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
struct_ptr = (png_voidp)farmalloc(size); struct_ptr = (png_voidp)farmalloc(size);
if (struct_ptr != NULL) if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
return (struct_ptr); return (struct_ptr);
@@ -78,7 +83,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
if (struct_ptr != NULL) if (struct_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(free_fn != NULL) if (free_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
@@ -110,6 +115,16 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
* result, we would be truncating potentially larger memory requests * result, we would be truncating potentially larger memory requests
* (which should cause a fatal error) and introducing major problems. * (which should cause a fatal error) and introducing major problems.
*/ */
png_voidp /* PRIVATE */
png_calloc(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
ret = (png_malloc(png_ptr, size));
if (ret != NULL)
png_memset(ret,0,(png_size_t)size);
return (ret);
}
png_voidp PNGAPI png_voidp PNGAPI
png_malloc(png_structp png_ptr, png_uint_32 size) png_malloc(png_structp png_ptr, png_uint_32 size)
@@ -120,10 +135,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
return (NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL) if (png_ptr->malloc_fn != NULL)
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
else else
ret = (png_malloc_default(png_ptr, size)); ret = (png_malloc_default(png_ptr, size));
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of memory!"); png_error(png_ptr, "Out of memory!");
return (ret); return (ret);
@@ -135,6 +150,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
png_voidp ret; png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr == NULL || size == 0)
return (NULL);
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
{ {
@@ -145,12 +163,12 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
#endif #endif
if (size != (size_t)size) if (size != (size_t)size)
ret = NULL; ret = NULL;
else if (size == (png_uint_32)65536L) else if (size == (png_uint_32)65536L)
{ {
if (png_ptr->offset_table == NULL) if (png_ptr->offset_table == NULL)
{ {
/* try to see if we need to do any of this fancy stuff */ /* Try to see if we need to do any of this fancy stuff */
ret = farmalloc(size); ret = farmalloc(size);
if (ret == NULL || ((png_size_t)ret & 0xffff)) if (ret == NULL || ((png_size_t)ret & 0xffff))
{ {
@@ -166,7 +184,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
ret = NULL; ret = NULL;
} }
if(png_ptr->zlib_window_bits > 14) if (png_ptr->zlib_window_bits > 14)
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
else else
num_blocks = 1; num_blocks = 1;
@@ -183,7 +201,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ png_error(png_ptr, "Out Of Memory."); /* Note "O", "M" */
else else
png_warning(png_ptr, "Out Of Memory."); png_warning(png_ptr, "Out Of Memory.");
#endif #endif
@@ -205,13 +223,13 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
png_ptr->offset_table = table; png_ptr->offset_table = table;
png_ptr->offset_table_ptr = farmalloc(num_blocks * png_ptr->offset_table_ptr = farmalloc(num_blocks *
png_sizeof (png_bytep)); png_sizeof(png_bytep));
if (png_ptr->offset_table_ptr == NULL) if (png_ptr->offset_table_ptr == NULL)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ png_error(png_ptr, "Out Of memory."); /* Note "O", "m" */
else else
png_warning(png_ptr, "Out Of memory."); png_warning(png_ptr, "Out Of memory.");
#endif #endif
@@ -265,9 +283,10 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
return (ret); return (ret);
} }
/* free a pointer allocated by png_malloc(). In the default /* Free a pointer allocated by png_malloc(). In the default
configuration, png_ptr is not used, but is passed in case it * configuration, png_ptr is not used, but is passed in case it
is needed. If ptr is NULL, return without taking any action. */ * is needed. If ptr is NULL, return without taking any action.
*/
void PNGAPI void PNGAPI
png_free(png_structp png_ptr, png_voidp ptr) png_free(png_structp png_ptr, png_voidp ptr)
{ {
@@ -280,7 +299,8 @@ png_free(png_structp png_ptr, png_voidp ptr)
(*(png_ptr->free_fn))(png_ptr, ptr); (*(png_ptr->free_fn))(png_ptr, ptr);
return; return;
} }
else png_free_default(png_ptr, ptr); else
png_free_default(png_ptr, ptr);
} }
void PNGAPI void PNGAPI
@@ -288,6 +308,9 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr == NULL || ptr == NULL)
return;
if (png_ptr->offset_table != NULL) if (png_ptr->offset_table != NULL)
{ {
int i; int i;
@@ -346,7 +369,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
return (NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if (malloc_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
@@ -362,7 +385,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
struct_ptr = (png_voidp)farmalloc(size); struct_ptr = (png_voidp)farmalloc(size);
#else #else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
struct_ptr = (png_voidp)halloc(size,1); struct_ptr = (png_voidp)halloc(size, 1);
# else # else
struct_ptr = (png_voidp)malloc(size); struct_ptr = (png_voidp)malloc(size);
# endif # endif
@@ -391,7 +414,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
if (struct_ptr != NULL) if (struct_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(free_fn != NULL) if (free_fn != NULL)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
@@ -413,10 +436,22 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
} }
/* Allocate memory. For reasonable files, size should never exceed /* Allocate memory. For reasonable files, size should never exceed
64K. However, zlib may allocate more then 64K if you don't tell * 64K. However, zlib may allocate more then 64K if you don't tell
it not to. See zconf.h and png.h for more information. zlib does * it not to. See zconf.h and png.h for more information. zlib does
need to allocate exactly 64K, so whatever you call here must * need to allocate exactly 64K, so whatever you call here must
have the ability to do that. */ * have the ability to do that.
*/
png_voidp /* PRIVATE */
png_calloc(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
ret = (png_malloc(png_ptr, size));
if (ret != NULL)
png_memset(ret,0,(png_size_t)size);
return (ret);
}
png_voidp PNGAPI png_voidp PNGAPI
png_malloc(png_structp png_ptr, png_uint_32 size) png_malloc(png_structp png_ptr, png_uint_32 size)
@@ -427,10 +462,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return (NULL); return (NULL);
if(png_ptr->malloc_fn != NULL) if (png_ptr->malloc_fn != NULL)
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
else else
ret = (png_malloc_default(png_ptr, size)); ret = (png_malloc_default(png_ptr, size));
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of Memory!"); png_error(png_ptr, "Out of Memory!");
return (ret); return (ret);
@@ -449,7 +484,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Cannot Allocate > 64K"); png_error(png_ptr, "Cannot Allocate > 64K");
else else
#endif #endif
@@ -457,23 +492,23 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
} }
#endif #endif
/* Check for overflow */ /* Check for overflow */
#if defined(__TURBOC__) && !defined(__FLAT__) #if defined(__TURBOC__) && !defined(__FLAT__)
if (size != (unsigned long)size) if (size != (unsigned long)size)
ret = NULL; ret = NULL;
else else
ret = farmalloc(size); ret = farmalloc(size);
#else #else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
if (size != (unsigned long)size) if (size != (unsigned long)size)
ret = NULL; ret = NULL;
else else
ret = halloc(size, 1); ret = halloc(size, 1);
# else # else
if (size != (size_t)size) if (size != (size_t)size)
ret = NULL; ret = NULL;
else else
ret = malloc((size_t)size); ret = malloc((size_t)size);
# endif # endif
#endif #endif
@@ -486,7 +521,8 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
} }
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return /* Free a pointer allocated by png_malloc(). If ptr is NULL, return
without taking any action. */ * without taking any action.
*/
void PNGAPI void PNGAPI
png_free(png_structp png_ptr, png_voidp ptr) png_free(png_structp png_ptr, png_voidp ptr)
{ {
@@ -499,7 +535,8 @@ png_free(png_structp png_ptr, png_voidp ptr)
(*(png_ptr->free_fn))(png_ptr, ptr); (*(png_ptr->free_fn))(png_ptr, ptr);
return; return;
} }
else png_free_default(png_ptr, ptr); else
png_free_default(png_ptr, ptr);
} }
void PNGAPI void PNGAPI
png_free_default(png_structp png_ptr, png_voidp ptr) png_free_default(png_structp png_ptr, png_voidp ptr)
@@ -522,7 +559,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
#endif /* Not Borland DOS special memory handler */ #endif /* Not Borland DOS special memory handler */
#if defined(PNG_1_0_X) #ifdef PNG_1_0_X
# define png_malloc_warn png_malloc # define png_malloc_warn png_malloc
#else #else
/* This function was added at libpng version 1.2.3. The png_malloc_warn() /* This function was added at libpng version 1.2.3. The png_malloc_warn()
@@ -534,8 +571,11 @@ png_voidp PNGAPI
png_malloc_warn(png_structp png_ptr, png_uint_32 size) png_malloc_warn(png_structp png_ptr, png_uint_32 size)
{ {
png_voidp ptr; png_voidp ptr;
png_uint_32 save_flags=png_ptr->flags; png_uint_32 save_flags;
if (png_ptr == NULL)
return (NULL);
save_flags = png_ptr->flags;
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
png_ptr->flags=save_flags; png_ptr->flags=save_flags;
@@ -551,7 +591,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
size = (png_size_t)length; size = (png_size_t)length;
if ((png_uint_32)size != length) if ((png_uint_32)size != length)
png_error(png_ptr,"Overflow in png_memcpy_check."); png_error(png_ptr, "Overflow in png_memcpy_check.");
return(png_memcpy (s1, s2, size)); return(png_memcpy (s1, s2, size));
} }
@@ -564,7 +604,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
size = (png_size_t)length; size = (png_size_t)length;
if ((png_uint_32)size != length) if ((png_uint_32)size != length)
png_error(png_ptr,"Overflow in png_memset_check."); png_error(png_ptr, "Overflow in png_memset_check.");
return (png_memset (s1, value, size)); return (png_memset (s1, value, size));
@@ -578,9 +618,12 @@ void PNGAPI
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
malloc_fn, png_free_ptr free_fn) malloc_fn, png_free_ptr free_fn)
{ {
png_ptr->mem_ptr = mem_ptr; if (png_ptr != NULL)
png_ptr->malloc_fn = malloc_fn; {
png_ptr->free_fn = free_fn; png_ptr->mem_ptr = mem_ptr;
png_ptr->malloc_fn = malloc_fn;
png_ptr->free_fn = free_fn;
}
} }
/* This function returns a pointer to the mem_ptr associated with the user /* This function returns a pointer to the mem_ptr associated with the user
@@ -590,6 +633,9 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
png_voidp PNGAPI png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr) png_get_mem_ptr(png_structp png_ptr)
{ {
if (png_ptr == NULL)
return (NULL);
return ((png_voidp)png_ptr->mem_ptr); return ((png_voidp)png_ptr->mem_ptr);
} }
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

File diff suppressed because it is too large Load Diff

919
pngread.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,15 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.43 [February 25, 2010]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* This file provides a location for all input. Users who need * This file provides a location for all input. Users who need
* special handling are expected to write a function that has the same * special handling are expected to write a function that has the same
* arguments as this and performs a similar function, but that possibly * arguments as this and performs a similar function, but that possibly
@@ -16,38 +19,45 @@
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#ifdef PNG_READ_SUPPORTED
/* Read the data from whatever input you are using. The default routine /* Read the data from whatever input you are using. The default routine
reads from a file pointer. Note that this routine sometimes gets called * reads from a file pointer. Note that this routine sometimes gets called
with very small lengths, so you should implement some kind of simple * with very small lengths, so you should implement some kind of simple
buffering if you are using unbuffered reads. This should never be asked * buffering if you are using unbuffered reads. This should never be asked
to read more then 64K on a 16 bit machine. */ * to read more then 64K on a 16 bit machine.
*/
void /* PRIVATE */ void /* PRIVATE */
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_debug1(4,"reading %d bytes\n", (int)length); png_debug1(4, "reading %d bytes", (int)length);
if (png_ptr->read_data_fn != NULL) if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length); (*(png_ptr->read_data_fn))(png_ptr, data, length);
else else
png_error(png_ptr, "Call to NULL read function"); png_error(png_ptr, "Call to NULL read function");
} }
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
/* This is the function that does the actual reading of data. If you are /* This is the function that does the actual reading of data. If you are
not reading from a standard C stream, you should create a replacement * not reading from a standard C stream, you should create a replacement
read_data function and use it at run time with png_set_read_fn(), rather * read_data function and use it at run time with png_set_read_fn(), rather
than changing the library. */ * than changing the library.
*/
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
void PNGAPI void PNGAPI
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_size_t check; png_size_t check;
if (png_ptr == NULL)
return;
/* fread() returns 0 on error, so it is OK to store this in a png_size_t /* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns. * instead of an int, which is what fread() actually returns.
*/ */
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
check = 0; check = 0;
#else #else
@@ -59,7 +69,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_error(png_ptr, "Read Error"); png_error(png_ptr, "Read Error");
} }
#else #else
/* this is the model-independent version. Since the standard I/O library /* This is the model-independent version. Since the standard I/O library
can't handle far buffers in the medium and small models, we have to copy can't handle far buffers in the medium and small models, we have to copy
the data. the data.
*/ */
@@ -67,20 +77,23 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define NEAR_BUF_SIZE 1024 #define NEAR_BUF_SIZE 1024
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
static void /* PRIVATE */ static void PNGAPI
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
int check; int check;
png_byte *n_data; png_byte *n_data;
png_FILE_p io_ptr; png_FILE_p io_ptr;
if (png_ptr == NULL)
return;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
n_data = (png_byte *)CVT_PTR_NOCHECK(data); 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_ptr->io_ptr);
if ((png_bytep)n_data == data) if ((png_bytep)n_data == data)
{ {
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check,
NULL) )
check = 0; check = 0;
#else #else
check = fread(n_data, 1, length, io_ptr); check = fread(n_data, 1, length, io_ptr);
@@ -95,14 +108,14 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
do do
{ {
read = MIN(NEAR_BUF_SIZE, remaining); read = MIN(NEAR_BUF_SIZE, remaining);
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
err = 0; err = 0;
#else #else
err = fread(buf, (png_size_t)1, read, io_ptr); err = fread(buf, (png_size_t)1, read, io_ptr);
#endif #endif
png_memcpy(data, buf, read); /* copy far buffer to near buffer */ png_memcpy(data, buf, read); /* copy far buffer to near buffer */
if(err != read) if (err != read)
break; break;
else else
check += err; check += err;
@@ -118,25 +131,30 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#endif #endif
/* This function allows the application to supply a new input function /* This function allows the application to supply a new input function
for libpng if standard C streams aren't being used. * for libpng if standard C streams aren't being used.
*
This function takes as its arguments: * This function takes as its arguments:
png_ptr - pointer to a png input data structure * png_ptr - pointer to a png input data structure
io_ptr - pointer to user supplied structure containing info about * io_ptr - pointer to user supplied structure containing info about
the input functions. May be NULL. * the input functions. May be NULL.
read_data_fn - pointer to a new input function that takes as its * read_data_fn - pointer to a new input function that takes as its
arguments a pointer to a png_struct, a pointer to * arguments a pointer to a png_struct, a pointer to
a location where input data can be stored, and a 32-bit * a location where input data can be stored, and a 32-bit
unsigned int that is the number of bytes to be read. * unsigned int that is the number of bytes to be read.
To exit and output any fatal error messages the new write * To exit and output any fatal error messages the new write
function should call png_error(png_ptr, "Error msg"). */ * function should call png_error(png_ptr, "Error msg").
* May be NULL, in which case libpng's default function will
* be used.
*/
void PNGAPI void PNGAPI
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn) png_rw_ptr read_data_fn)
{ {
if (png_ptr == NULL)
return;
png_ptr->io_ptr = io_ptr; png_ptr->io_ptr = io_ptr;
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
if (read_data_fn != NULL) if (read_data_fn != NULL)
png_ptr->read_data_fn = read_data_fn; png_ptr->read_data_fn = read_data_fn;
else else
@@ -155,7 +173,8 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
"same structure. Resetting write_data_fn to NULL."); "same structure. Resetting write_data_fn to NULL.");
} }
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #ifdef PNG_WRITE_FLUSH_SUPPORTED
png_ptr->output_flush_fn = NULL; png_ptr->output_flush_fn = NULL;
#endif #endif
} }
#endif /* PNG_READ_SUPPORTED */

1445
pngrtran.c

File diff suppressed because it is too large Load Diff

1502
pngrutil.c

File diff suppressed because it is too large Load Diff

996
pngset.c

File diff suppressed because it is too large Load Diff

795
pngtest.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +1,57 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* libpng 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.41 [December 3, 2009]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* turn on BGR-to-RGB mapping */ /* Turn on BGR-to-RGB mapping */
void PNGAPI void PNGAPI
png_set_bgr(png_structp png_ptr) png_set_bgr(png_structp png_ptr)
{ {
png_debug(1, "in png_set_bgr\n"); png_debug(1, "in png_set_bgr");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_BGR; png_ptr->transformations |= PNG_BGR;
} }
#endif #endif
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* turn on 16 bit byte swapping */ /* Turn on 16 bit byte swapping */
void PNGAPI void PNGAPI
png_set_swap(png_structp png_ptr) png_set_swap(png_structp png_ptr)
{ {
png_debug(1, "in png_set_swap\n"); png_debug(1, "in png_set_swap");
if (png_ptr == NULL)
return;
if (png_ptr->bit_depth == 16) if (png_ptr->bit_depth == 16)
png_ptr->transformations |= PNG_SWAP_BYTES; png_ptr->transformations |= PNG_SWAP_BYTES;
} }
#endif #endif
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* turn on pixel packing */ /* Turn on pixel packing */
void PNGAPI void PNGAPI
png_set_packing(png_structp png_ptr) png_set_packing(png_structp png_ptr)
{ {
png_debug(1, "in png_set_packing\n"); png_debug(1, "in png_set_packing");
if (png_ptr == NULL)
return;
if (png_ptr->bit_depth < 8) if (png_ptr->bit_depth < 8)
{ {
png_ptr->transformations |= PNG_PACK; png_ptr->transformations |= PNG_PACK;
@@ -47,11 +61,14 @@ png_set_packing(png_structp png_ptr)
#endif #endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* turn on packed pixel swapping */ /* Turn on packed pixel swapping */
void PNGAPI void PNGAPI
png_set_packswap(png_structp png_ptr) png_set_packswap(png_structp png_ptr)
{ {
png_debug(1, "in png_set_packswap\n"); png_debug(1, "in png_set_packswap");
if (png_ptr == NULL)
return;
if (png_ptr->bit_depth < 8) if (png_ptr->bit_depth < 8)
png_ptr->transformations |= PNG_PACKSWAP; png_ptr->transformations |= PNG_PACKSWAP;
} }
@@ -61,7 +78,10 @@ png_set_packswap(png_structp png_ptr)
void PNGAPI void PNGAPI
png_set_shift(png_structp png_ptr, png_color_8p true_bits) png_set_shift(png_structp png_ptr, png_color_8p true_bits)
{ {
png_debug(1, "in png_set_shift\n"); png_debug(1, "in png_set_shift");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_SHIFT; png_ptr->transformations |= PNG_SHIFT;
png_ptr->shift = *true_bits; png_ptr->shift = *true_bits;
} }
@@ -72,8 +92,9 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
int PNGAPI int PNGAPI
png_set_interlace_handling(png_structp png_ptr) png_set_interlace_handling(png_structp png_ptr)
{ {
png_debug(1, "in png_set_interlace handling\n"); png_debug(1, "in png_set_interlace handling");
if (png_ptr->interlaced)
if (png_ptr && png_ptr->interlaced)
{ {
png_ptr->transformations |= PNG_INTERLACE; png_ptr->transformations |= PNG_INTERLACE;
return (7); return (7);
@@ -92,9 +113,16 @@ png_set_interlace_handling(png_structp png_ptr)
void PNGAPI void PNGAPI
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
{ {
png_debug(1, "in png_set_filler\n"); png_debug(1, "in png_set_filler");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_FILLER; png_ptr->transformations |= PNG_FILLER;
#ifdef PNG_LEGACY_SUPPORTED
png_ptr->filler = (png_byte)filler; png_ptr->filler = (png_byte)filler;
#else
png_ptr->filler = (png_uint_16)filler;
#endif
if (filler_loc == PNG_FILLER_AFTER) if (filler_loc == PNG_FILLER_AFTER)
png_ptr->flags |= PNG_FLAG_FILLER_AFTER; png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
else else
@@ -119,12 +147,15 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
} }
} }
#if !defined(PNG_1_0_X) #ifndef PNG_1_0_X
/* Added to libpng-1.2.7 */ /* Added to libpng-1.2.7 */
void PNGAPI void PNGAPI
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
{ {
png_debug(1, "in png_set_add_alpha\n"); png_debug(1, "in png_set_add_alpha");
if (png_ptr == NULL)
return;
png_set_filler(png_ptr, filler, filler_loc); png_set_filler(png_ptr, filler, filler_loc);
png_ptr->transformations |= PNG_ADD_ALPHA; png_ptr->transformations |= PNG_ADD_ALPHA;
} }
@@ -137,7 +168,10 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
void PNGAPI void PNGAPI
png_set_swap_alpha(png_structp png_ptr) png_set_swap_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_swap_alpha\n"); png_debug(1, "in png_set_swap_alpha");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_SWAP_ALPHA; png_ptr->transformations |= PNG_SWAP_ALPHA;
} }
#endif #endif
@@ -147,7 +181,10 @@ png_set_swap_alpha(png_structp png_ptr)
void PNGAPI void PNGAPI
png_set_invert_alpha(png_structp png_ptr) png_set_invert_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_invert_alpha\n"); png_debug(1, "in png_set_invert_alpha");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_INVERT_ALPHA; png_ptr->transformations |= PNG_INVERT_ALPHA;
} }
#endif #endif
@@ -156,19 +193,23 @@ png_set_invert_alpha(png_structp png_ptr)
void PNGAPI void PNGAPI
png_set_invert_mono(png_structp png_ptr) png_set_invert_mono(png_structp png_ptr)
{ {
png_debug(1, "in png_set_invert_mono\n"); png_debug(1, "in png_set_invert_mono");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_INVERT_MONO; png_ptr->transformations |= PNG_INVERT_MONO;
} }
/* invert monochrome grayscale data */ /* Invert monochrome grayscale data */
void /* PRIVATE */ void /* PRIVATE */
png_do_invert(png_row_infop row_info, png_bytep row) png_do_invert(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_invert\n"); png_debug(1, "in png_do_invert");
/* This test removed from libpng version 1.0.13 and 1.2.0: /* This test removed from libpng version 1.0.13 and 1.2.0:
* if (row_info->bit_depth == 1 && * if (row_info->bit_depth == 1 &&
*/ */
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
if (row == NULL || row_info == NULL) if (row == NULL || row_info == NULL)
return; return;
#endif #endif
@@ -215,13 +256,14 @@ png_do_invert(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* swaps byte order on 16 bit depth images */ /* Swaps byte order on 16 bit depth images */
void /* PRIVATE */ void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row) png_do_swap(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_swap\n"); png_debug(1, "in png_do_swap");
if ( if (
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
row != NULL && row_info != NULL && row != NULL && row_info != NULL &&
#endif #endif
row_info->bit_depth == 16) row_info->bit_depth == 16)
@@ -241,7 +283,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
static png_byte onebppswaptable[256] = { static PNG_CONST png_byte onebppswaptable[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@@ -276,7 +318,7 @@ static png_byte onebppswaptable[256] = {
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
}; };
static png_byte twobppswaptable[256] = { static PNG_CONST png_byte twobppswaptable[256] = {
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@@ -311,7 +353,7 @@ static png_byte twobppswaptable[256] = {
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
}; };
static png_byte fourbppswaptable[256] = { static PNG_CONST png_byte fourbppswaptable[256] = {
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
@@ -346,13 +388,14 @@ static png_byte fourbppswaptable[256] = {
0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
}; };
/* swaps pixel packing order within bytes */ /* Swaps pixel packing order within bytes */
void /* PRIVATE */ void /* PRIVATE */
png_do_packswap(png_row_infop row_info, png_bytep row) png_do_packswap(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_packswap\n"); png_debug(1, "in png_do_packswap");
if ( if (
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
row != NULL && row_info != NULL && row != NULL && row_info != NULL &&
#endif #endif
row_info->bit_depth < 8) row_info->bit_depth < 8)
@@ -362,11 +405,11 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
end = row + row_info->rowbytes; end = row + row_info->rowbytes;
if (row_info->bit_depth == 1) if (row_info->bit_depth == 1)
table = onebppswaptable; table = (png_bytep)onebppswaptable;
else if (row_info->bit_depth == 2) else if (row_info->bit_depth == 2)
table = twobppswaptable; table = (png_bytep)twobppswaptable;
else if (row_info->bit_depth == 4) else if (row_info->bit_depth == 4)
table = fourbppswaptable; table = (png_bytep)fourbppswaptable;
else else
return; return;
@@ -378,12 +421,13 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED) defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* remove filler or alpha byte(s) */ /* Remove filler or alpha byte(s) */
void /* PRIVATE */ void /* PRIVATE */
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
{ {
png_debug(1, "in png_do_strip_filler\n"); png_debug(1, "in png_do_strip_filler");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#ifdef PNG_USELESS_TESTS_SUPPORTED
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
#endif #endif
{ {
@@ -393,9 +437,9 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
png_uint_32 i; png_uint_32 i;
if ((row_info->color_type == PNG_COLOR_TYPE_RGB || if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
(flags & PNG_FLAG_STRIP_ALPHA))) && (flags & PNG_FLAG_STRIP_ALPHA))) &&
row_info->channels == 4) row_info->channels == 4)
{ {
if (row_info->bit_depth == 8) if (row_info->bit_depth == 8)
{ {
@@ -536,13 +580,14 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
#endif #endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* swaps red and blue bytes within a pixel */ /* Swaps red and blue bytes within a pixel */
void /* PRIVATE */ void /* PRIVATE */
png_do_bgr(png_row_infop row_info, png_bytep row) png_do_bgr(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_bgr\n"); png_debug(1, "in png_do_bgr");
if ( if (
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
row != NULL && row_info != NULL && row != NULL && row_info != NULL &&
#endif #endif
(row_info->color_type & PNG_COLOR_MASK_COLOR)) (row_info->color_type & PNG_COLOR_MASK_COLOR))
@@ -613,19 +658,22 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) || \
defined(PNG_LEGACY_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void PNGAPI void PNGAPI
png_set_user_transform_info(png_structp png_ptr, png_voidp png_set_user_transform_info(png_structp png_ptr, png_voidp
user_transform_ptr, int user_transform_depth, int user_transform_channels) user_transform_ptr, int user_transform_depth, int user_transform_channels)
{ {
png_debug(1, "in png_set_user_transform_info\n"); png_debug(1, "in png_set_user_transform_info");
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (png_ptr == NULL)
return;
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_depth = (png_byte)user_transform_depth;
png_ptr->user_transform_channels = (png_byte)user_transform_channels; png_ptr->user_transform_channels = (png_byte)user_transform_channels;
#else #else
if(user_transform_ptr || user_transform_depth || user_transform_channels) if (user_transform_ptr || user_transform_depth || user_transform_channels)
png_warning(png_ptr, png_warning(png_ptr,
"This version of libpng does not support user transform info"); "This version of libpng does not support user transform info");
#endif #endif
@@ -640,11 +688,12 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
png_voidp PNGAPI png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr) png_get_user_transform_ptr(png_structp png_ptr)
{ {
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if (png_ptr == NULL)
return (NULL);
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
return ((png_voidp)png_ptr->user_transform_ptr); return ((png_voidp)png_ptr->user_transform_ptr);
#else #else
if(png_ptr)
return (NULL);
return (NULL); return (NULL);
#endif #endif
} }
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

3907
pngvcrd.c

File diff suppressed because it is too large Load Diff

152
pngwio.c
View File

@@ -1,12 +1,15 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.41 [December 3, 2009]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2009 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* This file provides a location for all output. Users who need * This file provides a location for all output. Users who need
* special handling are expected to write functions that have the same * special handling are expected to write functions that have the same
* arguments as these and perform similar functions, but that possibly * arguments as these and perform similar functions, but that possibly
@@ -16,14 +19,16 @@
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#ifdef PNG_WRITE_SUPPORTED #ifdef PNG_WRITE_SUPPORTED
/* Write the data to whatever output you are using. The default routine /* Write the data to whatever output you are using. The default routine
writes to a file pointer. Note that this routine sometimes gets called * writes to a file pointer. Note that this routine sometimes gets called
with very small lengths, so you should implement some kind of simple * with very small lengths, so you should implement some kind of simple
buffering if you are using unbuffered writes. This should never be asked * buffering if you are using unbuffered writes. This should never be asked
to write more than 64K on a 16 bit machine. */ * to write more than 64K on a 16 bit machine.
*/
void /* PRIVATE */ void /* PRIVATE */
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
@@ -34,18 +39,21 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_error(png_ptr, "Call to NULL write function"); png_error(png_ptr, "Call to NULL write function");
} }
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
/* This is the function that does the actual writing of data. If you are /* This is the function that does the actual writing of data. If you are
not writing to a standard C stream, you should create a replacement * not writing to a standard C stream, you should create a replacement
write_data function and use it at run time with png_set_write_fn(), rather * write_data function and use it at run time with png_set_write_fn(), rather
than changing the library. */ * than changing the library.
*/
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
void PNGAPI void PNGAPI
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_uint_32 check; png_uint_32 check;
#if defined(_WIN32_WCE) if (png_ptr == NULL)
return;
#ifdef _WIN32_WCE
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
check = 0; check = 0;
#else #else
@@ -55,10 +63,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_error(png_ptr, "Write Error"); png_error(png_ptr, "Write Error");
} }
#else #else
/* this is the model-independent version. Since the standard I/O library /* This is the model-independent version. Since the standard I/O library
can't handle far buffers in the medium and small models, we have to copy * can't handle far buffers in the medium and small models, we have to copy
the data. * the data.
*/ */
#define NEAR_BUF_SIZE 1024 #define NEAR_BUF_SIZE 1024
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
@@ -70,12 +78,14 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
png_FILE_p io_ptr; png_FILE_p io_ptr;
if (png_ptr == NULL)
return;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
near_data = (png_byte *)CVT_PTR_NOCHECK(data); 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_ptr->io_ptr);
if ((png_bytep)near_data == data) if ((png_bytep)near_data == data)
{ {
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
if ( !WriteFile(io_ptr, near_data, length, &check, NULL) ) if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
check = 0; check = 0;
#else #else
@@ -91,8 +101,8 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
do do
{ {
written = MIN(NEAR_BUF_SIZE, remaining); written = MIN(NEAR_BUF_SIZE, remaining);
png_memcpy(buf, data, written); /* copy far buffer to near buffer */ png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
#if defined(_WIN32_WCE) #ifdef _WIN32_WCE
if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
err = 0; err = 0;
#else #else
@@ -100,8 +110,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
#endif #endif
if (err != written) if (err != written)
break; break;
else else
check += err; check += err;
data += written; data += written;
remaining -= written; remaining -= written;
} }
@@ -115,9 +127,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
#endif #endif
/* This function is called to output any data pending writing (normally /* This function is called to output any data pending writing (normally
to disk). After png_flush is called, there should be no data pending * to disk). After png_flush is called, there should be no data pending
writing in any buffers. */ * writing in any buffers.
#if defined(PNG_WRITE_FLUSH_SUPPORTED) */
#ifdef PNG_WRITE_FLUSH_SUPPORTED
void /* PRIVATE */ void /* PRIVATE */
png_flush(png_structp png_ptr) png_flush(png_structp png_ptr)
{ {
@@ -125,61 +138,76 @@ png_flush(png_structp png_ptr)
(*(png_ptr->output_flush_fn))(png_ptr); (*(png_ptr->output_flush_fn))(png_ptr);
} }
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
void PNGAPI void PNGAPI
png_default_flush(png_structp png_ptr) png_default_flush(png_structp png_ptr)
{ {
#if !defined(_WIN32_WCE) #ifndef _WIN32_WCE
png_FILE_p io_ptr; png_FILE_p io_ptr;
#endif
if (png_ptr == NULL)
return;
#ifndef _WIN32_WCE
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
if (io_ptr != NULL) fflush(io_ptr);
fflush(io_ptr);
#endif #endif
} }
#endif #endif
#endif #endif
/* This function allows the application to supply new output functions for /* This function allows the application to supply new output functions for
libpng if standard C streams aren't being used. * libpng if standard C streams aren't being used.
*
This function takes as its arguments: * This function takes as its arguments:
png_ptr - pointer to a png output data structure * png_ptr - pointer to a png output data structure
io_ptr - pointer to user supplied structure containing info about * io_ptr - pointer to user supplied structure containing info about
the output functions. May be NULL. * the output functions. May be NULL.
write_data_fn - pointer to a new output function that takes as its * write_data_fn - pointer to a new output function that takes as its
arguments a pointer to a png_struct, a pointer to * arguments a pointer to a png_struct, a pointer to
data to be written, and a 32-bit unsigned int that is * data to be written, and a 32-bit unsigned int that is
the number of bytes to be written. The new write * the number of bytes to be written. The new write
function should call png_error(png_ptr, "Error msg") * function should call png_error(png_ptr, "Error msg")
to exit and output any fatal error messages. * to exit and output any fatal error messages. May be
flush_data_fn - pointer to a new flush function that takes as its * NULL, in which case libpng's default function will
arguments a pointer to a png_struct. After a call to * be used.
the flush function, there should be no data in any buffers * flush_data_fn - pointer to a new flush function that takes as its
or pending transmission. If the output method doesn't do * arguments a pointer to a png_struct. After a call to
any buffering of ouput, a function prototype must still be * the flush function, there should be no data in any buffers
supplied although it doesn't have to do anything. If * or pending transmission. If the output method doesn't do
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile * any buffering of output, a function prototype must still be
time, output_flush_fn will be ignored, although it must be * supplied although it doesn't have to do anything. If
supplied for compatibility. */ * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
* time, output_flush_fn will be ignored, although it must be
* supplied for compatibility. May be NULL, in which case
* libpng's default function will be used, if
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
* a good idea if io_ptr does not point to a standard
* *FILE structure.
*/
void PNGAPI void PNGAPI
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
{ {
if (png_ptr == NULL)
return;
png_ptr->io_ptr = io_ptr; png_ptr->io_ptr = io_ptr;
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
if (write_data_fn != NULL) if (write_data_fn != NULL)
png_ptr->write_data_fn = write_data_fn; png_ptr->write_data_fn = write_data_fn;
else else
png_ptr->write_data_fn = png_default_write_data; png_ptr->write_data_fn = png_default_write_data;
#else #else
png_ptr->write_data_fn = write_data_fn; png_ptr->write_data_fn = write_data_fn;
#endif #endif
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #ifdef PNG_WRITE_FLUSH_SUPPORTED
#if !defined(PNG_NO_STDIO) #ifdef PNG_STDIO_SUPPORTED
if (output_flush_fn != NULL) if (output_flush_fn != NULL)
png_ptr->output_flush_fn = output_flush_fn; png_ptr->output_flush_fn = output_flush_fn;
else else
png_ptr->output_flush_fn = png_default_flush; png_ptr->output_flush_fn = png_default_flush;
#else #else
@@ -198,29 +226,33 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
} }
} }
#if defined(USE_FAR_KEYWORD) #ifdef USE_FAR_KEYWORD
#if defined(_MSC_VER) #ifdef _MSC_VER
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
{ {
void *near_ptr; void *near_ptr;
void FAR *far_ptr; void FAR *far_ptr;
FP_OFF(near_ptr) = FP_OFF(ptr); FP_OFF(near_ptr) = FP_OFF(ptr);
far_ptr = (void FAR *)near_ptr; far_ptr = (void FAR *)near_ptr;
if(check != 0)
if(FP_SEG(ptr) != FP_SEG(far_ptr)) if (check != 0)
png_error(png_ptr,"segment lost in conversion"); if (FP_SEG(ptr) != FP_SEG(far_ptr))
png_error(png_ptr, "segment lost in conversion");
return(near_ptr); return(near_ptr);
} }
# else # else
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
{ {
void *near_ptr; void *near_ptr;
void FAR *far_ptr; void FAR *far_ptr;
near_ptr = (void FAR *)ptr; near_ptr = (void FAR *)ptr;
far_ptr = (void FAR *)near_ptr; far_ptr = (void FAR *)near_ptr;
if(check != 0)
if(far_ptr != ptr) if (check != 0)
png_error(png_ptr,"segment lost in conversion"); if (far_ptr != ptr)
png_error(png_ptr, "segment lost in conversion");
return(near_ptr); return(near_ptr);
} }
# endif # endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,18 @@
/* pngwtran.c - transforms the data in a row for PNG writers /* pngwtran.c - transforms the data in a row for PNG writers
* *
* libpng version 1.0.18 - December 3, 2004 * Last changed in libpng 1.2.43 [February 25, 2010]
* For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2010 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_PEDANTIC_WARNINGS
#include "png.h" #include "png.h"
#ifdef PNG_WRITE_SUPPORTED #ifdef PNG_WRITE_SUPPORTED
@@ -18,15 +22,16 @@
void /* PRIVATE */ void /* PRIVATE */
png_do_write_transformations(png_structp png_ptr) png_do_write_transformations(png_structp png_ptr)
{ {
png_debug(1, "in png_do_write_transformations\n"); png_debug(1, "in png_do_write_transformations");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
if (png_ptr->transformations & PNG_USER_TRANSFORM) if (png_ptr->transformations & PNG_USER_TRANSFORM)
if(png_ptr->write_user_transform_fn != NULL) if (png_ptr->write_user_transform_fn != NULL)
(*(png_ptr->write_user_transform_fn)) /* user write transform function */ (*(png_ptr->write_user_transform_fn)) /* User write transform
function */
(png_ptr, /* png_ptr */ (png_ptr, /* png_ptr */
&(png_ptr->row_info), /* row_info: */ &(png_ptr->row_info), /* row_info: */
/* png_uint_32 width; width of row */ /* png_uint_32 width; width of row */
@@ -37,48 +42,48 @@ png_do_write_transformations(png_structp png_ptr)
/* png_byte pixel_depth; bits per pixel (depth*channels) */ /* png_byte pixel_depth; bits per pixel (depth*channels) */
png_ptr->row_buf + 1); /* start of pixel data for row */ png_ptr->row_buf + 1); /* start of pixel data for row */
#endif #endif
#if defined(PNG_WRITE_FILLER_SUPPORTED) #ifdef PNG_WRITE_FILLER_SUPPORTED
if (png_ptr->transformations & PNG_FILLER) if (png_ptr->transformations & PNG_FILLER)
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
png_ptr->flags); png_ptr->flags);
#endif #endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) #ifdef PNG_WRITE_PACKSWAP_SUPPORTED
if (png_ptr->transformations & PNG_PACKSWAP) if (png_ptr->transformations & PNG_PACKSWAP)
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
#if defined(PNG_WRITE_PACK_SUPPORTED) #ifdef PNG_WRITE_PACK_SUPPORTED
if (png_ptr->transformations & PNG_PACK) if (png_ptr->transformations & PNG_PACK)
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1, png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
(png_uint_32)png_ptr->bit_depth); (png_uint_32)png_ptr->bit_depth);
#endif #endif
#if defined(PNG_WRITE_SWAP_SUPPORTED) #ifdef PNG_WRITE_SWAP_SUPPORTED
if (png_ptr->transformations & PNG_SWAP_BYTES) if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED) #ifdef PNG_WRITE_SHIFT_SUPPORTED
if (png_ptr->transformations & PNG_SHIFT) if (png_ptr->transformations & PNG_SHIFT)
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1, png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->shift)); &(png_ptr->shift));
#endif #endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_ALPHA) if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
#if defined(PNG_WRITE_BGR_SUPPORTED) #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_BGR_SUPPORTED
if (png_ptr->transformations & PNG_BGR) if (png_ptr->transformations & PNG_BGR)
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
#if defined(PNG_WRITE_INVERT_SUPPORTED) #ifdef PNG_WRITE_INVERT_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_MONO) if (png_ptr->transformations & PNG_INVERT_MONO)
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif #endif
} }
#if defined(PNG_WRITE_PACK_SUPPORTED) #ifdef PNG_WRITE_PACK_SUPPORTED
/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The /* Pack pixels into bytes. Pass the true bit depth in bit_depth. The
* row_info bit depth should be 8 (one pixel per byte). The channels * row_info bit depth should be 8 (one pixel per byte). The channels
* should be 1 (this only happens on grayscale and paletted images). * should be 1 (this only happens on grayscale and paletted images).
@@ -86,9 +91,10 @@ png_do_write_transformations(png_structp png_ptr)
void /* PRIVATE */ void /* PRIVATE */
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
{ {
png_debug(1, "in png_do_pack\n"); png_debug(1, "in png_do_pack");
if (row_info->bit_depth == 8 && if (row_info->bit_depth == 8 &&
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
row != NULL && row_info != NULL && row != NULL && row_info != NULL &&
#endif #endif
row_info->channels == 1) row_info->channels == 1)
@@ -201,7 +207,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
} }
#endif #endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED) #ifdef PNG_WRITE_SHIFT_SUPPORTED
/* Shift pixel values to take advantage of whole range. Pass the /* Shift pixel values to take advantage of whole range. Pass the
* true number of bits in bit_depth. The row should be packed * true number of bits in bit_depth. The row should be packed
* according to row_info->bit_depth. Thus, if you had a row of * according to row_info->bit_depth. Thus, if you had a row of
@@ -212,8 +218,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
void /* PRIVATE */ 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_color_8p bit_depth)
{ {
png_debug(1, "in png_do_shift\n"); png_debug(1, "in png_do_shift");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#ifdef PNG_USELESS_TESTS_SUPPORTED
if (row != NULL && row_info != NULL && if (row != NULL && row_info != NULL &&
#else #else
if ( if (
@@ -248,7 +255,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
channels++; channels++;
} }
/* with low row depths, could only be grayscale, so one channel */ /* With low row depths, could only be grayscale, so one channel */
if (row_info->bit_depth < 8) if (row_info->bit_depth < 8)
{ {
png_bytep bp = row; png_bytep bp = row;
@@ -332,12 +339,13 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
} }
#endif #endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
void /* PRIVATE */ void /* PRIVATE */
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_write_swap_alpha\n"); png_debug(1, "in png_do_write_swap_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#ifdef PNG_USELESS_TESTS_SUPPORTED
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
#endif #endif
{ {
@@ -420,12 +428,13 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
} }
#endif #endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
void /* PRIVATE */ void /* PRIVATE */
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_write_invert_alpha\n"); png_debug(1, "in png_do_write_invert_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
#ifdef PNG_USELESS_TESTS_SUPPORTED
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
#endif #endif
{ {
@@ -439,9 +448,12 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
png_uint_32 row_width = row_info->width; png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_width; i++) for (i = 0, sp = dp = row; i < row_width; i++)
{ {
/* Does nothing
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*/
sp+=3; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
} }
} }
@@ -454,12 +466,15 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row; i < row_width; i++) for (i = 0, sp = dp = row; i < row_width; i++)
{ {
/* Does nothing
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*/
sp+=6; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
} }
@@ -489,8 +504,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row; i < row_width; i++) for (i = 0, sp = dp = row; i < row_width; i++)
{ {
/* Does nothing
*(dp++) = *(sp++); *(dp++) = *(sp++);
*(dp++) = *(sp++); *(dp++) = *(sp++);
*/
sp+=2; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++)); *(dp++) = (png_byte)(255 - *(sp++));
} }
@@ -500,14 +518,15 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
} }
#endif #endif
#if defined(PNG_MNG_FEATURES_SUPPORTED) #ifdef PNG_MNG_FEATURES_SUPPORTED
/* undoes intrapixel differencing */ /* Undoes intrapixel differencing */
void /* PRIVATE */ void /* PRIVATE */
png_do_write_intrapixel(png_row_infop row_info, png_bytep row) png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_write_intrapixel\n"); png_debug(1, "in png_do_write_intrapixel");
if ( if (
#if defined(PNG_USELESS_TESTS_SUPPORTED) #ifdef PNG_USELESS_TESTS_SUPPORTED
row != NULL && row_info != NULL && row != NULL && row_info != NULL &&
#endif #endif
(row_info->color_type & PNG_COLOR_MASK_COLOR)) (row_info->color_type & PNG_COLOR_MASK_COLOR))
@@ -549,8 +568,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); png_uint_32 s0 = (*(rp ) << 8) | *(rp+1);
png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3);
png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5);
png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
*(rp ) = (png_byte)((red >> 8) & 0xff); *(rp ) = (png_byte)((red >> 8) & 0xff);
*(rp+1) = (png_byte)(red & 0xff); *(rp+1) = (png_byte)(red & 0xff);
*(rp+4) = (png_byte)((blue >> 8) & 0xff); *(rp+4) = (png_byte)((blue >> 8) & 0xff);

1122
pngwutil.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
A set of project files is available for Netware. Get A set of project files is available for Netware. Get
libpng-1.0.15-project-netware.zip from a libpng distribution libpng-1.2.5-project-netware.zip from a libpng distribution
site such as http://libpng.sourceforge.net site such as http://libpng.sourceforge.net
Put the zip file in this directory (projects) and then run Put the zip file in this directory (projects) and then run
"unzip -a libpng-1.0.15-project-netware.zip" "unzip -a libpng-1.2.5-project-netware.zip"

View File

@@ -4,13 +4,11 @@ Copyright (C) 2000-2004 Simon-Pierre Cadieux.
Copyright (C) 2004 Cosmin Truta. Copyright (C) 2004 Cosmin Truta.
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
Assumptions: Assumptions:
* The libpng source files are in ..\.. * The libpng source files are in ..\..
* The zlib source files are in ..\..\..\zlib * The zlib source files are in ..\..\..\zlib
* The zlib project files are in ..\..\..\zlib\projects\visualc6 * The zlib project files are in ..\..\..\zlib\projects\visualc6
To use: To use:
1) On the main menu, select "File | Open Workspace". 1) On the main menu, select "File | Open Workspace".
@@ -28,7 +26,6 @@ To use:
5) If you built the sample program (pngtest), 5) If you built the sample program (pngtest),
select "Build | Execute ... (Ctrl+F5)". select "Build | Execute ... (Ctrl+F5)".
This project builds the libpng binaries as follows: This project builds the libpng binaries as follows:
* Win32_DLL_Release\libpng10.dll DLL build * Win32_DLL_Release\libpng10.dll DLL build
@@ -41,21 +38,13 @@ This project builds the libpng binaries as follows:
* Win32_LIB_ASM_Release\libpng.lib static build using ASM code * Win32_LIB_ASM_Release\libpng.lib static build using ASM code
* Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version) * Win32_LIB_ASM_Debug\libpngd.lib static build using ASM (debug version)
Notes: Notes:
If you change anything in the source files, or select different compiler If you change anything in the source files, or select different compiler
settings, please change the DLL name to something different than any of settings, please change the DLL name to something different than any of
the above names. the above names. Also, make sure that in your "pngusr.h" you define
PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX according to the
Also, make sure that DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD) instructions provided in "pngconf.h".
are defined when compiling the resource file. DLLFNAME_POSTFIX contains
the trailing letters that come after the version number. PRIVATEBUILD
and/or SPECIALBUILD store information describing the type of change made
in the VERSIONINFO structure. Please refer to MSDN for more information
on the used macros and the nature of their content. For an example on
how to define these macros, look at the resource compiler settings for
the "Win32 DLL VB" configuration.
All DLLs built by this project use the Microsoft dynamic C runtime library 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 MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the

View File

@@ -50,7 +50,7 @@ CFG=libpng - Win32 DLL Release
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX /Yc /Yu # 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 # ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "PNG_NO_MMX_CODE" /D "ZLIB_DLL" /D "_CRT_SECURE_NO_WARNINGS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -81,7 +81,7 @@ LINK32=link.exe
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
# SUBTRACT BASE CPP /YX /Yc /Yu # 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 # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "PNG_NO_MMX_CODE" /D PNG_DEBUG=1 /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -112,14 +112,14 @@ LINK32=link.exe
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX /Yc /Yu # SUBTRACT BASE CPP /YX /Yc /Yu
# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /c # ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD" # ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions""""
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
@@ -143,14 +143,14 @@ LINK32=link.exe
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
# SUBTRACT BASE CPP /YX /Yc /Yu # SUBTRACT BASE CPP /YX /Yc /Yu
# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d "PNG_USE_PNGVCRD" # ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d PNG_LIBPNG_SPECIALBUILD=""""Use MMX instructions""""
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
@@ -174,14 +174,14 @@ LINK32=link.exe
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX /Yc /Yu # 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" /FD /c # ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /D PNGAPI=__stdcall /D "PNG_NO_MODULEDEF" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
MTL=midl.exe MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dDLLFNAME_POSTFIX=""""VB"""" /dSPECIALBUILD=""""__stdcall calling convention used for exported functions"""" # ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /dPNG_LIBPNG_DLLFNAME_POSTFIX=""""VB"""" /dPNG_LIBPNG_SPECIALBUILD=""""__stdcall calling convention used for exported functions""""
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
@@ -210,7 +210,7 @@ PostBuild_Cmds=echo Deleting $(targetname) import library and export file (No
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX /Yc /Yu # SUBTRACT BASE CPP /YX /Yc /Yu
# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /FD /c # ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "PNG_NO_MMX_CODE" /D "WIN32" /D "NDEBUG" /D "_CRT_SECURE_NO_WARNINGS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -237,7 +237,7 @@ LIB32=link.exe -lib
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
# SUBTRACT BASE CPP /YX /Yc /Yu # 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 # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "PNG_NO_MMX_CODE" /D PNG_DEBUG=1 /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -264,7 +264,7 @@ LIB32=link.exe -lib
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX /Yc /Yu # SUBTRACT BASE CPP /YX /Yc /Yu
# ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /FD /c # ADD CPP /nologo /MD /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -291,7 +291,7 @@ LIB32=link.exe -lib
CPP=cl.exe CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
# SUBTRACT BASE CPP /YX /Yc /Yu # SUBTRACT BASE CPP /YX /Yc /Yu
# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "DEBUG" /D PNG_DEBUG=1 /D "PNG_USE_PNGVCRD" /D "PNG_LIBPNG_SPECIALBUILD" /D "_CRT_SECURE_NO_WARNINGS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
RSC=rc.exe RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -365,41 +365,6 @@ SOURCE=..\..\pngtrans.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\..\pngvcrd.c
!IF "$(CFG)" == "libpng - Win32 DLL Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Release"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM Debug"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL VB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Release"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB ASM Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\scripts\pngw32.def SOURCE=..\..\scripts\pngw32.def
!IF "$(CFG)" == "libpng - Win32 DLL Release" !IF "$(CFG)" == "libpng - Win32 DLL Release"

View File

@@ -8,7 +8,6 @@ Copyright (C) 2004 Simon-Pierre Cadieux.
Copyright (C) 2004 Cosmin Truta. Copyright (C) 2004 Cosmin Truta.
For conditions of distribution and use, see copyright notice in zlib.h. For conditions of distribution and use, see copyright notice in zlib.h.
To use: To use:
1) On the main menu, select "File | Open Solution". 1) On the main menu, select "File | Open Solution".

View File

@@ -18,7 +18,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL" PreprocessorDefinitions="WIN32;PNG_NO_MMX_CODE;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL;_CRT_SECURE_NO_WARNINGS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
@@ -43,7 +43,7 @@
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG" PreprocessorDefinitions="NDEBUG;_CRT_SECURE_NO_WARNINGS"
Culture="1033" Culture="1033"
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
<Tool <Tool
@@ -66,7 +66,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_BUILD_DLL;ZLIB_DLL" PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_NO_MMX_CODE;PNG_DEBUG=1;PNG_BUILD_DLL;ZLIB_DLL;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="3" UsePrecompiledHeader="3"
@@ -91,7 +91,7 @@
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1" PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1;_CRT_SECURE_NO_WARNINGS"
Culture="1033" Culture="1033"
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
<Tool <Tool
@@ -114,7 +114,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD" PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD;_CRT_SECURE_NO_WARNINGS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
@@ -140,7 +140,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;Use MMX instructions&quot;&quot;&quot;&quot;" AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;Use MMX instructions&quot;&quot;&quot;&quot;"
PreprocessorDefinitions="NDEBUG" PreprocessorDefinitions="NDEBUG;_CRT_SECURE_NO_WARNINGS"
Culture="1033" Culture="1033"
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
<Tool <Tool
@@ -163,7 +163,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD" PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_BUILD_DLL;ZLIB_DLL;PNG_LIBPNG_SPECIALBUILD;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="3" UsePrecompiledHeader="3"
@@ -189,7 +189,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;Use MMX instructions&quot;&quot;&quot;&quot;" AdditionalOptions="/d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;Use MMX instructions&quot;&quot;&quot;&quot;"
PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1" PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1;_CRT_SECURE_NO_WARNINGS"
Culture="1033" Culture="1033"
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
<Tool <Tool
@@ -212,7 +212,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL;PNGAPI=__stdcall;PNG_NO_MODULEDEF;PNG_LIBPNG_SPECIALBUILD" PreprocessorDefinitions="WIN32;NDEBUG;PNG_BUILD_DLL;ZLIB_DLL;PNGAPI=__stdcall;PNG_NO_MMX_CODE;PNG_NO_MODULEDEF;PNG_LIBPNG_SPECIALBUILD;_CRT_SECURE_NO_WARNINGS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
@@ -237,7 +237,7 @@
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
AdditionalOptions="/d PNG_LIBPNG_DLLFNAME_POSTFIX=&quot;&quot;&quot;&quot;VB&quot;&quot;&quot;&quot; /d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;__stdcall calling convention used for exported functions&quot;&quot;&quot;&quot;" AdditionalOptions="/d PNG_LIBPNG_DLLFNAME_POSTFIX=&quot;&quot;&quot;&quot;VB&quot;&quot;&quot;&quot; /d PNG_LIBPNG_SPECIALBUILD=&quot;&quot;&quot;&quot;__stdcall calling convention used for exported functions&quot;&quot;&quot;&quot;"
PreprocessorDefinitions="NDEBUG" PreprocessorDefinitions="NDEBUG;_CRT_SECURE_NO_WARNINGS"
Culture="1033" Culture="1033"
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/> AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
<Tool <Tool
@@ -260,7 +260,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG" PreprocessorDefinitions="PNG_NO_MMX_CODE;WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
@@ -301,7 +301,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\..\zlib" AdditionalIncludeDirectories="..\..;..\..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1" PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_NO_MMX_CODE;PNG_DEBUG=1;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="3" UsePrecompiledHeader="3"
@@ -342,7 +342,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..,..\..\..\zlib" AdditionalIncludeDirectories="..\..,..\..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD" PreprocessorDefinitions="WIN32;NDEBUG;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD;_CRT_SECURE_NO_WARNINGS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
@@ -383,7 +383,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..,..\..\..\zlib" AdditionalIncludeDirectories="..\..,..\..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD" PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_USE_PNGVCRD;PNG_LIBPNG_SPECIALBUILD;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="3" UsePrecompiledHeader="3"
@@ -563,39 +563,6 @@
<File <File
RelativePath="..\..\pngtrans.c"> RelativePath="..\..\pngtrans.c">
</File> </File>
<File
RelativePath="..\..\pngvcrd.c">
<FileConfiguration
Name="DLL Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="DLL Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="DLL VB|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="LIB Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="LIB Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\..\scripts\pngw32.def"> RelativePath="..\..\scripts\pngw32.def">
<FileConfiguration <FileConfiguration

View File

@@ -1,6 +1,6 @@
A set of project files is available for WinCE. Get A set of project files is available for WinCE. Get
libpng-1.0.15-project-wince.zip from a libpng distribution libpng-1.0.62-project-wince.zip from a libpng distribution
site such as http://libpng.sourceforge.net site such as http://libpng.sourceforge.net/index.html
Put the zip file in this directory (projects) and then run Put the zip file in this directory (projects) and then run
"unzip -a libpng-1.0.15-project-wince.zip" "unzip -a libpng-1.0.62-project-wince.zip"

76
scripts/README.txt Normal file
View File

@@ -0,0 +1,76 @@
Makefiles for libpng version 1.0.62 - February 6, 2014
makefile.linux => Linux/ELF makefile
(gcc, creates libpng10.so.0.1.0.62)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.acorn => Acorn makefile
makefile.aix => AIX/gcc makefile
makefile.amiga => Amiga makefile
makefile.atari => Atari makefile
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 libpng10.so.0.1.0.62)
makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile
makefile.gccmmx => Generic gcc makefile previously using MMX code
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.nommx => Generic gcc makefile not using MMX code
makefile.openbsd => OpenBSD makefile
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc,
creates libpng10.so.0.1.0.62)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng10.so.0.1.0.62)
makefile.solaris-x86 => Solaris 2.X makefile (gcc, no MMX code,
creates libpng10.so.0.1.0.62)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng10.so.0.1.0.62)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.tc3 => Turbo C 3.0 makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 4.0 and later
previously using MMX code
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
Other supporting scripts:
descrip.mms => VMS makefile for MMS or MMK
libpng-config.in => Used by "configure" to create libpng-config.
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
libpng.pc-configure.in => Used by "configure" to create libpng.pc
libpng.icc
pngos2.def => OS/2 module definition file used by makefile.os2
pngw32.def => Module definitions for makefile.cygwin and mingw
png32ce.def => Module definition file used by makefile.cegcc
pngw32.rc => Used by the visualc6 and visualc71 projects.
SCOPTIONS.ppc => Used with smakefile.ppc
Further information can be found in comments in the individual makefiles.

View File

@@ -29,7 +29,7 @@ test : pngtest.exe
run pngtest run pngtest
clean : clean :
delete *.obj;*,*.exe;* delete *.obj;*,*.exe;
# Other dependencies. # Other dependencies.
@@ -44,9 +44,9 @@ pngerror.obj : png.h, pngconf.h
pngmem.obj : png.h, pngconf.h pngmem.obj : png.h, pngconf.h
pngrio.obj : png.h, pngconf.h pngrio.obj : png.h, pngconf.h
pngwio.obj : png.h, pngconf.h pngwio.obj : png.h, pngconf.h
pngtest.obj : png.h, pngconf.h
pngtrans.obj : png.h, pngconf.h pngtrans.obj : png.h, pngconf.h
pngwrite.obj : png.h, pngconf.h pngwrite.obj : png.h, pngconf.h
pngwtran.obj : png.h, pngconf.h pngwtran.obj : png.h, pngconf.h
pngwutil.obj : png.h, pngconf.h pngwutil.obj : png.h, pngconf.h
pngtest.obj : png.h, pngconf.h

Some files were not shown because too many files have changed in this diff Show More