Compare commits

..

12 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
352ca6bee0 Imported from libpng-1.0.4-pre3.tar 2009-04-06 16:04:34 -05:00
Glenn Randers-Pehrson
f8b008cd43 Imported from libpng-1.0.4-pre2.tar 2009-04-06 16:04:33 -05:00
Glenn Randers-Pehrson
4393a9ad6b Imported from libpng-1.0.4-pre1.tar 2009-04-06 16:04:32 -05:00
Glenn Randers-Pehrson
87544ac62b Imported from libpng-1.0.3.tar 2009-04-06 16:04:31 -05:00
Glenn Randers-Pehrson
c944229859 Imported from libpng-1.0.2b.tar 2009-04-06 16:04:30 -05:00
Glenn Randers-Pehrson
5c6aeb25c1 Imported from libpng-1.0.2a.tar 2009-04-06 16:04:29 -05:00
Glenn Randers-Pehrson
345bc27e70 Imported from libpng-1.0.2.tar 2009-04-06 16:04:28 -05:00
Glenn Randers-Pehrson
f7d1a17033 Imported from libpng-1.0.1e.tar 2009-04-06 16:04:27 -05:00
Glenn Randers-Pehrson
8686fff347 Imported from libpng-1.0.1d.tar 2009-04-06 16:04:26 -05:00
Glenn Randers-Pehrson
d0dce40075 Imported from libpng-1.0.1c.tar 2009-04-06 16:04:25 -05:00
Glenn Randers-Pehrson
1d96361273 Imported from libpng-1.0.1b.tar 2009-04-06 16:04:25 -05:00
Glenn Randers-Pehrson
896239be20 Imported from libpng-1.0.1a.tar 2009-04-06 16:04:24 -05:00
60 changed files with 10469 additions and 3433 deletions

57
ANNOUNCE Normal file
View File

@@ -0,0 +1,57 @@
Libpng 1.0.4 - September 18, 1999
This is a public release of libpng, intended for use in production codes.
Changes since the last public release (1.0.3):
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
if an attempt is made to read an interlaced image when it's not supported.
Added check if png_ptr->trans is defined before free'ing it in pngread.c
Modified the Y2K statement to include versions back to version 0.71
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
Replaced leading blanks with tab characters in makefile.hux
Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
Changed (float)red and (float)green to (double)red, (double)green
in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
Updated documentation to refer to the PNG-1.2 specification.
Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
in makefile.knr, INSTALL, and README (L. Peter Deutsch)
Fixed bugs in calculation of the length of rowbytes when adding alpha
channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
Added function png_set_user_transform_info() to store user_transform_ptr,
user_depth, and user_channels into the png_struct, and a function
png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
Added function png_set_empty_plte_permitted() to make libpng useable
in MNG applications.
Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
consistent with PNG-1.2, and allow variance of 500 before complaining.
Added assembler code contributed by Intel in file pngvcrd.c and modified
makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
Added makefile.beo for BEOS on X86, contributed by Sander Stok.
Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
Changed leading blanks to tabs in all makefiles.
Made alternate versions of png_set_expand() in pngrtran.c, namely
png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
(Greg Roelofs, in "PNG: The Definitive Guide").
Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
Revised calculation of num_blocks in pngmem.c to avoid a potentially
negative shift distance, whose results are undefined in the C language.
Added a check in pngset.c to prevent writing multiple tIME chunks.
Added a check in pngwrite.c to detect invalid small window_bits sizes.
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
Made several minor corrections to pngtest.c
Changed "hptr += 16L" to "hptr = hptr + 16L" in pngmem.c for Turbo 3.0
Renamed the makefiles with longer but more user friendly extensions
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
Glenn R-P

157
CHANGES
View File

@@ -283,6 +283,161 @@ version 1.0.0b [March 13, 1998]
Minor changes to makefile.s2x
Removed #ifdef/#endif around a png_free() in pngread.c
version 1.0.1 [March 14, 1998]
Changes makefile.s2x to reduce security risk of using a relative pathname
Changed makefile.s2x to reduce security risk of using a relative pathname
Fixed some typos in the documentation (Greg).
Fixed a problem with value of "channels" returned by png_read_update_info()
version 1.0.1a [April 21, 1998]
Optimized Paeth calculations by replacing abs() function calls with intrinsics
plus other loop optimizations. Improves avg decoding speed by about 20%.
Commented out i386istic "align" compiler flags in makefile.lnx.
Reduced the default warning level in some makefiles, to make them consistent.
Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
Added grayscale and 16-bit capability to png_do_read_filler().
Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
too large when writing an image with bit_depth < 8 (Bob Dellaca).
Corrected some bugs in the experimental weighted filtering heuristics.
Moved a misplaced pngrutil code block that truncates tRNS if it has more
than num_palette entries -- test was done before num_palette was defined.
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen).
version 1.0.1b [May 2, 1998]
Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
Relocated the png_composite macros from pngrtran.c to png.h (Greg).
Added makefile.sco (contributed by Mike Hopkirk).
Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert).
More work on loop optimization which may help when compiled with C++ compilers.
Added warnings when people try to use transforms they've defined out.
Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran.
Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg)
version 1.0.1c [May 11, 1998]
Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for
filler bytes should have been 0xff instead of 0xf.
Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images.
Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED
out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h
Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED,
for consistency, in pngconf.h
Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier
to remove unwanted capabilities via the compile line
Made some corrections to grammar (which, it's) in documentation (Greg).
Corrected example.c, use of row_pointers in png_write_image().
version 1.0.1d [May 24, 1998]
Corrected several statements that used side effects illegally in pngrutil.c
and pngtrans.c, that were introduced in version 1.0.1b
Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert)
More corrections to example.c, use of row_pointers in png_write_image()
and png_read_rows().
Added pngdll.mak and pngdef.pas to scripts directory, contributed by
Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
Changed several loops from count-down to count-up, for consistency.
version 1.0.1e [June 6, 1998]
Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
added warnings when people try to set png_read_fn and png_write_fn in
the same structure.
Added a test such that png_do_gamma will be done when num_trans==0
for truecolor images that have defined a background. This corrects an
error that was introduced in libpng-0.90 that can cause gamma processing
to be skipped.
Added tests in png.h to include "trans" and "trans_values" in structures
when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined.
Add png_free(png_ptr->time_buffer) in png_destroy_read_struct()
Moved png_convert_to_rfc_1123() from pngwrite.c to png.c
Added capability for user-provided malloc_fn() and free_fn() functions,
and revised pngtest.c to demonstrate their use, replacing the
PNGTEST_DEBUG_MEM feature.
Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
version 1.0.2 [June 14, 1998]
Fixed two bugs in makefile.bor .
version 1.0.2a [December 30, 1998]
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
the left-most pixel of each row (Kevin Bracey).
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
in pngtest.c (Duncan Simpson).
Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk
even when no tIME chunk was present in the source file.
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
Fixed a problem in png_read_push_finish_row(), which would not skip some
passes that it should skip, for images that are less than 3 pixels high.
Interchanged the order of calls to png_do_swap() and png_do_shift()
in pngwtran.c (John Cromer).
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
Fixed a documentation error about default filtering with 8-bit indexed-color.
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
(L. Peter Deutsch).
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
Added png_get_copyright() and png_get_header_version() functions.
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
Added information about debugging in libpng.txt and libpng.3 .
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
Removed lines after Dynamic Dependencies" in makefile.aco .
Revised makefile.dec to make a shared library (Jeremie Petit).
Removed trailing blanks from all files.
version 1.0.2a [January 6, 1999]
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
Changed "check_if_png" function in example.c to return true (nonzero) if PNG.
Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig()
which is obsolete.
version 1.0.3 [January 14, 1999]
Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice)
Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO.
version 1.0.3a [August 12, 1999]
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
if an attempt is made to read an interlaced image when it's not supported.
Added check if png_ptr->trans is defined before free'ing it in pngread.c
Modified the Y2K statement to include versions back to version 0.71
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
Replaced leading blanks with tab characters in makefile.hux
Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents.
Changed (float)red and (float)green to (double)red, (double)green
in png_set_rgb_to_gray() to avoid "promotion" problems in AIX.
Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey).
Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt).
Updated documentation to refer to the PNG-1.2 specification.
Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c
in makefile.knr, INSTALL, and README (L. Peter Deutsch)
Fixed bugs in calculation of the length of rowbytes when adding alpha
channels to 16-bit images, in pngrtran.c (Chris Nokleberg)
Added function png_set_user_transform_info() to store user_transform_ptr,
user_depth, and user_channels into the png_struct, and a function
png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg)
Added function png_set_empty_plte_permitted() to make libpng useable
in MNG applications.
Corrected the typedef for png_free_ptr in png.h (Jesse Jones).
Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be
consistent with PNG-1.2, and allow variance of 500 before complaining.
Added assembler code contributed by Intel in file pngvcrd.c and modified
makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant)
Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy.
Added some aliases for png_set_expand() in pngrtran.c, namely
png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS()
(Greg Roelofs, in "PNG: The Definitive Guide").
Added makefile.beo for BEOS on X86, contributed by Sander Stok.
version 1.0.3b [August 26, 1999]
Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h
Changed leading blanks to tabs in all makefiles.
Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code.
Made alternate versions of png_set_expand() in pngrtran.c, namely
png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha
(Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases.
Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h
Revised calculation of num_blocks in pngmem.c to avoid a potentially
negative shift distance, whose results are undefined in the C language.
Added a check in pngset.c to prevent writing multiple tIME chunks.
Added a check in pngwrite.c to detect invalid small window_bits sizes.
version 1.0.3d [September 4, 1999]
Fixed type casting of igamma in pngrutil.c
Added new png_expand functions to scripts/pngdef.pas and pngos2.def
Added a demo read_user_transform_fn that examines the row filters in pngtest.c
version 1.0.4 [September 18, 1999]
Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined
Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h
Made several minor corrections to pngtest.c
Renamed the makefiles with longer but more user friendly extensions

37
INSTALL
View File

@@ -1,5 +1,5 @@
Installing libpng version 1.0.1 March 15, 1998
Installing libpng version 1.0.4 - September 18, 1999
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be
@@ -10,8 +10,8 @@ zlib.h and zconf.h include files that correspond to the
version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.0.1 or "lpng100" and "zlib-1.1.1"
or "zlib111") so that you have directories called "zlib" and "libpng".
might be called "libpng-1.0.4" or "lpng103" and "zlib-1.1.3"
or "zlib113") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
@@ -40,27 +40,36 @@ include
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sun => Sun makefile
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
makefile.mip => MIPS makefile
makefile.aco => Acorn makefile
makefile.ama => Amiga makefile
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.4)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.4)
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.atr => Atari makefile
makefile.bor => Borland makefile
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.borland => Borland makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.tc3 => Turbo C 3.0 makefile
makefile.win32vc => makefile for Microsoft Visual C++ 4.0 and later
makefile.turboc3 => Turbo C 3.0 makefile
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
Copy the file (or files) that you need from the
scripts directory into this directory, for example

40
KNOWNBUG Normal file
View File

@@ -0,0 +1,40 @@
Known bugs and suggested enhancements in libpng-1.0.4
1. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
Loops need to be optimized everywhere
Make them count down instead of up -- Kevin Bracey
Optimizing compilers don't need this, and making
the change would be error prone -- Tom Lane, Glenn R-P
Question whether i-- or --i is better.
STATUS: Under investigation, postponed until after
libpng-1.0.4. About 160 loops will be turned around
in libpng-1.0.Nn, for testing.
2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
libpng-1.0.4 and earlier transform colors to gamma=1.0 space for
merging with background, and then back to the image's gamma. The
bit_depth of the intermediate (gamma=1.0) representation is probably
not sufficient. In the typical gamma=1/2.2 situation, the linear
pixels need about 4 more bits than the gamma-encoded ones, to avoid
loss of precision. A similar situation exists with the rgb_to_gray
operation.
STATUS: under development.
3. September 1999 -- ENHANCEMENT --
It should be possible to use libpng without floating-point aritmetic.
STATUS: Under investigation, implementation postponed until after
libpng-1.0.4. The application interface will change because replacements
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
functions will be needed.

52
README
View File

@@ -1,4 +1,4 @@
README for libpng 1.0.1 (shared library 2.1)
README for libpng 1.0.4 - September 18, 1999 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@@ -49,7 +49,7 @@ to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions
on the PNG implementation mailing list <png-implement@dworking.wustl.edu>
on the PNG implementation mailing list <png-implement@ccrc.wustl.edu>
and not on material submitted to Guy.
For a detailed description on using libpng, read libpng.txt. For
@@ -98,8 +98,8 @@ fix. Please mention "libpng" somewhere in the subject line. Thanks.
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.
randeg@alumni.rpi.edu
png-implement@dworkin.wustl.edu
randeg@alum.rpi.edu
png-implement@ccrc.wustl.edu
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
@@ -108,7 +108,7 @@ addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
the address in the specification (png-group@w3.org). At the same
time, please do not send libpng questions to that address, send them to me
or to png-implement@dworkin.wustl.edu. I'll
or to png-implement@ccrc.wustl.edu. I'll
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
to me. Send me any questions that start with "I was using libpng,
@@ -126,8 +126,6 @@ Files in this distribution:
CHANGES => Description of changes between libpng versions
README => This file
TODO => Things not implemented in the current library
ansi2knr.1 => Manual page for ansi2knr
ansi2knr.c => Converts files to K&R style function declarations
build.bat => MS-DOS batch file for Borland compiler
descrip.mms => VMS project file
example.c => Example code for using libpng functions
@@ -157,32 +155,44 @@ Files in this distribution:
scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost)
makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sun => Sun makefile
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0)
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0)
makefile.mip => MIPS makefile
makefile.aco => Acorn makefile
makefile.ama => Amiga makefile
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atr => Atari makefile
makefile.bor => Borland makefile
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng.so.2.1.0.4)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng.so.2.1.0.4)
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.borland => Borland makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.tc3 => Turbo C 3.0 makefile
makefile.win32vc => makefile for Microsoft Visual C++ 4.0 and later
makefile.turboc3 => Turbo C 3.0 makefile
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
makefile.wat => Watcom 10a+ Makefile, 32-bit flat memory model
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
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
Good luck, and happy coding.
-Glenn Randers-Pehrson
Internet: randeg@alumni.rpi.edu
Internet: randeg@alum.rpi.edu
Web: http://www.rpi.edu/~randeg/index.html
-Andreas Eric Dilger

44
TODO
View File

@@ -1,22 +1,24 @@
TODO - list of things to do for libpng
TODO - list of things to do for libpng:
fix problem with C++ and EXTERN "C"
add "grayscale->palette" transformation and "palette->grayscale" detection
add "grayscale" -> "grayscale+alpha" and "grayscale+FILLER" transformations
improved dithering
multi-lingual error and warning message support
sPLT chunk handling
cHRM transformation
complete sRGB transformation (presently it simply uses gamma=0.45)
man pages for function calls
high-level API for reading images
final bug fixes
better documentation
better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?)
optional palette creation
histogram creation
support for application-defined chunk handlers
keep up with public chunks
better C++ wrapper/full C++ implementation?
text conversion between different code pages (Latin-1 -> Mac and DOS)
Final bug fixes.
Fix problem with C++ and EXTERN "C".
Better C++ wrapper/full C++ implementation?
Keep up with public chunks.
sPLT chunk handling.
cHRM transformation.
Support for application-defined chunk handlers.
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
High-level API for reading images.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
Optional palette (sPLT) creation.
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr.
Make a no-floating-point version.

55
Y2KINFO Normal file
View File

@@ -0,0 +1,55 @@
Y2K compliance in libpng:
=========================
January 13, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.4 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer
that will hold years up to 65535. The other two hold the date in text
format, and will hold years up to 9999.
The integer is
"png_uint_16 year" in png_time_struct.
The strings are
"png_charp time_buffer" in png_struct and
"near_time_buffer", which is a local character string in png.c.
There are seven time-related functions:
png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
png_convert_from_time_t() in pngwrite.c
png_get_tIME() in pngget.c
png_handle_tIME() in pngrutil.c, called in pngread.c
png_set_tIME() in pngset.c
png_write_tIME() in pngwutil.c, called in pngwrite.c
All appear to handle dates properly in a Y2K environment. The
png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
function, or that they are incorrectly passing only a 2-digit year
instead of "year - 1900" into the png_convert_from_struct_tm() function,
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group

View File

@@ -1,36 +0,0 @@
.TH ANSI2KNR 1 "19 Jan 1996"
.SH NAME
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
.SH SYNOPSIS
.I ansi2knr
[--varargs] input_file [output_file]
.SH DESCRIPTION
If no output_file is supplied, output goes to stdout.
.br
There are no error messages.
.sp
.I ansi2knr
recognizes function definitions by seeing a non-keyword identifier at the left
margin, followed by a left parenthesis, with a right parenthesis as the last
character on the line, and with a left brace as the first token on the
following line (ignoring possible intervening comments). It will recognize a
multi-line header provided that no intervening line ends with a left or right
brace or a semicolon. These algorithms ignore whitespace and comments, except
that the function name must be the first thing on the line.
.sp
The following constructs will confuse it:
.br
- Any other construct that starts at the left margin and follows the
above syntax (such as a macro or function call).
.br
- Some macros that tinker with the syntax of the function header.
.sp
The --varargs switch is obsolete, and is recognized only for
backwards compatibility. The present version of
.I ansi2knr
will always attempt to convert a ... argument to va_alist and va_dcl.
.SH AUTHOR
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
continues to maintain the current version; most of the code in the current
version is his work. ansi2knr also includes contributions by Francois
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.

View File

@@ -1,693 +0,0 @@
/* ansi2knr.c */
/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
/*
ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY. No author or distributor accepts responsibility to anyone for the
consequences of using it or for whether it serves any particular purpose or
works at all, unless he says so in writing. Refer to the GNU General Public
License (the "GPL") for full details.
Everyone is granted permission to copy, modify and redistribute ansi2knr,
but only under the conditions described in the GPL. A copy of this license
is supposed to have been given to you along with ansi2knr so you can know
your rights and responsibilities. It should be in a file named COPYLEFT.
[In the IJG distribution, the GPL appears below, not in a separate file.]
Among other things, the copyright notice and this notice must be preserved
on all copies.
We explicitly state here what we believe is already implied by the GPL: if
the ansi2knr program is distributed as a separate set of sources and a
separate executable file which are aggregated on a storage medium together
with another program, this in itself does not bring the other program under
the GPL, nor does the mere fact that such a program or the procedures for
constructing it invoke the ansi2knr executable bring any other part of the
program under the GPL.
*/
/*
---------- Here is the GNU GPL file COPYLEFT, referred to above ----------
----- These terms do NOT apply to the JPEG software itself; see README ------
GHOSTSCRIPT GENERAL PUBLIC LICENSE
(Clarified 11 Feb 1988)
Copyright (C) 1988 Richard M. Stallman
Everyone is permitted to copy and distribute verbatim copies of this
license, but changing it is not allowed. You can also use this wording
to make the terms for other programs.
The license agreements of most software companies keep you at the
mercy of those companies. By contrast, our general public license is
intended to give everyone the right to share Ghostscript. To make sure
that you get the rights we want you to have, we need to make
restrictions that forbid anyone to deny you these rights or to ask you
to surrender the rights. Hence this license agreement.
Specifically, we want to make sure that you have the right to give
away copies of Ghostscript, that you receive source code or else can get
it if you want it, that you can change Ghostscript or use pieces of it
in new free programs, and that you know you can do these things.
To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies of Ghostscript, 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 tell them their rights.
Also, for our own protection, we must make certain that everyone finds
out that there is no warranty for Ghostscript. If Ghostscript is
modified by someone else and passed on, we want its recipients to know
that what they have is not what we distributed, so that any problems
introduced by others will not reflect on our reputation.
Therefore we (Richard M. Stallman and the Free Software Foundation,
Inc.) make the following terms which say what you must do to be allowed
to distribute or change Ghostscript.
COPYING POLICIES
1. You may copy and distribute verbatim copies of Ghostscript source
code as you receive it, in any medium, provided that you conspicuously
and appropriately publish on each copy a valid copyright and license
notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc." (or with whatever year is
appropriate); keep intact the notices on all files that refer to this
License Agreement and to the absence of any warranty; and give any other
recipients of the Ghostscript program a copy of this License Agreement
along with the program. You may charge a distribution fee for the
physical act of transferring a copy.
2. You may modify your copy or copies of Ghostscript or any portion of
it, and copy and distribute such modifications under the terms of
Paragraph 1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating
that you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish,
that in whole or in part contains or is a derivative of Ghostscript
or any part thereof, to be licensed at no charge to all third
parties on terms identical to those contained in this License
Agreement (except that you may choose to grant more extensive
warranty protection to some or all third parties, at your option).
c) You may charge a distribution fee for the physical act of
transferring a copy, and you may at your option offer warranty
protection in exchange for a fee.
Mere aggregation of another unrelated program with this program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other program under the scope of these terms.
3. You may copy and distribute Ghostscript (or a portion or derivative
of it, under Paragraph 2) in object code or executable form under the
terms of Paragraphs 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
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal
shipping charge) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
For an executable file, complete source code means all the source code for
all modules it contains; but, as a special exception, it need not include
source code for modules which are standard libraries that accompany the
operating system on which the executable file runs.
4. You may not copy, sublicense, distribute or transfer Ghostscript
except as expressly provided under this License Agreement. Any attempt
otherwise to copy, sublicense, distribute or transfer Ghostscript is
void and your rights to use the program under this License agreement
shall be automatically terminated. However, parties who have received
computer software programs from you with this License Agreement will not
have their licenses terminated so long as such parties remain in full
compliance.
5. If you wish to incorporate parts of Ghostscript into other free
programs whose distribution conditions are different, write to the Free
Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not
yet worked out a simple rule that can be stated here, but we will often
permit this. We 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.
Your comments and suggestions about our licensing policies and our
software are welcome! Please contact the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
NO WARRANTY
BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD
M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES
PROVIDE GHOSTSCRIPT "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 GHOSTSCRIPT IS WITH
YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN
ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE
GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING
ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM
BY ANY OTHER PARTY.
-------------------- End of file COPYLEFT ------------------------------
*/
/*
* Usage:
ansi2knr input_file [output_file]
* If no output_file is supplied, output goes to stdout.
* There are no error messages.
*
* ansi2knr recognizes function definitions by seeing a non-keyword
* identifier at the left margin, followed by a left parenthesis,
* with a right parenthesis as the last character on the line,
* and with a left brace as the first token on the following line
* (ignoring possible intervening comments).
* It will recognize a multi-line header provided that no intervening
* line ends with a left or right brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
* The following constructs will confuse it:
* - Any other construct that starts at the left margin and
* follows the above syntax (such as a macro or function call).
* - Some macros that tinker with the syntax of the function header.
*/
/*
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with
compilers that don't understand void, as suggested by
Tom Lane
lpd 96-01-15 changed to require that the first non-comment token
on the line following a function header be a left brace,
to reduce sensitivity to macros, as suggested by Tom Lane
<tgl@sss.pgh.pa.us>
lpd 95-06-22 removed #ifndefs whose sole purpose was to define
undefined preprocessor symbols as 0; changed all #ifdefs
for configuration symbols to #ifs
lpd 95-04-05 changed copyright notice to make it clear that
including ansi2knr in a program does not bring the entire
program under the GPL
lpd 94-12-18 added conditionals for systems where ctype macros
don't handle 8-bit characters properly, suggested by
Francois Pinard <pinard@iro.umontreal.ca>;
removed --varargs switch (this is now the default)
lpd 94-10-10 removed CONFIG_BROKETS conditional
lpd 94-07-16 added some conditionals to help GNU `configure',
suggested by Francois Pinard <pinard@iro.umontreal.ca>;
properly erase prototype args in function parameters,
contributed by Jim Avera <jima@netcom.com>;
correct error in writeblanks (it shouldn't erase EOLs)
lpd 89-xx-xx original version
*/
/* Most of the conditionals here are to make ansi2knr work with */
/* or without the GNU configure machinery. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <ctype.h>
#if HAVE_CONFIG_H
/*
For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
This will define HAVE_CONFIG_H and so, activate the following lines.
*/
# if STDC_HEADERS || HAVE_STRING_H
# include <string.h>
# else
# include <strings.h>
# endif
#else /* not HAVE_CONFIG_H */
/* Otherwise do it the hard way */
# ifdef BSD
# include <strings.h>
# else
# ifdef VMS
extern int strlen(), strncmp();
# else
# include <string.h>
# endif
# endif
#endif /* not HAVE_CONFIG_H */
#if STDC_HEADERS
# include <stdlib.h>
#else
/*
malloc and free should be declared in stdlib.h,
but if you've got a K&R compiler, they probably aren't.
*/
# ifdef MSDOS
# include <malloc.h>
# else
# ifdef VMS
extern char *malloc();
extern void free();
# else
extern char *malloc();
extern int free();
# endif
# endif
#endif
/*
* The ctype macros don't always handle 8-bit characters correctly.
* Compensate for this here.
*/
#ifdef isascii
# undef HAVE_ISASCII /* just in case */
# define HAVE_ISASCII 1
#else
#endif
#if STDC_HEADERS || !HAVE_ISASCII
# define is_ascii(c) 1
#else
# define is_ascii(c) isascii(c)
#endif
#define is_space(c) (is_ascii(c) && isspace(c))
#define is_alpha(c) (is_ascii(c) && isalpha(c))
#define is_alnum(c) (is_ascii(c) && isalnum(c))
/* Scanning macros */
#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
/* Forward references */
char *skipspace();
int writeblanks();
int test1();
int convert1();
/* The main program */
int
main(argc, argv)
int argc;
char *argv[];
{ FILE *in, *out;
#define bufsize 5000 /* arbitrary size */
char *buf;
char *line;
char *more;
/*
* In previous versions, ansi2knr recognized a --varargs switch.
* If this switch was supplied, ansi2knr would attempt to convert
* a ... argument to va_alist and va_dcl; if this switch was not
* supplied, ansi2knr would simply drop any such arguments.
* Now, ansi2knr always does this conversion, and we only
* check for this switch for backward compatibility.
*/
int convert_varargs = 1;
if ( argc > 1 && argv[1][0] == '-' )
{ if ( !strcmp(argv[1], "--varargs") )
{ convert_varargs = 1;
argc--;
argv++;
}
else
{ fprintf(stderr, "Unrecognized switch: %s\n", argv[1]);
exit(1);
}
}
switch ( argc )
{
default:
printf("Usage: ansi2knr input_file [output_file]\n");
exit(0);
case 2:
out = stdout;
break;
case 3:
out = fopen(argv[2], "w");
if ( out == NULL )
{ fprintf(stderr, "Cannot open output file %s\n", argv[2]);
exit(1);
}
}
in = fopen(argv[1], "r");
if ( in == NULL )
{ fprintf(stderr, "Cannot open input file %s\n", argv[1]);
exit(1);
}
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
buf = malloc(bufsize);
line = buf;
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
{
test: line += strlen(line);
switch ( test1(buf) )
{
case 2: /* a function header */
convert1(buf, out, 1, convert_varargs);
break;
case 1: /* a function */
/* Check for a { at the start of the next line. */
more = ++line;
f: if ( line >= buf + (bufsize - 1) ) /* overflow check */
goto wl;
if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
goto wl;
switch ( *skipspace(more, 1) )
{
case '{':
/* Definitely a function header. */
convert1(buf, out, 0, convert_varargs);
fputs(more, out);
break;
case 0:
/* The next line was blank or a comment: */
/* keep scanning for a non-comment. */
line += strlen(line);
goto f;
default:
/* buf isn't a function header, but */
/* more might be. */
fputs(buf, out);
strcpy(buf, more);
line = buf;
goto test;
}
break;
case -1: /* maybe the start of a function */
if ( line != buf + (bufsize - 1) ) /* overflow check */
continue;
/* falls through */
default: /* not a function */
wl: fputs(buf, out);
break;
}
line = buf;
}
if ( line != buf )
fputs(buf, out);
free(buf);
fclose(out);
fclose(in);
return 0;
}
/* Skip over space and comments, in either direction. */
char *
skipspace(p, dir)
register char *p;
register int dir; /* 1 for forward, -1 for backward */
{ for ( ; ; )
{ while ( is_space(*p) )
p += dir;
if ( !(*p == '/' && p[dir] == '*') )
break;
p += dir; p += dir;
while ( !(*p == '*' && p[dir] == '/') )
{ if ( *p == 0 )
return p; /* multi-line comment?? */
p += dir;
}
p += dir; p += dir;
}
return p;
}
/*
* Write blanks over part of a string.
* Don't overwrite end-of-line characters.
*/
int
writeblanks(start, end)
char *start;
char *end;
{ char *p;
for ( p = start; p < end; p++ )
if ( *p != '\r' && *p != '\n' )
*p = ' ';
return 0;
}
/*
* Test whether the string in buf is a function definition.
* The string may contain and/or end with a newline.
* Return as follows:
* 0 - definitely not a function definition;
* 1 - definitely a function definition;
* 2 - definitely a function prototype (NOT USED);
* -1 - may be the beginning of a function definition,
* append another line and look again.
* The reason we don't attempt to convert function prototypes is that
* Ghostscript's declaration-generating macros look too much like
* prototypes, and confuse the algorithms.
*/
int
test1(buf)
char *buf;
{ register char *p = buf;
char *bend;
char *endfn;
int contin;
if ( !isidfirstchar(*p) )
return 0; /* no name at left margin */
bend = skipspace(buf + strlen(buf) - 1, -1);
switch ( *bend )
{
case ';': contin = 0 /*2*/; break;
case ')': contin = 1; break;
case '{': return 0; /* not a function */
case '}': return 0; /* not a function */
default: contin = -1;
}
while ( isidchar(*p) )
p++;
endfn = p;
p = skipspace(p, 1);
if ( *p++ != '(' )
return 0; /* not a function */
p = skipspace(p, 1);
if ( *p == ')' )
return 0; /* no parameters */
/* Check that the apparent function name isn't a keyword. */
/* We only need to check for keywords that could be followed */
/* by a left parenthesis (which, unfortunately, is most of them). */
{ static char *words[] =
{ "asm", "auto", "case", "char", "const", "double",
"extern", "float", "for", "if", "int", "long",
"register", "return", "short", "signed", "sizeof",
"static", "switch", "typedef", "unsigned",
"void", "volatile", "while", 0
};
char **key = words;
char *kp;
int len = endfn - buf;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
return 0; /* name is a keyword */
key++;
}
}
return contin;
}
/* Convert a recognized function definition or header to K&R syntax. */
int
convert1(buf, out, header, convert_varargs)
char *buf;
FILE *out;
int header; /* Boolean */
int convert_varargs; /* Boolean */
{ char *endfn;
register char *p;
char **breaks;
unsigned num_breaks = 2; /* for testing */
char **btop;
char **bp;
char **ap;
char *vararg = 0;
/* Pre-ANSI implementations don't agree on whether strchr */
/* is called strchr or index, so we open-code it here. */
for ( endfn = buf; *(endfn++) != '('; )
;
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
if ( breaks == 0 )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(buf, out);
return -1;
}
btop = breaks + num_breaks * 2 - 2;
bp = breaks;
/* Parse the argument list */
do
{ int level = 0;
char *lp = NULL;
char *rp;
char *end = NULL;
if ( bp >= btop )
{ /* Filled up break table. */
/* Allocate a bigger one and start over. */
free((char *)breaks);
num_breaks <<= 1;
goto top;
}
*bp++ = p;
/* Find the end of the argument */
for ( ; end == NULL; p++ )
{ switch(*p)
{
case ',':
if ( !level ) end = p;
break;
case '(':
if ( !level ) lp = p;
level++;
break;
case ')':
if ( --level < 0 ) end = p;
else rp = p;
break;
case '/':
p = skipspace(p, 1) - 1;
break;
default:
;
}
}
/* Erase any embedded prototype parameters. */
if ( lp )
writeblanks(lp + 1, rp);
p--; /* back up over terminator */
/* Find the name being declared. */
/* This is complicated because of procedure and */
/* array modifiers. */
for ( ; ; )
{ p = skipspace(p - 1, -1);
switch ( *p )
{
case ']': /* skip array dimension(s) */
case ')': /* skip procedure args OR name */
{ int level = 1;
while ( level )
switch ( *--p )
{
case ']': case ')': level++; break;
case '[': case '(': level--; break;
case '/': p = skipspace(p, -1) + 1; break;
default: ;
}
}
if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
{ /* We found the name being declared */
while ( !isidfirstchar(*p) )
p = skipspace(p, 1) + 1;
goto found;
}
break;
default:
goto found;
}
}
found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
{ if ( convert_varargs )
{ *bp++ = "va_alist";
vararg = p-2;
}
else
{ p++;
if ( bp == breaks + 1 ) /* sole argument */
writeblanks(breaks[0], p);
else
writeblanks(bp[-1] - 1, p);
bp--;
}
}
else
{ while ( isidchar(*p) ) p--;
*bp++ = p+1;
}
p = end;
}
while ( *p++ == ',' );
*bp = p;
/* Make a special check for 'void' arglist */
if ( bp == breaks+2 )
{ p = skipspace(breaks[0], 1);
if ( !strncmp(p, "void", 4) )
{ p = skipspace(p+4, 1);
if ( p == breaks[2] - 1 )
{ bp = breaks; /* yup, pretend arglist is empty */
writeblanks(breaks[0], p + 1);
}
}
}
/* Put out the function name and left parenthesis. */
p = buf;
while ( p != endfn ) putc(*p, out), p++;
/* Put out the declaration. */
if ( header )
{ fputs(");", out);
for ( p = breaks[0]; *p; p++ )
if ( *p == '\r' || *p == '\n' )
putc(*p, out);
}
else
{ for ( ap = breaks+1; ap < bp; ap += 2 )
{ p = *ap;
while ( isidchar(*p) )
putc(*p, out), p++;
if ( ap < bp - 1 )
fputs(", ", out);
}
fputs(") ", out);
/* Put out the argument declarations */
for ( ap = breaks+2; ap <= bp; ap += 2 )
(*ap)[-1] = ';';
if ( vararg != 0 )
{ *vararg = 0;
fputs(breaks[0], out); /* any prior args */
fputs("va_dcl", out); /* the final arg */
fputs(bp[0], out);
}
else
fputs(breaks[0], out);
}
free((char *)breaks);
return 0;
}

View File

@@ -15,8 +15,11 @@
#include "png.h"
/* Check to see if a file is a PNG file using png_sig_cmp(). Returns
* non-zero if the image is a PNG, and 0 if it isn't a PNG.
/* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp()
* returns zero if the image is a PNG and nonzero if it isn't a PNG.
*
* The function check_if_png() shown here, but not used, returns nonzero (true)
* if the file can be opened and is a PNG, 0 (false) otherwise.
*
* If this call is successful, and you are going to keep the file open,
* you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once
@@ -41,12 +44,14 @@ int check_if_png(char *file_name, FILE **fp)
if ((*fp = fopen(file_name, "rb")) != NULL);
return 0;
/* Read in the signature bytes */
/* Read in some of the signature bytes */
if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)
return 0;
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. */
return(png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
Return nonzero (true) if they match */
return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));
}
/* Read a PNG file. You may want to return an error code if the read
@@ -83,7 +88,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
* was compiled with a compatible version of the library. REQUIRED
*/
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
@@ -146,7 +151,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr);
/* Strip alpha bytes from the input data without combining with th
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
png_set_strip_alpha(png_ptr);
@@ -221,10 +226,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_sRGB(png_ptr, intent, 0);
else
{
double image_gamma;
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.50);
png_set_gamma(png_ptr, screen_gamma, 0.45455);
}
/* Dither RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
@@ -316,18 +324,18 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
#ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++)
{
png_bytep row_pointers = row[y];
png_read_rows(png_ptr, &row_pointers, NULL, 1);
png_read_rows(png_ptr, &row_pointers[y], NULL, 1);
}
#else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows)
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows);
png_read_rows(png_ptr, NULL, row_pointers[y], number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, row_pointers, number_of_rows);
png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows);
#endif no_sparkle /* use only one of these two methods */
}
@@ -362,7 +370,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
* linked libraries.
*/
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (*png_ptr == NULL)
{
@@ -384,8 +392,11 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
return ERROR;
}
/* this one's new. You will need to provide all three
/* This one's new. You will need to provide all three
* function callbacks, even if you aren't using them all.
* If you aren't using all functions, you can specify NULL
* parameters. Even when all three functions are NULL,
* you need to call png_set_progressive_read_fn().
* These functions shouldn't be dependent on global or
* static variables if you are decoding several images
* simultaneously. You should store stream specific data
@@ -498,7 +509,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* in case we are using dynamically linked libraries. REQUIRED.
*/
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
(void *)user_error_ptr, user_error_fn, user_warning_fn);
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
if (png_ptr == NULL)
{
@@ -581,7 +592,7 @@ void write_png(char *file_name /* , ... other image information ... */)
text_ptr[2].key = "Description";
text_ptr[2].text = "<long text>";
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
png_set_text(png_ptr, info_ptr, text_ptr, 2);
png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
/* note that if sRGB is present the cHRM chunk must be ignored
@@ -638,7 +649,11 @@ void write_png(char *file_name /* , ... other image information ... */)
* layout, however, so choose what fits your needs best). You need to
* use the first method if you aren't handling interlacing yourself.
*/
png_byte row_pointers[height][width];
png_uint_32 k, height, width;
png_byte image[height][width];
png_bytep row_pointers[height];
for (k = 0; k < height; k++)
row_pointers[k] = image + k*width;
/* One of the following output methods is REQUIRED */
#ifdef entire /* write out the entire image data in one call */
@@ -653,13 +668,12 @@ void write_png(char *file_name /* , ... other image information ... */)
for (pass = 0; pass < number_passes; pass++)
{
/* Write a few rows at a time. */
png_write_rows(png_ptr, row_pointers, number_of_rows);
png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);
/* If you are only writing one row at a time, this works */
for (y = 0; y < height; y++)
{
png_bytep row_pointers = row[y];
png_write_rows(png_ptr, &row_pointers, 1);
png_write_rows(png_ptr, &row_pointers[y], 1);
}
}
#endif no_entire /* use only one output method */

1137
libpng.3

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.1 March 15, 1998
libpng version 1.0.4 - September 18, 1999
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
@@ -22,7 +22,8 @@ libpng.txt - A description on how to use and modify libpng
Copyright (c) 1995 Frank J. T. Wojcik
December 18, 1995 && January 20, 1996
Introduction
*
I. Introduction
This file describes how to use and modify the PNG reference library
(known as libpng) for your own use. There are five sections to this
@@ -35,12 +36,19 @@ INSTALL file for instructions on how to install libpng.
Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs. The PNG specification is available
file format in application programs.
The PNG-1.2 specification is available at <http://www.cdrom.com/png>.
The PNG-1.0 specification is available
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
additional chunks are described in the special-purpose public chunks
documents at <ftp://ftp.uu.net/graphics/png/documents/>. Other information
about PNG can be found at the PNG home page, <http://www.cdrom.com/pub/png/>.
documents at <ftp://ftp.uu.net/graphics/png/documents/>.
Other information
about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.cdrom.com/pub/png/>.
Most users will not have to modify the library significantly; advanced
users may want to modify it more. All attempts were made to make it as
@@ -57,6 +65,8 @@ work to be done (see the TODO file), libpng should cover the
majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@@ -126,7 +136,7 @@ Customizing libpng.
return;
}
fread(header, 1, number, fp);
is_png = png_check_sig(header, 0, number);
is_png = !png_sig_cmp(header, 0, number);
if (!is_png)
{
return;
@@ -143,7 +153,7 @@ be NULL if the default error handlers are to be used). See the section
on Changes to Libpng below regarding the old initialization functions.
png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn);
if (!png_ptr)
return;
@@ -164,12 +174,23 @@ on Changes to Libpng below regarding the old initialization functions.
return;
}
If you want to use your own memory allocation routines,
define PNG_USER_MEM_SUPPORTED and use
png_create_read_struct_2() instead of png_create_read_struct():
The error handling routines passed to png_create_read_struct() are only
necessary if you are not using the libpng supplied error handling
functions. When libpng encounters an error, it expects to longjmp back
to your routine. Therefore, you will need to call setjmp and pass the
jmpbuf field of your png_struct. If you read the file from different
png_structp png_ptr = png_create_read_struct_2
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn, (png_voidp)
user_mem_ptr, user_malloc_fn, user_free_fn);
The error handling routines passed to png_create_read_struct()
and the memory alloc/free routines passed to png_create_struct_2()
are only necessary if you are not using the libpng supplied error
handling and memory alloc/free functions.
When libpng encounters an error, it expects to longjmp back
to your routine. Therefore, you will need to call setjmp and pass
your png_ptr->jmpbuf. If you read the file from different
routines, you will need to update the jmpbuf field every time you enter
a new routine that will call a png_ function.
@@ -247,6 +268,21 @@ You must supply the function
See pngtest.c for a working example. Your function will be called
after all of the other transformations have been processed.
You can also set up a pointer to a user structure for use by your
callback function, and you can inform libpng that your transform
function will change the number of channels or bit depth with the
function
png_set_user_transform_info(png_ptr, user_ptr,
user_depth, user_channels);
You can retrieve the pointer via the function
png_get_user_transform_ptr(). For example:
voidp read_user_transform_ptr =
png_get_user_transform_ptr(png_ptr);
You are now ready to read all the file information up to the actual
image data. You do this with a call to png_read_info().
@@ -476,11 +512,14 @@ unless the library has been told to transform it into another format.
For example, 4 bit/pixel paletted or grayscale data will be returned
2 pixels/byte with the leftmost pixel in the high-order bits of the
byte, unless png_set_packing() is called. 8-bit RGB data will be stored
in RGBRGBRGB format unless png_set_filler() is called to insert filler
in RGB RGB RGB format unless png_set_filler() is called to insert filler
bytes, either before or after each RGB triplet. 16-bit RGB data will
be returned RRGGBBRRGGBB, with the most significant byte of the color
be returned RRGGBB RRGGBB, with the most significant byte of the color
value first, unless png_set_strip_16() is called to transform it to
regular RGBRGB triplets.
regular RGB RGB triplets, or png_set_filler() is called to insert
filler bytes, either before or after each RRGGBB triplet. Similarly,
8-bit or 16-bit grayscale data can be modified with png_set_filler()
or png_set_strip_16().
The following code transforms grayscale images of less than 8 to 8 bits,
changes paletted images to RGB, and adds a full alpha channel if there is
@@ -489,13 +528,18 @@ grayscale images with bit depths of 2 or 4 or if there is a multiple-image
viewing application that wishes to treat all images in the same way.
if (color_type == PNG_COLOR_TYPE_PALETTE &&
bit_depth <= 8) png_set_expand(png_ptr);
bit_depth <= 8) png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY &&
bit_depth < 8) png_set_expand(png_ptr);
bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr,
PNG_INFO_tRNS)) png_set_expand(png_ptr);
PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
These three functions are actually aliases for png_set_expand(), added
in libpng version 1.0.4, with the function names expanded to improve code
readability. In some future version they may actually do different
things.
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.
@@ -556,7 +600,7 @@ into 4 bytes for windowing systems that need them in this format:
PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr,
filler, PNG_FILLER_BEFORE);
where "filler" is the number to fill with, and the location is
where "filler" is the 8 or 16-bit number to fill with, and the location is
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
you want the filler before the RGB or after. This transformation
does not affect images that already have full alpha channels.
@@ -574,21 +618,77 @@ RGB. This code will do that conversion:
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
If you have a grayscale and you are using png_set_expand() to change to
a higher bit-depth you must indicate if the supplied background gray
is supplied in the original file bit depth (need_expand = 1) or in the
expanded bit depth (need_expand = 0). Similarly, if you are reading
a paletted image, you must indicate if you have supplied the background
as a palette index that needs to be expanded (need_expand = 1). You can
also specify an RGB triplet that isn't in the palette when setting your
background for a paletted image.
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
with alpha. This is intended for conversion of images that really are
gray (red == green == blue), so the function simply strips out the red
and blue channels, leaving the green channel in the gray position.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
double red_weight, double green_weight);
error_action = 1: silently do the conversion
error_action = 2: issue a warning if the original
image has any pixel where
red != green or red != blue
error_action = 3: issue an error and abort the
conversion if the original
image has any pixel where
red != green or red != blue
red_weight: weight of red component
(NULL -> default 54/256)
green_weight: weight of green component
(NULL -> default 183/256)
If you have set error_action = 1 or 2, you can
later check whether the image really was gray, after processing
the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
It will return a png_byte that is zero if the image was gray or
1 if there were any non-gray pixels. bKGD and sBIT data
will be silently converted to grayscale, using the green channel
data, regardless of the error_action setting.
With 0.0<=red_weight+green_weight<=1.0,
the normalized graylevel is computed:
int rw = red_weight * 256;
int gw = green_weight * 256;
int bw = 256 - (rw + gw);
gray = (rw*red + gw*green + bw*blue)/256;
The default values approximate those recommended in the Charles
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng approximates this with
Y = 0.211 * R + 0.715 * G + 0.074 * B
which can be expressed with integers as
Y = (54 * R + 183 * G + 19 * B)/256
The calculation is done in a linear colorspace, if the image gamma
is known.
If you have a grayscale and you are using png_set_expand_depth() or
png_set_expand() to change to
a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the
background color as an RGB triplet at the final, expanded bit depth
(need_expand = 0). Similarly, if you are reading a paletted image, you
must either supply the background color as a palette index (need_expand = 1)
or as an RGB triplet that may or may not be in the palette (need_expand = 0).
png_color_16 my_background;
png_color_16p image_background;
if (png_get_bKGD(png_ptr, info_ptr,
&image_background))
png_set_background(png_ptr, image_background),
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
@@ -609,6 +709,8 @@ the amount of additional gamma correction needed to compensate for
a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
compensation other than the display_gamma is needed (viewing_gamma=1.0).
double gamma, screen_gamma;
if (/* We have a user-defined screen
gamma value */)
{
@@ -619,7 +721,7 @@ compensation other than the display_gamma is needed (viewing_gamma=1.0).
else if ((gamma_str = getenv("SCREEN_GAMMA"))
!= NULL)
{
screen_gamma = atof(gamma_str);
screen_gamma = (double)atof(gamma_str);
}
/* If we don't have another value */
else
@@ -635,7 +737,7 @@ compensation other than the display_gamma is needed (viewing_gamma=1.0).
The png_set_gamma() function handles gamma transformations of the data.
Pass both the file gamma and the current screen_gamma. If the file does
not have a gamma value, you can pass one anyway if you have an idea what
it is (usually 0.50 is a good guess for GIF images on PCs). Note
it is (usually 0.45455 is a good guess for GIF images on PCs). Note
that file gammas are inverted from screen gammas. See the discussions
on gamma in the PNG specification for an excellent description of what
gamma is, and why all applications should support it. It is strongly
@@ -644,7 +746,7 @@ recommended that PNG viewers support gamma correction.
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
png_set_gamma(png_ptr, screen_gamma, gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.50);
png_set_gamma(png_ptr, screen_gamma, 0.45455);
If you need to reduce an RGB file to a paletted file, or if a paletted
file has more entries then will fit on your screen, png_set_dither()
@@ -759,7 +861,7 @@ row_pointers:
png_read_row(png_ptr, &row_pointers, NULL);
If the file is interlaced (info_ptr->interlace_type != 0), things get
somewhat harder. The only current (PNG Specification version 1.0)
somewhat harder. The only current (PNG Specification version 1.2)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
is a somewhat complicated 2D interlace scheme, known as Adam7, that
breaks down an image into seven smaller images of varying size, based
@@ -872,7 +974,7 @@ png_infop info_ptr;
initialize_png_reader()
{
png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn);
if (!png_ptr)
return -1;
@@ -895,7 +997,9 @@ png_infop info_ptr;
to be called when the header info is valid,
when each row is completed, and when the image
is finished. If you aren't using all functions,
you can specify a NULL parameter. You can use
you can specify NULL parameters. Even when all
three functions are NULL, you need to call
png_set_progressive_read_fn(). You can use
any struct as the user_ptr (cast to a void pointer
for the function call), and retrieve the pointer
from inside the callbacks using the function
@@ -941,7 +1045,7 @@ png_infop info_ptr;
}
/* This function is called (as set by
png_set_progressive_fn() above) when enough data
png_set_progressive_read_fn() above) when enough data
has been supplied so all of the header has been
read.
*/
@@ -991,8 +1095,8 @@ png_infop info_ptr;
new_row);
/* where old_row is what was displayed for
previous rows. Note that the first pass
(pass == 0, really) will completely cover
previously for the row. Note that the first
pass (pass == 0, really) will completely cover
the old row, so the rows do not have to be
initialized. After the first pass (and only
for interlaced images), you will have to pass
@@ -1044,7 +1148,7 @@ both "png_ptr"; you can call them anything you like, such as
"read_ptr" and "write_ptr". Look at pngtest.c, for example.
png_structp png_ptr = png_create_write_struct
(PNG_LIBPNG_VER_STRING, (void *)user_error_ptr,
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn);
if (!png_ptr)
return;
@@ -1057,10 +1161,19 @@ both "png_ptr"; you can call them anything you like, such as
return;
}
If you want to use your own memory allocation routines,
define PNG_USER_MEM_SUPPORTED and use
png_create_write_struct_2() instead of png_create_read_struct():
png_structp png_ptr = png_create_write_struct_2
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn, (png_voidp)
user_mem_ptr, user_malloc_fn, user_free_fn);
After you have these structures, you will need to set up the
error handling. When libpng encounters an error, it expects to
longjmp() back to your routine. Therefore, you will need to call
setjmp and pass the jmpbuf field of your png_struct. If you
setjmp() and pass the png_ptr->jmpbuf. If you
write the file from different routines, you will need to update
the jmpbuf field every time you enter a new routine that will
call a png_ function. See your documentation of setjmp/longjmp
@@ -1074,6 +1187,8 @@ section below for more information on the libpng error handling.
fclose(fp);
return;
}
...
return;
Now you need to set up the output code. The default for libpng is to
use the C function fwrite(). If you use this, you will need to pass a
@@ -1109,10 +1224,10 @@ have no special needs in this area, let the library do what it wants by
not calling this function at all, as it has been tuned to deliver a good
speed/compression ratio. The second parameter to png_set_filter() is
the filter method, for which the only valid value is '0' (as of the
October 1996 PNG specification, version 1.0). The third parameter is a
flag that indicates
which filter type(s) are to be tested for each scanline. See the
Compression Library for details on the specific filter types.
July 1999 PNG specification, version 1.2). The third parameter is a
flag that indicates which filter type(s) are to be tested for each
scanline. See the Compression Library for details on the specific filter
types.
/* turn on or off filtering, and/or choose
@@ -1141,7 +1256,7 @@ data. See the Compression Library for details on the compression levels.
You now need to fill in the png_info structure with all the data you
wish to write before the actual image. Note that the only thing you
are allowed to write after the image is the text chunks and the time
chunk (as of PNG Specification 1.0, anyway). See png_write_end() and
chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
the latest PNG specification for more information on that. If you
wish to write them before the image, fill them in now, and flag that
data as being valid. If you want to wait until after the data, don't
@@ -1304,7 +1419,7 @@ png_text structure holds a keyword-text value, and a compression type.
The compression types have the same valid numbers as the compression
types of the image data. Currently, the only valid number is zero.
However, you can store text either compressed or uncompressed, unlike
images which always have to be compressed. So if you don't want the
images, which always have to be compressed. So if you don't want the
text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
Until text gets around 1000 bytes, it is not worth compressing it.
After the text has been written out to the file, the compression type
@@ -1364,7 +1479,7 @@ depending on whether you mean the PNG file, the time the image was
created in a non-PNG format, a still photo from which the image was
scanned, or possibly the subject matter itself. In order to facilitate
machine-readable dates, it is recommended that the "Creation Time"
tEXt chunk use RFC 1123 format dates (e.g. 22 May 1997 18:07:10 GMT"),
tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function
@@ -1386,8 +1501,9 @@ checks to see if it has data that it can do something with, you should
make sure to only enable a transformation if it will be valid for the
data. For example, don't swap red and blue on grayscale data.
PNG files store RGB pixels packed into 3 bytes. This code tells
the library to expect input data with 4 bytes per pixel
PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
the library to expand the input data to 4 or 8 bytes per pixel
(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
@@ -1469,7 +1585,21 @@ You must supply the function
row_info, png_bytep data)
See pngtest.c for a working example. Your function will be called
before any of the other transformations have been processed.
before any of the other transformations are processed.
You can also set up a pointer to a user structure for use by your
callback function.
png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
The user_channels and user_depth parameters of this function are ignored
when writing; you can set them to zero as shown.
You can retrieve the pointer via the function
png_get_user_transform_ptr(). For example:
voidp write_user_transform_ptr =
png_get_user_transform_ptr(png_ptr);
It is possible to have libpng flush any pending output, either manually,
or automatically after a certain number of lines have been written. To
@@ -1505,11 +1635,11 @@ times, or any of that other stuff necessary with png_write_rows().
where row_pointers is:
png_bytef *row_pointers[height];
png_byte *row_pointers[height];
You can point to void or char or whatever you use for pixels.
If you can't want to write the whole image at once, you can
If you don't want to write the whole image at once, you can
use png_write_rows() instead. If the file is not interlaced,
this is simple:
@@ -1526,8 +1656,8 @@ row_pointers:
png_write_row(png_ptr, &row_pointer);
When the file is interlaced, things can get a good deal more
complicated. The only currently (as of February 1998 -- PNG Specification
version 1.0, dated October 1996) defined interlacing scheme for PNG files
complicated. The only currently (as of August 1999 -- PNG Specification
version 1.2, dated July 1999) defined interlacing scheme for PNG files
is the "Adam7" interlace scheme, that breaks down an
image into seven smaller images of varying size. libpng will build
these images for you, or you can do them yourself. If you want to
@@ -1572,7 +1702,6 @@ palette, or histogram, before the call to png_destroy_write_struct();
For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng:
There are two issues here. The first is changing how libpng does
@@ -1581,7 +1710,7 @@ The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works.
All of the memory allocation, input/output, and error handling in libpng
goes through callbacks which are user settable. The default routines are
goes through callbacks that are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
these functions, call the appropriate png_set_???_fn() function.
@@ -1599,18 +1728,20 @@ 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
the method of I/O, the library supplies callbacks that you can set
through the function png_set_read_fn() and png_set_write_fn() at run
time, instead of calling the png_init_io() function. These functions
time, instead of calling the png_init_io() function.
These functions
also provide a void pointer that can be retrieved via the function
png_get_io_ptr(). For example:
png_set_read_fn(png_structp png_ptr,
voidp io_ptr, png_rw_ptr read_data_fn)
png_set_read_fn(png_structp read_ptr,
voidp read_io_ptr, png_rw_ptr read_data_fn)
png_set_write_fn(png_structp png_ptr,
voidp io_ptr, png_rw_ptr write_data_fn,
png_set_write_fn(png_structp write_ptr,
voidp write_io_ptr, png_rw_ptr write_data_fn,
png_flush_ptr output_flush_fn);
voidp io_ptr = png_get_io_ptr(png_ptr);
voidp read_io_ptr = png_get_io_ptr(read_ptr);
voidp write_io_ptr = png_get_io_ptr(write_ptr);
The replacement I/O functions should have prototypes as follows:
@@ -1689,7 +1820,7 @@ won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Configuring for DOS:
For DOS users which only have access to the lower 640K, you will
For DOS users who only have access to the lower 640K, you will
have to limit zlib's memory usage via a png_set_compression_mem_level()
call. See zlib.h or zconf.h in the zlib library for more information.
@@ -1701,7 +1832,7 @@ defined, and FAR gets defined to far in pngconf.h, and you should be
all set. Everything in the library (except for zlib's structure) is
expecting far data. You must use the typedefs with the p or pp on
the end for pointers (or at least look at them and be careful). Make
note that the row's of data are defined as png_bytepp which is a
note that the row's of data are defined as png_bytepp, which is an
unsigned char far * far *.
Configuring for gui/windowing platforms:
@@ -1761,11 +1892,11 @@ can call one of these functions. The selection and configuration
of row filters can have a significant impact on the size and
encoding speed and a somewhat lesser impact on the decoding speed
of an image. Filtering is enabled by default for RGB and grayscale
images (with and without alpha), and for 8-bit paletted images, but
not for paletted images with bit depths less than 8 bits/pixel.
images (with and without alpha), but not for paletted images nor
for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.0 specification. The 'filters'
currently only '0' in the PNG 1.2 specification. The 'filters'
parameter sets which filter(s), if any, should be used for each
scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
to turn filtering on and off, respectively.
@@ -1797,10 +1928,10 @@ by telling it the relative computational costs of the filters.
PNG_FILTER_SELECTION_WEIGHTED, 3,
weights, costs);
The weights are multiplying factors which indicate to libpng that row
should be the same for successive rows unless another row filter is that
many times better than the previous filter. In the above example, if
the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
The weights are multiplying factors that indicate to libpng that the
row filter should be the same for successive rows unless another row filter
is that many times better than the previous filter. In the above example,
if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
"sum of absolute differences" 1.5 x 1.3 times higher than other filters
and still be chosen, while the NONE filter could have a sum 1.1 times
higher than other filters and still be chosen. Unspecified weights are
@@ -1823,19 +1954,23 @@ Removing unwanted object code:
There are a bunch of #define's in pngconf.h that control what parts of
libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use an ability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space.
You can also turn a number of them off en masse with a compiler directive
that defines PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED, or
PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED, or all four,
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
PNG_NO_.
You can also turn all of the transforms and ancillary chunk capabilities
off en masse with compiler directives that define
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
or all four,
along with directives to turn on any of the capabilities that you do
want. The PNG_READ[or WRITE]_TRANSFORMS_NOT_SUPPORTED directives disable
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
the extra transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks [except for sPLT].
Use of the PNG_READ[or WRITE]_ANCILLARY_CHUNKS_NOT_SUPPORTED directive
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
produces a library that is incapable of reading or writing ancillary chunks.
If you are not using the progressive reading capability, you can
turn that off with PNG_PROGRESSIVE_READ_NOT_SUPPORTED (don't confuse
turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
this with the INTERLACING capability, which you'll still have).
All the reading and writing specific code are in separate files, so the
@@ -1851,10 +1986,46 @@ or DLL file), you should not remove or disable any parts of the library,
as this will cause applications linked with different versions of the
library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections which are actually used will be loaded into memory.
those sections that are actually used will be loaded into memory.
Requesting debug printout:
Changes to Libpng from version 0.88
The macro definition PNG_DEBUG can be used to request debugging
printout. Set it to an integer value in the range 0 to 3. Higher
numbers result in increasing amounts of debugging information. The
information is printed to the "stderr" file, unless another file
name is specified in the PNG_DEBUG_FILE macro definition.
When PNG_DEBUG > 0, the following functions (macros) become available:
png_debug(level, message)
png_debug1(level, message, p1)
png_debug2(level, message, p1, p2)
in which "level" is compared to PNG_DEBUG to decide whether to print
the message, "message" is the formatted string to be printed,
and p1 and p2 are parameters that are to be embedded in the string
according to printf-style formatting directives. For example,
png_debug1(2, "foo=%d\n", foo);
is expanded to
if(PNG_DEBUG > 2)
fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
can still use PNG_DEBUG to control your own debugging:
#ifdef PNG_DEBUG
fprintf(stderr, ...
#endif
When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
VI. Changes to Libpng from version 0.88
It should be noted that versions of libpng later than 0.96 are not
distributed by the original libpng author, Guy Schalnat, nor by
@@ -1880,10 +2051,64 @@ allocating and freeing the png_struct for each image read.
Setting the error callbacks via png_set_message_fn() before
png_read_init() as was suggested in libpng-0.88 is no longer supported
because this caused applications which do not use custom error functions
because this caused applications that do not use custom error functions
to fail if the png_ptr was not initialized to zero. It is still possible
to set the error callbacks AFTER png_read_init(), or to change them with
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 method.
VII. Y2K Compliance in libpng
January 13, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.4 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that
will hold years up to 65535. The other two hold the date in text
format, and will hold years up to 9999.
The integer is
"png_uint_16 year" in png_time_struct.
The strings are
"png_charp time_buffer" in png_struct and
"near_time_buffer", which is a local character string in png.c.
There are seven time-related functions:
png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
png_convert_from_time_t() in pngwrite.c
png_get_tIME() in pngget.c
png_handle_tIME() in pngrutil.c, called in pngread.c
png_set_tIME() in pngset.c
png_write_tIME() in pngwutil.c, called in pngwrite.c
All appear to handle dates properly in a Y2K environment. The
png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
function, or that they are incorrectly passing only a 2-digit year
instead of "year - 1900" into the png_convert_from_struct_tm() function,
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group

View File

@@ -1,334 +1,497 @@
.TH LIBPNGPF 3 "March 15, 1998"
.TH LIBPNGPF 3 "September 18, 1999"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4 - September 18, 1999
(private functions)
.SH SYNOPSIS
#include <png.h>
\fB#include <png.h>\fP
void png_build_gamma_table (png_structp png_ptr);
\fI\fB
void png_build_grayscale_palette (int bit_depth, png_colorp
palette);
\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP
void png_calculate_crc (png_structp png_ptr, png_bytep ptr,
png_size_t length);
void png_check_chunk_name (png_structp png_ptr, png_bytep
chunk_name);
\fI\fB
png_size_t png_check_keyword (png_structp png_ptr, png_charp
key, png_charpp new_key);
\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP
void png_combine_row (png_structp png_ptr, png_bytep row, int
mask);
\fI\fB
void png_correct_palette (png_structp png_ptr, png_colorp
palette, int num_palette);
\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP
int png_crc_error (png_structp png_ptr);
\fI\fB
int png_crc_finish (png_structp png_ptr, png_uint_32 skip);
\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
void png_crc_read (png_structp png_ptr, png_bytep buf,
png_size_t length);
\fI\fB
png_voidp png_create_struct (int type);
\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP
void png_destroy_struct (png_voidp struct_ptr);
\fI\fB
void png_do_background (png_row_infop row_info, png_bytep row,
png_color_16p trans_values, png_color_16p background,
png_color_16p background_1, png_bytep gamma_table, png_bytep
gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16,
png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int
gamma_shift);
\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP
void png_do_bgr (png_row_infop row_info, png_bytep row);
\fI\fB
void png_do_chop (png_row_infop row_info, png_bytep row);
\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP
void png_do_dither (png_row_infop row_info, png_bytep row,
png_bytep palette_lookup, png_bytep dither_lookup);
\fI\fB
void png_do_expand (png_row_infop row_info, png_bytep row,
png_color_16p trans_value);
\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP
void png_do_expand_palette (png_row_infop row_info, png_bytep
row, png_colorp palette, png_bytep trans, int num_trans);
\fI\fB
void png_do_gamma (png_row_infop row_info, png_bytep row,
png_bytep gamma_table, png_uint_16pp gamma_16_table, int
gamma_shift);
\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP
void png_do_gray_to_rgb (png_row_infop row_info, png_bytep
row);
\fI\fB
void png_do_invert (png_row_infop row_info, png_bytep row);
\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP
void png_do_pack (png_row_infop row_info, png_bytep row,
png_uint_32 bit_depth);
\fI\fB
void png_do_packswap (png_row_infop row_info, png_bytep row);
\fBpng_voidp png_create_struct (int \fP\fItype\fP\fB, png_malloc_ptr \fImalloc_fn\fP\fB);\fP
void png_do_read_filler (png_row_infop row_info, png_bytep row,
png_uint_32 filler, png_uint_32 flags);
\fI\fB
void png_do_read_interlace (png_row_infop row_info, png_bytep
row, int pass, png_uint_32 transformations);
\fBpng_voidp png_create_struct_2 (int \fItype\fP\fB);\fP
void png_do_read_invert_alpha (png_row_infop row_info,
png_bytep row);
\fI\fB
void png_do_read_swap_alpha (png_row_infop row_info, png_bytep
row);
\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
void png_do_read_transformations (png_structp png_ptr);
\fI\fB
void png_do_rgb_to_gray (png_row_infop row_info, png_bytep
row);
\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
void png_do_shift (png_row_infop row_info, png_bytep row,
png_color_8p bit_depth);
\fI\fB
void png_do_strip_filler (png_row_infop row_info, png_bytep
row, png_uint_32 flags);
\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP
void png_do_swap (png_row_infop row_info, png_bytep row);
\fI\fB
void png_do_unpack (png_row_infop row_info, png_bytep row);
\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_do_unshift (png_row_infop row_info, png_bytep row,
png_color_8p sig_bits);
\fI\fB
void png_do_write_interlace (png_row_infop row_info, png_bytep
row, int pass);
\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_do_write_invert_alpha (png_row_infop row_info,
png_bytep row);
\fI\fB
void png_do_write_swap_alpha (png_row_infop row_info, png_bytep
row);
\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP
void png_do_write_transformations (png_structp png_ptr);
\fI\fB
void *png_far_to_near (png_structp png_ptr,png_voidp ptr,
int check);
\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP
void png_flush (png_structp png_ptr);
\fI\fB
png_int_32 png_get_int_32 (png_bytep buf);
\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP
png_uint_16 png_get_uint_16 (png_bytep buf);
\fI\fB
png_uint_32 png_get_uint_32 (png_bytep buf);
\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP
void png_handle_bKGD (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_cHRM (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_handle_gAMA (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_hIST (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_handle_IEND (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_IHDR (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP
void png_handle_oFFs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_pCAL (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_handle_pHYs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_PLTE (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
void png_handle_sBIT (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_sRGB (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP
void png_handle_tEXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_tIME (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_handle_tRNS (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_handle_zTXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
\fI\fB
void png_info_destroy (png_structp png_ptr, png_infop
info_ptr);
\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
void png_init_read_transformations (png_structp png_ptr);
\fI\fB
void png_process_IDAT_data (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_process_some_data (png_structp png_ptr, png_infop
info_ptr);
\fI\fB
void png_push_check_crc (png_structp png_ptr);
\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP
void png_push_crc_finish (png_structp png_ptr);
\fI\fB
void png_push_crc_skip (png_structp png_ptr, png_uint_32
length);
\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
void png_push_fill_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t length);
\fI\fB
void png_push_handle_tEXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_push_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
\fI\fB
void png_push_handle_zTXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_push_have_end (png_structp png_ptr, png_infop
info_ptr);
\fI\fB
void png_push_have_info (png_structp png_ptr, png_infop
info_ptr);
\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP
void png_push_have_row (png_structp png_ptr, png_bytep row);
\fI\fB
void png_push_process_row (png_structp png_ptr);
\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP
void png_push_read_chunk (png_structp png_ptr, png_infop
info_ptr);
\fI\fB
void png_push_read_end (png_structp png_ptr, png_infop
info_ptr);
\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_push_read_IDAT (png_structp png_ptr);
\fI\fB
void png_push_read_sig (png_structp png_ptr, png_infop
info_ptr);
\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
void png_push_read_tEXt (png_structp png_ptr, png_infop
info_ptr);
\fI\fB
void png_push_read_zTXt (png_structp png_ptr, png_infop
info_ptr);
\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP
void png_push_restore_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
\fI\fB
void png_push_save_buffer (png_structp png_ptr);
\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP
void png_read_data (png_structp png_ptr, png_bytep data,
png_size_t length);
\fI\fB
void png_read_filter_row (png_structp png_ptr, png_row_infop
row_info, png_bytep row, png_bytep prev_row, int filter);
\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP
void png_read_finish_row (png_structp png_ptr);
\fI\fB
void png_read_init (png_structp png_ptr);
\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
void png_read_push_finish_row (png_structp png_ptr);
\fI\fB
void png_read_start_row (png_structp png_ptr);
\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
void png_read_transform_info (png_structp png_ptr, png_infop
info_ptr);
\fI\fB
void png_reset_crc (png_structp png_ptr);
\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
void png_save_int_32 (png_bytep buf, png_int_32 i);
\fI\fB
void png_save_uint_16 (png_bytep buf, unsigned int i);
\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_save_uint_32 (png_bytep buf, png_uint_32 i);
\fI\fB
void png_write_bKGD (png_structp png_ptr, png_color_16p values,
int color_type);
\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_cHRM (png_structp png_ptr, double white_x,
double white_y, double red_x, double red_y, double green_x,
double green_y, double blue_x, double blue_y);
\fI\fB
void png_write_data (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_write_filtered_row (png_structp png_ptr, png_bytep
filtered_row);
\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_find_filter (png_structp png_ptr, png_row_infop
row_info);
\fI\fB
void png_write_finish_row (png_structp png_ptr);
\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_gAMA (png_structp png_ptr, double file_gamma);
\fI\fB
void png_write_hIST (png_structp png_ptr, png_uint_16p hist,
int num_hist);
\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_init (png_structp png_ptr);
\fI\fB
void png_write_IDAT (png_structp png_ptr, png_bytep data,
png_size_t length);
\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_IEND (png_structp png_ptr);
\fI\fB
void png_write_IHDR (png_structp png_ptr, png_uint_32 width,
png_uint_32 height, int bit_depth, int color_type, int
compression_type, int filter_type, int interlace_type);
\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_oFFs (png_structp png_ptr, png_uint_32 x_offset,
png_uint_32 y_offset, int unit_type);
\fI\fB
void png_write_pCAL (png_structp png_ptr, png_charp purpose,
png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp
units, png_charpp params);
\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_pHYs (png_structp png_ptr, png_uint_32
x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int
unit_type);
\fI\fB
void png_write_PLTE (png_structp png_ptr, png_colorp palette,
png_uint_32 num_pal);
\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_sBIT (png_structp png_ptr, png_color_8p sbit,
int color_type);
\fI\fB
void png_write_sig (png_structp png_ptr);
\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_sRGB (png_structp png_ptr, int intent);
\fI\fB
void png_write_start_row (png_structp png_ptr);
\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_tEXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len);
\fI\fB
void png_write_tIME (png_structp png_ptr, png_timep mod_time);
\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
void png_write_tRNS (png_structp png_ptr, png_bytep trans,
png_color_16p values, int number, int color_type);
\fI\fB
void png_write_zTXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len, int compression);
\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
voidpf png_zalloc (voidpf png_ptr, uInt items, uInt size);
\fI\fB
void png_zfree (voidpf png_ptr, voidpf ptr);
\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
\fI\fB
\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
\fI\fB
\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
\fI\fB
\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP
\fI\fB
\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
\fI\fB
\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
\fI\fB
\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
\fI\fB
\fBvoid png_write_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fIcolor_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
\fI\fB
\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
\fI\fB
\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP
\fI\fB
\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
\fI\fB
\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP
\fI\fB
\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP
\fI\fB
\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP
\fI\fB
\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP
\fI\fB
\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP
\fI\fB
\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
\fI\fB
\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP
\fI\fB
\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP
\fI\fB
\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
\fI\fB
\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
\fI\fB
.SH DESCRIPTION
The functions listed above are used privately by libpng

22
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "March 15, 1998"
.TH PNG 5 "September 18, 1999"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@@ -20,7 +20,14 @@ platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
.LP
PNG specification:
PNG 1.1 specification, January 1999:
.IP
.br
http://www.cdrom.com/pub/png
.LP
PNG 1.0 specification, October 1996:
.IP
.br
RFC 2083
.IP
.br
@@ -32,12 +39,19 @@ http://www.w3.org/TR/REC-png.html
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
Glenn Randers-Pehrson and others (png-list@ccrc.wustl.edu).
.LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list@dworkin.wustl.edu).
Thomas Boutell and others (png-list@ccrc.wustl.edu).
.LP
.SH COPYRIGHT NOTICE
The PNG specification is copyright (c) 1996 Massachussets Institute of
The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
See the specification for conditions of use and distribution.
.LP
The PNG-1.0 specification is copyright (c) 1996 Massachussets Institute of
Technology. See the specification for conditions of use and distribution.
.LP
.\" end of man page

83
png.c
View File

@@ -1,12 +1,11 @@
/* png.c - location for general purpose libpng functions
*
* libpng 1.0.1
* For conditions of distribution and use, see copyright notice in png.h
* libpng version 1.0.4 - September 18, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
*/
#define PNG_INTERNAL
@@ -16,7 +15,8 @@
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
char png_libpng_ver[12] = "1.0.1";
char png_libpng_ver[12] = "1.0.4";
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@@ -115,8 +115,8 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
}
/* (Obsolete) function to check signature bytes. It does not allow one
* to check a partial signature. This function will be removed in the
* future - use png_sig_cmp().
* to check a partial signature. This function might be removed in the
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
*/
int
png_check_sig(png_bytep sig, int num)
@@ -128,12 +128,10 @@ png_check_sig(png_bytep sig, int num)
voidpf
png_zalloc(voidpf png_ptr, uInt items, uInt size)
{
png_voidp ptr;
png_uint_32 num_bytes;
png_uint_32 num_bytes = (png_uint_32)items * size;
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
num_bytes = (png_uint_32)items * size;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
if (num_bytes > (png_uint_32)0x8000)
if (num_bytes > (png_uint_32)0x8000L)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
@@ -201,7 +199,12 @@ png_create_info_struct(png_structp png_ptr)
png_debug(1, "in png_create_info_struct\n");
if(png_ptr == NULL) return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
png_ptr->malloc_fn)) != NULL)
#else
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
#endif
{
png_info_init(info_ptr);
}
@@ -227,7 +230,11 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
{
png_info_destroy(png_ptr, info_ptr);
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn);
#else
png_destroy_struct((png_voidp)info_ptr);
#endif
*info_ptr_ptr = (png_infop)NULL;
}
}
@@ -252,11 +259,10 @@ void
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
{
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
int i;
png_debug(1, "in png_info_destroy\n");
if (info_ptr->text != NULL)
{
int i;
for (i = 0; i < info_ptr->num_text; i++)
{
png_free(png_ptr, info_ptr->text[i].key);
@@ -269,6 +275,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
png_free(png_ptr, info_ptr->pcal_units);
if (info_ptr->pcal_params != NULL)
{
int i;
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{
png_free(png_ptr, info_ptr->pcal_params[i]);
@@ -302,3 +309,51 @@ png_init_io(png_structp png_ptr, FILE *fp)
png_ptr->io_ptr = (png_voidp)fp;
}
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
/* Convert the supplied time into an RFC 1123 string suitable for use in
* a "Creation Time" or other text-based time string.
*/
png_charp
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
{
static PNG_CONST char short_months[12][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
if (png_ptr->time_buffer == NULL)
{
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
sizeof(char)));
}
#ifdef USE_FAR_KEYWORD
{
char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
png_memcpy(png_ptr->time_buffer, near_time_buf,
29*sizeof(char));
}
#else
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
#endif
return ((png_charp)png_ptr->time_buffer);
}
#endif /* PNG_TIME_RFC1123_SUPPORTED */
png_charp
png_get_copyright(png_structp png_ptr)
{
if(png_ptr == NULL)
/* silence compiler warning about unused png_ptr */ ;
return("\n libpng version 1.0.4 - September 18, 1999\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
}

371
png.h
View File

@@ -1,12 +1,70 @@
/* png.h - header file for PNG reference library
*
* libpng 1.0.1
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
* libpng version 1.0.4 - September 18, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998 Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.0.4 - September 18, 1999: Glenn R-P
* See also "Contributing Authors", below.
*
* Y2K compliance in libpng:
* =========================
*
* January 13, 1999
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.0.4 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
* that will hold years up to 65535. The other two hold the date in text
* format, and will hold years up to 9999.
*
* The integer is
* "png_uint_16 year" in png_time_struct.
*
* The strings are
* "png_charp time_buffer" in png_struct and
* "near_time_buffer", which is a local character string in png.c.
*
* There are seven time-related functions:
* png.c: png_convert_to_rfc_1123() in png.c
* (formerly png_convert_to_rfc_1152() in error)
* png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
* png_convert_from_time_t() in pngwrite.c
* png_get_tIME() in pngget.c
* png_handle_tIME() in pngrutil.c, called in pngread.c
* png_set_tIME() in pngset.c
* png_write_tIME() in pngwutil.c, called in pngwrite.c
*
* All handle dates properly in a Y2K environment. The
* png_convert_from_time_t() function calls gmtime() to convert from system
* clock time, which returns (year - 1900), which we properly convert to
* the full 4-digit year. There is a possibility that applications using
* libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
* function, or that they are incorrectly passing only a 2-digit year
* instead of "year - 1900" into the png_convert_from_struct_tm() function,
* but this is not under our control. The libpng documentation has always
* stated that it works with 4-digit years, and the APIs have been
* documented as such.
*
* The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
* integer to hold the year, and can hold years as large as 65535.
*
* zlib, upon which libpng depends, is also Y2K compliant. It contains
* no date-related code.
*
* Glenn Randers-Pehrson
* libpng maintainer
* PNG Development Group
*
* Note about libpng version numbers:
*
@@ -18,7 +76,7 @@
*
* source png.h png.h shared-lib
* version string int version
* ------- ------ ------ ----------
* ------- ------ ----- ----------
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
@@ -31,17 +89,23 @@
* 1.00 1.00 100 2.1.0 [int should be 10000]
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
* 1.0.1 1.0.1 10001 2.1.0
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
* 1.0.2 1.0.2 10002 2.1.0.2
* 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b
* 1.0.3 1.0.3 10003 2.1.0.3
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
* 1.0.4 1.0.4 10004 2.1.0.4
*
* Henceforth the source version will match the shared-library minor
* and patch numbers; the shared-library major version number will be
* used for changes in backward compatibility, as it is intended.
* The PNG_PNGLIB_VER macro, which is not used within libpng but
* is available for applications, is an unsigned integer of the form
* xyyzz corresponding to the source version x.y.z (leading zeros in y and z).
* used for changes in backward compatibility, as it is intended. The
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
* for applications, is an unsigned integer of the form xyyzz corresponding
* to the source version x.y.z (leading zeros in y and z). Internal
* png-group versions (x.y.z[a-z]) will be given the next higher number.
*
*
* See libpng.txt for more information. The PNG specification is available
* as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
*
* Contributing Authors:
@@ -68,6 +132,13 @@
*
* COPYRIGHT NOTICE:
*
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
* Copyright (c) 1996, 1997 Andreas Dilger
* (libpng versions 0.90, December 1996, through 0.96, May 1997)
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* (libpng versions 0.97, January 1998, through 1.0.4 - September 18, 1999)
*
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
* and Group 42, Inc. disclaim all warranties, expressed or implied,
* including, without limitation, the warranties of merchantability and of
@@ -92,13 +163,10 @@
* appreciated.
*/
#ifndef _PNG_H
#define _PNG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This is not the place to learn how to use libpng. The file libpng.txt
* describes how to use libpng, and the file example.c summarizes it
* with some code on which to build. This file is useful for looking
@@ -111,6 +179,11 @@ extern "C" {
/* include all user configurable info */
#include "pngconf.h"
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This file is arranged in several sections. The first section contains
* structure and type definitions. The second section contains the external
* library functions, while the third has the internal library functions,
@@ -118,14 +191,14 @@ extern "C" {
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.1"
#define PNG_LIBPNG_VER_STRING "1.0.4"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
#define PNG_LIBPNG_VER 10001 /* 1.0.1 */
#define PNG_LIBPNG_VER 10004 /* 1.0.4 */
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
@@ -145,6 +218,7 @@ extern int FARDATA png_pass_dsp_mask[7];
extern int FARDATA png_pass_width[7];
extern int FARDATA png_pass_height[7];
*/
#endif /* PNG_NO_EXTERN */
/* Three color definitions. The order of the red, green, and blue, (and the
@@ -231,7 +305,7 @@ typedef png_time FAR * FAR * png_timepp;
* With libpng < 0.95, it was only possible to directly set and read the
* the values in the png_info_struct, which meant that the contents and
* order of the values had to remain fixed. With libpng 0.95 and later,
* however, * there are now functions which abstract the contents of
* however, there are now functions that abstract the contents of
* png_info_struct from the application, so this makes it easier to use
* libpng with dynamic libraries, and even makes it possible to use
* libraries that don't have all of the libpng ancillary chunk-handing
@@ -289,14 +363,14 @@ typedef struct png_info_struct
/* The tEXt and zTXt chunks contain human-readable textual data in
* uncompressed and compressed forms, respectively. The data in "text"
* is an array of pointers to uncompressed, null-terminated C strings.
* Each chunk has a keyword which describes the textual data contained
* Each chunk has a keyword that describes the textual data contained
* in that chunk. Keywords are not required to be unique, and the text
* string may be empty. Any number of text chunks may be in an image.
*/
int num_text; /* number of comments read/to write */
int max_text; /* current size of text array */
png_textp text; /* array of comments read/to write */
#endif /* PNG_READ_tEXt/zTXt_SUPPORTED || PNG_WRITE_tEXt/zTXt_SUPPORTED */
#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
/* The tIME chunk holds the last time the displayed image data was
* modified. See the png_time struct for the contents of this struct.
@@ -312,14 +386,15 @@ typedef struct png_info_struct
*/
png_color_8 sig_bit; /* significant bits in color channels */
#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
/* The tRNS chunk supplies transparency data for paletted images and
* other image types that don't need a full alpha channel. There are
* "num_trans" transparency values for a paletted image, stored in the
* same order as the palette colors, starting from index 0. Values
* for the data are in the range [0, 255], ranging from fully transparent
* to fully opaque, respectively. For non-paletted images, there is a
* single color specified which should be treated as fully transparent.
* single color specified that should be treated as fully transparent.
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
*/
png_bytep trans; /* transparent values for paletted image */
@@ -404,6 +479,9 @@ typedef struct png_info_struct
typedef png_info FAR * png_infop;
typedef png_info FAR * FAR * png_infopp;
/* Maximum positive integer used in PNG is (2^31)-1 */
#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
/* These describe the color_type field in png_info. */
/* color type masks */
#define PNG_COLOR_MASK_PALETTE 1
@@ -417,11 +495,11 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
/* This is for compression type. PNG 1.0 only defines the single type. */
/* This is for compression type. PNG 1.0-1.2 only define the single type. */
#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
/* This is for filter type. PNG 1.0 only defines the single type. */
/* This is for filter type. PNG 1.0-1.2 only define the single type. */
#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
@@ -491,10 +569,11 @@ typedef struct png_row_info_struct
typedef png_row_info FAR * png_row_infop;
typedef png_row_info FAR * FAR * png_row_infopp;
/* These are the function types for the I/O functions, and the functions which
* modify the default I/O functions to user I/O functions. The png_error_ptr
* type should match that of user supplied warning and error functions, while
* the png_rw_ptr type should match that of the user read/write data functions.
/* These are the function types for the I/O functions and for the functions
* that allow the user to override the default I/O functions with his or her
* own. The png_error_ptr type should match that of user-supplied warning
* and error functions, while the png_rw_ptr type should match that of the
* user read/write data functions.
*/
typedef struct png_struct_def png_struct;
typedef png_struct FAR * png_structp;
@@ -517,6 +596,9 @@ typedef void (*png_user_transform_ptr) PNGARG((png_structp,
png_row_infop, png_bytep));
#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
/* The structure that holds the information to read and write PNG files.
* The only people who need to care about what is inside of this are the
* people who will be modifying the library for their own special needs.
@@ -533,12 +615,19 @@ struct png_struct_def
png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr read_user_transform_fn; /* user read transform */
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp user_transform_ptr; /* user supplied struct for user transform */
int user_transform_depth; /* bit depth of user transformed pixels */
int user_transform_channels; /* channels in user transformed pixels */
#endif
png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */
@@ -589,7 +678,7 @@ struct png_struct_def
png_byte sig_bytes; /* magic bytes read/written from start of file */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_byte filler; /* filler byte for 24->32-bit pixel expansion */
png_uint_16 filler; /* filler bytes for pixel expansion */
#endif /* PNG_READ_FILLER_SUPPORTED */
#if defined(PNG_READ_bKGD_SUPPORTED)
png_byte background_gamma_type;
@@ -604,16 +693,16 @@ struct png_struct_def
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
png_uint_32 flush_rows; /* number of rows written since last flush */
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
#if defined(PNG_READ_GAMMA_SUPPORTED)
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
float gamma; /* file gamma value */
float screen_gamma; /* screen gamma value (display_gamma/viewing_gamma */
#endif /* PNG_READ_GAMMA_SUPPORTED */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8 bit depth files */
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_bytep gamma_from_1; /* converts from 1.0 to screen */
png_bytep gamma_to_1; /* converts from file to 1.0 */
png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
@@ -623,10 +712,11 @@ struct png_struct_def
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans; /* transparency values for paletted files */
png_color_16 trans_values; /* transparency values for non-paletted files */
#endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */
#endif /* PNG_READ|WRITE_tRNS_SUPPORTED||PNG_READ_EXPAND|BACKGROUND_SUPPORTED */
png_read_status_ptr read_row_fn; /* called after each row is decoded */
png_write_status_ptr write_row_fn; /* called after each row is encoded */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@@ -679,6 +769,21 @@ struct png_struct_def
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_charp time_buffer; /* String to hold RFC 1123 time text */
#endif /* PNG_TIME_RFC1123_SUPPORTED */
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte rgb_to_gray_status;
png_byte rgb_to_gray_red_coeff;
png_byte rgb_to_gray_green_coeff;
png_byte rgb_to_gray_blue_coeff;
#endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
png_byte empty_plte_permitted;
#endif
};
typedef png_struct FAR * FAR * png_structpp;
@@ -710,14 +815,25 @@ extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
extern PNG_EXPORT(png_structp,png_create_read_struct)
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn));
/* Allocate and initialize png_ptr struct for reading, and any other memory */
/* Allocate and initialize png_ptr struct for writing, and any other memory */
extern PNG_EXPORT(png_structp,png_create_write_struct)
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn));
#ifdef PNG_USER_MEM_SUPPORTED
extern PNG_EXPORT(png_structp,png_create_read_struct_2)
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn));
extern PNG_EXPORT(png_structp,png_create_write_struct_2)
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn));
#endif
/* Write a PNG chunk - size, type, (optional) data, CRC. */
extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
png_bytep chunk_name, png_bytep data, png_size_t length));
@@ -764,8 +880,11 @@ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
#endif /* PNG_WRITE_tIME_SUPPORTED */
#if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha if available. */
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_EXPAND_SUPPORTED */
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
@@ -774,13 +893,16 @@ extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* Expand the grayscale to 24 bit RGB if necessary. */
/* Expand the grayscale to 24-bit RGB if necessary. */
extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
/* Reduce RGB to grayscale. (Not yet implemented) */
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr));
/* Reduce RGB to grayscale. */
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
int error_action, double red, double green ));
extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
png_ptr));
#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
@@ -811,19 +933,19 @@ extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swap bytes in 16 bit depth files. */
/* Swap bytes in 16-bit depth files. */
extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* Swap packing order of pixels in bytes. */
extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPOR */
#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPORTED */
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
/* Converts files to legal bit depths. */
@@ -854,7 +976,7 @@ extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
#if defined(PNG_READ_16_TO_8_SUPPORTED)
/* strip the second byte of information from a 16 bit depth file. */
/* strip the second byte of information from a 16-bit depth file. */
extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
#endif /* PNG_READ_16_TO_8_SUPPORTED */
@@ -871,6 +993,13 @@ extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
double screen_gamma, double default_file_gamma));
#endif /* PNG_READ_GAMMA_SUPPORTED */
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
int empty_plte_permitted));
#endif /* PNG_READ_EMPTY_PLTE_SUPPORTED */
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
/* Set how many lines between output flushes - 0 for no flushing */
extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
@@ -1084,6 +1213,7 @@ extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
* method of error handling. If error_fn or warning_fn is NULL, the
* default function will be used.
*/
extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
@@ -1111,6 +1241,15 @@ extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
png_write_status_ptr write_row_fn));
#ifdef PNG_USER_MEM_SUPPORTED
/* Replace the default memory allocation functions with user supplied one(s). */
extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
/* Return the user pointer associated with the memory functions */
extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
#endif /* PNG_USER_MEM_SUPPORTED */
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
png_ptr, png_user_transform_ptr read_user_transform_fn));
@@ -1121,6 +1260,16 @@ extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
png_ptr, png_user_transform_ptr write_user_transform_fn));
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
int user_transform_channels));
/* Return the user pointer associated with the user transform functions */
extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
PNGARG((png_structp png_ptr));
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
/* Sets the function callbacks for the push reader, and a pointer to a
* user-defined structure available to the callback functions.
@@ -1138,7 +1287,7 @@ extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
/* function which combines rows. Not very much different than the
/* function that combines rows. Not very much different than the
* png_combine_row() call. Is this even used?????
*/
extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
@@ -1151,19 +1300,19 @@ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
/* frees a pointer allocated by png_malloc() */
extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
#ifdef PNG_USER_MEM_SUPPORTED
extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
png_uint_32 size));
extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
png_voidp ptr));
#endif /* PNG_USER_MEM_SUPPORTED */
extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
png_voidp s1, png_voidp s2, png_uint_32 size));
extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
png_voidp s1, int value, png_uint_32 size));
#ifdef PNGTEST_MEMORY_DEBUG
/* debugging versions of png_malloc() and png_free() */
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
png_uint_32 size));
extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
png_voidp ptr));
#endif
#if defined(USE_FAR_KEYWORD) /* memory model conversion function */
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
@@ -1390,8 +1539,7 @@ extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp text_ptr, int num_text));
#endif /* PNG_READ_tEXt_SUPPORTED || PNG_WRITE_tEXt_SUPPORTED ||
PNG_READ_zTXt_SUPPORTED || PNG_WRITE_zTXt_SUPPORTED */
#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
#if defined(PNG_READ_tIME_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
@@ -1420,28 +1568,87 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
* only been added since version 0.95 so it is not implemented throughout
* libpng yet, but more support will be added as needed.
*/
#ifdef PNG_DEBUG
#if (PNG_DEBUG > 0)
#ifdef PNG_NO_STDIO
#include <stdio.h>
#endif
#ifndef PNG_DEBUG_FILE
#define PNG_DEBUG_FILE stderr
#endif /* PNG_DEBUG_FILE */
#define png_debug(l,m) if (PNG_DEBUG > l) \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
(l==2 ? "\t\t":(l==3 ? "\t\t\t":""))))
(l==2 ? "\t\t":(l>2 ? "\t\t\t":""))))
#define png_debug1(l,m,p1) if (PNG_DEBUG > l) \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
(l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1)
(l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1)
#define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
(l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1,p2)
#else
#define png_debug(l, m)
#define png_debug1(l, m, p1)
#define png_debug2(l, m, p1, p2)
(l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1,p2)
#endif /* (PNG_DEBUG > 0) */
#endif /* PNG_DEBUG */
#ifndef png_debug
#define png_debug(l, m)
#endif
#ifndef png_debug1
#define png_debug1(l, m, p1)
#endif
#ifndef png_debug2
#define png_debug2(l, m, p1, p2)
#endif
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
#ifdef PNG_NO_EXTERN
/* this only gets included in png.c */
png_charp
png_get_header_version(png_structp png_ptr)
{
if(png_ptr == NULL)
/* silence compiler warning about unused png_ptr */ ;
return("\n libpng version 1.0.4 - September 18, 1999 (header)\n");
}
#endif
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on
* most machines. However, it does take more operations than the corresponding
* divide method, so it may be slower on a few RISC systems. There are two
* shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
*
* Note that the rounding factors are NOT supposed to be the same! 128 and
* 32768 are correct for the NODIV code; 127 and 32767 are correct for the
* standard method.
*
* [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
*/
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
# define png_composite(composite, fg, alpha, bg) \
{ png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
(png_uint_16)(bg)*(png_uint_16)(255 - \
(png_uint_16)(alpha)) + (png_uint_16)128); \
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
# define png_composite_16(composite, fg, alpha, bg) \
{ png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
(png_uint_32)(bg)*(png_uint_32)(65535L - \
(png_uint_32)(alpha)) + (png_uint_32)32768L); \
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
#else /* standard method using integer division */
# define png_composite(composite, fg, alpha, bg) \
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
(png_uint_16)127) / 255)
# define png_composite_16(composite, fg, alpha, bg) \
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
(png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
(png_uint_32)32767) / (png_uint_32)65535L)
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
/* These next functions are used internally in the code. They generally
* shouldn't be used unless you are writing code to add or replace some
@@ -1484,7 +1691,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#define PNG_DITHER 0x0040
#define PNG_BACKGROUND 0x0080
#define PNG_BACKGROUND_EXPAND 0x0100
#define PNG_RGB_TO_GRAY 0x0200 /* Not currently implemented */
/* 0x0200 unused */
#define PNG_16_TO_8 0x0400
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
@@ -1496,6 +1703,9 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#define PNG_STRIP_ALPHA 0x40000L
#define PNG_INVERT_ALPHA 0x80000L
#define PNG_USER_TRANSFORM 0x100000L
#define PNG_RGB_TO_GRAY_ERR 0x200000L
#define PNG_RGB_TO_GRAY_WARN 0x400000L
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
/* flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
@@ -1525,6 +1735,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#define PNG_FLAG_FREE_HIST 0x4000
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
#define PNG_FLAG_WROTE_tIME 0x10000L
#define PNG_FLAG_BACKGROUND_IS_GRAY 0x20000L
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN)
@@ -1590,7 +1801,7 @@ PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
#endif /* PNG_READ_pCAL_SUPPORTED */
PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
#endif /* PNG_BIG_ENDIAN_GET_SUPPORTED */
#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
/* Initialize png_ptr struct for reading, and allocate any other memory.
* (old interface - NOT DLL EXPORTED).
@@ -1608,6 +1819,11 @@ PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
/* free memory from internal libpng struct */
PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
malloc_fn));
PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
png_free_ptr free_fn));
/* free any memory that info_ptr points to and reset struct. */
PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
png_infop info_ptr));
@@ -1651,8 +1867,8 @@ PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
#endif
/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
* The only currently known PNG chunk that uses signed numbers is
* the ancillary extension chunk, pCAL.
* The only currently known PNG chunks that use signed numbers are
* the ancillary extension chunks, oFFs and pCAL.
*/
PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
@@ -1660,7 +1876,7 @@ PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
#endif
/* Place a 16 bit number into a buffer in PNG byte order.
/* Place a 16-bit number into a buffer in PNG byte order.
* The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers.
*/
@@ -1723,7 +1939,8 @@ PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
int num_hist));
#endif
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
defined(PNG_WRITE_pCAL_SUPPORTED)
PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
png_charp key, png_charpp new_key));
#endif
@@ -1847,8 +2064,8 @@ PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
PNG_EXTERN void png_do_rgb_to_gray PNGARG((png_row_infop row_info,
png_bytep row));
PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
row_info, png_bytep row));
#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)

32
pngasmrd.h Normal file
View File

@@ -0,0 +1,32 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1999 Glenn Randers-Pehrson
*
*/
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* Set this in the makefile for VC++ on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGVCRD
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
* MMX will be detected at run time and used if present.
*/
#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 on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGGCCRD
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
* (not available in libpng 1.0.4).
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
#define PNG_HAVE_ASSEMBLER_READ_INTERLACE
#define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
#endif
#endif

235
pngconf.h
View File

@@ -1,12 +1,11 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
/* Any machine specific code is near the front of this file, so if you
@@ -18,6 +17,7 @@
#ifndef PNGCONF_H
#define PNGCONF_H
/* This is the size of the compression buffer, and thus the size of
* an IDAT chunk. Make this whatever size you feel is best for your
* machine. One of these will be allocated per png_struct. When this
@@ -47,17 +47,31 @@
#define PNG_MAX_MALLOC_64K
#endif
/* This protects us against compilers which run on a windowing system
/* This protects us against compilers that run on a windowing system
* and thus don't have or would rather us not use the stdio types:
* stdin, stdout, and stderr. The only one currently used is stderr
* in png_error() and png_warning(). #defining PNG_NO_STDIO will
* prevent these from being compiled and used.
* in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
* prevent these from being compiled and used. #defining PNG_NO_STDIO
* will also prevent these, plus will prevent the entire set of stdio
* macros and functions (FILE *, printf, etc.) from being compiled and used,
* unless (PNG_DEBUG > 0) has been #defined.
*
* #define PNG_NO_CONSOLE_IO
* #define PNG_NO_STDIO
*/
#ifndef PNG_NO_STDIO
#include <stdio.h>
#endif
# ifdef PNG_NO_STDIO
# ifndef PNG_NO_CONSOLE_IO
# define PNG_NO_CONSOLE_IO
# endif
# ifdef PNG_DEBUG
# if (PNG_DEBUG > 0)
# include <stdio.h>
# endif
# endif
# else
# include <stdio.h>
# endif
/* This macro protects us against machines that don't have function
* prototypes (ie K&R style headers). If your compiler does not handle
@@ -158,7 +172,7 @@ __dont__ include it again
#endif
/* Codewarrior on NT has linking problems without this. */
#if defined(__MWERKS__) && defined(WIN32)
#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
#define PNG_ALWAYS_EXTERN
#endif
@@ -237,72 +251,147 @@ __dont__ include it again
/* Any transformations you will not be using can be undef'ed here */
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" on the compile line,
then pick and choose which ones to define without having to edit
this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED if you
only want to have a png-compliant reader/writer but don't need
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
on the compile line, then pick and choose which ones to define without
having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
if you only want to have a png-compliant reader/writer but don't need
any of the extra transformations. This saves about 80 kbytes in a
typical installation of the library.
typical installation of the library. (PNG_NO_* form added in version
1.0.1c, for consistency)
*/
#ifndef PNG_READ_TRANSFORMS_NOT_SUPPORTED
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_TRANSFORMS)
#define PNG_READ_TRANSFORMS_SUPPORTED
#endif
#ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_TRANSFORMS)
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#endif
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
#ifndef PNG_NO_READ_EXPAND
#define PNG_READ_EXPAND_SUPPORTED
#endif
#ifndef PNG_NO_READ_SHIFT
#define PNG_READ_SHIFT_SUPPORTED
#endif
#ifndef PNG_NO_READ_PACK
#define PNG_READ_PACK_SUPPORTED
#endif
#ifndef PNG_NO_READ_BGR
#define PNG_READ_BGR_SUPPORTED
#endif
#ifndef PNG_NO_READ_SWAP
#define PNG_READ_SWAP_SUPPORTED
#endif
#ifndef PNG_NO_READ_PACKSWAP
#define PNG_READ_PACKSWAP_SUPPORTED
#endif
#ifndef PNG_NO_READ_INVERT
#define PNG_READ_INVERT_SUPPORTED
#endif
#ifndef PNG_NO_READ_DITHER
#define PNG_READ_DITHER_SUPPORTED
#endif
#ifndef PNG_NO_READ_BACKGROUND
#define PNG_READ_BACKGROUND_SUPPORTED
#endif
#ifndef PNG_NO_READ_16_TO_8
#define PNG_READ_16_TO_8_SUPPORTED
#endif
#ifndef PNG_NO_READ_FILLER
#define PNG_READ_FILLER_SUPPORTED
#endif
#ifndef PNG_NO_READ_GAMMA
#define PNG_READ_GAMMA_SUPPORTED
#endif
#ifndef PNG_NO_READ_GRAY_TO_RGB
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#endif
#ifndef PNG_NO_READ_SWAP_ALPHA
#define PNG_READ_SWAP_ALPHA_SUPPORTED
#endif
#ifndef PNG_NO_READ_INVERT_ALPHA
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#endif
#ifndef PNG_NO_READ_STRIP_ALPHA
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#endif
#ifndef PNG_NO_READ_USER_TRANSFORM
#define PNG_READ_USER_TRANSFORM_SUPPORTED
/* the following aren't implemented yet
#endif
#ifndef PNG_NO_READ_RGB_TO_GRAY
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
*/
#endif
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
#ifndef PNG_PROGRESSIVE_READ_NOT_SUPPORTED /* if you don't do progressive */
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
#define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
#endif /* about interlacing capability! You'll */
/* still have interlacing unless you change the following line: */
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
#ifndef PNG_NO_READ_COMPOSITED_NODIV
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
#endif
#ifndef PNG_NO_READ_EMPTY_PLTE
#define PNG_READ_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */
#endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
#ifndef PNG_NO_WRITE_SHIFT
#define PNG_WRITE_SHIFT_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_PACK
#define PNG_WRITE_PACK_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_BGR
#define PNG_WRITE_BGR_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_SWAP
#define PNG_WRITE_SWAP_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_PACKSWAP
#define PNG_WRITE_PACKSWAP_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_INVERT
#define PNG_WRITE_INVERT_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_FILLER
#define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
#define PNG_WRITE_FLUSH_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_SWAP_ALPHA
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_INVERT_ALPHA
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_USER_TRANSFORM
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#endif
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
encoders, but can cause trouble
if left undefined */
#if !defined(PNG_NO_STDIO)
#ifndef PNG_NO_WRITE_WEIGHTED_FILTER
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_FLUSH
#define PNG_WRITE_FLUSH_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_EMPTY_PLTE
#define PNG_WRITE_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */
#endif
#ifndef PNG_NO_STDIO
#define PNG_TIME_RFC1123_SUPPORTED
#endif
@@ -322,15 +411,20 @@ __dont__ include it again
* png_get_x_offset_microns()
* png_get_y_offset_microns()
*/
#if !defined(PNG_NO_EASY_ACCESS)
#ifndef PNG_NO_EASY_ACCESS
#define PNG_EASY_ACCESS_SUPPORTED
#endif
#ifndef PNG_NO_ASSEMBLER_CODE
#define PNG_ASSEMBLER_CODE_SUPPORTED
#endif
/* These are currently experimental features, define them if you want */
/* very little testing */
/*
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#define PNG_USER_MEM_SUPPORTED
*/
/* This is only for PowerPC big-endian and 680x0 systems */
@@ -351,45 +445,100 @@ __dont__ include it again
* a bit smaller.
*/
#ifndef PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
#if !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_ANCILLARY_CHUNKS)
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#endif
#ifndef PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
#if !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#endif
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_READ_bKGD
#define PNG_READ_bKGD_SUPPORTED
#endif
#ifndef PNG_NO_READ_cHRM
#define PNG_READ_cHRM_SUPPORTED
#endif
#ifndef PNG_NO_READ_gAMA
#define PNG_READ_gAMA_SUPPORTED
#endif
#ifndef PNG_NO_READ_hIST
#define PNG_READ_hIST_SUPPORTED
#endif
#ifndef PNG_NO_READ_oFFs
#define PNG_READ_oFFs_SUPPORTED
#endif
#ifndef PNG_NO_READ_pCAL
#define PNG_READ_pCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_pHYs
#define PNG_READ_pHYs_SUPPORTED
#endif
#ifndef PNG_NO_READ_sBIT
#define PNG_READ_sBIT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sRGB
#define PNG_READ_sRGB_SUPPORTED
#endif
#ifndef PNG_NO_READ_tEXt
#define PNG_READ_tEXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_tIME
#define PNG_READ_tIME_SUPPORTED
#endif
#ifndef PNG_NO_READ_tRNS
#define PNG_READ_tRNS_SUPPORTED
#endif
#ifndef PNG_NO_READ_zTXt
#define PNG_READ_zTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_OPT_PLTE
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
/* PLTE chunk in RGB and RGBA images */
#endif /* PLTE chunk in RGB and RGBA images */
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_WRITE_bKGD
#define PNG_WRITE_bKGD_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_cHRM
#define PNG_WRITE_cHRM_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_gAMA
#define PNG_WRITE_gAMA_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_hIST
#define PNG_WRITE_hIST_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_oFFs
#define PNG_WRITE_oFFs_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_pCAL
#define PNG_WRITE_pCAL_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_pHYs
#define PNG_WRITE_pHYs_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_sBIT
#define PNG_WRITE_sBIT_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_sRGB
#define PNG_WRITE_sRGB_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_tEXt
#define PNG_WRITE_tEXt_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_tIME
#define PNG_WRITE_tIME_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_tRNS
#define PNG_WRITE_tRNS_SUPPORTED
#endif
#ifndef PNG_NO_WRITE_zTXt
#define PNG_WRITE_zTXt_SUPPORTED
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
/* need the time information for reading tIME chunks */
@@ -509,23 +658,31 @@ typedef charf * png_zcharp;
typedef charf * FAR * png_zcharpp;
typedef z_stream FAR * png_zstreamp;
/* allow for compilation as dll under MS Windows */
#ifdef __WIN32DLL__
#define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
#endif
/* allow for compilation as dll with BORLAND C++ 5.0 */
#if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
#ifndef PNG_EXPORT
/* allow for compilation as dll under MS Windows */
# ifdef __WIN32DLL__
# define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
# endif
/* this variant is used in Mozilla; may correspond to MSVC++ 6.0 changes */
# ifdef ALT_WIN32_DLL
# define PNG_EXPORT(type,symbol) type __attribute__((dllexport)) symbol
# endif
/* allow for compilation as dll with Borland C++ 5.0 */
# if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
# define PNG_EXPORT(type,symbol) type _export symbol
#endif
# endif
/* allow for compilation as shared lib under BeOS */
#ifdef __BEOSDLL__
#define PNG_EXPORT(type,symbol) __declspec(export) type symbol
/* allow for compilation as shared lib under BeOS */
# ifdef __BEOSDLL__
# define PNG_EXPORT(type,symbol) __declspec(export) type symbol
# endif
#endif
#ifndef PNG_EXPORT
#define PNG_EXPORT(type,symbol) type symbol
# define PNG_EXPORT(type,symbol) type symbol
#endif
@@ -539,6 +696,7 @@ typedef z_stream FAR * png_zstreamp;
# define NOCHECK 0
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
# define png_strcpy _fstrcpy
# define png_strlen _fstrlen
# define png_memcmp _fmemcmp /* SJT: added */
# define png_memcpy _fmemcpy
@@ -546,6 +704,7 @@ typedef z_stream FAR * png_zstreamp;
#else /* use the usual functions */
# define CVT_PTR(ptr) (ptr)
# define CVT_PTR_NOCHECK(ptr) (ptr)
# define png_strcpy strcpy
# define png_strlen strlen
# define png_memcmp memcmp /* SJT: added */
# define png_memcpy memcpy

View File

@@ -1,14 +1,13 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file provides a location for all error handling. Users which
* This file provides a location for all error handling. Users who
* need special error handling are expected to write replacement functions
* and use png_set_error_fn() to use those functions. See the instructions
* at each function.
@@ -52,7 +51,7 @@ png_warning(png_structp png_ptr, png_const_charp message)
png_default_warning(png_ptr, message);
}
/* These utilities are used internally to build an error message which 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,
* this is used to prefix the message. The message is limited in length
* to 63 bytes, the name characters are output as hex digits wrapped in []
@@ -114,7 +113,7 @@ png_chunk_warning(png_structp png_ptr, png_const_charp message)
static void
png_default_error(png_structp png_ptr, png_const_charp message)
{
#ifndef PNG_NO_STDIO
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng error: %s\n", message);
#endif
@@ -131,18 +130,17 @@ png_default_error(png_structp png_ptr, png_const_charp message)
/* 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
* here if you don't want to. In the default configuration, png_ptr is
* here if you don't want them to. In the default configuration, png_ptr is
* not used, but it is passed in case it may be useful.
*/
static void
png_default_warning(png_structp png_ptr, png_const_charp message)
{
if (png_ptr == NULL)
return;
#ifndef PNG_NO_STDIO
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng warning: %s\n", message);
#endif
if (png_ptr == NULL)
return;
}
/* This function is called when the application wants to use another method

View File

@@ -1,12 +1,11 @@
/* pngget.c - retrieval of values from info struct
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
@@ -302,11 +301,11 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
}
return (retval);
}
#endif
#endif /* PNG_READ_pHYs_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
#endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte
@@ -455,7 +454,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
channels++;
pixel_depth = *bit_depth * channels;
rowbytes_per_pixel = (pixel_depth + 7) >> 3;
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
if ((*width > PNG_MAX_UINT/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large for libpng to process image data.");
@@ -642,3 +641,10 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
}
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte
png_get_rgb_to_gray_status (png_structp png_ptr)
{
return png_ptr->rgb_to_gray_status;
}
#endif

212
pngmem.c
View File

@@ -1,31 +1,22 @@
/* pngmem.c - stub functions for memory allocation
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file provides a location for all memory allocation. Users which
* need special memory handling are expected to modify the code in this file
* to meet their needs. See the instructions at each function.
* This file provides a location for all memory allocation. Users who
* need special memory handling are expected to supply replacement
* functions for png_malloc() and png_free(), and to use
* png_create_read_struct_2() and png_create_write_struct_2() to
* identify the replacement functions.
*/
#define PNG_INTERNAL
#include "png.h"
/* The following "hides" PNG_MALLOC and PNG_FREE thus allowing the pngtest
application to put a wrapper on top of them. */
#ifdef PNGTEST_MEMORY_DEBUG
#define PNG_MALLOC png_debug_malloc
#define PNG_FREE png_debug_free
#else
#define PNG_MALLOC png_malloc
#define PNG_FREE png_free
#endif
/* Borland DOS special memory handler */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* if you change this, be sure to change the one in png.h also */
@@ -35,6 +26,15 @@
png_voidp
png_create_struct(int type)
{
#ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL));
}
/* Alternate version of png_create_struct, for use with user-defined malloc. */
png_voidp
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
@@ -45,11 +45,18 @@ png_create_struct(int type)
else
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL)
{
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
{
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
@@ -58,8 +65,27 @@ png_create_struct(int type)
void
png_destroy_struct(png_voidp struct_ptr)
{
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
}
/* Free memory allocated by a png_create_struct() call */
void
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{
#endif
if (struct_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED
if(free_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
(*(free_fn))(png_ptr, struct_ptr);
struct_ptr = NULL;
return;
}
#endif /* PNG_USER_MEM_SUPPORTED */
farfree (struct_ptr);
struct_ptr = NULL;
}
@@ -72,7 +98,7 @@ png_destroy_struct(png_voidp struct_ptr)
* have the ability to do that.
*
* Borland seems to have a problem in DOS mode for exactly 64K.
* It gives you a segment with an offset of 8 (perhaps to store it's
* It gives you a segment with an offset of 8 (perhaps to store its
* memory stuff). zlib doesn't like this at all, so we have to
* detect and deal with it. This code should not be needed in
* Windows or OS/2 modes, and only in 16 bit mode. This code has
@@ -85,12 +111,27 @@ png_destroy_struct(png_voidp struct_ptr)
* (which should cause a fatal error) and introducing major problems.
*/
png_voidp
PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
png_malloc(png_structp png_ptr, png_uint_32 size)
{
#ifndef PNG_USER_MEM_SUPPORTED
png_voidp ret;
#endif
if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL)
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
else
return png_malloc_default(png_ptr, size);
}
png_voidp
png_malloc_default(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */
#ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L)
png_error(png_ptr, "Cannot Allocate > 64K");
@@ -116,8 +157,9 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
ret = NULL;
}
if(png_ptr->zlib_window_bits > 14)
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
if (num_blocks < 1)
else
num_blocks = 1;
if (png_ptr->zlib_mem_level >= 7)
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
@@ -151,12 +193,12 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
if ((png_size_t)hptr & 0xf)
{
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
hptr += 16L;
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
}
for (i = 0; i < num_blocks; i++)
{
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
hptr += (png_uint_32)65536L;
hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
}
png_ptr->offset_table_number = num_blocks;
@@ -181,15 +223,30 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
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
is needed. If ptr is NULL, return without taking any action. */
void
PNG_FREE(png_structp png_ptr, png_voidp ptr)
png_free(png_structp png_ptr, png_voidp ptr)
{
if (png_ptr == NULL || ptr == NULL)
return;
#ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->free_fn != NULL)
{
(*(png_ptr->free_fn))(png_ptr, ptr);
ptr = NULL;
return;
}
else png_free_default(png_ptr, ptr);
}
void
png_free_default(png_structp png_ptr, png_voidp ptr)
{
#endif /* PNG_USER_MEM_SUPPORTED */
if (png_ptr->offset_table != NULL)
{
int i;
@@ -227,6 +284,17 @@ PNG_FREE(png_structp png_ptr, png_voidp ptr)
png_voidp
png_create_struct(int type)
{
#ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL));
}
/* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably.*/
png_voidp
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
@@ -237,6 +305,15 @@ png_create_struct(int type)
else
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL)
{
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__)
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
#else
@@ -258,15 +335,37 @@ png_create_struct(int type)
void
png_destroy_struct(png_voidp struct_ptr)
{
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL);
}
/* Free memory allocated by a png_create_struct() call */
void
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
if (struct_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED
if(free_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
(*(free_fn))(png_ptr, struct_ptr);
struct_ptr = NULL;
return;
}
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__)
farfree(struct_ptr);
struct_ptr = NULL;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(struct_ptr);
struct_ptr = NULL;
# else
free(struct_ptr);
struct_ptr = NULL;
# endif
#endif
}
@@ -280,13 +379,26 @@ png_destroy_struct(png_voidp struct_ptr)
have the ability to do that. */
png_voidp
PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
png_malloc(png_structp png_ptr, png_uint_32 size)
{
#ifndef PNG_USER_MEM_SUPPORTED
png_voidp ret;
#endif
if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL)
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
else
return (png_malloc_default(png_ptr, size));
}
png_voidp
png_malloc_default(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
#endif /* PNG_USER_MEM_SUPPORTED */
#ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L)
png_error(png_ptr, "Cannot Allocate > 64K");
@@ -310,22 +422,38 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
return (ret);
}
/* Free a pointer allocated by PNG_MALLOC(). In the default
configuration, png_ptr is not used, but is passed in case it
is needed. If ptr is NULL, return without taking any action. */
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
without taking any action. */
void
PNG_FREE(png_structp png_ptr, png_voidp ptr)
png_free(png_structp png_ptr, png_voidp ptr)
{
if (png_ptr == NULL || ptr == NULL)
return;
#ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr->free_fn != NULL)
{
(*(png_ptr->free_fn))(png_ptr, ptr);
ptr = NULL;
return;
}
else png_free_default(png_ptr, ptr);
}
void
png_free_default(png_structp png_ptr, png_voidp ptr)
{
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__)
farfree(ptr);
ptr = NULL;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(ptr);
ptr = NULL;
# else
free(ptr);
ptr = NULL;
# endif
#endif
}
@@ -358,3 +486,27 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
return (png_memset (s1, value, size));
}
#ifdef PNG_USER_MEM_SUPPORTED
/* This function is called when the application wants to use another method
* of allocating and freeing memory.
*/
void
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
malloc_fn, png_free_ptr 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
* functions. The application should free any memory associated with this
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp
png_get_mem_ptr(png_structp png_ptr)
{
return ((png_voidp)png_ptr->mem_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */

View File

@@ -1,12 +1,11 @@
/* pngpread.c - read a png file in push mode
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
@@ -78,8 +77,9 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
/* Read any remaining signature bytes from the stream and compare them with
* the correct PNG signature. It is possible that this routine is called
* with bytes already read from the signature, whether because they have been
* checked by the calling application, or from multiple calls to this routine.
* with bytes already read from the signature, either because they have been
* checked by the calling application, or because of multiple calls to this
* routine.
*/
void
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
@@ -446,13 +446,13 @@ png_push_save_buffer(png_structp png_ptr)
{
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
{
png_size_t i;
png_size_t i,istop;
png_bytep sp;
png_bytep dp;
istop = png_ptr->save_buffer_size;
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
i < png_ptr->save_buffer_size;
i++, sp++, dp++)
i < istop; i++, sp++, dp++)
{
*dp = *sp;
}
@@ -781,6 +781,7 @@ png_read_push_finish_row(png_structp png_ptr)
png_ptr->pass++;
if (png_ptr->pass >= 7)
break;
png_ptr->iwidth = (png_ptr->width +
png_pass_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) /
@@ -789,18 +790,15 @@ png_read_push_finish_row(png_structp png_ptr)
png_ptr->irowbytes = ((png_ptr->iwidth *
png_ptr->pixel_depth + 7) >> 3) + 1;
if (!(png_ptr->transformations & PNG_INTERLACE))
{
if (png_ptr->transformations & PNG_INTERLACE)
break;
png_ptr->num_rows = (png_ptr->height +
png_pass_yinc[png_ptr->pass] - 1 -
png_pass_ystart[png_ptr->pass]) /
png_pass_yinc[png_ptr->pass];
if (!(png_ptr->num_rows))
continue;
}
if (png_ptr->transformations & PNG_INTERLACE)
break;
} while (png_ptr->iwidth == 0);
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
}
}
@@ -1070,7 +1068,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
#endif
/* This function is called when we haven't found a handler for this
* chunk. In the future we will have code here which can handle
* chunk. In the future we will have code here that can handle
* user-defined callback functions for unknown chunks before they are
* ignored or cause an error. If there isn't a problem with the
* chunk itself (ie a bad chunk name or a critical chunk), the chunk
@@ -1117,7 +1115,7 @@ void
png_progressive_combine_row (png_structp png_ptr,
png_bytep old_row, png_bytep new_row)
{
if (new_row != NULL)
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
}

179
pngread.c
View File

@@ -1,12 +1,11 @@
/* pngread.c - read a PNG file
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file contains routines that an application calls directly to
* read a PNG file or stream.
@@ -17,15 +16,34 @@
/* Create a PNG structure for reading, and allocate any memory needed. */
png_structp
png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn)
{
#ifdef PNG_USER_MEM_SUPPORTED
return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL));
}
/* Alternate create PNG structure for reading, and allocate any memory needed. */
png_structp
png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_structp png_ptr;
#ifdef USE_FAR_KEYWORD
jmp_buf jmpbuf;
#endif
png_debug(1, "in png_create_read_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL)
#else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
#endif
{
return (png_structp)NULL;
}
@@ -42,6 +60,11 @@ png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
#ifdef USE_FAR_KEYWORD
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
#endif /* PNG_USER_MEM_SUPPORTED */
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
@@ -82,7 +105,7 @@ png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
}
/* Initialize PNG structure for reading, and allocate any memory needed.
This interface is depreciated in favour of the png_create_read_struct(),
This interface is deprecated in favour of the png_create_read_struct(),
and it will eventually disappear. */
void
png_read_init(png_structp png_ptr)
@@ -125,7 +148,7 @@ png_read_init(png_structp png_ptr)
/* Read the information before the actual image data. This has been
* changed in v0.90 to allow reading a file that already has the magic
* bytes read from the stream. You can tell libpng how many bytes have
* been read from the beginning of the stream (up to the maxumum of 8)
* been read from the beginning of the stream (up to the maximum of 8)
* via png_set_sig_bytes(), and we will only check the remaining bytes
* here. The application can then have access to the signature bytes we
* read if it is determined that this isn't a valid PNG file.
@@ -165,7 +188,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
png_debug2(0, "Reading %s chunk, length=%d.\n", png_ptr->chunk_name,
length);
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
@@ -258,7 +282,7 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
/* Initialize palette, background, etc, after transformations
* are set, but before any reading takes place. This allows
* the user to obtail a gamma corrected palette, for example.
* the user to obtain a gamma-corrected palette, for example.
* If the user doesn't call this, we will do it ourselves.
*/
void
@@ -279,6 +303,38 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
/* save jump buffer and error functions */
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* check for transforms that have been set but were defined out */
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_MONO)
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
if (png_ptr->transformations & PNG_FILLER)
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
if (png_ptr->transformations & PNG_PACK)
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
if (png_ptr->transformations & PNG_SHIFT)
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR)
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined.");
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined.");
#endif
}
#if defined(PNG_READ_INTERLACING_SUPPORTED)
/* if interlaced and we do not need a new row, combine row and return */
@@ -457,7 +513,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
/* Read one or more rows of image data. If the image is interlaced,
* and png_set_interlace_handling() has been called, the rows need to
* contain the contents of the rows from the previous pass. If the
* image has alpha or transparency, and png_handle_alpha() has been
* image has alpha or transparency, and png_handle_alpha()[*] has been
* called, the rows contents must be initialized to the contents of the
* screen.
*
@@ -474,6 +530,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* also, but you may. If the image is not interlaced, or if you have
* not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4.
*/
void
@@ -488,29 +546,32 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
/* save jump buffer and error functions */
rp = row;
dp = display_row;
if (rp != NULL && dp != NULL)
for (i = 0; i < num_rows; i++)
{
png_bytep rptr;
png_bytep dptr;
png_bytep rptr = *rp++;
png_bytep dptr = *dp++;
if (rp != NULL)
rptr = *rp;
else
rptr = NULL;
if (dp != NULL)
dptr = *dp;
else
dptr = NULL;
png_read_row(png_ptr, rptr, dptr);
if (row != NULL)
}
else if(rp != NULL)
for (i = 0; i < num_rows; i++)
{
png_bytep rptr = *rp;
png_read_row(png_ptr, rptr, NULL);
rp++;
if (display_row != NULL)
}
else if(dp != NULL)
for (i = 0; i < num_rows; i++)
{
png_bytep dptr = *dp;
png_read_row(png_ptr, NULL, dptr);
dp++;
}
}
/* Read the entire image. If the image has an alpha channel or a tRNS
* chunk, and you have called png_handle_alpha(), you will need to
* chunk, and you have called png_handle_alpha()[*], you will need to
* initialize the image to the current image that PNG will be overlaying.
* We set the num_rows again here, in case it was incorrectly set in
* png_read_start_row() by a call to png_read_update_info() or
@@ -518,24 +579,36 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* prior to either of these functions like it should have been. You can
* only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4.
*/
void
png_read_image(png_structp png_ptr, png_bytepp image)
{
png_uint_32 i;
png_uint_32 i,image_height;
int pass, j;
png_bytepp rp;
png_debug(1, "in png_read_image\n");
/* save jump buffer and error functions */
pass = png_set_interlace_handling(png_ptr);
png_ptr->num_rows = png_ptr->height; /* Make sure this is set correctly */
#ifdef PNG_READ_INTERLACING_SUPPORTED
pass = png_set_interlace_handling(png_ptr);
#else
if (png_ptr->interlaced)
png_error(png_ptr,
"Cannot read interlaced image -- interlace handler disabled.");
pass = 1;
#endif
image_height=png_ptr->height;
png_ptr->num_rows = image_height; /* Make sure this is set correctly */
for (j = 0; j < pass; j++)
{
rp = image;
for (i = 0; i < png_ptr->height; i++)
for (i = 0; i < image_height; i++)
{
png_read_row(png_ptr, *rp, NULL);
rp++;
@@ -647,6 +720,9 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
{
png_structp png_ptr = NULL;
png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL;
#endif /* PNG_USER_MEM_SUPPORTED */
png_debug(1, "in png_destroy_read_struct\n");
/* save jump buffer and error functions */
@@ -659,6 +735,10 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (end_info_ptr_ptr != NULL)
end_info_ptr = *end_info_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
#endif
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
if (info_ptr != NULL)
@@ -666,7 +746,12 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
png_free(png_ptr, info_ptr->text);
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
#else
png_destroy_struct((png_voidp)info_ptr);
#endif
*info_ptr_ptr = (png_infop)NULL;
}
@@ -675,13 +760,21 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
png_free(png_ptr, end_info_ptr->text);
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn);
#else
png_destroy_struct((png_voidp)end_info_ptr);
#endif
*end_info_ptr_ptr = (png_infop)NULL;
}
if (png_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
#else
png_destroy_struct((png_voidp)png_ptr);
#endif
*png_ptr_ptr = (png_structp)NULL;
}
}
@@ -694,6 +787,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_error_ptr error_fn;
png_error_ptr warning_fn;
png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
#endif
png_debug(1, "in png_read_destroy\n");
/* save jump buffer and error functions */
@@ -719,8 +815,11 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
png_zfree(png_ptr, png_ptr->palette);
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
png_free(png_ptr, png_ptr->trans);
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
png_free(png_ptr, png_ptr->hist);
@@ -729,33 +828,39 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
if (png_ptr->gamma_16_table != NULL)
{
int i;
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_table[i]);
}
}
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_free(png_ptr, png_ptr->gamma_16_table);
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
if (png_ptr->gamma_16_from_1 != NULL)
{
int i;
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
}
}
png_free(png_ptr, png_ptr->gamma_16_from_1);
}
if (png_ptr->gamma_16_to_1 != NULL)
{
int i;
for (i = 0; i < (1 << (8 - png_ptr->gamma_shift)); i++)
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
}
}
png_free(png_ptr, png_ptr->gamma_16_to_1);
}
#endif
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer);
#endif /* PNG_TIME_RFC1123_SUPPORTED */
inflateEnd(&png_ptr->zstream);
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@@ -770,12 +875,18 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
error_fn = png_ptr->error_fn;
warning_fn = png_ptr->warning_fn;
error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
#endif
png_memset(png_ptr, 0, sizeof (png_struct));
png_ptr->error_fn = error_fn;
png_ptr->warning_fn = warning_fn;
png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr->free_fn = free_fn;
#endif
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
}

View File

@@ -1,17 +1,16 @@
/* pngrio.c - functions for data input
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file provides a location for all input. Users which need
* special handling are expected to write a function which has the same
* arguments as this, and perform a similar function, but possibly has
* a different input method. Note that you shouldn't change this
* This file provides a location for all input. Users who need
* special handling are expected to write a function that has the same
* arguments as this and performs a similar function, but that possibly
* has a different input method. Note that you shouldn't change this
* function, but rather write a replacement function and then make
* libpng use it at run time with png_set_read_fn(...).
*/
@@ -35,7 +34,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
}
#if !defined(PNG_NO_STDIO)
/* This is the function which 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
read_data function and use it at run time with png_set_read_fn(), rather
than changing the library. */
@@ -114,10 +113,10 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_ptr - pointer to a png input data structure
io_ptr - pointer to user supplied structure containing info about
the input functions. May be NULL.
read_data_fn - pointer to a new input function which takes as it's
read_data_fn - pointer to a new input function that takes as its
arguments a pointer to a png_struct, a pointer to
a location where input data can be stored, and a 32-bit
unsigned int which 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
function should call png_error(png_ptr, "Error msg"). */
void
@@ -136,7 +135,14 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
#endif
/* It is an error to write to a read device */
if (png_ptr->write_data_fn != NULL)
{
png_ptr->write_data_fn = NULL;
png_warning(png_ptr,
"It's an error to set both read_data_fn and write_data_fn in the ");
png_warning(png_ptr,
"same structure. Resetting write_data_fn to NULL.");
}
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_ptr->output_flush_fn = NULL;

1412
pngrtran.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,29 @@
/* pngrutil.c - utilities to read a PNG file
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file contains routines which are only called from within
* This file contains routines that are only called from within
* libpng itself during the course of reading an image.
*/
#define PNG_INTERNAL
#include "png.h"
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
#include "pngasmrd.h"
#endif
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
/* Grab an unsigned 32-bit integer from a buffer in big endian format. */
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32
png_get_uint_32(png_bytep buf)
{
png_uint_32 i;
i = ((png_uint_32)(*buf) << 24) +
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
((png_uint_32)(*(buf + 1)) << 16) +
((png_uint_32)(*(buf + 2)) << 8) +
(png_uint_32)(*(buf + 3));
@@ -31,15 +32,13 @@ png_get_uint_32(png_bytep buf)
}
#if defined(PNG_READ_pCAL_SUPPORTED)
/* Grab a signed 32-bit integer from a buffer in big endian format. The
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same. */
png_int_32
png_get_int_32(png_bytep buf)
{
png_int_32 i;
i = ((png_int_32)(*buf) << 24) +
png_int_32 i = ((png_int_32)(*buf) << 24) +
((png_int_32)(*(buf + 1)) << 16) +
((png_int_32)(*(buf + 2)) << 8) +
(png_int_32)(*(buf + 3));
@@ -48,13 +47,11 @@ png_get_int_32(png_bytep buf)
}
#endif /* PNG_READ_pCAL_SUPPORTED */
/* Grab an unsigned 16-bit integer from a buffer in big endian format. */
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16
png_get_uint_16(png_bytep buf)
{
png_uint_16 i;
i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
(png_uint_16)(*(buf + 1)));
return (i);
@@ -76,15 +73,16 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
int
png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{
png_uint_32 i;
png_size_t i;
png_size_t istop = png_ptr->zbuf_size;
for (i = skip; i > (png_uint_32)png_ptr->zbuf_size; i -= png_ptr->zbuf_size)
for (i = (png_size_t)skip; i > istop; i -= istop)
{
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
}
if (i)
{
png_crc_read(png_ptr, png_ptr->zbuf, (png_size_t)i);
png_crc_read(png_ptr, png_ptr->zbuf, i);
}
if (png_crc_error(png_ptr))
@@ -171,8 +169,8 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
interlace_type = buf[12];
/* check for width and height valid values */
if (width == 0 || width > (png_uint_32)2147483647L || height == 0 ||
height > (png_uint_32)2147483647L)
if (width == 0 || width > PNG_MAX_UINT || height == 0 ||
height > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image size in IHDR");
/* check other values */
@@ -184,7 +182,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
color_type == 5 || color_type > 6)
png_error(png_ptr, "Invalid color type in IHDR");
if ((color_type == PNG_COLOR_TYPE_PALETTE && bit_depth) > 8 ||
if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
((color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
@@ -258,20 +256,6 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->mode |= PNG_HAVE_PLTE;
#if defined (PNG_READ_tRNS_SUPPORTED)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{
if (png_ptr->num_trans > png_ptr->num_palette)
{
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
png_ptr->num_trans = png_ptr->num_palette;
}
}
}
#endif
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{
@@ -349,6 +333,21 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->palette = palette;
png_ptr->num_palette = (png_uint_16)num;
png_set_PLTE(png_ptr, info_ptr, palette, num);
#if defined (PNG_READ_tRNS_SUPPORTED)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{
if (png_ptr->num_trans > png_ptr->num_palette)
{
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
png_ptr->num_trans = png_ptr->num_palette;
}
}
}
#endif
}
void
@@ -425,11 +424,11 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB)
if(igamma != (png_uint_32)45000L)
if(fabs((float)igamma - 45455.)>500.)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_STDIO
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "igamma = %lu\n", igamma);
#endif
return;
@@ -501,6 +500,9 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
else
{
png_ptr->sig_bit.gray = buf[0];
png_ptr->sig_bit.red = buf[0];
png_ptr->sig_bit.green = buf[0];
png_ptr->sig_bit.blue = buf[0];
png_ptr->sig_bit.alpha = buf[1];
}
png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));
@@ -629,7 +631,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_STDIO
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
white_x, white_y, red_x, red_y);
fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",
@@ -694,11 +696,11 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
if ((info_ptr->valid & PNG_INFO_gAMA))
if((png_uint_32)(png_ptr->gamma*(float)100000.+.5) != (png_uint_32)45000L)
if(fabs((png_ptr->gamma*(float)100000.+.5)-45455.) > 500.)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_STDIO
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr,"gamma=%f\n",png_ptr->gamma);
#endif
}
@@ -758,6 +760,12 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
return;
}
if (length == 0)
{
png_warning(png_ptr, "Zero length tRNS chunk");
png_crc_finish(png_ptr, length);
return;
}
png_ptr->trans = (png_bytep)png_malloc(png_ptr, length);
png_ptr->flags |= PNG_FLAG_FREE_TRANS;
@@ -867,9 +875,21 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_ptr->background.index = buf[0];
png_ptr->background.red = (png_uint_16)png_ptr->palette[buf[0]].red;
png_ptr->background.green = (png_uint_16)png_ptr->palette[buf[0]].green;
png_ptr->background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;
if(info_ptr->num_palette)
{
if(buf[0] > info_ptr->num_palette)
{
png_warning(png_ptr, "Incorrect bKGD chunk index value");
png_crc_finish(png_ptr, length);
return;
}
png_ptr->background.red =
(png_uint_16)png_ptr->palette[buf[0]].red;
png_ptr->background.green =
(png_uint_16)png_ptr->palette[buf[0]].green;
png_ptr->background.blue =
(png_uint_16)png_ptr->palette[buf[0]].blue;
}
}
else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */
{
@@ -1075,7 +1095,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
purpose[slength] = 0x00; /* null terminate the last string */
png_debug(3, "Finding end of pCAL purpose string\n");
for (buf = purpose; *buf != '\0'; buf++)
for (buf = purpose; *buf; buf++)
/* empty loop */ ;
endptr = purpose + slength;
@@ -1113,7 +1133,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
}
for (buf = units; *buf != 0x00; buf++)
for (buf = units; *buf; buf++)
/* Empty loop to move past the units string. */ ;
png_debug(3, "Allocating pCAL parameters array\n");
@@ -1465,19 +1485,23 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
}
}
/* Combines the row recently read in with the previous row.
This routine takes care of alpha and transparency if requested.
/* Combines the row recently read in with the existing pixels in the
row. This routine takes care of alpha and transparency if requested.
This routine also handles the two methods of progressive display
of interlaced images, depending on the mask value.
The mask value describes which pixels are to be combined with
the row. The pattern always repeats every 8 pixels, so just 8
bits are needed. A one indicates the pixels is to be combined,
bits are needed. A one indicates the pixel is to be combined,
a zero indicates the pixel is to be skipped. This is in addition
to any alpha or transparency value associated with the pixel. If
you want all pixels to be combined, pass 0xff (255) in mask. */
void
png_combine_row(png_structp png_ptr, png_bytep row,
int mask)
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
png_combine_row_c
#else
png_combine_row
#endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */
(png_structp png_ptr, png_bytep row, int mask)
{
png_debug(1,"in png_combine_row\n");
if (mask == 0xff)
@@ -1492,16 +1516,14 @@ png_combine_row(png_structp png_ptr, png_bytep row,
{
case 1:
{
png_bytep sp;
png_bytep dp;
png_bytep sp = png_ptr->row_buf + 1;
png_bytep dp = row;
int s_inc, s_start, s_end;
int m;
int m = 0x80;
int shift;
png_uint_32 i;
png_uint_32 row_width = png_ptr->width;
sp = png_ptr->row_buf + 1;
dp = row;
m = 0x80;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
{
@@ -1519,7 +1541,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
shift = s_start;
for (i = 0; i < png_ptr->width; i++)
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
@@ -1548,17 +1570,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
}
case 2:
{
png_bytep sp;
png_bytep dp;
png_bytep sp = png_ptr->row_buf + 1;
png_bytep dp = row;
int s_start, s_end, s_inc;
int m;
int m = 0x80;
int shift;
png_uint_32 i;
png_uint_32 row_width = png_ptr->width;
int value;
sp = png_ptr->row_buf + 1;
dp = row;
m = 0x80;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
{
@@ -1576,7 +1596,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
shift = s_start;
for (i = 0; i < png_ptr->width; i++)
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
@@ -1602,17 +1622,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
}
case 4:
{
png_bytep sp;
png_bytep dp;
png_bytep sp = png_ptr->row_buf + 1;
png_bytep dp = row;
int s_start, s_end, s_inc;
int m;
int m = 0x80;
int shift;
png_uint_32 i;
png_uint_32 row_width = png_ptr->width;
int value;
sp = png_ptr->row_buf + 1;
dp = row;
m = 0x80;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
{
@@ -1629,7 +1647,7 @@ png_combine_row(png_structp png_ptr, png_bytep row,
}
shift = s_start;
for (i = 0; i < png_ptr->width; i++)
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
@@ -1655,18 +1673,15 @@ png_combine_row(png_structp png_ptr, png_bytep row,
}
default:
{
png_bytep sp;
png_bytep dp;
png_size_t pixel_bytes;
png_bytep sp = png_ptr->row_buf + 1;
png_bytep dp = row;
png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
png_uint_32 i;
png_byte m;
png_uint_32 row_width = png_ptr->width;
png_byte m = 0x80;
pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
sp = png_ptr->row_buf + 1;
dp = row;
m = 0x80;
for (i = 0; i < png_ptr->width; i++)
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
@@ -1689,7 +1704,12 @@ png_combine_row(png_structp png_ptr, png_bytep row,
#if defined(PNG_READ_INTERLACING_SUPPORTED)
void
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
png_do_read_interlace_c
#else
png_do_read_interlace
#endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */
(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations)
{
png_debug(1,"in png_do_read_interlace\n");
@@ -1703,15 +1723,15 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{
case 1:
{
png_bytep sp, dp;
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
int sshift, dshift;
int s_start, s_end, s_inc;
int jstop = png_pass_inc[pass];
png_byte v;
png_uint_32 i;
int j;
sp = row + (png_size_t)((row_info->width - 1) >> 3);
dp = row + (png_size_t)((final_width - 1) >> 3);
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
@@ -1731,10 +1751,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
s_inc = 1;
}
for (i = row_info->width; i; i--)
for (i = 0; i < row_info->width; i++)
{
v = (png_byte)((*sp >> sshift) & 0x1);
for (j = 0; j < png_pass_inc[pass]; j++)
for (j = 0; j < jstop; j++)
{
*dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
*dp |= (png_byte)(v << dshift);
@@ -1758,13 +1778,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
}
case 2:
{
png_bytep sp, dp;
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
int sshift, dshift;
int s_start, s_end, s_inc;
int jstop = png_pass_inc[pass];
png_uint_32 i;
sp = row + (png_uint_32)((row_info->width - 1) >> 2);
dp = row + (png_uint_32)((final_width - 1) >> 2);
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
@@ -1784,13 +1804,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
s_inc = 2;
}
for (i = row_info->width; i; i--)
for (i = 0; i < row_info->width; i++)
{
png_byte v;
int j;
v = (png_byte)((*sp >> sshift) & 0x3);
for (j = 0; j < png_pass_inc[pass]; j++)
for (j = 0; j < jstop; j++)
{
*dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
*dp |= (png_byte)(v << dshift);
@@ -1814,13 +1834,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
}
case 4:
{
png_bytep sp, dp;
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
int sshift, dshift;
int s_start, s_end, s_inc;
png_uint_32 i;
int jstop = png_pass_inc[pass];
sp = row + (png_size_t)((row_info->width - 1) >> 1);
dp = row + (png_size_t)((final_width - 1) >> 1);
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
@@ -1840,13 +1860,12 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
s_inc = 4;
}
for (i = row_info->width; i; i--)
for (i = 0; i < row_info->width; i++)
{
png_byte v;
png_byte v = (png_byte)((*sp >> sshift) & 0xf);
int j;
v = (png_byte)((*sp >> sshift) & 0xf);
for (j = 0; j < png_pass_inc[pass]; j++)
for (j = 0; j < jstop; j++)
{
*dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);
*dp |= (png_byte)(v << dshift);
@@ -1870,21 +1889,19 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
}
default:
{
png_bytep sp, dp;
png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
int jstop = png_pass_inc[pass];
png_uint_32 i;
png_size_t pixel_bytes;
pixel_bytes = (row_info->pixel_depth >> 3);
sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
for (i = row_info->width; i; i--)
for (i = 0; i < row_info->width; i++)
{
png_byte v[8];
int j;
png_memcpy(v, sp, pixel_bytes);
for (j = 0; j < png_pass_inc[pass]; j++)
for (j = 0; j < jstop; j++)
{
png_memcpy(dp, v, pixel_bytes);
dp -= pixel_bytes;
@@ -1902,13 +1919,16 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
#endif
void
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
png_read_filter_row_c
#else
png_read_filter_row
#endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row\n");
png_debug2(2,"row = %d, filter = %d\n", png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@@ -1916,97 +1936,112 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
case PNG_FILTER_VALUE_SUB:
{
png_uint_32 i;
int bpp;
png_bytep rp;
png_bytep lp;
png_uint_32 istop = row_info->rowbytes;
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
png_bytep rp = row + bpp;
png_bytep lp = row;
bpp = (row_info->pixel_depth + 7) / 8;
for (i = (png_uint_32)bpp, rp = row + bpp, lp = row;
i < row_info->rowbytes; i++, rp++, lp++)
for (i = bpp; i < istop; i++)
{
*rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff);
*rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff);
rp++;
}
break;
}
case PNG_FILTER_VALUE_UP:
{
png_uint_32 i;
png_bytep rp;
png_bytep pp;
png_uint_32 istop = row_info->rowbytes;
png_bytep rp = row;
png_bytep pp = prev_row;
for (i = 0, rp = row, pp = prev_row;
i < row_info->rowbytes; i++, rp++, pp++)
for (i = 0; i < istop; i++)
{
*rp = (png_byte)(((int)(*rp) + (int)(*pp)) & 0xff);
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
rp++;
}
break;
}
case PNG_FILTER_VALUE_AVG:
{
png_uint_32 i;
int bpp;
png_bytep rp;
png_bytep pp;
png_bytep lp;
png_bytep rp = row;
png_bytep pp = prev_row;
png_bytep lp = row;
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
png_uint_32 istop = row_info->rowbytes - bpp;
bpp = (row_info->pixel_depth + 7) / 8;
for (i = 0, rp = row, pp = prev_row;
i < (png_uint_32)bpp; i++, rp++, pp++)
for (i = 0; i < bpp; i++)
{
*rp = (png_byte)(((int)(*rp) +
((int)(*pp) / 2)) & 0xff);
((int)(*pp++) / 2)) & 0xff);
rp++;
}
for (lp = row; i < row_info->rowbytes; i++, rp++, lp++, pp++)
for (i = 0; i < istop; i++)
{
*rp = (png_byte)(((int)(*rp) +
(int)(*pp + *lp) / 2) & 0xff);
(int)(*pp++ + *lp++) / 2) & 0xff);
rp++;
}
break;
}
case PNG_FILTER_VALUE_PAETH:
{
int bpp;
png_uint_32 i;
png_bytep rp;
png_bytep pp;
png_bytep lp;
png_bytep cp;
png_bytep rp = row;
png_bytep pp = prev_row;
png_bytep lp = row;
png_bytep cp = prev_row;
png_uint_32 bpp = (row_info->pixel_depth + 7) / 8;
png_uint_32 istop=row_info->rowbytes - bpp;
bpp = (row_info->pixel_depth + 7) / 8;
for (i = 0, rp = row, pp = prev_row,
lp = row - bpp, cp = prev_row - bpp;
i < row_info->rowbytes; i++, rp++, pp++, lp++, cp++)
for (i = 0; i < bpp; i++)
{
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
rp++;
}
for (i = 0; i < istop; i++) /* use leftover rp,pp */
{
int a, b, c, pa, pb, pc, p;
b = *pp;
if (i >= (png_uint_32)bpp)
{
c = *cp;
a = *lp;
}
else
{
a = c = 0;
}
p = a + b - c;
pa = abs(p - a);
pb = abs(p - b);
pc = abs(p - c);
a = *lp++;
b = *pp++;
c = *cp++;
p = b - c;
pc = a - c;
#ifdef PNG_USE_ABS
pa = abs(p);
pb = abs(pc);
pc = abs(p + pc);
#else
pa = p < 0 ? -p : p;
pb = pc < 0 ? -pc : pc;
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif
/*
if (pa <= pb && pa <= pc)
p = a;
else if (pb <= pc)
p = b;
else
p = c;
*/
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
rp++;
}
break;
}
default:
png_error(png_ptr, "Bad adaptive filter type");
png_warning(png_ptr, "Ignoring bad adaptive filter type");
*row=0;
break;
}
}
@@ -2044,7 +2079,7 @@ png_read_finish_row(png_structp png_ptr)
if (!(png_ptr->num_rows))
continue;
}
if (png_ptr->transformations & PNG_INTERLACE)
else /* if (png_ptr->transformations & PNG_INTERLACE) */
break;
} while (png_ptr->iwidth == 0);
@@ -2118,7 +2153,7 @@ void
png_read_start_row(png_structp png_ptr)
{
int max_pixel_depth;
png_uint_32 rowbytes;
png_uint_32 row_bytes;
png_debug(1, "in png_read_start_row\n");
png_ptr->zstream.avail_in = 0;
@@ -2136,10 +2171,10 @@ png_read_start_row(png_structp png_ptr)
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
rowbytes = ((png_ptr->iwidth *
row_bytes = ((png_ptr->iwidth *
(png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
png_ptr->irowbytes = (png_size_t)rowbytes;
if((png_uint_32)png_ptr->irowbytes != rowbytes)
png_ptr->irowbytes = (png_size_t)row_bytes;
if((png_uint_32)png_ptr->irowbytes != row_bytes)
png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
}
else
@@ -2186,27 +2221,47 @@ png_read_start_row(png_structp png_ptr)
#if defined(PNG_READ_FILLER_SUPPORTED)
if (png_ptr->transformations & (PNG_FILLER))
{
if (max_pixel_depth < 32)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
max_pixel_depth = 32;
else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
{
if (max_pixel_depth <= 8)
max_pixel_depth = 16;
else
max_pixel_depth = 32;
}
else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
{
if (max_pixel_depth <= 32)
max_pixel_depth = 32;
else
max_pixel_depth = 64;
}
}
#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
{
if ((png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||
if (
#if defined(PNG_READ_EXPAND_SUPPORTED)
(png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||
#endif
#if defined(PNG_READ_FILLER_SUPPORTED)
(png_ptr->transformations & (PNG_FILLER)) ||
#endif
png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
if (max_pixel_depth <= 16)
max_pixel_depth = 32;
else if (max_pixel_depth <= 32)
else
max_pixel_depth = 64;
}
else
{
if (max_pixel_depth <= 8)
max_pixel_depth = 24;
else if (max_pixel_depth <= 16)
else
max_pixel_depth = 48;
}
}
@@ -2214,16 +2269,16 @@ png_read_start_row(png_structp png_ptr)
/* align the width on the next larger 8 pixels. Mainly used
for interlacing */
rowbytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
/* calculate the maximum bytes needed, adding a byte and a pixel
for safety sake */
rowbytes = ((rowbytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
for safety's sake */
row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) +
1 + ((max_pixel_depth + 7) >> 3);
#ifdef PNG_MAX_MALLOC_64K
if (rowbytes > (png_uint_32)65536L)
if (row_bytes > (png_uint_32)65536L)
png_error(png_ptr, "This image requires a row greater than 64KB");
#endif
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, rowbytes);
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes);
#ifdef PNG_MAX_MALLOC_64K
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)

View File

@@ -1,12 +1,11 @@
/* pngset.c - storage of image information into info struct
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data
@@ -108,13 +107,14 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
/* check for overflow */
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
info_ptr->rowbytes = info_ptr->width * rowbytes_per_pixel;
if (( width > (png_uint_32)2147483647L/rowbytes_per_pixel))
if (( width > PNG_MAX_UINT/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large to process image data; rowbytes will overflow.");
info_ptr->rowbytes = (png_size_t)0;
}
else
info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3;
}
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
@@ -344,7 +344,8 @@ void
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{
png_debug1(1, "in %s storage function\n", "tIME");
if (png_ptr == NULL || info_ptr == NULL)
if (png_ptr == NULL || info_ptr == NULL ||
(png_ptr->flags & PNG_FLAG_WROTE_tIME))
return;
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
@@ -378,3 +379,13 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
}
#endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
void
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{
png_debug1(1, "in png_permit_empty_plte\n", "");
if (png_ptr == NULL)
return;
png_ptr->empty_plte_permitted=(png_byte)empty_plte_permitted;
}
#endif

221
pngtest.c
View File

@@ -1,12 +1,11 @@
/* pngtest.c - a simple test program to test libpng
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This program reads in a PNG image, writes it out again, and then
* compares the two files. If the files are identical, this shows that
@@ -14,9 +13,9 @@
* properly. It does not currently test all of the transforms, although
* it probably should.
*
* The program will fail in certain legitimate cases:
* The program will report "FAIL" in certain legitimate cases:
* 1) when the compression level or filter selection method is changed.
* 2) when the chunk size is smaller than 8K.
* 2) when the chunk size is not 8K.
* 3) unknown ancillary chunks exist in the input file.
* 4) others not listed here...
* In these cases, it is best to check with another tool such as "pngcheck"
@@ -24,7 +23,8 @@
*
* If a filename is given on the command-line, then this file is used
* for the input, rather than the default "pngtest.png". This allows
* testing a wide variety of files easily.
* testing a wide variety of files easily. You can also test a number
* of files at once by typing "pngtest -m file1.png file2.png ..."
*/
#include <stdio.h>
@@ -37,6 +37,13 @@
#include "png.h"
#if defined(PNG_TIME_RFC1123_SUPPORTED)
static int tIME_chunk_present=0;
static char tIME_string[30] = "no tIME chunk present in file";
#endif /* PNG_TIME_RFC1123_SUPPORTED */
static int verbose = 0;
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
#ifdef __TURBOC__
@@ -55,12 +62,12 @@ static int status_dots=1;
void
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
if(png_ptr == NULL || row_number > 0x3fffffffL) return;
if(png_ptr == NULL || row_number > PNG_MAX_UINT) return;
if(status_pass != pass)
{
fprintf(stdout,"\n Pass %d: ",pass);
status_pass = pass;
status_dots = 30;
status_dots = 31;
}
status_dots--;
if(status_dots == 0)
@@ -74,19 +81,32 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
void
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
if(png_ptr == NULL || row_number > 0x3fffffffL || pass > 7) return;
if(png_ptr == NULL || row_number > PNG_MAX_UINT || pass > 7) return;
fprintf(stdout, "w");
}
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
/* Example of using user transform callback (we don't transform anything,
but merely examine the row filters. We set this to 256 rather than
5 in case illegal filter values are present.) */
static png_uint_32 filters_used[256];
void
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
if(png_ptr != NULL && row_info != NULL)
++filters_used[*(data-1)];
}
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
/* example of using user transform callback (we don't transform anything,
but merely count the black pixels) */
but merely count the zero samples) */
static png_uint_32 black_pixels;
static png_uint_32 zero_samples;
void
count_black_pixels(png_structp png_ptr, png_row_infop row_info, png_bytep data)
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
png_bytep dp = data;
if(png_ptr == NULL)return;
@@ -100,60 +120,67 @@ count_black_pixels(png_structp png_ptr, png_row_infop row_info, png_bytep data)
* png_byte pixel_depth bits per pixel (depth*channels)
*/
/* counts the number of black pixels (or zero pixels if color_type is 3 */
/* counts the number of zero samples (or zero pixels if color_type is 3 */
if(row_info->color_type == 0 || row_info->color_type == 3)
{
int pos=0;
png_uint_32 n;
for (n=0; n<row_info->width; n++)
png_uint_32 n, nstop;
for (n=0, nstop=row_info->width; n<nstop; n++)
{
if(row_info->bit_depth == 1)
if(((*dp << pos++ )& 0x80) == 0) black_pixels++;
{
if(((*dp << pos++ )& 0x80) == 0) zero_samples++;
if(pos == 8)
{
pos=0;
pos = 0;
dp++;
}
}
if(row_info->bit_depth == 2)
if(((*dp << (pos+=2))& 0xc0) == 0) black_pixels++;
{
if(((*dp << (pos+=2))& 0xc0) == 0) zero_samples++;
if(pos == 8)
{
pos=0;
pos = 0;
dp++;
}
}
if(row_info->bit_depth == 4)
if(((*dp << (pos+=4))& 0xf0) == 0) black_pixels++;
{
if(((*dp << (pos+=4))& 0xf0) == 0) zero_samples++;
if(pos == 8)
{
pos=0;
pos = 0;
dp++;
}
}
if(row_info->bit_depth == 8)
if(*dp++ == 0) black_pixels++;
if(*dp++ == 0) zero_samples++;
if(row_info->bit_depth == 16)
{
if((*dp | *(dp+1)) == 0) black_pixels++;
if((*dp | *(dp+1)) == 0) zero_samples++;
dp+=2;
}
}
}
else /* other color types */
{
png_uint_32 n;
png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
if(row_info->color_type > 3)color_channels--;
for (n=0; n<row_info->width; n++)
for (n=0, nstop=row_info->width; n<nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
if(row_info->bit_depth == 8)
if(*dp++ == 0) black_pixels++;
if(*dp++ == 0) zero_samples++;
if(row_info->bit_depth == 16)
{
if((*dp | *(dp+1)) == 0) black_pixels++;
if((*dp | *(dp+1)) == 0) zero_samples++;
dp+=2;
}
}
@@ -167,14 +194,13 @@ count_black_pixels(png_structp png_ptr, png_row_infop row_info, png_bytep data)
}
#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
static int verbose = 0;
static int wrote_question = 0;
#if defined(PNG_NO_STDIO)
/* START of code to validate stdio-free compilation */
/* These copies of the default read/write functions come from pngrio.c and */
/* pngwio.c. They allow "don't include stdio" testing of the library. */
/* This is the function which 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
read_data function and use it at run time with png_set_read_fn(), rather
than changing the library. */
@@ -256,7 +282,7 @@ png_default_flush(png_structp png_ptr)
}
#endif
/* This is the function which 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
write_data function and use it at run time with png_set_write_fn(), rather
than changing the library. */
@@ -346,18 +372,14 @@ static void
png_default_error(png_structp png_ptr, png_const_charp message)
{
png_default_warning(png_ptr, message);
/* We can return because png_error calls the default handler which is
* actually ok in this case. */
/* We can return because png_error calls the default handler, which is
* actually OK in this case. */
}
#endif /* PNG_NO_STDIO */
/* END of code to validate stdio-free compilation */
/* START of code to validate memory allocation and deallocation */
#ifdef PNGTEST_MEMORY_DEBUG
/* Borland DOS special memory handler */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
ERROR - memory debugging is not supported on this platform
#else
#ifdef PNG_USER_MEM_SUPPORTED
/* Allocate memory. For reasonable files, size should never exceed
64K. However, zlib may allocate more then 64K if you don't tell
@@ -384,23 +406,23 @@ extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
png_voidp ptr));
png_voidp
png_malloc(png_structp png_ptr, png_uint_32 size) {
if (png_ptr == NULL) {
fprintf(STDERR, "NULL pointer to memory allocator\n");
return (NULL);
}
png_debug_malloc(png_structp png_ptr, png_uint_32 size) {
/* png_malloc has already tested for NULL; png_create_struct calls
png_debug_malloc directly, with png_ptr == NULL which is OK */
if (size == 0)
return (png_voidp)(NULL);
/* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */
{
memory_infop pinfo = png_debug_malloc(png_ptr, sizeof *pinfo);
memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo);
pinfo->size = size;
current_allocation += size;
if (current_allocation > maximum_allocation)
maximum_allocation = current_allocation;
pinfo->pointer = png_debug_malloc(png_ptr, size);
pinfo->pointer = png_malloc_default(png_ptr, size);
pinfo->next = pinformation;
pinformation = pinfo;
/* Make sure the caller isn't assuming zeroed memory. */
@@ -411,10 +433,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size) {
/* Free a pointer. It is removed from the list at the same time. */
void
png_free(png_structp png_ptr, png_voidp ptr)
png_debug_free(png_structp png_ptr, png_voidp ptr)
{
if (png_ptr == NULL)
fprintf(STDERR, "NULL pointer to memory allocator\n");
fprintf(STDERR, "NULL pointer to png_debug_free.\n");
if (ptr == 0) {
#if 0 /* This happens all the time. */
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
@@ -433,9 +455,9 @@ png_free(png_structp png_ptr, png_voidp ptr)
if (current_allocation < 0)
fprintf(STDERR, "Duplicate free of memory\n");
/* We must free the list element too, but first kill
the memory which is to be freed. */
the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size);
png_debug_free(png_ptr, pinfo);
png_free_default(png_ptr, pinfo);
break;
}
if (pinfo->next == NULL) {
@@ -447,10 +469,9 @@ png_free(png_structp png_ptr, png_voidp ptr)
}
/* Finally free the data. */
png_debug_free(png_ptr, ptr);
png_free_default(png_ptr, ptr);
}
#endif /* Not Borland DOS special memory handler */
#endif
#endif /* PNG_USER_MEM_SUPPORTED */
/* END of code to test memory allocation/deallocation */
/* Test one file */
@@ -487,14 +508,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
png_debug(0, "Allocating read and write structures\n");
#ifdef PNG_USER_MEM_SUPPORTED
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
#else
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
(png_error_ptr)NULL, (png_error_ptr)NULL);
#endif
#if defined(PNG_NO_STDIO)
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error,
png_default_warning);
#endif
#ifdef PNG_USER_MEM_SUPPORTED
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
#else
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
(png_error_ptr)NULL, (png_error_ptr)NULL);
#endif
#if defined(PNG_NO_STDIO)
png_set_error_fn(write_ptr, (png_voidp)inname, png_default_error,
png_default_warning);
@@ -503,6 +536,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
read_info_ptr = png_create_info_struct(read_ptr);
write_info_ptr = png_create_info_struct(write_ptr);
end_info_ptr = png_create_info_struct(read_ptr);
#ifdef PNG_USER_MEM_SUPPORTED
#endif
png_debug(0, "Setting jmpbuf for read struct\n");
#ifdef USE_FAR_KEYWORD
@@ -518,10 +553,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
fclose(fpout);
return (1);
}
#ifdef USE_FAR_KEYWORD
png_memcpy(read_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#endif
png_debug(0, "Setting jmpbuf for write struct\n");
#ifdef USE_FAR_KEYWORD
png_memcpy(read_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
if (setjmp(jmpbuf))
#else
if (setjmp(write_ptr->jmpbuf))
@@ -534,10 +571,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
fclose(fpout);
return (1);
}
#ifdef USE_FAR_KEYWORD
png_memcpy(write_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#endif
png_debug(0, "Initializing input and output streams\n");
#if !defined(PNG_NO_STDIO)
png_init_io(read_ptr, fpin);
@@ -562,10 +599,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_set_read_status_fn(read_ptr, NULL);
}
# if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
black_pixels=0;
png_set_write_user_transform_fn(write_ptr, count_black_pixels);
# endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
{
int i;
for(i=0; i<256; i++)
filters_used[i]=0;
png_set_read_user_transform_fn(read_ptr, count_filters);
}
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
zero_samples=0;
png_set_write_user_transform_fn(write_ptr, count_zero_samples);
#endif
png_debug(0, "Reading info struct\n");
png_read_info(read_ptr, read_info_ptr);
@@ -713,6 +758,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))
{
png_set_tIME(write_ptr, write_info_ptr, mod_time);
#if defined(PNG_TIME_RFC1123_SUPPORTED)
/* we have to use png_strcpy instead of "=" because the string
pointed to by png_convert_to_rfc1123() gets free'ed before
we use it */
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
tIME_chunk_present++;
#endif /* PNG_TIME_RFC1123_SUPPORTED */
}
}
#endif
@@ -830,7 +882,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (png_memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
if(wrote_question == 0)
{
fprintf(STDERR,
@@ -856,8 +908,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* input and output filenames */
#ifdef RISCOS
PNG_CONST char *inname = "pngtest/png";
PNG_CONST char *outname = "pngout/png";
static PNG_CONST char *inname = "pngtest/png";
static PNG_CONST char *outname = "pngout/png";
#else
static PNG_CONST char *inname = "pngtest.png";
static PNG_CONST char *outname = "pngout.png";
@@ -871,6 +923,7 @@ main(int argc, char *argv[])
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
fprintf(STDERR,"%s",png_get_copyright(NULL));
/* Do some consistency checking on the memory allocation settings, I'm
not sure this matters, but it is nice to know, the first of these
@@ -938,25 +991,39 @@ main(int argc, char *argv[])
if (multiple)
{
int i;
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
int allocation_now = current_allocation;
#endif
for (i=2; i<argc; ++i)
{
int kerror;
int k, kerror;
fprintf(STDERR, "Testing %s:",argv[i]);
kerror = test_one_file(argv[i], outname);
if (kerror == 0)
{
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
else {
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
for (k=0; k<256; k++)
if(filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k,filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
if(tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n",tIME_string);
tIME_chunk_present = 0;
#endif /* PNG_TIME_RFC1123_SUPPORTED */
}
else
{
fprintf(STDERR, " FAIL\n");
ierror += kerror;
}
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation-allocation_now);
@@ -972,7 +1039,7 @@ main(int argc, char *argv[])
}
#endif
}
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
maximum_allocation);
#endif
@@ -982,7 +1049,7 @@ main(int argc, char *argv[])
int i;
for (i=0; i<3; ++i) {
int kerror;
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
int allocation_now = current_allocation;
#endif
if (i == 1) status_dots_requested = 1;
@@ -993,11 +1060,24 @@ main(int argc, char *argv[])
if(kerror == 0)
{
if(verbose == 1 || i == 2)
{
int k;
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
fprintf(STDERR, " PASS (%lu zero samples)\n",zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
for (k=0; k<256; k++)
if(filters_used[k])
fprintf(STDERR, " Filter %d was used %lu times\n",
k,filters_used[k]);
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
if(tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n",tIME_string);
#endif /* PNG_TIME_RFC1123_SUPPORTED */
}
}
else
{
@@ -1006,7 +1086,7 @@ main(int argc, char *argv[])
fprintf(STDERR, " FAIL\n");
ierror += kerror;
}
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
current_allocation-allocation_now);
@@ -1022,7 +1102,7 @@ main(int argc, char *argv[])
}
#endif
}
#ifdef PNGTEST_MEMORY_DEBUG
#ifdef PNG_USER_MEM_SUPPORTED
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
maximum_allocation);
#endif
@@ -1034,3 +1114,4 @@ main(int argc, char *argv[])
fprintf(STDERR, "libpng FAILS test\n");
return (int)(ierror != 0);
}

View File

@@ -1,19 +1,18 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* turn on bgr to rgb mapping */
/* turn on BGR-to-RGB mapping */
void
png_set_bgr(png_structp png_ptr)
{
@@ -87,8 +86,8 @@ png_set_interlace_handling(png_structp png_ptr)
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
/* Add a filler byte on read, or remove a filler or alpha byte on write.
* The filler type has changed in v0.95 to allow future 2-byte fillers
* for 48-bit input data, as well as avoiding problems with some compilers
* which don't like bytes as parameters.
* for 48-bit input data, as well as to avoid problems with some compilers
* that don't like bytes as parameters.
*/
void
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
@@ -101,11 +100,23 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
else
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
/* This should probably go in the "do_filler" routine */
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB && png_ptr->bit_depth == 8)
/* This should probably go in the "do_filler" routine.
* I attempted to do that in libpng-1.0.1a but that caused problems
* so I restored it in libpng-1.0.2a
*/
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
{
png_ptr->usr_channels = 4;
}
/* Also I added this in libpng-1.0.2a (what happens when we expand
* a less-than-8-bit grayscale to GA? */
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
{
png_ptr->usr_channels = 2;
}
}
#endif
@@ -137,7 +148,7 @@ png_set_invert_mono(png_structp png_ptr)
png_ptr->transformations |= PNG_INVERT_MONO;
}
/* invert monocrome grayscale data */
/* invert monochrome grayscale data */
void
png_do_invert(png_row_infop row_info, png_bytep row)
{
@@ -148,12 +159,14 @@ png_do_invert(png_row_infop row_info, png_bytep row)
#endif
row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
png_bytep rp;
png_bytep rp = row;
png_uint_32 i;
png_uint_32 istop = row_info->rowbytes;
for (i = 0, rp = row; i < row_info->rowbytes; i++, rp++)
for (i = 0; i < istop; i++)
{
*rp = (png_byte)(~(*rp));
rp++;
}
}
}
@@ -171,15 +184,13 @@ png_do_swap(png_row_infop row_info, png_bytep row)
#endif
row_info->bit_depth == 16)
{
png_bytep rp;
png_byte t;
png_bytep rp = row;
png_uint_32 i;
png_uint_32 istop= row_info->width * row_info->channels;
for (i = 0, rp = row;
i < row_info->width * row_info->channels;
i++, rp += 2)
for (i = 0; i < istop; i++, rp += 2)
{
t = *rp;
png_byte t = *rp;
*rp = *(rp + 1);
*(rp + 1) = t;
}
@@ -338,6 +349,11 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
if (row_info->color_type == PNG_COLOR_TYPE_RGB ||
row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
*/
png_bytep sp=row;
png_bytep dp=row;
png_uint_32 row_width=row_info->width;
png_uint_32 i;
if (row_info->channels == 4)
{
if (row_info->bit_depth == 8)
@@ -345,10 +361,8 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
/* This converts from RGBX or RGBA to RGB */
if (flags & PNG_FLAG_FILLER_AFTER)
{
png_bytep sp, dp;
png_uint_32 i;
for (i = 1, sp = row + 4, dp = row + 3; i < row_info->width; i++)
dp+=3; sp+=4;
for (i = 1; i < row_width; i++)
{
*dp++ = *sp++;
*dp++ = *sp++;
@@ -359,10 +373,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
/* This converts from XRGB or ARGB to RGB */
else
{
png_bytep sp, dp;
png_uint_32 i;
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
sp++;
*dp++ = *sp++;
@@ -371,17 +382,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
}
row_info->pixel_depth = 24;
row_info->rowbytes = row_info->width * 3;
row_info->rowbytes = row_width * 3;
}
else /* if (row_info->bit_depth == 16) */
{
if (flags & PNG_FLAG_FILLER_AFTER)
{
png_bytep sp, dp;
png_uint_32 i;
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
for (i = 1, sp = row + 8, dp = row + 6; i < row_info->width; i++)
sp += 8; dp += 6;
for (i = 1; i < row_width; i++)
{
/* This could be (although memcpy is probably slower):
png_memcpy(dp, sp, 6);
@@ -399,17 +408,15 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
else
{
png_bytep sp, dp;
png_uint_32 i;
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
for (i = 0, sp = row + 2, dp = row; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
/* This could be (although memcpy is probably slower):
png_memcpy(dp, sp, 6);
sp += 8;
dp += 6;
*/
sp+=2;
*dp++ = *sp++;
*dp++ = *sp++;
*dp++ = *sp++;
@@ -419,9 +426,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
}
row_info->pixel_depth = 48;
row_info->rowbytes = row_info->width * 6;
row_info->rowbytes = row_width * 6;
}
row_info->channels = 3;
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
}
/*
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY ||
@@ -434,10 +442,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
/* This converts from GX or GA to G */
if (flags & PNG_FLAG_FILLER_AFTER)
{
png_bytep sp, dp;
png_uint_32 i;
for (i = 1, sp = row + 2, dp = row + 1; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
*dp++ = *sp++;
sp++;
@@ -446,27 +451,22 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
/* This converts from XG or AG to G */
else
{
png_bytep sp, dp;
png_uint_32 i;
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
sp++;
*dp++ = *sp++;
}
}
row_info->pixel_depth = 8;
row_info->rowbytes = row_info->width;
row_info->rowbytes = row_width;
}
else /* if (row_info->bit_depth == 16) */
{
if (flags & PNG_FLAG_FILLER_AFTER)
{
png_bytep sp, dp;
png_uint_32 i;
/* This converts from GGXX or GGAA to GG */
for (i = 1, sp = row + 4, dp = row + 2; i < row_info->width; i++)
sp += 4; dp += 2;
for (i = 1; i < row_width; i++)
{
*dp++ = *sp++;
*dp++ = *sp++;
@@ -475,11 +475,8 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
else
{
png_bytep sp, dp;
png_uint_32 i;
/* This converts from XXGG or AAGG to GG */
for (i = 0, sp = row, dp = row; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
sp += 2;
*dp++ = *sp++;
@@ -487,9 +484,10 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
}
row_info->pixel_depth = 16;
row_info->rowbytes = row_info->width * 2;
row_info->rowbytes = row_width * 2;
}
row_info->channels = 1;
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
}
}
}
@@ -507,17 +505,17 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
#endif
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
png_uint_32 row_width = row_info->width;
if (row_info->bit_depth == 8)
{
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
{
png_bytep rp;
png_byte save;
png_uint_32 i;
for (i = 0, rp = row; i < row_info->width; i++, rp += 3)
for (i = 0, rp = row; i < row_width; i++, rp += 3)
{
save = *rp;
png_byte save = *rp;
*rp = *(rp + 2);
*(rp + 2) = save;
}
@@ -525,12 +523,11 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
png_bytep rp;
png_byte save;
png_uint_32 i;
for (i = 0, rp = row; i < row_info->width; i++, rp += 4)
for (i = 0, rp = row; i < row_width; i++, rp += 4)
{
save = *rp;
png_byte save = *rp;
*rp = *(rp + 2);
*(rp + 2) = save;
}
@@ -541,33 +538,31 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
{
png_bytep rp;
png_byte save[2];
png_uint_32 i;
for (i = 0, rp = row; i < row_info->width; i++, rp += 6)
for (i = 0, rp = row; i < row_width; i++, rp += 6)
{
save[0] = *rp;
save[1] = *(rp + 1);
png_byte save = *rp;
*rp = *(rp + 4);
*(rp + 4) = save;
save = *(rp + 1);
*(rp + 1) = *(rp + 5);
*(rp + 4) = save[0];
*(rp + 5) = save[1];
*(rp + 5) = save;
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
png_bytep rp;
png_byte save[2];
png_uint_32 i;
for (i = 0, rp = row; i < row_info->width; i++, rp += 8)
for (i = 0, rp = row; i < row_width; i++, rp += 8)
{
save[0] = *rp;
save[1] = *(rp + 1);
png_byte save = *rp;
*rp = *(rp + 4);
*(rp + 4) = save;
save = *(rp + 1);
*(rp + 1) = *(rp + 5);
*(rp + 4) = save[0];
*(rp + 5) = save[1];
*(rp + 5) = save;
}
}
}
@@ -575,3 +570,26 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
}
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void
png_set_user_transform_info(png_structp png_ptr, png_voidp
user_transform_ptr, int user_transform_depth, int user_transform_channels)
{
png_debug(1, "in png_set_user_transform_info\n");
png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = user_transform_depth;
png_ptr->user_transform_channels = user_transform_channels;
}
/* This function returns a pointer to the user_transform_ptr associated with
* the user transform functions. The application should free any memory
* associated with this pointer before png_write_destroy and png_read_destroy
* are called.
*/
png_voidp
png_get_user_transform_ptr(png_structp png_ptr)
{
return ((png_voidp)png_ptr->user_transform_ptr);
}
#endif

3888
pngvcrd.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,16 @@
/* pngwio.c - functions for data output
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
* This file provides a location for all output. Users which need
* special handling are expected to write functions which have the same
* arguments as these, and perform similar functions, but possibly use
* different output methods. Note that you shouldn't change these
* This file provides a location for all output. Users who need
* special handling are expected to write functions that have the same
* arguments as these and perform similar functions, but that possibly
* use different output methods. Note that you shouldn't change these
* functions, but rather write replacement functions and then change
* them at run time with png_set_write_fn(...).
*/
@@ -23,7 +22,7 @@
writes to a file pointer. Note that this routine sometimes gets called
with very small lengths, so you should implement some kind of simple
buffering if you are using unbuffered writes. This should never be asked
to write more then 64K on a 16 bit machine. */
to write more than 64K on a 16 bit machine. */
void
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
@@ -35,7 +34,7 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
}
#if !defined(PNG_NO_STDIO)
/* This is the function which 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
write_data function and use it at run time with png_set_write_fn(), rather
than changing the library. */
@@ -133,13 +132,13 @@ png_default_flush(png_structp png_ptr)
png_ptr - pointer to a png output data structure
io_ptr - pointer to user supplied structure containing info about
the output functions. May be NULL.
write_data_fn - pointer to a new output function which 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
data to be written, and a 32-bit unsigned int which is
data to be written, and a 32-bit unsigned int that is
the number of bytes to be written. The new write
function should call png_error(png_ptr, "Error msg")
to exit and output any fatal error messages.
flush_data_fn - pointer to a new flush function which takes as its
flush_data_fn - pointer to a new flush function that takes as its
arguments a pointer to a png_struct. After a call to
the flush function, there should be no data in any buffers
or pending transmission. If the output method doesn't do
@@ -175,7 +174,14 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
/* It is an error to read while writing a png file */
if (png_ptr->read_data_fn != NULL)
{
png_ptr->read_data_fn = NULL;
png_warning(png_ptr,
"Attempted to set both read_data_fn and write_data_fn in");
png_warning(png_ptr,
"the same structure. Resetting read_data_fn to NULL.");
}
}
#if defined(USE_FAR_KEYWORD)

View File

@@ -1,12 +1,11 @@
/* pngwrite.c - general routines to write a PNG file
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
/* get internal access to png.h */
@@ -16,7 +15,7 @@
/* Writes all the PNG information. This is the suggested way to use the
* library. If you have a new chunk to add, make a function to write it,
* and put it in the correct location here. If you want the chunk written
* after the image data, put it in png_write_end(). I strongly encurage
* after the image data, put it in png_write_end(). I strongly encourage
* you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
* the chunk, as that will keep the code from breaking if you want to just
* write a plain PNG file. If you have long comments, I suggest writing
@@ -218,43 +217,6 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
png_write_IEND(png_ptr);
}
#if defined(PNG_TIME_RFC1123_SUPPORTED)
/* Convert the supplied time into an RFC 1123 string suitable for use in
* a "Creation Time" or other text-based time string.
*/
png_charp
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
{
static PNG_CONST char short_months[12][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
if (png_ptr->time_buffer == NULL)
{
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
sizeof(char)));
}
#ifdef USE_FAR_KEYWORD
{
char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 31, short_months[ptime->month - 1],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
png_memcpy(png_ptr->time_buffer, near_time_buf,
29*sizeof(char));
}
#else
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 31, short_months[ptime->month - 1],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
#endif
return ((png_charp)png_ptr->time_buffer);
}
#endif /* PNG_TIME_RFC1123_SUPPORTED */
#if defined(PNG_WRITE_tIME_SUPPORTED)
void
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
@@ -281,15 +243,32 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
/* Initialize png_ptr structure, and allocate any memory needed */
png_structp
png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn)
{
#ifdef PNG_USER_MEM_SUPPORTED
return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL));
}
/* Alternate initialize png_ptr structure, and allocate any memory needed */
png_structp
png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_structp png_ptr;
#ifdef USE_FAR_KEYWORD
jmp_buf jmpbuf;
#endif
png_debug(1, "in png_create_write_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL)
#else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
#endif /* PNG_USER_MEM_SUPPORTED */
{
return ((png_structp)NULL);
}
@@ -306,6 +285,9 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
#ifdef USE_FAR_KEYWORD
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
#endif /* PNG_USER_MEM_SUPPORTED */
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
@@ -335,7 +317,6 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
return ((png_structp)png_ptr);
}
/* Initialize png_ptr structure, and allocate any memory needed */
void
png_write_init(png_structp png_ptr)
@@ -422,6 +403,36 @@ png_write_row(png_structp png_ptr, png_bytep row)
/* initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* check for transforms that have been set but were defined out */
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_MONO)
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
if (png_ptr->transformations & PNG_FILLER)
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
if (png_ptr->transformations & PNG_PACK)
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
if (png_ptr->transformations & PNG_SHIFT)
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR)
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined.");
#endif
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined.");
#endif
png_write_start_row(png_ptr);
}
@@ -601,10 +612,18 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL;
#endif
png_debug(1, "in png_destroy_write_struct\n");
if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
#endif
}
if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr;
@@ -627,14 +646,22 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_free(png_ptr, info_ptr->pcal_params);
}
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
#else
png_destroy_struct((png_voidp)info_ptr);
#endif
*info_ptr_ptr = (png_infop)NULL;
}
if (png_ptr != NULL)
{
png_write_destroy(png_ptr);
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn);
#else
png_destroy_struct((png_voidp)png_ptr);
#endif
*png_ptr_ptr = (png_structp)NULL;
}
}
@@ -648,6 +675,9 @@ png_write_destroy(png_structp png_ptr)
png_error_ptr error_fn;
png_error_ptr warning_fn;
png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
#endif
png_debug(1, "in png_write_destroy\n");
/* free any memory zlib uses */
@@ -678,12 +708,18 @@ png_write_destroy(png_structp png_ptr)
error_fn = png_ptr->error_fn;
warning_fn = png_ptr->warning_fn;
error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
#endif
png_memset(png_ptr, 0, sizeof (png_struct));
png_ptr->error_fn = error_fn;
png_ptr->warning_fn = warning_fn;
png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr->free_fn = free_fn;
#endif
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
}
@@ -794,9 +830,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
int num_weights, png_doublep filter_weights,
png_doublep filter_costs)
{
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
int i;
#endif
png_debug(1, "in png_set_filter_heuristics\n");
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
@@ -937,6 +971,8 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
{
if (window_bits > 15)
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
else if (window_bits < 8)
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
png_ptr->zlib_window_bits = window_bits;
}
@@ -967,4 +1003,3 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
png_ptr->write_user_transform_fn = write_user_transform_fn;
}
#endif

View File

@@ -1,18 +1,17 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
#include "png.h"
/* Transform the data according to the users wishes. The order of
/* Transform the data according to the user's wishes. The order of
* transformations is significant.
*/
void
@@ -48,15 +47,15 @@ png_do_write_transformations(png_structp png_ptr)
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
(png_uint_32)png_ptr->bit_depth);
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
if (png_ptr->transformations & PNG_SHIFT)
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->shift));
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(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);
@@ -97,12 +96,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
png_bytep sp, dp;
int mask, v;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
sp = row;
dp = row;
mask = 0x80;
v = 0;
for (i = 0; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
if (*sp != 0)
v |= mask;
@@ -126,12 +127,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
png_bytep sp, dp;
int shift, v;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
sp = row;
dp = row;
shift = 6;
v = 0;
for (i = 0; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
png_byte value;
@@ -157,12 +159,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
png_bytep sp, dp;
int shift, v;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
sp = row;
dp = row;
shift = 4;
v = 0;
for (i = 0; i < row_info->width; i++)
for (i = 0; i < row_width; i++)
{
png_byte value;
@@ -214,9 +217,8 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
{
int shift_start[4], shift_dec[4];
png_uint_32 channels;
int channels = 0;
channels = 0;
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
{
shift_start[channels] = row_info->bit_depth - bit_depth->red;
@@ -245,9 +247,10 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
/* with low row depths, could only be grayscale, so one channel */
if (row_info->bit_depth < 8)
{
png_bytep bp;
png_bytep bp = row;
png_uint_32 i;
png_byte mask;
png_uint_32 row_bytes = row_info->rowbytes;
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
mask = 0x55;
@@ -256,7 +259,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
else
mask = 0xff;
for (bp = row, i = 0; i < row_info->rowbytes; i++, bp++)
for (i = 0; i < row_bytes; i++, bp++)
{
png_uint_16 v;
int j;
@@ -274,17 +277,16 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
}
else if (row_info->bit_depth == 8)
{
png_bytep bp;
png_bytep bp = row;
png_uint_32 i;
png_uint_32 istop = channels * row_info->width;
for (bp = row, i = 0; i < row_info->width; i++)
for (i = 0; i < istop; i++, bp++)
{
png_uint_32 c;
for (c = 0; c < channels; c++, bp++)
{
png_uint_16 v;
int j;
int c = (int)(i%channels);
v = *bp;
*bp = 0;
@@ -297,18 +299,15 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
}
}
}
}
else
{
png_bytep bp;
png_uint_32 i;
png_uint_32 istop = channels * row_info->width;
for (bp = row, i = 0; i < row_info->width * row_info->channels; i++)
{
png_uint_32 c;
for (c = 0; c < channels; c++, bp += 2)
for (bp = row, i = 0; i < istop; i++)
{
int c = (int)(i%channels);
png_uint_16 value, v;
int j;
@@ -321,9 +320,8 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
else
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
}
*bp = (png_byte)(value >> 8);
*(bp + 1) = (png_byte)(value & 0xff);
}
*bp++ = (png_byte)(value >> 8);
*bp++ = (png_byte)(value & 0xff);
}
}
}
@@ -345,12 +343,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
if (row_info->bit_depth == 8)
{
png_bytep sp, dp;
png_byte save;
png_uint_32 i;
for (i = 0, sp = dp = row; i < row_info->width; i++)
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_width; i++)
{
save = *(sp++);
png_byte save = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
@@ -361,11 +358,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
else
{
png_bytep sp, dp;
png_byte save[2];
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
png_byte save[2];
save[0] = *(sp++);
save[1] = *(sp++);
*(dp++) = *(sp++);
@@ -385,12 +383,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
if (row_info->bit_depth == 8)
{
png_bytep sp, dp;
png_byte save;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
save = *(sp++);
png_byte save = *(sp++);
*(dp++) = *(sp++);
*(dp++) = save;
}
@@ -399,11 +397,12 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
else
{
png_bytep sp, dp;
png_byte save[2];
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
png_byte save[2];
save[0] = *(sp++);
save[1] = *(sp++);
*(dp++) = *(sp++);
@@ -433,8 +432,8 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_bytep sp, dp;
png_uint_32 i;
for (i = 0, sp = dp = row; i < row_info->width; i++)
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_width; i++)
{
*(dp++) = *(sp++);
*(dp++) = *(sp++);
@@ -447,8 +446,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_bytep sp, dp;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
*(dp++) = *(sp++);
*(dp++) = *(sp++);
@@ -468,8 +468,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_bytep sp, dp;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
*(dp++) = *(sp++);
*(dp++) = 255 - *(sp++);
@@ -480,8 +481,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_bytep sp, dp;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_info->width; i++)
for (i = 0, sp = dp = row; i < row_width; i++)
{
*(dp++) = *(sp++);
*(dp++) = *(sp++);

View File

@@ -1,12 +1,11 @@
/* pngwutil.c - utilities to write a PNG file
*
* libpng 1.0.1
* libpng 1.0.4 - September 18, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* March 15, 1998
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
@@ -274,7 +273,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
}
/* write the palette. We are careful not to trust png_color to be in the
* correct order for PNG, so people can redefine it to any convient
* correct order for PNG, so people can redefine it to any convenient
* structure.
*/
void
@@ -285,7 +284,11 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_byte buf[3];
png_debug(1, "in png_write_PLTE\n");
if (num_pal == 0 || num_pal > 256)
if ((
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED
!png_ptr->empty_plte_permitted &&
#endif
num_pal == 0) || num_pal > 256)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
@@ -377,7 +380,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
{
png_byte maxbits;
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8:png_ptr->usr_bit_depth;
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8 : png_ptr->usr_bit_depth;
if (sbit->red == 0 || sbit->red > maxbits ||
sbit->green == 0 || sbit->green > maxbits ||
sbit->blue == 0 || sbit->blue > maxbits)
@@ -525,7 +528,12 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
png_debug(1, "in png_write_bKGD\n");
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (back->index > png_ptr->num_palette)
if (
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED
(!png_ptr->empty_plte_permitted ||
(png_ptr->empty_plte_permitted && png_ptr->num_palette)) &&
#endif
back->index > png_ptr->num_palette)
{
png_warning(png_ptr, "Invalid background palette index");
return;
@@ -575,7 +583,8 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
}
#endif
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
defined(PNG_WRITE_pCAL_SUPPORTED)
/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,
* and if invalid, correct the keyword rather than discarding the entire
* chunk. The PNG 1.0 specification requires keywords 1-79 characters in
@@ -713,6 +722,11 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
/* make sure we include the 0 after the key */
png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
/*
* We leave it to the application to meet PNG-1.0 requirements on the
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
*/
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
if (text_len)
png_write_chunk_data(png_ptr, (png_bytep)text, text_len);
@@ -766,7 +780,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
}
/* We can't write the chunk until we find out how much data we have,
* which means we need to run the compressor first, and save the
* which means we need to run the compressor first and save the
* output. This shouldn't be a problem, as the vast majority of
* comments should be reasonable, but we will set up an array of
* malloc'd pointers to be sure.
@@ -835,7 +849,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
}
/* continue until we don't have anymore to compress */
/* continue until we don't have any more to compress */
} while (png_ptr->zstream.avail_in);
/* finish the compression */
@@ -1241,7 +1255,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
if (pass < 6)
#endif
{
/* each pixel depth is handled seperately */
/* each pixel depth is handled separately */
switch (row_info->pixel_depth)
{
case 1:
@@ -1252,11 +1266,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
int d;
int value;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
dp = row;
d = 0;
shift = 7;
for (i = png_pass_start[pass]; i < row_info->width;
for (i = png_pass_start[pass]; i < row_width;
i += png_pass_inc[pass])
{
sp = row + (png_size_t)(i >> 3);
@@ -1285,11 +1300,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
int d;
int value;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
dp = row;
shift = 6;
d = 0;
for (i = png_pass_start[pass]; i < row_info->width;
for (i = png_pass_start[pass]; i < row_width;
i += png_pass_inc[pass])
{
sp = row + (png_size_t)(i >> 2);
@@ -1317,11 +1333,12 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
int d;
int value;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
dp = row;
shift = 4;
d = 0;
for (i = png_pass_start[pass]; i < row_info->width;
for (i = png_pass_start[pass]; i < row_width;
i += png_pass_inc[pass])
{
sp = row + (png_size_t)(i >> 1);
@@ -1346,6 +1363,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
png_bytep sp;
png_bytep dp;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
png_size_t pixel_bytes;
/* start at the beginning */
@@ -1354,7 +1372,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
pixel_bytes = (row_info->pixel_depth >> 3);
/* loop through the row, only looking at the pixels that
matter */
for (i = png_pass_start[pass]; i < row_info->width;
for (i = png_pass_start[pass]; i < row_width;
i += png_pass_inc[pass])
{
/* find out where the original pixel is */
@@ -1392,6 +1410,11 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep prev_row, best_row, row_buf;
png_uint_32 mins, bpp;
png_byte filter_to_do = png_ptr->do_filter;
png_uint_32 row_bytes = row_info->rowbytes;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
int num_p_filters = (int)png_ptr->num_prev_filters;
#endif
png_debug(1, "in png_write_find_filter\n");
/* find out how many bytes offset each pixel is */
@@ -1403,28 +1426,38 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
/* The prediction method we use is to find which method provides the
* smallest value when summing the absolute values of the distances
* from zero using anything >= 128 as negative numbers. This is known
* from zero, using anything >= 128 as negative numbers. This is known
* as the "minimum sum of absolute differences" heuristic. Other
* heuristics are the "weighted minumum sum of absolute differences"
* heuristics are the "weighted minimum sum of absolute differences"
* (experimental and can in theory improve compression), and the "zlib
* predictive" method (not implemented in libpng 0.95), which does test
* compressions of lines using different filter methods, and then chooses
* the (series of) filter(s) which give minimum compressed data size (VERY
* predictive" method (not implemented yet), which does test compressions
* of lines using different filter methods, and then chooses the
* (series of) filter(s) that give minimum compressed data size (VERY
* computationally expensive).
*
* GRR 980525: consider also
* (1) minimum sum of absolute differences from running average (i.e.,
* keep running sum of non-absolute differences & count of bytes)
* [track dispersion, too? restart average if dispersion too large?]
* (1b) minimum sum of absolute differences from sliding average, probably
* with window size <= deflate window (usually 32K)
* (2) minimum sum of squared differences from zero or running average
* (i.e., ~ root-mean-square approach)
*/
/* We don't need to test the 'no filter' case if this is the only filter
* that has been chosen, as it doesn't actually do anything to the data.
*/
if (png_ptr->do_filter & PNG_FILTER_NONE &&
png_ptr->do_filter != PNG_FILTER_NONE)
if (filter_to_do & PNG_FILTER_NONE &&
filter_to_do != PNG_FILTER_NONE)
{
png_bytep rp;
png_uint_32 sum = 0;
png_uint_32 i;
int v;
for (i = 0, rp = row_buf + 1; i < row_info->rowbytes; i++, rp++)
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
{
v = *rp;
sum += (v < 128) ? v : 256 - v;
@@ -1434,17 +1467,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
png_uint_32 sumhi, sumlo;
int j;
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */
/* Reduce the sum if we match any of the previous rows */
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
{
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1468,7 +1502,25 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
}
/* sub filter */
if (png_ptr->do_filter & PNG_FILTER_SUB)
if (filter_to_do == PNG_FILTER_SUB)
/* it's the only filter so no testing is needed */
{
png_bytep rp, lp, dp;
png_uint_32 i;
for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
i++, rp++, dp++)
{
*dp = *rp;
}
for (lp = row_buf + 1; i < row_bytes;
i++, rp++, lp++, dp++)
{
*dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
}
best_row = png_ptr->sub_row;
}
else if (filter_to_do & PNG_FILTER_SUB)
{
png_bytep rp, dp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -1476,23 +1528,24 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
/* We temporarily increase the "minumum sum" by the factor we
/* We temporarily increase the "minimum sum" by the factor we
* would reduce the sum of this filter, so that we can do the
* early exit comparison without scaling the sum each time.
*/
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 lmhi, lmlo;
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
{
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1530,17 +1583,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 sumhi, sumlo;
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)
{
sumlo = (sumlo * png_ptr->inv_filter_weights[i]) >>
sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
sumhi = (sumhi * png_ptr->inv_filter_weights[i]) >>
sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1565,27 +1619,43 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
}
/* up filter */
if (png_ptr->do_filter & PNG_FILTER_UP)
if (filter_to_do == PNG_FILTER_UP)
{
png_bytep rp, dp, pp;
png_uint_32 i;
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
pp = prev_row + 1; i < row_bytes;
i++, rp++, pp++, dp++)
{
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
}
best_row = png_ptr->up_row;
}
else if (filter_to_do & PNG_FILTER_UP)
{
png_bytep rp, dp, pp;
png_uint_32 sum = 0, lmins = mins;
png_uint_32 i;
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 lmhi, lmlo;
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
{
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1603,10 +1673,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
pp = prev_row + 1; i < row_info->rowbytes;
i++, rp++, pp++, dp++)
pp = prev_row + 1; i < row_bytes; i++)
{
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
sum += (v < 128) ? v : 256 - v;
@@ -1617,17 +1686,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 sumhi, sumlo;
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_UP)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)
{
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1652,7 +1722,24 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
}
/* avg filter */
if (png_ptr->do_filter & PNG_FILTER_AVG)
if (filter_to_do == PNG_FILTER_AVG)
{
png_bytep rp, dp, pp, lp;
png_uint_32 i;
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
pp = prev_row + 1; i < bpp; i++)
{
*dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
}
for (lp = row_buf + 1; i < row_bytes; i++)
{
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
& 0xff);
}
best_row = png_ptr->avg_row;
}
else if (filter_to_do & PNG_FILTER_AVG)
{
png_bytep rp, dp, pp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -1662,17 +1749,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 lmhi, lmlo;
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_AVG)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)
{
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1690,16 +1778,16 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
pp = prev_row + 1; i < bpp; i++, rp++, pp++, dp++)
pp = prev_row + 1; i < bpp; i++)
{
v = *dp = (png_byte)(((int)*rp - ((int)*pp / 2)) & 0xff);
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
sum += (v < 128) ? v : 256 - v;
}
for (lp = row_buf + 1; i < row_info->rowbytes;
i++, rp++, pp++, lp++, dp++)
for (lp = row_buf + 1; i < row_bytes; i++)
{
v = *dp = (png_byte)(((int)*rp - (((int)*pp + (int)*lp) / 2)) & 0xff);
v = *dp++ =
(png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);
sum += (v < 128) ? v : 256 - v;
@@ -1710,17 +1798,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 sumhi, sumlo;
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)
{
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1745,7 +1834,45 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
}
/* Paeth filter */
if (png_ptr->do_filter & PNG_FILTER_PAETH)
if (filter_to_do == PNG_FILTER_PAETH)
{
png_bytep rp, dp, pp, cp, lp;
png_uint_32 i;
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
pp = prev_row + 1; i < bpp; i++)
{
*dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
}
for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
{
int a, b, c, pa, pb, pc, p;
b = *pp++;
c = *cp++;
a = *lp++;
p = b - c;
pc = a - c;
#ifdef PNG_USE_ABS
pa = abs(p);
pb = abs(pc);
pc = abs(p + pc);
#else
pa = p < 0 ? -p : p;
pb = pc < 0 ? -pc : pc;
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
*dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
}
best_row = png_ptr->paeth_row;
}
else if (filter_to_do & PNG_FILTER_PAETH)
{
png_bytep rp, dp, pp, cp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -1755,17 +1882,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 lmhi, lmlo;
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_PAETH)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
{
lmlo = (lmlo * png_ptr->inv_filter_weights[i]) >>
lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
lmhi = (lmhi * png_ptr->inv_filter_weights[i]) >>
lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1783,34 +1911,48 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
pp = prev_row + 1; (unsigned)i < bpp; i++, rp++, pp++, dp++)
pp = prev_row + 1; i < bpp; i++)
{
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
sum += (v < 128) ? v : 256 - v;
}
for (lp = row_buf + 1, cp = prev_row + 1; i < row_info->rowbytes;
i++, rp++, pp++, lp++, dp++, cp++)
for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
{
int a, b, c, pa, pb, pc, p;
b = *pp;
c = *cp;
a = *lp;
b = *pp++;
c = *cp++;
a = *lp++;
#ifndef PNG_SLOW_PAETH
p = b - c;
pc = a - c;
#ifdef PNG_USE_ABS
pa = abs(p);
pb = abs(pc);
pc = abs(p + pc);
#else
pa = p < 0 ? -p : p;
pb = pc < 0 ? -pc : pc;
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
#else /* PNG_SLOW_PAETH */
p = a + b - c;
pa = abs(p - a);
pb = abs(p - b);
pc = abs(p - c);
if (pa <= pb && pa <= pc)
p = a;
else if (pb <= pc)
p = b;
else
p = c;
#endif /* PNG_SLOW_PAETH */
v = *dp = (png_byte)(((int)*rp - p) & 0xff);
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
sum += (v < 128) ? v : 256 - v;
@@ -1821,17 +1963,18 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
{
int j;
png_uint_32 sumhi, sumlo;
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (j = 0; j < num_p_filters; j++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_PAETH)
if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)
{
sumlo = (sumlo * png_ptr->filter_weights[i]) >>
sumlo = (sumlo * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
sumhi = (sumhi * png_ptr->filter_weights[i]) >>
sumhi = (sumhi * png_ptr->filter_weights[j]) >>
PNG_WEIGHT_SHIFT;
}
}
@@ -1855,19 +1998,19 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
}
/* Do the actual writing of the filtered row data from the chosen filter. */
png_write_filtered_row(png_ptr, best_row);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
/* Save the type of filter we picked this time for future calculations */
if (png_ptr->num_prev_filters > 0)
{
int i;
for (i = 1; i < (int)png_ptr->num_prev_filters; i++)
int j;
for (j = 1; j < num_p_filters; j++)
{
png_ptr->prev_filters[i] = png_ptr->prev_filters[i - 1];
png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];
}
png_ptr->prev_filters[i] = best_row[0];
png_ptr->prev_filters[j] = best_row[0];
}
#endif
}

View File

@@ -1,221 +0,0 @@
# Project: libpng
# Toolflags:
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend
CMHGflags =
LibFileflags = -c -l -o $@
Squeezeflags = -o $@
# Final targets:
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
@.mm.pngwtran @.mm.pngwutil
# User-editable dependencies:
# (C) Copyright 1997 Tom Tanner
Test: @.pngtest
<Prefix$Dir>.pngtest
@remove <Prefix$Dir>.pngtest
#It would be nice if you could stop "make" listing from here on!
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
.SUFFIXES: .o .mm .c
.c.mm:
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
.c.o:
cc $(ccflags) -o $@ $<
# Static dependencies:
# Dynamic dependencies:
o.pngtest: c.pngtest
o.pngtest: h.png
o.pngtest: Zlib:h.zlib
o.pngtest: Zlib:h.zconf
o.pngtest: h.pngconf
mm.png: LibPng:c.png
mm.png: LibPng:h.png
mm.png: Zlib:h.zlib
mm.png: Zlib:h.zconf
mm.png: LibPng:h.pngconf
mm.png: MemCheck:ANSI.h.stdio
mm.pngerror: LibPng:c.pngerror
mm.pngerror: LibPng:h.png
mm.pngerror: Zlib:h.zlib
mm.pngerror: Zlib:h.zconf
mm.pngerror: LibPng:h.pngconf
mm.pngerror: MemCheck:ANSI.h.stdio
mm.pngrio: LibPng:c.pngrio
mm.pngrio: LibPng:h.png
mm.pngrio: Zlib:h.zlib
mm.pngrio: Zlib:h.zconf
mm.pngrio: LibPng:h.pngconf
mm.pngrio: MemCheck:ANSI.h.stdio
mm.pngwio: LibPng:c.pngwio
mm.pngwio: LibPng:h.png
mm.pngwio: Zlib:h.zlib
mm.pngwio: Zlib:h.zconf
mm.pngwio: LibPng:h.pngconf
mm.pngwio: MemCheck:ANSI.h.stdio
mm.pngmem: LibPng:c.pngmem
mm.pngmem: LibPng:h.png
mm.pngmem: Zlib:h.zlib
mm.pngmem: Zlib:h.zconf
mm.pngmem: LibPng:h.pngconf
mm.pngmem: MemCheck:ANSI.h.stdio
mm.pngpread: LibPng:c.pngpread
mm.pngpread: LibPng:h.png
mm.pngpread: Zlib:h.zlib
mm.pngpread: Zlib:h.zconf
mm.pngpread: LibPng:h.pngconf
mm.pngpread: MemCheck:ANSI.h.stdio
mm.pngset: LibPng:c.pngset
mm.pngset: LibPng:h.png
mm.pngset: Zlib:h.zlib
mm.pngset: Zlib:h.zconf
mm.pngset: LibPng:h.pngconf
mm.pngset: MemCheck:ANSI.h.stdio
mm.pngget: LibPng:c.pngget
mm.pngget: LibPng:h.png
mm.pngget: Zlib:h.zlib
mm.pngget: Zlib:h.zconf
mm.pngget: LibPng:h.pngconf
mm.pngget: MemCheck:ANSI.h.stdio
mm.pngread: LibPng:c.pngread
mm.pngread: LibPng:h.png
mm.pngread: Zlib:h.zlib
mm.pngread: Zlib:h.zconf
mm.pngread: LibPng:h.pngconf
mm.pngread: MemCheck:ANSI.h.stdio
mm.pngrtran: LibPng:c.pngrtran
mm.pngrtran: LibPng:h.png
mm.pngrtran: Zlib:h.zlib
mm.pngrtran: Zlib:h.zconf
mm.pngrtran: LibPng:h.pngconf
mm.pngrtran: MemCheck:ANSI.h.stdio
mm.pngrutil: LibPng:c.pngrutil
mm.pngrutil: LibPng:h.png
mm.pngrutil: Zlib:h.zlib
mm.pngrutil: Zlib:h.zconf
mm.pngrutil: LibPng:h.pngconf
mm.pngrutil: MemCheck:ANSI.h.stdio
mm.pngtrans: LibPng:c.pngtrans
mm.pngtrans: LibPng:h.png
mm.pngtrans: Zlib:h.zlib
mm.pngtrans: Zlib:h.zconf
mm.pngtrans: LibPng:h.pngconf
mm.pngtrans: MemCheck:ANSI.h.stdio
mm.pngwrite: LibPng:c.pngwrite
mm.pngwrite: LibPng:h.png
mm.pngwrite: Zlib:h.zlib
mm.pngwrite: Zlib:h.zconf
mm.pngwrite: LibPng:h.pngconf
mm.pngwrite: MemCheck:ANSI.h.stdio
mm.pngwtran: LibPng:c.pngwtran
mm.pngwtran: LibPng:h.png
mm.pngwtran: Zlib:h.zlib
mm.pngwtran: Zlib:h.zconf
mm.pngwtran: LibPng:h.pngconf
mm.pngwtran: MemCheck:ANSI.h.stdio
mm.pngwutil: LibPng:c.pngwutil
mm.pngwutil: LibPng:h.png
mm.pngwutil: Zlib:h.zlib
mm.pngwutil: Zlib:h.zconf
mm.pngwutil: LibPng:h.pngconf
mm.pngwutil: MemCheck:ANSI.h.stdio
o.png: c.png
o.png: h.png
o.png: Zlib:h.zlib
o.png: Zlib:h.zconf
o.png: h.pngconf
o.pngerror: c.pngerror
o.pngerror: h.png
o.pngerror: Zlib:h.zlib
o.pngerror: Zlib:h.zconf
o.pngerror: h.pngconf
o.pngrio: c.pngrio
o.pngrio: h.png
o.pngrio: Zlib:h.zlib
o.pngrio: Zlib:h.zconf
o.pngrio: h.pngconf
o.pngwio: c.pngwio
o.pngwio: h.png
o.pngwio: Zlib:h.zlib
o.pngwio: Zlib:h.zconf
o.pngwio: h.pngconf
o.pngmem: c.pngmem
o.pngmem: h.png
o.pngmem: Zlib:h.zlib
o.pngmem: Zlib:h.zconf
o.pngmem: h.pngconf
o.pngpread: c.pngpread
o.pngpread: h.png
o.pngpread: Zlib:h.zlib
o.pngpread: Zlib:h.zconf
o.pngpread: h.pngconf
o.pngset: c.pngset
o.pngset: h.png
o.pngset: Zlib:h.zlib
o.pngset: Zlib:h.zconf
o.pngset: h.pngconf
o.pngget: c.pngget
o.pngget: h.png
o.pngget: Zlib:h.zlib
o.pngget: Zlib:h.zconf
o.pngget: h.pngconf
o.pngread: c.pngread
o.pngread: h.png
o.pngread: Zlib:h.zlib
o.pngread: Zlib:h.zconf
o.pngread: h.pngconf
o.pngrtran: c.pngrtran
o.pngrtran: h.png
o.pngrtran: Zlib:h.zlib
o.pngrtran: Zlib:h.zconf
o.pngrtran: h.pngconf
o.pngrutil: c.pngrutil
o.pngrutil: h.png
o.pngrutil: Zlib:h.zlib
o.pngrutil: Zlib:h.zconf
o.pngrutil: h.pngconf
o.pngtrans: c.pngtrans
o.pngtrans: h.png
o.pngtrans: Zlib:h.zlib
o.pngtrans: Zlib:h.zconf
o.pngtrans: h.pngconf
o.pngwrite: c.pngwrite
o.pngwrite: h.png
o.pngwrite: Zlib:h.zlib
o.pngwrite: Zlib:h.zconf
o.pngwrite: h.pngconf
o.pngwtran: c.pngwtran
o.pngwtran: h.png
o.pngwtran: Zlib:h.zlib
o.pngwtran: Zlib:h.zconf
o.pngwtran: h.pngconf
o.pngwutil: c.pngwutil
o.pngwutil: h.png
o.pngwutil: Zlib:h.zlib
o.pngwutil: Zlib:h.zconf
o.pngwutil: h.pngconf

51
scripts/makefile.acorn Normal file
View File

@@ -0,0 +1,51 @@
# Project: libpng
# Toolflags:
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend
CMHGflags =
LibFileflags = -c -l -o $@
Squeezeflags = -o $@
# Final targets:
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
@.mm.pngwtran @.mm.pngwutil
# User-editable dependencies:
# (C) Copyright 1997 Tom Tanner
Test: @.pngtest
<Prefix$Dir>.pngtest
@remove <Prefix$Dir>.pngtest
#It would be nice if you could stop "make" listing from here on!
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
.SUFFIXES: .o .mm .c
.c.mm:
MemCheck.CC cc $(ccflags) -o $@ LibPng:$<
.c.o:
cc $(ccflags) -o $@ $<
# Static dependencies:
# Dynamic dependencies:

View File

@@ -9,6 +9,7 @@ LBR = png.lib
LDFLAGS=-lpng -lz -lm
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
@@ -28,4 +29,5 @@ install: libpng.a
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/p
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h

104
scripts/makefile.beos Normal file
View File

@@ -0,0 +1,104 @@
# makefile for libpng on BeOS x86 ELF with gcc
# modified from makefile.lnx by Sander Stoks
# Copyright (C) 1996, 1997 Andreas Dilger
# Copyright (C) 1999 Greg Roelofs
# For conditions of distribution and use, see copyright notice in png.h
CC=gcc
# Where the zlib library and include files are located
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
ALIGN=
# For i386:
# ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
# On BeOS, -O1 is actually better than -O3. This is a known bug but it's
# still here in R4.5
CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
LDFLAGS=-L. -Wl,-soname=libpng.so.$(PNGMAJ) -L$(ZLIBLIB) -lz -lm
RANLIB=ranlib
#RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS)
.SUFFIXES: .c .o
all: libpng.a libpng.so pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -sf libpng.so.$(PNGMAJ) libpng.so
cp libpng.so* /boot/home/config/lib
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,libpng.so.$(PNGMAJ) -o
libpng.so.$(PNGVER) \
$(OBJSDLL)
pngtest: pngtest.o libpng.so
$(CC) -L$(ZLIBLIB) -lz -lpng -o pngtest pngtest.o
test: pngtest
./pngtest
install: libpng.a libpng.so.$(PNGVER)
-@mkdir $(INCPATH) $(LIBPATH)
cp png.h pngconf.h $(INCPATH)
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -sf libpng.so.$(PNGMAJ) libpng.so)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@@ -100,7 +100,7 @@ LIBOBJS = \
+pngtrans.$(O) \
+pngwrite.$(O) \
+pngwtran.$(O) \
+pngwio.$(O)
+pngwio.$(O) \
+pngwutil.$(O)
LIBNAME=libpng$(MODEL).lib
@@ -121,7 +121,7 @@ libpng: $(LIBNAME)
pngtest: pngtest$(MODEL).exe
test:
test: pngtest$(MODEL).exe
pngtest$(MODEL)

View File

@@ -2,12 +2,21 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=cc
CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
@@ -15,26 +24,33 @@ LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
#RANLIB=echo
RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
all: libpng.so libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -f -s libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJS)
$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install: libpng.a
install: libpng.a libpng.so.$(PNGVER)
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
@@ -42,10 +58,15 @@ install: libpng.a
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib
cp libpng.so.$(PNGVER) $(prefix)/lib
chmod 644 $(prefix)/lib/libpng.a
chmod 644 $(prefix)/lib/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -f -s libpng.so.$(PNGMAJ) libpng.so)
clean:
rm -f *.o libpng.a pngtest pngout.png
rm -f *.o libpng.a pngtest pngout.png libpng.so*
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@@ -2,16 +2,16 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
#prefix=/usr/local
prefix=.
CC=gcc
CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
RANLIB=ranlib
# where make install puts libpng.a and png.h
#prefix=/usr/local
prefix=.
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o pngwtran.o \
pngmem.o pngerror.o pngpread.o

67
scripts/makefile.hpux Normal file
View File

@@ -0,0 +1,67 @@
# makefile for libpng, HPUX (10.20 and 11.00)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Copyright (C) 1999 Glenn Randers-Pehrson
# contributed by Jim Rice, Hewlett Packard
# For conditions of distribution and use, see copyright notice in png.h
# Where the zlib library and include files are located
ZLIBLIB=/opt/zlib/lib
ZLIBINC=/opt/zlib/include
CC=cc
CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0
CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/opt/libpng
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install: libpng.a
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib
chmod 644 $(prefix)/lib/libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngset.o: png.h pngconf.h
pngget.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h
pngpread.o: png.h pngconf.h

View File

@@ -2,6 +2,14 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# This makefile requires file file ansi2knr.c, which you can get
# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/
# If you have libjpeg, you probably already have ansi2knr.c in the jpeg
# source distribution.
# where make install puts libpng.a and png.h
prefix=/usr/local
CC=cc
CFLAGS=-I../zlib -O
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
@@ -11,9 +19,6 @@ ANSI2KNRFLAGS=
RANLIB=ranlib
#RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o

View File

@@ -1,21 +1,29 @@
# makefile for libpng on Linux ELF with gcc
# Copyright (C) 1996, 1997 Andreas Dilger
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1998, 1999 Greg Roelofs
# For conditions of distribution and use, see copyright notice in png.h
CC=gcc
# where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
ALIGN=
# for i386:
#ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -malign-loops=2 \
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib
@@ -24,11 +32,9 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
@@ -57,7 +63,7 @@ libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
libpng.so.$(PNGVER): $(OBJSDLL)
$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
$(OBJSDLL)
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
pngtest: pngtest.o libpng.so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)

View File

@@ -2,6 +2,9 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
prefix=/usr/local
CC=cc
CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
#CFLAGS=-O
@@ -10,9 +13,6 @@ LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
#RANLIB=ranlib
RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o

98
scripts/makefile.sco Normal file
View File

@@ -0,0 +1,98 @@
# makefile for SCO OSr5 ELF and Unixware 7 with Native cc
# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx
# force ELF build dynamic linking, SONAME setting in lib and RPATH in app
# Copyright (C) 1996, 1997 Andreas Dilger
# Copyright (C) 1998 Greg Roelofs
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
CFLAGS= -dy -belf -I$(ZLIBINC) -O3
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
#RANLIB=ranlib
RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
all: libpng.a libpng.so pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -f -s libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(CC) -G -Wl,-h,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
$(OBJSDLL)
pngtest: pngtest.o libpng.so
LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install: libpng.a libpng.so.$(PNGVER)
-@mkdir $(INCPATH) $(LIBPATH)
cp png.h pngconf.h $(INCPATH)
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -f -s libpng.so.$(PNGMAJ) libpng.so)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@@ -2,6 +2,9 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
@@ -10,15 +13,14 @@ ZLIBINC=../zlib
CC=cc
CFLAGS=-I$(ZLIBINC) -O -fullwarn # -g -DPNG_DEBUG=1
WARNMORE=-fullwarn
# You can add the -n32 option; then zlib must also be compiled with -n32
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) # -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=echo
#RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o

View File

@@ -6,6 +6,14 @@
CC=gcc
# The commands "CC" and "LD" must NOT refer to /usr/ucb/cc and /usr/ucb/ld.
# If they do, you need to adjust your PATH environment variable.
# The environment variable LD_LIBRARY_PATH should not be set at all. If
# it is, things are likely to break.
# Where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
# Where the zlib library and include files are located
# Changing these to ../zlib poses a security risk. If you want
# to have zlib in an adjacent directory, specify the full path instead of "..".
@@ -15,12 +23,11 @@ CC=gcc
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -Wall -O3 \
#$(WARNMORE) -g -DPNG_DEBUG=5
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm
#RANLIB=ranlib
@@ -29,11 +36,9 @@ RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0
PNGMIN = 1.0.4
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
@@ -55,10 +60,10 @@ libpng.a: $(OBJS)
$(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ)
ln -sf libpng.so.$(PNGMAJ) libpng.so
ln -f -s libpng.so.$(PNGMAJ) libpng.so
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
libpng.so.$(PNGVER): $(OBJSDLL)
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
@@ -77,8 +82,8 @@ install: libpng.a libpng.so.$(PNGVER)
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -sf libpng.so.$(PNGMAJ) libpng.so)
(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -f -s libpng.so.$(PNGMAJ) libpng.so)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png

View File

@@ -2,6 +2,9 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
@@ -9,15 +12,12 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib
CC=cc
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
#RANLIB=echo
RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o

View File

@@ -2,6 +2,9 @@
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
@@ -13,15 +16,12 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow -Wconversion \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes
CC=gcc
CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) -DPNG_DEBUG=4
CFLAGS=-I$(ZLIBINC) -O # $(WARNMORE) -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib
#RANLIB=echo
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o

View File

@@ -1,15 +1,15 @@
# Makefile for libpng
# Watcom 10a and later 32-bit protected mode flat memory model
# Watcom 10.0 and later 32-bit protected mode flat memory model
# Adapted by Pawel Mrochen, based on makefile.msc
# For conditions of distribution and use, see copyright notice in png.h
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
# To use, do "wmake -f makefile.wat"
# To use, do "wmake /f scripts\makefile.wat"
# ------------- Watcom 10a and later -------------
# ------------- Watcom 10.0 and later -------------
MODEL=-mf
CFLAGS= $(MODEL) -fpi87 -fp5 -5r -oaeilmnrt -s -zp4 -i=..\zlib
CFLAGS= $(MODEL) -5r -fp5 -fpi87 -oneatx -i=..\zlib
CC=wcc386
LD=wcl386
LIB=wlib -b -c
@@ -75,14 +75,14 @@ pngwutil$(O): png.h pngconf.h
$(CC) $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
$(LIB) -n libpng.lib +$(OBJS1)
$(LIB) libpng.lib +$(OBJS2)
$(LIB) libpng.lib +$(OBJS3)
$(LIB) -n libpng.lib $(OBJS1)
$(LIB) libpng.lib $(OBJS2)
$(LIB) libpng.lib $(OBJS3)
pngtest.exe: pngtest.obj libpng.lib
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib
test: pngtest.exe
test: pngtest.exe .symbolic
pngtest
# End of makefile for libpng

88
scripts/makefile.win32vc Normal file
View File

@@ -0,0 +1,88 @@
# makefile for libpng
# Copyright (C) 1998 Tim Wegner
# For conditions of distribution and use, see copyright notice in png.h
# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
# To use, do "nmake /f scripts\makefile.w32"
# ------------- Microsoft Visual C++ 4.0 and later -------------
MODEL=-
CFLAGS=-DPNG_USE_PNGVCRD -Ox -GA3s -nologo -W3 -I..\zlib
CC=cl
LD=link
LDFLAGS=
O=.obj
#uncomment next to put error messages in a file
#ERRFILE= >> pngerrs
# variables
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
OBJS2 = pngmem$(O) pngpread$(O) pngread$(O) pngerror$(O) pngwrite$(O)
OBJS3 = pngrtran$(O) pngwtran$(O) pngrio$(O) pngwio$(O) pngvcrd$(O)
all: libpng.lib
png$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngset$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngget$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngpread$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrutil$(O): png.h pngconf.h pngasmrd.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngvcrd$(O): png.h pngconf.h pngasmrd.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngerror$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngmem$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngrio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwio$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtest$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngtrans$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwrite$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwtran$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
pngwutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
del libpng.lib
lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
pngtest.exe: pngtest.obj libpng.lib
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib /OUT:pngtest.exe /SUBSYSTEM:CONSOLE
test: pngtest.exe
pngtest
# End of makefile for libpng

722
scripts/pngdef.pas Normal file
View File

@@ -0,0 +1,722 @@
unit pngdef;
interface
const
PNG_LIBPNG_VER_STRING = '1.0.4';
PNG_LIBPNG_VER = 10004;
type
png_uint_32 = Cardinal;
png_int_32 = Longint;
png_uint_16 = Word;
png_int_16 = Smallint;
png_byte = Byte;
png_size_t = png_uint_32;
png_charpp = ^png_charp;
png_charp = PChar;
float = single;
int = Integer;
png_bytepp = ^png_bytep;
png_bytep = ^png_byte;
png_uint_16p = ^png_uint_16;
png_uint_16pp = ^png_uint_16p;
png_voidp = pointer;
time_t = Longint;
png_doublep = ^png_double;
png_double = double;
user_error_ptr = Pointer;
png_error_ptrp = ^png_error_ptr;
png_error_ptr = procedure(png_ptr: Pointer; msg: Pointer);
stdcall;
png_rw_ptrp = ^png_rw_ptr;
png_rw_ptr = procedure(png_ptr: Pointer; data: Pointer;
length: png_size_t);
stdcall;
png_flush_ptrp = ^png_flush_ptr;
png_flush_ptr = procedure(png_ptr: Pointer);
stdcall;
png_progressive_info_ptrp = ^png_progressive_info_ptr;
png_progressive_info_ptr = procedure(png_ptr: Pointer;
info_ptr: Pointer);
stdcall;
png_progressive_end_ptrp = ^png_progressive_end_ptr;
png_progressive_end_ptr = procedure(png_ptr: Pointer;
info_ptr: Pointer);
stdcall;
png_progressive_row_ptrp = ^png_progressive_row_ptr;
png_progressive_row_ptr = procedure(png_ptr: Pointer;
data: Pointer; length: png_uint_32;
count: int);
stdcall;
png_read_status_ptr = procedure(png_ptr: Pointer;
row_number: png_uint_32; pass: int);
stdcall;
png_write_status_ptr = procedure(png_ptr: Pointer;
row_number: png_uint_32; pass: int);
stdcall;
png_user_transform_ptr = procedure(png_ptr: Pointer;
row_info: Pointer; data: png_bytep);
stdcall;
png_colorpp = ^png_colorp;
png_colorp = ^png_color;
png_color = packed record
red, green, blue: png_byte;
end;
png_color_16pp = ^png_color_16p;
png_color_16p = ^png_color_16;
png_color_16 = packed record
index: png_byte; //used for palette files
red, green, blue: png_uint_16; //for use in red green blue files
gray: png_uint_16; //for use in grayscale files
end;
png_color_8pp = ^png_color_8p;
png_color_8p = ^png_color_8;
png_color_8 = packed record
red, green, blue: png_byte; //for use in red green blue files
gray: png_byte; //for use in grayscale files
alpha: png_byte; //for alpha channel files
end;
png_textpp = ^png_textp;
png_textp = ^png_text;
png_text = packed record
compression: int; //compression value
key: png_charp; //keyword, 1-79 character description of "text"
text: png_charp; //comment, may be empty ("")
text_length: png_size_t; //length of text field
end;
png_timepp = ^png_timep;
png_timep = ^png_time;
png_time = packed record
year: png_uint_16; //yyyy
month: png_byte; //1..12
day: png_byte; //1..31
hour: png_byte; //0..23
minute: png_byte; //0..59
second: png_byte; //0..60 (leap seconds)
end;
png_infopp = ^png_infop;
png_infop = Pointer;
png_row_infopp = ^png_row_infop;
png_row_infop = ^png_row_info;
png_row_info = packed record
width: png_uint_32; //width of row
rowbytes: png_size_t; //number of bytes in row
color_type: png_byte; //color type of row
bit_depth: png_byte; //bit depth of row
channels: png_byte; //number of channels (1, 2, 3, or 4)
pixel_depth: png_byte; //bits per pixel (depth * channels)
end;
png_structpp = ^png_structp;
png_structp = Pointer;
const
// Supported compression types for text in PNG files (tEXt, and zTXt).
// The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
PNG_TEXT_COMPRESSION_NONE_WR = -3;
PNG_TEXT_COMPRESSION_zTXt_WR = -2;
PNG_TEXT_COMPRESSION_NONE = -1;
PNG_TEXT_COMPRESSION_zTXt = 0;
// These describe the color_type field in png_info.
// color type masks
PNG_COLOR_MASK_PALETTE = 1;
PNG_COLOR_MASK_COLOR = 2;
PNG_COLOR_MASK_ALPHA = 4;
// color types. Note that not all combinations are legal
PNG_COLOR_TYPE_GRAY = 0;
PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR or
PNG_COLOR_MASK_PALETTE;
PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR;
PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR or
PNG_COLOR_MASK_ALPHA;
PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA;
// This is for compression type. PNG 1.0 only defines the single type.
PNG_COMPRESSION_TYPE_BASE = 0; // Deflate method 8, 32K window
PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE;
// This is for filter type. PNG 1.0 only defines the single type.
PNG_FILTER_TYPE_BASE = 0; // Single row per-byte filtering
PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE;
// These are for the interlacing type. These values should NOT be changed.
PNG_INTERLACE_NONE = 0; // Non-interlaced image
PNG_INTERLACE_ADAM7 = 1; // Adam7 interlacing
// These are for the oFFs chunk. These values should NOT be changed.
PNG_OFFSET_PIXEL = 0; // Offset in pixels
PNG_OFFSET_MICROMETER = 1; // Offset in micrometers (1/10^6 meter)
// These are for the pCAL chunk. These values should NOT be changed.
PNG_EQUATION_LINEAR = 0; // Linear transformation
PNG_EQUATION_BASE_E = 1; // Exponential base e transform
PNG_EQUATION_ARBITRARY = 2; // Arbitrary base exponential transform
PNG_EQUATION_HYPERBOLIC = 3; // Hyperbolic sine transformation
// These are for the pHYs chunk. These values should NOT be changed.
PNG_RESOLUTION_UNKNOWN = 0; // pixels/unknown unit (aspect ratio)
PNG_RESOLUTION_METER = 1; // pixels/meter
// These are for the sRGB chunk. These values should NOT be changed.
PNG_sRGB_INTENT_SATURATION = 0;
PNG_sRGB_INTENT_PERCEPTUAL = 1;
PNG_sRGB_INTENT_ABSOLUTE = 2;
PNG_sRGB_INTENT_RELATIVE = 3;
// Handle alpha and tRNS by replacing with a background color.
PNG_BACKGROUND_GAMMA_UNKNOWN = 0;
PNG_BACKGROUND_GAMMA_SCREEN = 1;
PNG_BACKGROUND_GAMMA_FILE = 2;
PNG_BACKGROUND_GAMMA_UNIQUE = 3;
// Values for png_set_crc_action() to say how to handle CRC errors in
// ancillary and critical chunks, and whether to use the data contained
// therein. Note that it is impossible to "discard" data in a critical
// chunk. For versions prior to 0.90, the action was always error/quit,
// whereas in version 0.90 and later, the action for CRC errors in ancillary
// chunks is warn/discard. These values should NOT be changed.
// value action:critical action:ancillary
PNG_CRC_DEFAULT = 0; // error/quit warn/discard data
PNG_CRC_ERROR_QUIT = 1; // error/quit error/quit
PNG_CRC_WARN_DISCARD = 2; // (INVALID) warn/discard data
PNG_CRC_WARN_USE = 3; // warn/use data warn/use data
PNG_CRC_QUIET_USE = 4; // quiet/use data quiet/use data
PNG_CRC_NO_CHANGE = 5; // use current value use current value
// Flags for png_set_filter() to say which filters to use. The flags
// are chosen so that they don't conflict with real filter types
// below, in case they are supplied instead of the #defined constants.
// These values should NOT be changed.
PNG_NO_FILTERS = $00;
PNG_FILTER_NONE = $08;
PNG_FILTER_SUB = $10;
PNG_FILTER_UP = $20;
PNG_FILTER_AVG = $40;
PNG_FILTER_PAETH = $80;
PNG_ALL_FILTERS = PNG_FILTER_NONE or PNG_FILTER_SUB or
PNG_FILTER_UP or PNG_FILTER_AVG or
PNG_FILTER_PAETH;
// Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
// These defines should NOT be changed.
PNG_FILTER_VALUE_NONE = 0;
PNG_FILTER_VALUE_SUB = 1;
PNG_FILTER_VALUE_UP = 2;
PNG_FILTER_VALUE_AVG = 3;
PNG_FILTER_VALUE_PAETH = 4;
// Heuristic used for row filter selection. These defines should NOT be
// changed.
PNG_FILTER_HEURISTIC_DEFAULT = 0; // Currently "UNWEIGHTED"
PNG_FILTER_HEURISTIC_UNWEIGHTED = 1; // Used by libpng < 0.95
PNG_FILTER_HEURISTIC_WEIGHTED = 2; // Experimental feature
PNG_FILTER_HEURISTIC_LAST = 3; // Not a valid value
procedure png_build_grayscale_palette(bit_depth: int; palette: png_colorp);
stdcall;
function png_check_sig(sig: png_bytep; num: int): int;
stdcall;
procedure png_chunk_error(png_ptr: png_structp;
const mess: png_charp);
stdcall;
procedure png_chunk_warning(png_ptr: png_structp;
const mess: png_charp);
stdcall;
procedure png_convert_from_time_t(ptime: png_timep; ttime: time_t);
stdcall;
function png_convert_to_rfc1123(png_ptr: png_structp; ptime: png_timep):
png_charp;
stdcall;
function png_create_info_struct(png_ptr: png_structp): png_infop;
stdcall;
function png_create_read_struct(user_png_ver: png_charp;
error_ptr: user_error_ptr; error_fn: png_error_ptr;
warn_fn: png_error_ptr): png_structp;
stdcall;
function png_get_copyright(png_ptr: png_structp): png_charp;
stdcall;
function png_get_header_version(png_ptr: png_structp): png_charp;
stdcall;
function png_create_write_struct(user_png_ver: png_charp;
error_ptr: user_error_ptr; error_fn: png_error_ptr;
warn_fn: png_error_ptr): png_structp;
stdcall;
procedure png_destroy_info_struct(png_ptr: png_structp;
info_ptr_ptr: png_infopp);
stdcall;
procedure png_destroy_read_struct(png_ptr_ptr: png_structpp;
info_ptr_ptr, end_info_ptr_ptr: png_infopp);
stdcall;
procedure png_destroy_write_struct(png_ptr_ptr: png_structpp;
info_ptr_ptr: png_infopp);
stdcall;
function png_get_IHDR(png_ptr: png_structp; info_ptr: png_infop;
var width, height: png_uint_32; var bit_depth,
color_type, interlace_type, compression_type,
filter_type: int): png_uint_32;
stdcall;
function png_get_PLTE(png_ptr: png_structp; info_ptr: png_infop;
var palette: png_colorp; var num_palette: int):
png_uint_32;
stdcall;
function png_get_bKGD(png_ptr: png_structp; info_ptr: png_infop;
var background: png_color_16p): png_uint_32;
stdcall;
function png_get_bit_depth(png_ptr: png_structp; info_ptr: png_infop):
png_byte;
stdcall;
function png_get_cHRM(png_ptr: png_structp; info_ptr: png_infop;
var white_x, white_y, red_x, red_y, green_x, green_y,
blue_x, blue_y: double): png_uint_32;
stdcall;
function png_get_channels(png_ptr: png_structp; info_ptr: png_infop):
png_byte;
stdcall;
function png_get_color_type(png_ptr: png_structp; info_ptr: png_infop):
png_byte;
stdcall;
function png_get_compression_type(png_ptr: png_structp;
info_ptr: png_infop): png_byte;
stdcall;
function png_get_error_ptr(png_ptr: png_structp): png_voidp;
stdcall;
function png_get_filter_type(png_ptr: png_structp; info_ptr: png_infop):
png_byte;
stdcall;
function png_get_gAMA(png_ptr: png_structp; info_ptr: png_infop;
var file_gamma: double): png_uint_32;
stdcall;
function png_get_hIST(png_ptr: png_structp; info_ptr: png_infop;
var hist: png_uint_16p): png_uint_32;
stdcall;
function png_get_image_height(png_ptr: png_structp; info_ptr: png_infop):
png_uint_32;
stdcall;
function png_get_image_width(png_ptr: png_structp; info_ptr: png_infop):
png_uint_32;
stdcall;
function png_get_interlace_type(png_ptr: png_structp;
info_ptr: png_infop): png_byte;
stdcall;
function png_get_io_ptr(png_ptr: png_structp): png_voidp;
stdcall;
function png_get_oFFs(png_ptr: png_structp; info_ptr: png_infop;
var offset_x, offset_y: png_uint_32;
var unit_type: int): png_uint_32;
stdcall;
function png_get_pCAL(png_ptr: png_structp; info_ptr: png_infop;
var purpose: png_charp; var X0, X1: png_int_32;
var typ, nparams: int; var units: png_charp;
var params: png_charpp): png_uint_32;
stdcall;
function png_get_pHYs(png_ptr: png_structp; info_ptr: png_infop;
var res_x, res_y: png_uint_32; var unit_type: int):
png_uint_32;
stdcall;
function png_get_pixel_aspect_ratio(png_ptr: png_structp;
info_ptr: png_infop): float;
stdcall;
function png_get_pixels_per_meter(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_progressive_ptr(png_ptr: png_structp): png_voidp;
stdcall;
function png_get_rgb_to_gray_status(png_ptr: png_structp);
stdcall;
function png_get_rowbytes(png_ptr: png_structp; info_ptr: png_infop):
png_uint_32;
stdcall;
function png_get_sBIT(png_ptr: png_structp; info_ptr: png_infop;
var sig_bits: png_color_8p): png_uint_32;
stdcall;
function png_get_sRGB(png_ptr: png_structp; info_ptr: png_infop;
var file_srgb_intent: int): png_uint_32;
stdcall;
function png_get_signature(png_ptr: png_structp; info_ptr: png_infop):
png_bytep;
stdcall;
function png_get_tIME(png_ptr: png_structp; info_ptr: png_infop;
var mod_time: png_timep): png_uint_32;
stdcall;
function png_get_tRNS(png_ptr: png_structp; info_ptr: png_infop;
var trans: png_bytep; var num_trans: int;
var trans_values: png_color_16p): png_uint_32;
stdcall;
function png_get_text(png_ptr: png_structp; info_ptr: png_infop;
var text_ptr: png_textp; var num_text: int):
png_uint_32;
stdcall;
function png_get_valid(png_ptr: png_structp; info_ptr: png_infop;
flag: png_uint_32): png_uint_32;
stdcall;
function png_get_x_offset_microns(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_x_offset_pixels(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_x_pixels_per_meter(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_y_offset_microns(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_y_offset_pixels(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
function png_get_y_pixels_per_meter(png_ptr: png_structp;
info_ptr: png_infop): png_uint_32;
stdcall;
procedure png_process_data(png_ptr: png_structp; info_ptr: png_infop;
buffer: png_bytep; buffer_size: png_size_t);
stdcall;
procedure png_progressive_combine_row(png_ptr: png_structp;
old_row, new_row: png_bytep);
stdcall;
procedure png_read_end(png_ptr: png_structp; info_ptr: png_infop);
stdcall;
procedure png_read_image(png_ptr: png_structp; image: png_bytepp);
stdcall;
procedure png_read_info(png_ptr: png_structp; info_ptr: png_infop);
stdcall;
procedure png_read_row(png_ptr: png_structp; row, dsp_row: png_bytep);
stdcall;
procedure png_read_rows(png_ptr: png_structp; row, display_row:
png_bytepp; num_rows: png_uint_32);
stdcall;
procedure png_read_update_info(png_ptr: png_structp; info_ptr: png_infop);
stdcall;
procedure png_set_IHDR(png_ptr: png_structp; info_ptr: png_infop;
width, height: png_uint_32; bit_depth, color_type,
interlace_type, compression_type, filter_type: int);
stdcall;
procedure png_set_PLTE(png_ptr: png_structp; info_ptr: png_infop;
palette: png_colorp; num_palette: int);
stdcall;
procedure png_set_bKGD(png_ptr: png_structp; info_ptr: png_infop;
background: png_color_16p);
stdcall;
procedure png_set_background(png_ptr: png_structp;
background_color: png_color_16p;
background_gamma_code, need_expand: int;
background_gamma: double);
stdcall;
procedure png_set_bgr(png_ptr: png_structp);
stdcall;
procedure png_set_cHRM(png_ptr: png_structp; info_ptr: png_infop;
white_x, white_y, red_x, red_y, green_x, green_y,
blue_x, blue_y: double);
stdcall;
procedure png_set_compression_level(png_ptr: png_structp; level: int);
stdcall;
procedure png_set_compression_mem_level(png_ptr: png_structp;
mem_level: int);
stdcall;
procedure png_set_compression_method(png_ptr: png_structp; method: int);
stdcall;
procedure png_set_compression_strategy(png_ptr: png_structp;
strategy: int);
stdcall;
procedure png_set_compression_window_bits(png_ptr: png_structp;
window_bits: int);
stdcall;
procedure png_set_crc_action(png_ptr: png_structp;
crit_action, ancil_action: int);
stdcall;
procedure png_set_dither(png_ptr: png_structp; plaette: png_colorp;
num_palette, maximum_colors: int;
histogram: png_uint_16p; full_dither: int);
stdcall;
procedure png_set_error_fn(png_ptr: png_structp; error_ptr: png_voidp;
error_fn, warning_fn: png_error_ptr);
stdcall;
procedure png_set_expand(png_ptr: png_structp);
stdcall;
procedure png_set_filler(png_ptr: png_structp; filler: png_uint_32;
filler_loc: int);
stdcall;
procedure png_set_filter(png_ptr: png_structp; method, filters: int);
stdcall;
procedure png_set_filter_heuristics(png_ptr: png_structp;
heuristic_method, num_weights: int;
filter_weights, filter_costs: png_doublep);
stdcall;
procedure png_set_flush(png_ptr: png_structp; nrows: int);
stdcall;
procedure png_set_gAMA(png_ptr: png_structp; info_ptr: png_infop;
file_gamma: double);
stdcall;
procedure png_set_gamma(png_ptr: png_structp; screen_gamma,
default_file_gamma: double);
stdcall;
procedure png_set_gray_1_2_4_to_8(png_ptr: png_structp);
stdcall;
procedure png_set_gray_to_rgb(png_ptr: png_structp);
stdcall;
procedure png_set_hIST(png_ptr: png_structp; info_ptr: png_infop;
hist: png_uint_16p);
stdcall;
function png_set_interlace_handling(png_ptr: png_structp): int;
stdcall;
procedure png_set_invert_alpha(png_ptr: png_structp);
stdcall;
procedure png_set_invert_mono(png_ptr: png_structp);
stdcall;
procedure png_set_oFFs(png_ptr: png_structp; info_ptr: png_infop;
offset_x, offset_y: png_uint_32; unit_type: int);
stdcall;
procedure png_set_palette_to_rgb(png_ptr: png_structp);
stdcall;
procedure png_set_pCAL(png_ptr: png_structp; info_ptr: png_infop;
purpose: png_charp; X0, X1: png_int_32;
typ, nparams: int; units: png_charp;
params: png_charpp);
stdcall;
procedure png_set_pHYs(png_ptr: png_structp; info_ptr: png_infop;
res_x, res_y: png_uint_32; unit_type: int);
stdcall;
procedure png_set_packing(png_ptr: png_structp);
stdcall;
procedure png_set_packswap(png_ptr: png_structp);
stdcall;
procedure png_set_progressive_read_fn(png_ptr: png_structp;
progressive_ptr: png_voidp;
info_fn: png_progressive_info_ptr;
row_fn: png_progressive_row_ptr;
end_fn: png_progressive_end_ptr);
stdcall;
procedure png_set_read_fn(png_ptr: png_structp;
io_ptr: png_voidp; read_data_fn: png_rw_ptr);
stdcall;
procedure png_set_read_status_fn(png_ptr: png_structp;
read_row_fn: png_read_status_ptr);
stdcall;
procedure png_set_read_user_transform_fn(png_ptr: png_structp;
read_user_transform_fn: png_user_transform_ptr);
stdcall;
procedure png_set_rgb_to_gray(png_ptr: png_structp; int: error_action);
stdcall;
procedure png_set_sBIT(png_ptr: png_structp; info_ptr: png_infop;
sig_bits: png_color_8p);
stdcall;
procedure png_set_sRGB(png_ptr: png_structp; info_ptr: png_infop;
intent: int);
stdcall;
procedure png_set_sRGB_gAMA_and_cHRM(png_ptr: png_structp;
info_ptr: png_infop; intent: int);
stdcall;
procedure png_set_shift(png_ptr: png_structp; true_bits: png_color_8p);
stdcall;
procedure png_set_sig_bytes(png_ptr: png_structp; num_bytes: int);
stdcall;
procedure png_set_strip_16(png_ptr: png_structp);
stdcall;
procedure png_set_strip_alpha(png_ptr: png_structp);
stdcall;
procedure png_set_swap(png_ptr: png_structp);
stdcall;
procedure png_set_swap_alpha(png_ptr: png_structp);
stdcall;
procedure png_set_tIME(png_ptr: png_structp; info_ptr: png_infop;
mod_time: png_timep);
stdcall;
procedure png_set_tRNS(png_ptr: png_structp; info_ptr: png_infop;
trans: png_bytep; num_trans: int;
trans_values: png_color_16p);
stdcall;
procedure png_set_tRNS_to_alpha(png_ptr: png_structp);
stdcall;
procedure png_set_text(png_ptr: png_structp; info_ptr: png_infop;
text_ptr: png_textp; num_text: int);
stdcall;
procedure png_set_write_fn(png_ptr: png_structp;
io_ptr: png_voidp; write_data_fn: png_rw_ptr;
output_flush_fn: png_flush_ptr);
stdcall;
procedure png_set_write_status_fn(png_ptr: png_structp;
write_row_fn: png_write_status_ptr);
stdcall;
procedure png_set_write_user_transform_fn(png_ptr: png_structp;
write_user_transform_fn: png_user_transform_ptr);
stdcall;
function png_sig_cmp(sig: png_bytep; start, num_to_check: png_size_t):
int;
stdcall;
procedure png_start_read_image(png_ptr: png_structp);
stdcall;
procedure png_write_chunk(png_ptr: png_structp;
chunk_name, data: png_bytep; length: png_size_t);
stdcall;
procedure png_write_chunk_data(png_ptr: png_structp;
data: png_bytep; length: png_size_t);
stdcall;
procedure png_write_chunk_end(png_ptr: png_structp);
stdcall;
procedure png_write_chunk_start(png_ptr: png_structp;
chunk_name: png_bytep; length: png_uint_32);
stdcall;
procedure png_write_end(png_ptr: png_structp; info_ptr: png_infop);
stdcall;
procedure png_write_flush(png_ptr: png_structp);
stdcall;
procedure png_write_image(png_ptr: png_structp; image: png_bytepp);
stdcall;
procedure png_write_info(png_ptr: png_structp; info_ptr: png_infop);
stdcall;
procedure png_write_row(png_ptr: png_structp; row: png_bytep);
stdcall;
procedure png_write_rows(png_ptr: png_structp; row: png_bytepp;
num_rows: png_uint_32);
stdcall;
implementation
const
pngDLL = 'png32bd.dll';
procedure png_build_grayscale_palette; external pngDLL;
function png_check_sig; external pngDLL;
procedure png_chunk_error; external pngDLL;
procedure png_chunk_warning; external pngDLL;
procedure png_convert_from_time_t; external pngDLL;
function png_convert_to_rfc1123; external pngDLL;
function png_create_info_struct; external pngDLL;
function png_create_read_struct; external pngDLL;
function png_create_write_struct; external pngDLL;
procedure png_destroy_info_struct; external pngDLL;
procedure png_destroy_read_struct; external pngDLL;
procedure png_destroy_write_struct; external pngDLL;
function png_get_IHDR; external pngDLL;
function png_get_PLTE; external pngDLL;
function png_get_bKGD; external pngDLL;
function png_get_bit_depth; external pngDLL;
function png_get_cHRM; external pngDLL;
function png_get_channels; external pngDLL;
function png_get_color_type; external pngDLL;
function png_get_compression_type; external pngDLL;
function png_get_error_ptr; external pngDLL;
function png_get_filter_type; external pngDLL;
function png_get_gAMA; external pngDLL;
function png_get_hIST; external pngDLL;
function png_get_image_height; external pngDLL;
function png_get_image_width; external pngDLL;
function png_get_interlace_type; external pngDLL;
function png_get_io_ptr; external pngDLL;
function png_get_oFFs; external pngDLL;
function png_get_pCAL; external pngDLL;
function png_get_pHYs; external pngDLL;
function png_get_pixel_aspect_ratio; external pngDLL;
function png_get_pixels_per_meter; external pngDLL;
function png_get_progressive_ptr; external pngDLL;
function png_get_rowbytes; external pngDLL;
function png_get_sBIT; external pngDLL;
function png_get_sRGB; external pngDLL;
function png_get_signature; external pngDLL;
function png_get_tIME; external pngDLL;
function png_get_tRNS; external pngDLL;
function png_get_text; external pngDLL;
function png_get_valid; external pngDLL;
function png_get_x_offset_microns; external pngDLL;
function png_get_x_offset_pixels; external pngDLL;
function png_get_x_pixels_per_meter; external pngDLL;
function png_get_y_offset_microns; external pngDLL;
function png_get_y_offset_pixels; external pngDLL;
function png_get_y_pixels_per_meter; external pngDLL;
procedure png_process_data; external pngDLL;
procedure png_progressive_combine_row; external pngDLL;
procedure png_read_end; external pngDLL;
procedure png_read_image; external pngDLL;
procedure png_read_info; external pngDLL;
procedure png_read_row; external pngDLL;
procedure png_read_rows; external pngDLL;
procedure png_read_update_info; external pngDLL;
procedure png_set_IHDR; external pngDLL;
procedure png_set_PLTE; external pngDLL;
procedure png_set_bKGD; external pngDLL;
procedure png_set_background; external pngDLL;
procedure png_set_bgr; external pngDLL;
procedure png_set_cHRM; external pngDLL;
procedure png_set_compression_level; external pngDLL;
procedure png_set_compression_mem_level; external pngDLL;
procedure png_set_compression_method; external pngDLL;
procedure png_set_compression_strategy; external pngDLL;
procedure png_set_compression_window_bits; external pngDLL;
procedure png_set_crc_action; external pngDLL;
procedure png_set_dither; external pngDLL;
procedure png_set_error_fn; external pngDLL;
procedure png_set_expand; external pngDLL;
procedure png_set_filler; external pngDLL;
procedure png_set_filter; external pngDLL;
procedure png_set_filter_heuristics; external pngDLL;
procedure png_set_flush; external pngDLL;
procedure png_set_gAMA; external pngDLL;
procedure png_set_gamma; external pngDLL;
procedure png_set_gray_to_rgb; external pngDLL;
procedure png_set_hIST; external pngDLL;
function png_set_interlace_handling; external pngDLL;
procedure png_set_invert_alpha; external pngDLL;
procedure png_set_invert_mono; external pngDLL;
procedure png_set_oFFs; external pngDLL;
procedure png_set_pCAL; external pngDLL;
procedure png_set_pHYs; external pngDLL;
procedure png_set_packing; external pngDLL;
procedure png_set_packswap; external pngDLL;
procedure png_set_progressive_read_fn; external pngDLL;
procedure png_set_read_fn; external pngDLL;
procedure png_set_read_status_fn; external pngDLL;
procedure png_set_read_user_transform_fn; external pngDLL;
procedure png_set_sBIT; external pngDLL;
procedure png_set_sRGB; external pngDLL;
procedure png_set_sRGB_gAMA_and_cHRM; external pngDLL;
procedure png_set_shift; external pngDLL;
procedure png_set_sig_bytes; external pngDLL;
procedure png_set_strip_16; external pngDLL;
procedure png_set_strip_alpha; external pngDLL;
procedure png_set_swap; external pngDLL;
procedure png_set_swap_alpha; external pngDLL;
procedure png_set_tIME; external pngDLL;
procedure png_set_tRNS; external pngDLL;
procedure png_set_text; external pngDLL;
procedure png_set_write_fn; external pngDLL;
procedure png_set_write_status_fn; external pngDLL;
procedure png_set_write_user_transform_fn; external pngDLL;
function png_sig_cmp; external pngDLL;
procedure png_start_read_image; external pngDLL;
procedure png_write_chunk; external pngDLL;
procedure png_write_chunk_data; external pngDLL;
procedure png_write_chunk_end; external pngDLL;
procedure png_write_chunk_start; external pngDLL;
procedure png_write_end; external pngDLL;
procedure png_write_flush; external pngDLL;
procedure png_write_image; external pngDLL;
procedure png_write_info; external pngDLL;
procedure png_write_row; external pngDLL;
procedure png_write_rows; external pngDLL;
end.

53
scripts/pngdll.mak Normal file
View File

@@ -0,0 +1,53 @@
# Makefile for png32bd.dll
# ------------- Borland C++ 4.5 -------------
# This makefile expects to find zlib.h and zlib32bd.lib in the
# $(ZLIBDIR) directory.
# The object files here are compiled with the "stdcall" calling convention.
# This DLL requires zlib32bd.lib to be compiled in the same way.
# Note that png32bd.dll exports the zlib functions adler32, crc32 and
# the deflate... and inflate... functions. It does not export the
# compress and uncompress functions, nor any of the gz... functions,
# since libpng does not call them.
ZLIBDIR=..\zlib112
ZLIB=zlib32bd.lib
PNGDLL=png32bd.dll
CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE -I$(ZLIBDIR)
CC=f:\bc45\bin\bcc32
LINKFLAGS= -Tpd -aa -c
LINK=f:\bc45\bin\tlink32
LIBDIR=f:\bc45\lib
IMPLIB=f:\bc45\bin\implib
.autodepend
.c.obj:
$(CC) -c $(CFLAGS) $<
OBJ1=png.obj pngerror.obj pngget.obj pngmem.obj pngpread.obj
OBJ2=pngread.obj pngrio.obj pngrtran.obj pngrutil.obj pngset.obj
OBJ3=pngtrans.obj pngwio.obj pngwrite.obj pngwtran.obj pngwutil.obj
all: $(PNGDLL)
$(PNGDLL): $(OBJ1) $(OBJ2) $(OBJ3) $(ZLIBDIR)\$(ZLIB)
$(LINK) @&&|
$(LINKFLAGS) $(LIBDIR)\c0d32 +
$(OBJ1) +
$(OBJ2) +
$(OBJ3)
$@
-x
$(ZLIBDIR)\$(ZLIB) $(LIBDIR)\import32 $(LIBDIR)\cw32
|,&&|
LIBRARY $(@B)
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|
$(IMPLIB) -c $(@R).lib $@
# End of makefile for png32bd.dll

View File

@@ -12,7 +12,9 @@ EXPORTS
png_sig_cmp
png_check_sig
png_create_read_struct
; png_create_read_struct_2
png_create_write_struct
; png_create_write_struct_2
png_write_chunk
png_write_chunk_start
png_write_chunk_data
@@ -27,7 +29,7 @@ EXPORTS
png_set_expand
png_set_bgr
png_set_gray_to_rgb
; png_set_rgb_to_gray
png_set_rgb_to_gray
png_build_grayscale_palette
png_set_strip_alpha
png_set_swap_alpha
@@ -70,8 +72,12 @@ EXPORTS
png_set_compression_window_bits
png_set_compression_method
png_init_io
png_get_copyright
png_set_error_fn
png_get_error_ptr
png_get_header_version
; png_get_mem_fn
; png_set_mem_fn
png_set_write_fn
png_set_read_fn
png_set_write_status_fn
@@ -89,8 +95,8 @@ EXPORTS
png_free
png_memcpy_check
png_memset_check
; png_debug_malloc
; png_debug_free
; png_malloc_default
; png_free_default
; png_far_to_near
png_error
png_chunk_error
@@ -108,6 +114,7 @@ EXPORTS
png_get_compression_type
png_get_pixels_per_meter
png_get_pixel_aspect_ratio
png_get_rgb_to_gray_status
png_get_x_offset_pixels
png_get_y_offset_pixels
png_get_x_offset_microns
@@ -142,6 +149,9 @@ EXPORTS
png_set_tIME
png_get_tRNS
png_set_tRNS
png_set_gray_1_2_4_to_8
png_set_tRNS_to_alpha
png_set_palette_to_rgb
png_create_struct
png_destroy_struct
@@ -198,7 +208,7 @@ EXPORTS
png_do_strip_filler
png_do_swap
png_do_packswap
; png_do_rgb_to_gray
png_do_rgb_to_gray
png_do_gray_to_rgb
png_do_unpack
png_do_unshift