mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
983ec160b4 | ||
|
|
08a3343e05 | ||
|
|
cbe52d8720 | ||
|
|
a357b99113 | ||
|
|
0f881d62b3 | ||
|
|
b212002101 | ||
|
|
46f61e2398 | ||
|
|
c4a2ae6cac | ||
|
|
2687fcc7b5 |
101
CHANGES
101
CHANGES
@@ -1,4 +1,4 @@
|
||||
pngchange.txt - changes for libpng
|
||||
CHANGES - changes for libpng
|
||||
|
||||
version 0.2
|
||||
added reader into png.h
|
||||
@@ -167,21 +167,98 @@ version 0.96 [May, 1997]
|
||||
added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
|
||||
added typecasts to quiet compiler errors
|
||||
added more debugging info
|
||||
version 1.00 [not distributed, but Andreas handed off to G&G]
|
||||
skipped version 1.00 to avoid potential problems with shared libraries
|
||||
created with version 0.89
|
||||
version 0.97 [January, 1998]
|
||||
removed PNG_USE_OWN_CRC capability
|
||||
relocated png_set_crc_action from pngrutil.c to pngrtran.c
|
||||
fixed typecasts of "new_key" etc.
|
||||
added RFC 1152 date support
|
||||
version 1.00.97 [Dec 1997]
|
||||
fixed typecasts of "new_key", etc. (Andreas Dilger)
|
||||
added RFC 1152 [sic] date support
|
||||
fixed bug in gamma handling of 4-bit grayscale
|
||||
added more typecasts. 65536L becomes (png_uint_32)65536L, etc.
|
||||
added 2-bit grayscale gamma handling (Glenn R-P)
|
||||
added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
|
||||
minor corrections in libpng.txt
|
||||
added simple sRGB support
|
||||
make it simpler to do conditional compiling
|
||||
fixed memory leak in pngwrite.c (free info_ptr->text)
|
||||
added simple sRGB support (Glenn R-P)
|
||||
easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
|
||||
all configurable options can be selected from command-line instead
|
||||
of having to edit pngconf.h (Glenn R-P)
|
||||
fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
|
||||
added more conditions for png_do_background, to avoid changing
|
||||
black pixels to background when a background is supplied and
|
||||
no pixels are transparent
|
||||
include stdio.h in pngconf.h even when PNG_NO_STDIO is defined.
|
||||
repaired PNG_NO_STDIO behaviour
|
||||
tested NODIV support and made it default behaviour (Greg Roelofs)
|
||||
added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
|
||||
regularized version numbering scheme and bumped shared-library major
|
||||
version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
|
||||
version 0.98 [January, 1998]
|
||||
cleaned up some typos in libpng.txt and in code documentation
|
||||
fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler)
|
||||
cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c
|
||||
changed recommendation about file_gamma for PC images to .51 from .45,
|
||||
in example.c and libpng.txt, added comments to distinguish between
|
||||
screen_gamma, viewing_gamma, and display_gamma.
|
||||
changed all references to RFC1152 to read RFC1123 and changed the
|
||||
PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED
|
||||
added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent)
|
||||
changed srgb_intent from png_byte to int to avoid compiler bugs
|
||||
version 0.99 [January 30, 1998]
|
||||
free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler)
|
||||
fixed a longstanding "packswap" bug in pngtrans.c
|
||||
fixed some inconsistencies in pngconf.h that prevented compiling with
|
||||
PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined
|
||||
fixed some typos and made other minor rearrangement of libpng.txt (Andreas)
|
||||
changed recommendation about file_gamma for PC images to .50 from .51 in
|
||||
example.c and libpng.txt, and changed file_gamma for sRGB images to .45
|
||||
added a number of functions to access information from the png structure
|
||||
png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit)
|
||||
added TARGET_MACOS similar to zlib-1.0.8
|
||||
define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
|
||||
added type casting to all png_malloc() function calls
|
||||
version 0.99a [January 31, 1998]
|
||||
Added type casts and parentheses to all returns that return a value.(Tim W.)
|
||||
version 0.99b [February 4, 1998]
|
||||
Added type cast png_uint_32 on malloc function calls where needed.
|
||||
Changed type of num_hist from png_uint_32 to int (same as num_palette).
|
||||
Added checks for rowbytes overflow, in case png_size_t is less than 32 bits.
|
||||
Renamed makefile.elf to makefile.lnx.
|
||||
version 0.99c [February 7, 1998]
|
||||
More type casting. Removed erroneous overflow test in pngmem.c.
|
||||
Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
|
||||
Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5.
|
||||
version 0.99d [February 11, 1998]
|
||||
Renamed "far_to_near()" "png_far_to_near()"
|
||||
Revised libpng.3
|
||||
Version 99c "buffered" operations didn't work as intended. Replaced them
|
||||
with png_memcpy_check() and png_memset_check().
|
||||
Added many "if (png_ptr == NULL) return" to quell compiler warnings about
|
||||
unused png_ptr, mostly in pngget.c and pngset.c.
|
||||
Check for overlength tRNS chunk present when indexed-color PLTE is read.
|
||||
Cleaned up spelling errors in libpng.3/libpng.txt
|
||||
Corrected a problem with png_get_tRNS() which returned undefined trans array
|
||||
version 0.99e [February 28, 1998]
|
||||
Corrected png_get_tRNS() again.
|
||||
Add parentheses for easier reading of pngget.c, fixed "||" should be "&&".
|
||||
Touched up example.c to make more of it compileable, although the entire
|
||||
file still can't be compiled (Willem van Schaik)
|
||||
Fixed a bug in png_do_shift() (Bryan Tsai)
|
||||
Added a space in png.h prototype for png_write_chunk_start()
|
||||
Replaced pngtest.png with one created with zlib 1.1.1
|
||||
Changed pngtest to report PASS even when file size is different (Jean-loup G.)
|
||||
Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)
|
||||
version 0.99f [March 5, 1998]
|
||||
Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey)
|
||||
Moved makefiles into a "scripts" directory, and added INSTALL instruction file
|
||||
Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok)
|
||||
Added pointers to "note on libpng versions" in makefile.lnx and README
|
||||
Added row callback feature when reading and writing nonprogressive rows
|
||||
and added a test of this feature in pngtest.c
|
||||
Added user transform callbacks, with test of the feature in pngtest.c
|
||||
version 0.99g [March 6, 1998, morning]
|
||||
Minor changes to pngtest.c to suppress compiler warnings.
|
||||
Removed "beta" language from documentation.
|
||||
version 0.99h [March 6, 1998, evening]
|
||||
Minor changes to previous minor changes to pngtest.c
|
||||
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
|
||||
version 1.00 [March 7, 1998]
|
||||
Changed several typedefs in pngrutil.c
|
||||
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
|
||||
|
||||
85
INSTALL
Normal file
85
INSTALL
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
Installing libpng version 1.00 March 7, 1998
|
||||
|
||||
Before installing libpng, you must first install zlib. zlib
|
||||
can usually be found wherever you got libpng. zlib can be
|
||||
placed in another directory, at the same level as libpng.
|
||||
Note that your system might already have a preinstalled
|
||||
zlib, but you will still need to have access to the
|
||||
zlib.h and zconf.h include files that correspond to the
|
||||
version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-1.00 or "lpng100" and "zlib-1.1.1"
|
||||
or "zlib111") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
.. (the parent directory)
|
||||
libpng (this directory)
|
||||
INSTALL (this file)
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
scripts
|
||||
makefile.*
|
||||
pngtest.png
|
||||
etc.
|
||||
zlib
|
||||
README
|
||||
*.h
|
||||
*.c
|
||||
contrib
|
||||
etc.
|
||||
|
||||
First enter the zlib directory and follow the instructions
|
||||
in zlib/README. Then come back here and choose the
|
||||
appropriate makefile.sys in the scripts directory.
|
||||
The files that are presently available in the scripts directory
|
||||
include
|
||||
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sun => Sun makefile
|
||||
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.aco => Acorn makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => 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.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
|
||||
makevms.com => VMS build script
|
||||
|
||||
Copy the file (or files) that you need from the
|
||||
scripts directory into this directory, for example
|
||||
|
||||
MSDOS example: copy scripts\makefile.msd makefile
|
||||
UNIX example: cp scripts/makefile.std makefile
|
||||
|
||||
Read the makefile to see if you need to change any source or
|
||||
target directories to match your preferences.
|
||||
|
||||
Then read pngconf.h to see if you want to make any configuration
|
||||
changes.
|
||||
|
||||
Then just run "make test" which will create the libpng library in
|
||||
this directory and run a quick test that reads the "pngtest.png"
|
||||
file and writes a "pngout.png" file that should be identical to it.
|
||||
|
||||
Most of the makefiles will allow you to run "make install" to
|
||||
put the library in its final resting place (if you want to
|
||||
do that, run "make install" in the zlib directory first if necessary).
|
||||
|
||||
Further information can be found in the README and libpng.txt
|
||||
files, in the individual makefiles, and in png.h, and the manual
|
||||
pages libpng.3 and png.5.
|
||||
89
README
89
README
@@ -1,23 +1,21 @@
|
||||
README for libpng 1.10
|
||||
README for libpng 1.00 (shared library 2.1)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
This first official release of libpng. Don't let the fact that
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
This is the first official release of libpng. Don't let the fact that
|
||||
it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing for about two years. However, it's
|
||||
extensive use and testing for about two and a half years. However, it's
|
||||
finally gotten to the stage where there haven't been significant
|
||||
changes to the API in some time, and people have a bad feeling about
|
||||
libraries with versions < 1.0.
|
||||
|
||||
Note that the version number is 1.10 to avoid potential problems
|
||||
with shared libraries created for Linux ELF under version 0.89,
|
||||
which mistakenly used 1.0.89 as the library version number in
|
||||
false anticipation of an imminent 1.0 release.
|
||||
|
||||
****
|
||||
Note that some of the changes to the png_info structure render this
|
||||
version of the library binary incompatible with libpng-0.89 or
|
||||
earlier versions if you are using a shared library. The type of the
|
||||
"filler" parameter for png_set_filler() has changed from png_byte to
|
||||
png_uint_32, which will affect shared-library applications which use
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
|
||||
To avoid problems with changes to the internals of png_info_struct,
|
||||
@@ -28,7 +26,7 @@ accessing/storing the info_struct data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs do not make current programs
|
||||
which access the info struct directly incompatible with the new
|
||||
that access the info struct directly incompatible with the new
|
||||
library. However, it is strongly suggested that new programs use
|
||||
the new APIs (as shown in example.c), and older programs be converted
|
||||
to the new format, to facilitate upgrades in the future.
|
||||
@@ -78,7 +76,7 @@ If not, it should be at ftp.uu.net in /graphics/png
|
||||
Eventually, it will be at ftp.uu.net in /pub/archiving/zip/zlib
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an Internet Draft, and RFC, and a W3C Recommendation. Failing
|
||||
as an RFC and a W3C Recommendation. Failing
|
||||
these resources you can try ftp.uu.net in the /graphics/png directory.
|
||||
|
||||
This code is currently being archived at ftp.uu.net in the
|
||||
@@ -98,19 +96,19 @@ Finally, if you get any warning messages when compiling libpng
|
||||
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 earlier work), and the PNG group.
|
||||
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
|
||||
|
||||
adilger@enel.ucalgary.ca
|
||||
randeg@alumni.rpi.edu
|
||||
png-implement@dworkin.wustl.edu
|
||||
|
||||
You can reach Guy, the original libpng author, at (internet preferred):
|
||||
|
||||
internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
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
|
||||
addressed to the png-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
the address in the specification. At the same time, please do
|
||||
not send libpng questions to that address, send them to me. I'll
|
||||
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
|
||||
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,
|
||||
@@ -118,7 +116,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
|
||||
to others, if necessary.
|
||||
|
||||
Please do not send suggestions on how to change PNG. We have
|
||||
been discussing PNG for a couple years now, and it is official and
|
||||
been discussing PNG for three years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used for version
|
||||
1.0, it may be used later.
|
||||
@@ -128,28 +126,20 @@ 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
|
||||
libpng.3 => manual page for libpng
|
||||
libpng.txt => Description of libpng and its functions
|
||||
makefile => Default Unixish makefile
|
||||
makefile.aco => ACORN makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => Borland makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.elf => Unix ELF makefile
|
||||
makefile.knr => Makefile which calls ansi2knr to convert files
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.std => Standard Unix makefile
|
||||
makefile.tc => Turbo C makefile
|
||||
makevms.com => VMS make program
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
pngconf.h => System specific library configuration
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
pngpread.c => Progressive reading functions
|
||||
pngread.c => Read data/helper high-level functions
|
||||
@@ -164,16 +154,39 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
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.dec => DEC Alpha UNIX makefile
|
||||
makefile.sgi => Silicon Graphics IRIX makefile
|
||||
makefile.sun => Sun makefile
|
||||
makefile.s2x => Solaris 2.X makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.lnx => Linux/ELF makefile (gcc, creates libpng.so.2.1.00)
|
||||
makefile.mip => MIPS makefile
|
||||
makefile.aco => Acorn makefile
|
||||
makefile.ama => Amiga makefile
|
||||
makefile.atr => Atari makefile
|
||||
makefile.bor => 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.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
|
||||
makevms.com => VMS build script
|
||||
|
||||
Good luck, and happy coding.
|
||||
|
||||
-Glenn Randers-Pehrson
|
||||
Internet: randeg@alumni.rpi.edu
|
||||
Web: http://www.rpi.edu/~randeg/index.html
|
||||
|
||||
-Andreas Eric Dilger
|
||||
Internet: adilger@enel.ucalgary.ca
|
||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
||||
|
||||
-Guy Eric Schalnat
|
||||
Group 42, Inc.
|
||||
Internet: schalnat@group42.com
|
||||
CompuServe: 75501,1625
|
||||
Web: http://www.group42.com/
|
||||
|
||||
(formerly of Group 42, Inc)
|
||||
Internet: gschal@infinet.com
|
||||
|
||||
4
TODO
4
TODO
@@ -1,11 +1,11 @@
|
||||
pngtodo.txt - list of things to do for libpng
|
||||
TODO - list of things to do for libpng
|
||||
|
||||
add "grayscale->palette" transformation and "palette->grayscale" detection
|
||||
improved dithering
|
||||
multi-lingual error and warning message support
|
||||
sPLT chunk handling
|
||||
cHRM transformation
|
||||
complete sRGB transformation (presently it simply uses gamma=0.5)
|
||||
complete sRGB transformation (presently it simply uses gamma=0.45)
|
||||
man pages for function calls
|
||||
high-level API for reading images
|
||||
final bug fixes
|
||||
|
||||
36
ansi2knr.1
Normal file
36
ansi2knr.1
Normal file
@@ -0,0 +1,36 @@
|
||||
.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>.
|
||||
83
example.c
83
example.c
@@ -1,3 +1,4 @@
|
||||
|
||||
/* example.c - an example of using libpng */
|
||||
|
||||
/* This is an example of how to use libpng to read and write PNG files.
|
||||
@@ -12,7 +13,7 @@
|
||||
* working PNG reader/writer, see pngtest.c, included in this distribution.
|
||||
*/
|
||||
|
||||
#include <png.h>
|
||||
#include "png.h"
|
||||
|
||||
/* Check to see if a file is a PNG file using png_check_sig(). Returns
|
||||
* non-zero if the image is a PNG, and 0 if it isn't a PNG.
|
||||
@@ -54,7 +55,7 @@ int check_if_png(char *file_name, FILE **fp)
|
||||
* file, and the other where we are given an open file (possibly with
|
||||
* some or all of the magic bytes read - see comments above).
|
||||
*/
|
||||
**** prototype 1 ****
|
||||
#ifdef open_file /* prototype 1 */
|
||||
void read_png(char *file_name) /* We need to open the file */
|
||||
{
|
||||
png_structp png_ptr;
|
||||
@@ -66,14 +67,14 @@ void read_png(char *file_name) /* We need to open the file */
|
||||
|
||||
if ((fp = fopen(file_name, "rb")) == NULL)
|
||||
return;
|
||||
**** prototype 2 ****
|
||||
#else no_open_file /* prototype 2 */
|
||||
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
{
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_uint_32 width, height;
|
||||
int bit_depth, color_type, interlace_type;
|
||||
**** only use one prototype! ****
|
||||
#endif no_open_file /* only use one prototype! */
|
||||
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
@@ -113,17 +114,17 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization methods is REQUIRED */
|
||||
**** PNG file I/O method 1 ****
|
||||
#ifdef streams /* PNG file I/O method 1 */
|
||||
/* Set up the input control if you are using standard C streams */
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
**** PNG file I/O method 2 ****
|
||||
#else no_streams /* PNG file I/O method 2 */
|
||||
/* If you are using replacement read functions, instead of calling
|
||||
* png_init_io() here you would call:
|
||||
*/
|
||||
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
**** Use only one I/O method! ****
|
||||
#endif no_streams /* Use only one I/O method! */
|
||||
|
||||
/* If we have already read some of the signature */
|
||||
png_set_sig_bytes_read(png_ptr, sig_read);
|
||||
@@ -180,29 +181,32 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
* use it - you should use the (solid) application background if it has one.
|
||||
*/
|
||||
|
||||
png_color_16 my_background, *image_background);
|
||||
png_color_16 my_background, *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,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
|
||||
/* Some suggestions as to how to get a screen gamma value */
|
||||
|
||||
/* Note that screen gamma is (display_gamma/viewing_gamma) */
|
||||
if (/* We have a user-defined screen gamma value */)
|
||||
{
|
||||
screen_gamma = user-defined screen_gamma;
|
||||
}
|
||||
/* This is one way that applications share the same screen gamma value */
|
||||
else if ((gamma_str = getenv("DISPLAY_GAMMA")) != NULL)
|
||||
else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL)
|
||||
{
|
||||
screen_gamma = atof(gamma_str);
|
||||
}
|
||||
/* If we don't have another value */
|
||||
else
|
||||
{
|
||||
screen_gamma = 2.2; /* A good guess for PC monitors */
|
||||
screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly
|
||||
lit room */
|
||||
screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */
|
||||
}
|
||||
|
||||
@@ -211,13 +215,16 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
* by the user at run time by the user. It is strongly suggested that
|
||||
* your application support gamma correction.
|
||||
*/
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &srgb_intent)
|
||||
png_set_sRGB(png_ptr, srgb_intent, 0);
|
||||
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(png_ptr, info_ptr, &intent))
|
||||
png_set_sRGB(png_ptr, intent, 0);
|
||||
else
|
||||
if (png_get_gAMA(png_ptr, info_ptr, &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.45);
|
||||
png_set_gamma(png_ptr, screen_gamma, 0.50);
|
||||
|
||||
/* Dither RGB files down to 8 bit palette or reduce palettes
|
||||
* to the number of colors available on your screen.
|
||||
@@ -228,7 +235,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
png_colorp palette;
|
||||
|
||||
/* This reduces the image to the application supplied palette */
|
||||
if (we have our own palette)
|
||||
if (/* we have our own palette */)
|
||||
{
|
||||
/* An array of colors to which the image should be dithered */
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS];
|
||||
@@ -237,7 +244,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
}
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)))
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
|
||||
{
|
||||
png_color16p histogram;
|
||||
|
||||
@@ -249,7 +256,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
|
||||
/* invert monocrome files to have 0 as white and 1 as black */
|
||||
png_set_invert(png_ptr);
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* If you want to shift the pixel values from the range [0,255] or
|
||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||
@@ -298,37 +305,37 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
|
||||
}
|
||||
|
||||
/* Now it's time to read the image. One of these methods is REQUIRED */
|
||||
**** Read the entire image in one go ****
|
||||
#ifdef entire /* Read the entire image in one go */
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
||||
**** Read the image one or more scanlines at a time ****
|
||||
#else no_entire /* Read the image one or more scanlines at a time */
|
||||
/* The other way to read images - deal with interlacing: */
|
||||
|
||||
for (pass = 0; pass < number_passes; pass++)
|
||||
{
|
||||
[[[[[[[ Read the image a single row at a time ]]]]]]]
|
||||
#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);
|
||||
}
|
||||
|
||||
[[[[[[[ Read the image several rows at a time ]]]]]]]
|
||||
#else no_single /* Read the image several rows at a time */
|
||||
for (y = 0; y < height; y += number_of_rows)
|
||||
{
|
||||
<<<<<<<<<< Read the image using the "sparkle" effect. >>>>>>>>>>
|
||||
#ifdef sparkle /* Read the image using the "sparkle" effect. */
|
||||
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
|
||||
|
||||
<<<<<<<<<< Read the image using the "rectangle" effect >>>>>>>>>>
|
||||
#else no_sparkle /* Read the image using the "rectangle" effect */
|
||||
png_read_rows(png_ptr, NULL, row_pointers, number_of_rows);
|
||||
<<<<<<<<<< use only one of these two methods >>>>>>>>>>
|
||||
#endif no_sparkle /* use only one of these two methods */
|
||||
}
|
||||
|
||||
/* if you want to display the image after every pass, do
|
||||
so here */
|
||||
[[[[[[[ use only one of these two methods ]]]]]]]
|
||||
#endif no_single /* use only one of these two methods */
|
||||
}
|
||||
**** use only one of these two methods ****
|
||||
#endif no_entire /* use only one of these two methods */
|
||||
|
||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
@@ -473,7 +480,7 @@ end_callback(png_structp png_ptr, png_infop info)
|
||||
}
|
||||
|
||||
/* write a png file */
|
||||
void write_png(char *file_name, ... other image information ...)
|
||||
void write_png(char *file_name /* , ... other image information ... */)
|
||||
{
|
||||
FILE *fp;
|
||||
png_structp png_ptr;
|
||||
@@ -520,16 +527,16 @@ void write_png(char *file_name, ... other image information ...)
|
||||
}
|
||||
|
||||
/* One of the following I/O initialization functions is REQUIRED */
|
||||
**** I/O initialization method 1 ****
|
||||
#ifdef streams /* I/O initialization method 1 */
|
||||
/* set up the output control if you are using standard C streams */
|
||||
png_init_io(png_ptr, fp);
|
||||
**** I/O initialization method 2 ****
|
||||
#else no_streams /* I/O initialization method 2 */
|
||||
/* If you are using replacement read functions, instead of calling
|
||||
* png_init_io() here you would call */
|
||||
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
|
||||
user_IO_flush_function);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
**** only use 1 initialization method ****
|
||||
#endif no_streams /* only use one initialization method */
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
@@ -543,8 +550,8 @@ void write_png(char *file_name, ... other image information ...)
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
... set palette colors ...
|
||||
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
|
||||
/* ... set palette colors ... */
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, 256);
|
||||
|
||||
/* optional significant bit chunk */
|
||||
@@ -594,7 +601,7 @@ void write_png(char *file_name, ... other image information ...)
|
||||
*/
|
||||
|
||||
/* invert monocrome pixels */
|
||||
png_set_invert(png_ptr);
|
||||
png_set_invert_mono(png_ptr);
|
||||
|
||||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
* as appropriate to correctly scale the image.
|
||||
@@ -634,12 +641,12 @@ void write_png(char *file_name, ... other image information ...)
|
||||
png_byte row_pointers[height][width];
|
||||
|
||||
/* One of the following output methods is REQUIRED */
|
||||
**** write out the entire image data in one call ***
|
||||
#ifdef entire /* write out the entire image data in one call */
|
||||
png_write_image(png_ptr, row_pointers);
|
||||
|
||||
/* the other way to write the image - deal with interlacing */
|
||||
|
||||
**** write out the image data by one or more scanlines ****
|
||||
#else no_entire /* write out the image data by one or more scanlines */
|
||||
/* The number of passes is either 1 for non-interlaced images,
|
||||
* or 7 for interlaced images.
|
||||
*/
|
||||
@@ -655,7 +662,7 @@ void write_png(char *file_name, ... other image information ...)
|
||||
png_write_rows(png_ptr, &row_pointers, 1);
|
||||
}
|
||||
}
|
||||
**** use only one output method ****
|
||||
#endif no_entire /* use only one output method */
|
||||
|
||||
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
|
||||
* as well.
|
||||
|
||||
1067
libpng.txt
1067
libpng.txt
File diff suppressed because it is too large
Load Diff
342
libpngpf.3
Normal file
342
libpngpf.3
Normal file
@@ -0,0 +1,342 @@
|
||||
.TH LIBPNGPF 3 "March 7, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
#include <png.h>
|
||||
|
||||
void png_build_gamma_table (png_structp png_ptr);
|
||||
|
||||
void png_build_grayscale_palette (int bit_depth, png_colorp
|
||||
palette);
|
||||
|
||||
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);
|
||||
|
||||
png_size_t png_check_keyword (png_structp png_ptr, png_charp
|
||||
key, png_charpp new_key);
|
||||
|
||||
void png_combine_row (png_structp png_ptr, png_bytep row, int
|
||||
mask);
|
||||
|
||||
void png_correct_palette (png_structp png_ptr, png_colorp
|
||||
palette, int num_palette);
|
||||
|
||||
int png_crc_error (png_structp png_ptr);
|
||||
|
||||
int png_crc_finish (png_structp png_ptr, png_uint_32 skip);
|
||||
|
||||
void png_crc_read (png_structp png_ptr, png_bytep buf,
|
||||
png_size_t length);
|
||||
|
||||
png_voidp png_create_struct (int type);
|
||||
|
||||
void png_destroy_struct (png_voidp struct_ptr);
|
||||
|
||||
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);
|
||||
|
||||
void png_do_bgr (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_chop (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_dither (png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep dither_lookup);
|
||||
|
||||
void png_do_expand (png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_value);
|
||||
|
||||
void png_do_expand_palette (png_row_infop row_info, png_bytep
|
||||
row, png_colorp palette, png_bytep trans, int num_trans);
|
||||
|
||||
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);
|
||||
|
||||
void png_do_gray_to_rgb (png_row_infop row_info, png_bytep
|
||||
row);
|
||||
|
||||
void png_do_invert (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_pack (png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 bit_depth);
|
||||
|
||||
void png_do_packswap (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_read_filler (png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 filler, png_uint_32 flags);
|
||||
|
||||
void png_do_read_interlace (png_row_infop row_info, png_bytep
|
||||
row, int pass, png_uint_32 transformations);
|
||||
|
||||
void png_do_read_invert_alpha (png_row_infop row_info,
|
||||
png_bytep row);
|
||||
|
||||
void png_do_read_swap_alpha (png_row_infop row_info, png_bytep
|
||||
row);
|
||||
|
||||
void png_do_read_transformations (png_structp png_ptr);
|
||||
|
||||
void png_do_rgb_to_gray (png_row_infop row_info, png_bytep
|
||||
row);
|
||||
|
||||
void png_do_shift (png_row_infop row_info, png_bytep row,
|
||||
png_color_8p bit_depth);
|
||||
|
||||
void png_do_strip_filler (png_row_infop row_info, png_bytep
|
||||
row, png_uint_32 flags);
|
||||
|
||||
void png_do_swap (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_unpack (png_row_infop row_info, png_bytep row);
|
||||
|
||||
void png_do_unshift (png_row_infop row_info, png_bytep row,
|
||||
png_color_8p sig_bits);
|
||||
|
||||
void png_do_write_interlace (png_row_infop row_info, png_bytep
|
||||
row, int pass);
|
||||
|
||||
void png_do_write_invert_alpha (png_row_infop row_info,
|
||||
png_bytep row);
|
||||
|
||||
void png_do_write_swap_alpha (png_row_infop row_info, png_bytep
|
||||
row);
|
||||
|
||||
void png_do_write_transformations (png_structp png_ptr);
|
||||
|
||||
void *png_far_to_near (png_structp png_ptr,png_voidp ptr,
|
||||
int check);
|
||||
|
||||
void png_flush (png_structp png_ptr);
|
||||
|
||||
png_int_32 png_get_int_32 (png_bytep buf);
|
||||
|
||||
png_uint_16 png_get_uint_16 (png_bytep buf);
|
||||
|
||||
png_uint_32 png_get_uint_32 (png_bytep buf);
|
||||
|
||||
void png_handle_bKGD (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_cHRM (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_gAMA (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_hIST (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_IEND (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_IHDR (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_oFFs (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_pCAL (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_pHYs (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_PLTE (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_sBIT (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_sRGB (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_tEXt (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_tIME (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_tRNS (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_handle_unknown (png_structp png_ptr, png_infop
|
||||
info_ptr, png_uint_32 length);
|
||||
|
||||
void png_handle_zTXt (png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length);
|
||||
|
||||
void png_info_destroy (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_init_read_transformations (png_structp png_ptr);
|
||||
|
||||
void png_process_IDAT_data (png_structp png_ptr, png_bytep
|
||||
buffer, png_size_t buffer_length);
|
||||
|
||||
void png_process_some_data (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_check_crc (png_structp png_ptr);
|
||||
|
||||
void png_push_crc_finish (png_structp png_ptr);
|
||||
|
||||
void png_push_crc_skip (png_structp png_ptr, png_uint_32
|
||||
length);
|
||||
|
||||
void png_push_fill_buffer (png_structp png_ptr, png_bytep
|
||||
buffer, png_size_t length);
|
||||
|
||||
void png_push_handle_tEXt (png_structp png_ptr, png_infop
|
||||
info_ptr, png_uint_32 length);
|
||||
|
||||
void png_push_handle_unknown (png_structp png_ptr, png_infop
|
||||
info_ptr, png_uint_32 length);
|
||||
|
||||
void png_push_handle_zTXt (png_structp png_ptr, png_infop
|
||||
info_ptr, png_uint_32 length);
|
||||
|
||||
void png_push_have_end (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_have_info (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_have_row (png_structp png_ptr, png_bytep row);
|
||||
|
||||
void png_push_process_row (png_structp png_ptr);
|
||||
|
||||
void png_push_read_chunk (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_read_end (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_read_IDAT (png_structp png_ptr);
|
||||
|
||||
void png_push_read_sig (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_read_tEXt (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_read_zTXt (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_push_restore_buffer (png_structp png_ptr, png_bytep
|
||||
buffer, png_size_t buffer_length);
|
||||
|
||||
void png_push_save_buffer (png_structp png_ptr);
|
||||
|
||||
void png_read_data (png_structp png_ptr, png_bytep data,
|
||||
png_size_t length);
|
||||
|
||||
void png_read_filter_row (png_structp png_ptr, png_row_infop
|
||||
row_info, png_bytep row, png_bytep prev_row, int filter);
|
||||
|
||||
void png_read_finish_row (png_structp png_ptr);
|
||||
|
||||
void png_read_init (png_structp png_ptr);
|
||||
|
||||
void png_read_push_finish_row (png_structp png_ptr);
|
||||
|
||||
void png_read_start_row (png_structp png_ptr);
|
||||
|
||||
void png_read_transform_info (png_structp png_ptr, png_infop
|
||||
info_ptr);
|
||||
|
||||
void png_reset_crc (png_structp png_ptr);
|
||||
|
||||
void png_save_int_32 (png_bytep buf, png_int_32 i);
|
||||
|
||||
void png_save_uint_16 (png_bytep buf, unsigned int i);
|
||||
|
||||
void png_save_uint_32 (png_bytep buf, png_uint_32 i);
|
||||
|
||||
void png_write_bKGD (png_structp png_ptr, png_color_16p values,
|
||||
int color_type);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
void png_write_find_filter (png_structp png_ptr, png_row_infop
|
||||
row_info);
|
||||
|
||||
void png_write_finish_row (png_structp png_ptr);
|
||||
|
||||
void png_write_gAMA (png_structp png_ptr, double file_gamma);
|
||||
|
||||
void png_write_hIST (png_structp png_ptr, png_uint_16p hist,
|
||||
int num_hist);
|
||||
|
||||
void png_write_init (png_structp png_ptr);
|
||||
|
||||
void png_write_IDAT (png_structp png_ptr, png_bytep data,
|
||||
png_size_t length);
|
||||
|
||||
void png_write_IEND (png_structp png_ptr);
|
||||
|
||||
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);
|
||||
|
||||
void png_write_oFFs (png_structp png_ptr, png_uint_32 x_offset,
|
||||
png_uint_32 y_offset, int unit_type);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
void png_write_PLTE (png_structp png_ptr, png_colorp palette,
|
||||
png_uint_32 num_pal);
|
||||
|
||||
void png_write_sBIT (png_structp png_ptr, png_color_8p sbit,
|
||||
int color_type);
|
||||
|
||||
void png_write_sig (png_structp png_ptr);
|
||||
|
||||
void png_write_sRGB (png_structp png_ptr, int intent);
|
||||
|
||||
void png_write_start_row (png_structp png_ptr);
|
||||
|
||||
void png_write_tEXt (png_structp png_ptr, png_charp key,
|
||||
png_charp text, png_size_t text_len);
|
||||
|
||||
void png_write_tIME (png_structp png_ptr, png_timep mod_time);
|
||||
|
||||
void png_write_tRNS (png_structp png_ptr, png_bytep trans,
|
||||
png_color_16p values, int number, int color_type);
|
||||
|
||||
void png_write_zTXt (png_structp png_ptr, png_charp key,
|
||||
png_charp text, png_size_t text_len, int compression);
|
||||
|
||||
voidpf png_zalloc (voidpf png_ptr, uInt items, uInt size);
|
||||
|
||||
void png_zfree (voidpf png_ptr, voidpf ptr);
|
||||
|
||||
.SH DESCRIPTION
|
||||
The functions listed above are used privately by libpng
|
||||
and are not recommended for use by applications. They
|
||||
are listed alphabetically here as an aid to libpng maintainers.
|
||||
See png.h for more information on these functions.
|
||||
|
||||
.SH SEE ALSO
|
||||
libpng(3), png(5)
|
||||
.SH AUTHOR
|
||||
Glenn Randers-Pehrson
|
||||
44
png.5
Normal file
44
png.5
Normal file
@@ -0,0 +1,44 @@
|
||||
.TH PNG 5 "March 7, 1998"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
PNG (Portable Network Graphics) is an extensible file format for the
|
||||
lossless, portable, well-compressed storage of raster images. PNG provides
|
||||
a patent-free replacement for GIF and can also replace many
|
||||
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
|
||||
supported, plus an optional alpha channel. Sample depths range from
|
||||
1 to 16 bits.
|
||||
.br
|
||||
|
||||
PNG is designed to work well in online viewing applications, such as the
|
||||
World Wide Web, so it is fully streamable with a progressive display
|
||||
option. PNG is robust, providing both full file integrity checking and
|
||||
fast, simple detection of common transmission errors. Also, PNG can store
|
||||
gamma and chromaticity data for improved color matching on heterogeneous
|
||||
platforms.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
|
||||
.LP
|
||||
PNG specification:
|
||||
RFC 2083
|
||||
.IP
|
||||
.br
|
||||
ftp://ds.internic.net/rfc/rfc2083.txt
|
||||
.br
|
||||
or (as a W3C Recommendation) at
|
||||
.br
|
||||
http://www.w3.org/TR/REC-png.html
|
||||
.SH AUTHORS
|
||||
This man page: Glenn Randers-Pehrson
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
|
||||
Thomas Boutell and others (png-list@dworkin.wustl.edu).
|
||||
.LP
|
||||
|
||||
.SH COPYRIGHT NOTICE
|
||||
The PNG specification is copyright (c) 1996 Massachussets Institute of
|
||||
Technology. See the specification for conditions of use and distribution.
|
||||
.LP
|
||||
.\" end of man page
|
||||
|
||||
30
png.c
30
png.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -15,9 +16,9 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[] = "1.00.97";
|
||||
char png_libpng_ver[5] = "1.00";
|
||||
|
||||
/* Place to hold the signiture string for a PNG file. */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||
@@ -102,15 +103,15 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
if (num_to_check > 8)
|
||||
num_to_check = 8;
|
||||
else if (num_to_check < 1)
|
||||
return 0;
|
||||
return (0);
|
||||
|
||||
if (start > 7)
|
||||
return 0;
|
||||
return (0);
|
||||
|
||||
if (start + num_to_check > 8)
|
||||
num_to_check = 8 - start;
|
||||
|
||||
return (png_memcmp(&sig[start], &png_sig[start], num_to_check));
|
||||
return ((int)(png_memcmp(&sig[start], &png_sig[start], num_to_check)));
|
||||
}
|
||||
|
||||
/* (Obsolete) function to check signature bytes. It does not allow one
|
||||
@@ -120,7 +121,7 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
int
|
||||
png_check_sig(png_bytep sig, int num)
|
||||
{
|
||||
return !png_sig_cmp(sig, (png_size_t)0, (png_size_t)num);
|
||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||
}
|
||||
|
||||
/* Function to allocate memory for zlib. */
|
||||
@@ -131,7 +132,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
num_bytes = (png_uint_32)items * size;
|
||||
ptr = png_malloc((png_structp)png_ptr, num_bytes);
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
|
||||
if (num_bytes > (png_uint_32)0x8000)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)0x8000L);
|
||||
@@ -142,7 +143,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
png_memset(ptr, 0, (png_size_t)num_bytes);
|
||||
}
|
||||
return (voidpf)(ptr);
|
||||
return ((voidpf)ptr);
|
||||
}
|
||||
|
||||
/* function to free memory for zlib */
|
||||
@@ -184,7 +185,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
}
|
||||
|
||||
if (need_crc)
|
||||
png_ptr->crc = crc32(png_ptr->crc, ptr, length);
|
||||
png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
|
||||
}
|
||||
|
||||
/* Allocate the memory for an info_struct for the application. We don't
|
||||
@@ -199,12 +200,13 @@ png_create_info_struct(png_structp png_ptr)
|
||||
png_infop info_ptr;
|
||||
|
||||
png_debug(1, "in png_create_info_struct\n");
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
|
||||
{
|
||||
png_info_init(info_ptr);
|
||||
}
|
||||
|
||||
return info_ptr;
|
||||
return (info_ptr);
|
||||
}
|
||||
|
||||
/* This function frees the memory associated with a single info struct.
|
||||
@@ -267,7 +269,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)
|
||||
{
|
||||
for (i = 0; i < info_ptr->pcal_nparams; i++)
|
||||
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->pcal_params[i]);
|
||||
}
|
||||
@@ -285,7 +287,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
png_voidp
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_ptr;
|
||||
return (png_ptr->io_ptr);
|
||||
}
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
|
||||
346
png.h
346
png.h
@@ -1,31 +1,47 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 1.00.97 beta 7
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* libpng 1.00
|
||||
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Dec 31, 1997
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* BETA NOTICE:
|
||||
* This is a beta version. It reads and writes valid files on the
|
||||
* platforms I have, and has had a wide testing program. You may
|
||||
* have to modify the includes below to get it to work on your
|
||||
* system, and you may have to supply the correct compiler flags in
|
||||
* the makefile if you can't find a makefile suitable for your
|
||||
* operating system/compiler combination. Read libpng.txt for more
|
||||
* information, including how to contact the authors if you have any
|
||||
* problems, or if you want your compiler/platform to be supported in
|
||||
* the next official libpng release.
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
* Due to various miscommunications, unforeseen code incompatibilities
|
||||
* and occasional factors outside the authors' control, version numbering
|
||||
* on the library has not always been consistent and straightforward.
|
||||
* The following table summarizes matters since version 0.89c, which was
|
||||
* the first widely used release:
|
||||
*
|
||||
* source png.h shared-lib
|
||||
* version string version
|
||||
* ------- ------ ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 1.0.0 [should have been 2.0.97]
|
||||
* 0.97c 0.97 2.0.97
|
||||
* 0.98 0.98 2.0.98
|
||||
* 0.99 0.99 2.0.99
|
||||
* 0.99a-i 0.99 2.0.99
|
||||
* 1.00 1.00 2.1.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* See libpng.txt 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/pub/WWW/TR/REC.png.html>
|
||||
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
||||
*
|
||||
* Contributing Authors:
|
||||
* John Bowler
|
||||
* Sam Bushell
|
||||
* Kevin Bracey
|
||||
* Sam Bushell
|
||||
* Andreas Dilger
|
||||
* Magnus Holmgren
|
||||
* Tom Lane
|
||||
@@ -35,6 +51,7 @@
|
||||
* Guy Eric Schalnat
|
||||
* Paul Schmidt
|
||||
* Tom Tanner
|
||||
* Willem van Schaik
|
||||
* Tim Wegner
|
||||
*
|
||||
* The contributing authors would like to thank all those who helped
|
||||
@@ -43,6 +60,8 @@
|
||||
*
|
||||
* Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
*
|
||||
* COPYRIGHT NOTICE:
|
||||
*
|
||||
* 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
|
||||
@@ -93,30 +112,30 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.00.97"
|
||||
#define PNG_LIBPNG_VER_STRING "1.00"
|
||||
|
||||
/* careful here. At one time, I wanted to use 082, but that would be octal.
|
||||
* Version 1.0 will be 100 here, etc.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 97
|
||||
#define PNG_LIBPNG_VER 100
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||
/* Version information for C files, stored in png.c. This had better match
|
||||
* the version above.
|
||||
*/
|
||||
extern char png_libpng_ver[];
|
||||
extern char png_libpng_ver[5];
|
||||
|
||||
/* Structures to facilitate easy interlacing. See png.c for more details */
|
||||
extern int FARDATA png_pass_start[];
|
||||
extern int FARDATA png_pass_inc[];
|
||||
extern int FARDATA png_pass_ystart[];
|
||||
extern int FARDATA png_pass_yinc[];
|
||||
extern int FARDATA png_pass_mask[];
|
||||
extern int FARDATA png_pass_dsp_mask[];
|
||||
extern int FARDATA png_pass_start[7];
|
||||
extern int FARDATA png_pass_inc[7];
|
||||
extern int FARDATA png_pass_ystart[7];
|
||||
extern int FARDATA png_pass_yinc[7];
|
||||
extern int FARDATA png_pass_mask[7];
|
||||
extern int FARDATA png_pass_dsp_mask[7];
|
||||
/* These aren't currently used. If you need them, see png.c for more details
|
||||
extern int FARDATA png_pass_width[];
|
||||
extern int FARDATA png_pass_height[];
|
||||
extern int FARDATA png_pass_width[7];
|
||||
extern int FARDATA png_pass_height[7];
|
||||
*/
|
||||
#endif /* PNG_NO_EXTERN */
|
||||
|
||||
@@ -220,7 +239,7 @@ typedef struct png_info_struct
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
|
||||
png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
|
||||
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
|
||||
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
|
||||
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
|
||||
@@ -242,7 +261,8 @@ typedef struct png_info_struct
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED) || \
|
||||
defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
@@ -297,7 +317,8 @@ typedef struct png_info_struct
|
||||
png_bytep trans; /* transparent values for paletted image */
|
||||
png_color_16 trans_values; /* transparent color for non-palette image */
|
||||
#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The bKGD chunk gives the suggested image background color if the
|
||||
* display program does not have its own background color and the image
|
||||
* is needs to composited onto a background before display. The colors
|
||||
@@ -418,6 +439,15 @@ typedef png_info FAR * FAR * png_infopp;
|
||||
#define PNG_RESOLUTION_METER 1 /* pixels/meter */
|
||||
#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
|
||||
|
||||
/* These are for the sRGB chunk. These values should NOT be changed. */
|
||||
#define PNG_sRGB_INTENT_SATURATION 0
|
||||
#define PNG_sRGB_INTENT_PERCEPTUAL 1
|
||||
#define PNG_sRGB_INTENT_ABSOLUTE 2
|
||||
#define PNG_sRGB_INTENT_RELATIVE 3
|
||||
#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
|
||||
|
||||
|
||||
|
||||
/* These determine if an ancillary chunk's data has been successfully read
|
||||
* from the PNG header, or if the application has filled in the corresponding
|
||||
* data in the info_struct to be written into the output file. The values
|
||||
@@ -443,7 +473,7 @@ typedef png_info FAR * FAR * png_infopp;
|
||||
typedef struct png_row_info_struct
|
||||
{
|
||||
png_uint_32 width; /* width of row */
|
||||
png_size_t rowbytes; /* number of bytes in row */
|
||||
png_uint_32 rowbytes; /* number of bytes in row */
|
||||
png_byte color_type; /* color type of row */
|
||||
png_byte bit_depth; /* bit depth of row */
|
||||
png_byte channels; /* number of channels (1, 2, 3, or 4) */
|
||||
@@ -464,6 +494,8 @@ typedef png_struct FAR * png_structp;
|
||||
typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
|
||||
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
|
||||
typedef void (*png_flush_ptr) PNGARG((png_structp));
|
||||
typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
|
||||
typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
|
||||
typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
|
||||
@@ -471,6 +503,12 @@ typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
|
||||
png_uint_32, int));
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
typedef void (*png_user_transform_ptr) PNGARG((png_structp,
|
||||
png_row_infop, png_bytep));
|
||||
#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
|
||||
/* 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.
|
||||
@@ -487,9 +525,14 @@ 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_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
|
||||
|
||||
png_uint_32 mode; /* tells us whre we are in the PNG file */
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
@@ -506,8 +549,8 @@ struct png_struct_def
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
png_uint_32 usr_width; /* width of row at start of write */
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_size_t irowbytes; /* size of current interlaced row in bytes */
|
||||
png_uint_32 rowbytes; /* size of row in bytes */
|
||||
png_uint_32 irowbytes; /* size of current interlaced row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
||||
@@ -554,9 +597,9 @@ struct png_struct_def
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
|
||||
float gamma; /* file gamma value */
|
||||
float display_gamma; /* display gamma value */
|
||||
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 */
|
||||
@@ -576,9 +619,11 @@ struct png_struct_def
|
||||
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 */
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after each row is decoded */
|
||||
png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
@@ -598,6 +643,7 @@ struct png_struct_def
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* for the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
@@ -605,13 +651,14 @@ struct png_struct_def
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED&&__TURBOC__&&!_Windows&&!__FLAT__ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* __TURBOC__&&!_Windows&&!__FLAT__ */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_bytep palette_lookup; /* lookup table for dithering */
|
||||
png_bytep dither_index; /* index translation for palette files */
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
@@ -621,9 +668,9 @@ struct png_struct_def
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
png_charp time_buffer; /* String to hold RFC 1152 time text */
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
png_charp time_buffer; /* String to hold RFC 1123 time text */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
};
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
@@ -663,6 +710,21 @@ extern PNG_EXPORT(png_structp,png_create_write_struct)
|
||||
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Write the start of a PNG chunk - length and chunk name. */
|
||||
extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
|
||||
png_bytep chunk_name, png_uint_32 length));
|
||||
|
||||
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
|
||||
extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
|
||||
png_bytep data, png_size_t length));
|
||||
|
||||
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
|
||||
extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
|
||||
|
||||
/* Allocate and initialize the info structure */
|
||||
extern PNG_EXPORT(png_infop,png_create_info_struct)
|
||||
PNGARG((png_structp png_ptr));
|
||||
@@ -678,10 +740,10 @@ extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
|
||||
extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
extern PNG_EXPORT(png_charp,png_convert_to_rfc1152)
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
|
||||
PNGARG((png_structp png_ptr, png_timep ptime));
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
/* convert from a struct tm to png_time */
|
||||
@@ -725,6 +787,11 @@ extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
|
||||
extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
|
||||
#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
|
||||
#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED || PNG_WRITE_INVERT_ALPHA_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
/* Add a filler byte to 24-bit RGB images. */
|
||||
extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
|
||||
@@ -791,7 +858,7 @@ extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
|
||||
#endif /* PNG_READ_DITHER_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* Handle gamma correction. */
|
||||
/* Handle gamma correction. Screen_gamma=(display_gamma/viewing_gamma) */
|
||||
extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
|
||||
double screen_gamma, double default_file_gamma));
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
@@ -1030,6 +1097,22 @@ extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
|
||||
/* Return the user pointer associated with the I/O functions */
|
||||
extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
|
||||
|
||||
extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
|
||||
png_read_status_ptr read_row_fn));
|
||||
|
||||
extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
|
||||
png_write_status_ptr write_row_fn));
|
||||
|
||||
#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));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
|
||||
png_ptr, png_user_transform_ptr write_user_transform_fn));
|
||||
#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.
|
||||
@@ -1060,8 +1143,22 @@ 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));
|
||||
|
||||
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 *far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,int check));
|
||||
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
||||
int check));
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
/* Fatal error in PNG image of libpng - can't continue */
|
||||
@@ -1092,18 +1189,71 @@ extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
|
||||
* to avoid problems with future changes in the size and internal layout of
|
||||
* png_info_struct.
|
||||
*/
|
||||
/* Returns "flag" if chunk data is valid in info_ptr */
|
||||
/* Returns "flag" if chunk data is valid in info_ptr. */
|
||||
extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 flag));
|
||||
|
||||
/* Returns number of bytes needed to hold a transformed row */
|
||||
/* Returns number of bytes needed to hold a transformed row. */
|
||||
extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
/* Returns number of color channels in image */
|
||||
/* Returns number of color channels in image. */
|
||||
extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* Returns image width in pixels. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image height in pixels. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image bit_depth. */
|
||||
extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image color_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image filter_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image interlace_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image compression_type. */
|
||||
extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
|
||||
extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
|
||||
extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp
|
||||
png_ptr, png_infop info_ptr));
|
||||
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
@@ -1212,14 +1362,14 @@ extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_bytep srgb_intent));
|
||||
png_infop info_ptr, int *intent));
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_byte srgb_intent));
|
||||
png_infop info_ptr, int intent));
|
||||
extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_byte srgb_intent));
|
||||
png_infop info_ptr, int intent));
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
@@ -1263,6 +1413,9 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
* libpng yet, but more support will be added as needed.
|
||||
*/
|
||||
#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 */
|
||||
@@ -1330,9 +1483,11 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_GAMMA 0x2000
|
||||
#define PNG_GRAY_TO_RGB 0x4000
|
||||
#define PNG_FILLER 0x8000
|
||||
#define PNG_PACKSWAP 0x10000
|
||||
#define PNG_SWAP_ALPHA 0x20000
|
||||
#define PNG_STRIP_ALPHA 0x40000
|
||||
#define PNG_PACKSWAP 0x10000L
|
||||
#define PNG_SWAP_ALPHA 0x20000L
|
||||
#define PNG_STRIP_ALPHA 0x40000L
|
||||
#define PNG_INVERT_ALPHA 0x80000L
|
||||
#define PNG_USER_TRANSFORM 0x100000L
|
||||
|
||||
/* flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
@@ -1360,8 +1515,8 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_FLAG_FREE_PALETTE 0x1000
|
||||
#define PNG_FLAG_FREE_TRANS 0x2000
|
||||
#define PNG_FLAG_FREE_HIST 0x4000
|
||||
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000
|
||||
#define PNG_FLAG_WROTE_tIME 0x10000
|
||||
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
|
||||
#define PNG_FLAG_WROTE_tIME 0x10000L
|
||||
|
||||
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||
@@ -1378,32 +1533,32 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
abs((int)((c1).blue) - (int)((c2).blue)))
|
||||
|
||||
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
|
||||
#ifndef PNG_NO_EXTERN
|
||||
/* place to hold the signiture string for a PNG file. */
|
||||
extern png_byte FARDATA png_sig[];
|
||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||
/* place to hold the signature string for a PNG file. */
|
||||
extern png_byte FARDATA png_sig[8];
|
||||
|
||||
/* Constant strings for known chunk types. If you need to add a chunk,
|
||||
* add a string holding the name here. See png.c for more details. We
|
||||
* can't selectively include these, since we still check for chunk in the
|
||||
* wrong locations with these labels.
|
||||
*/
|
||||
extern png_byte FARDATA png_IHDR[];
|
||||
extern png_byte FARDATA png_IDAT[];
|
||||
extern png_byte FARDATA png_IEND[];
|
||||
extern png_byte FARDATA png_PLTE[];
|
||||
extern png_byte FARDATA png_bKGD[];
|
||||
extern png_byte FARDATA png_cHRM[];
|
||||
extern png_byte FARDATA png_gAMA[];
|
||||
extern png_byte FARDATA png_hIST[];
|
||||
extern png_byte FARDATA png_oFFs[];
|
||||
extern png_byte FARDATA png_pCAL[];
|
||||
extern png_byte FARDATA png_pHYs[];
|
||||
extern png_byte FARDATA png_sBIT[];
|
||||
extern png_byte FARDATA png_sRGB[];
|
||||
extern png_byte FARDATA png_tEXt[];
|
||||
extern png_byte FARDATA png_tIME[];
|
||||
extern png_byte FARDATA png_tRNS[];
|
||||
extern png_byte FARDATA png_zTXt[];
|
||||
extern png_byte FARDATA png_IHDR[5];
|
||||
extern png_byte FARDATA png_IDAT[5];
|
||||
extern png_byte FARDATA png_IEND[5];
|
||||
extern png_byte FARDATA png_PLTE[5];
|
||||
extern png_byte FARDATA png_bKGD[5];
|
||||
extern png_byte FARDATA png_cHRM[5];
|
||||
extern png_byte FARDATA png_gAMA[5];
|
||||
extern png_byte FARDATA png_hIST[5];
|
||||
extern png_byte FARDATA png_oFFs[5];
|
||||
extern png_byte FARDATA png_pCAL[5];
|
||||
extern png_byte FARDATA png_pHYs[5];
|
||||
extern png_byte FARDATA png_sBIT[5];
|
||||
extern png_byte FARDATA png_sRGB[5];
|
||||
extern png_byte FARDATA png_tEXt[5];
|
||||
extern png_byte FARDATA png_tIME[5];
|
||||
extern png_byte FARDATA png_tRNS[5];
|
||||
extern png_byte FARDATA png_zTXt[5];
|
||||
|
||||
#endif /* PNG_NO_EXTERN */
|
||||
|
||||
@@ -1503,22 +1658,7 @@ PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
|
||||
*/
|
||||
PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
|
||||
|
||||
/* Write a PNG chunk - size, type, (optional) data, CRC. */
|
||||
PNG_EXTERN void png_write_chunk PNGARG((png_structp png_ptr,
|
||||
png_bytep chunk_name, png_bytep data, png_size_t length));
|
||||
|
||||
/* Write the start of a PNG chunk - length and chunk name. */
|
||||
PNG_EXTERN void png_write_chunk_start PNGARG((png_structp png_ptr,
|
||||
png_bytep chunk_name, png_uint_32 length));
|
||||
|
||||
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
|
||||
PNG_EXTERN void png_write_chunk_data PNGARG((png_structp png_ptr,
|
||||
png_bytep data, png_size_t length));
|
||||
|
||||
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
|
||||
PNG_EXTERN void png_write_chunk_end PNGARG((png_structp png_ptr));
|
||||
|
||||
/* simple function to write the signiture */
|
||||
/* simple function to write the signature */
|
||||
PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
|
||||
|
||||
/* write various chunks */
|
||||
@@ -1557,7 +1697,7 @@ PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
|
||||
png_byte srgb_intent));
|
||||
int intent));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
@@ -1572,7 +1712,7 @@ PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
|
||||
|
||||
#if defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
|
||||
png_uint_32 num_hist));
|
||||
int num_hist));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
@@ -1674,6 +1814,16 @@ PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
||||
|
||||
150
pngconf.h
150
pngconf.h
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngconf.c - machine configurable file for libpng
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
@@ -26,7 +27,7 @@
|
||||
* where it becomes significant, if you are concerned with memory
|
||||
* usage. Note that zlib allocates at least 32Kb also. For readers,
|
||||
* this describes the size of the buffer available to read the data in.
|
||||
* Unless this gets smaller then the size of a row (compressed),
|
||||
* Unless this gets smaller than the size of a row (compressed),
|
||||
* it should not make much difference how big this is.
|
||||
*/
|
||||
|
||||
@@ -54,8 +55,6 @@
|
||||
* #define PNG_NO_STDIO
|
||||
*/
|
||||
|
||||
/* We still need stdio.h for FILE even when PNG_NO_STDIO is defined.
|
||||
*/
|
||||
#ifndef PNG_NO_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@@ -87,10 +86,12 @@
|
||||
* just __MWERKS__ is not good enough, because the Codewarrior is now used
|
||||
* on non-Mac platforms.
|
||||
*/
|
||||
#ifndef MACOS
|
||||
#if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__)
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
#define MACOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* enough people need this for various reasons to include it here */
|
||||
#if !defined(MACOS) && !defined(RISCOS)
|
||||
@@ -156,6 +157,11 @@ __dont__ include it again
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
/* Codewarrior on NT has linking problems without this. */
|
||||
#if defined(__MWERKS__) && defined(WIN32)
|
||||
#define PNG_ALWAYS_EXTERN
|
||||
#endif
|
||||
|
||||
/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
|
||||
* stdlib.h like it should (I think). Or perhaps this is a C++
|
||||
* "feature"?
|
||||
@@ -190,24 +196,25 @@ __dont__ include it again
|
||||
* less then 8, and even that may not work (I haven't tested it).
|
||||
*/
|
||||
|
||||
#ifndef PNG_MAX_GAMMA_8
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#endif
|
||||
|
||||
/* This controls how much a difference in gamma we can tolerate before
|
||||
* we actually start doing gamma conversion.
|
||||
*/
|
||||
#ifndef PNG_GAMMA_THRESHOLD
|
||||
#define PNG_GAMMA_THRESHOLD 0.05
|
||||
#endif
|
||||
|
||||
#endif /* PNG_INTERNAL */
|
||||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you want to use const, define PNG_USE_CONST here. It is not
|
||||
* normally defined to make configuration easier, as it is not a
|
||||
* critical part of the code.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
*/
|
||||
#define PNG_USE_CONST
|
||||
|
||||
#ifdef PNG_USE_CONST
|
||||
#ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
#else
|
||||
# define PNG_CONST
|
||||
@@ -229,21 +236,24 @@ __dont__ include it again
|
||||
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
|
||||
/* GR-P, 0.96a: Set "*FULLY_SUPPORTED as default but allow user
|
||||
to turn it off with "*NOT_FULLY_SUPPORTED" on the compile line,
|
||||
/* 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 */
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PNG_READ_NOT_FULLY_SUPPORTED
|
||||
#define PNG_READ_FULLY_SUPPORTED
|
||||
|
||||
#ifndef PNG_READ_TRANSFORMS_NOT_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_NOT_FULLY_SUPPORTED
|
||||
#define PNG_WRITE_FULLY_SUPPORTED
|
||||
#ifndef PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
|
||||
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_FULLY_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_SHIFT_SUPPORTED
|
||||
#define PNG_READ_PACK_SUPPORTED
|
||||
@@ -258,12 +268,22 @@ __dont__ include it again
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
/* the following aren't implemented yet
|
||||
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
*/
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FULLY_SUPPORTED
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||
#ifndef 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 */
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||
#define PNG_WRITE_PACK_SUPPORTED
|
||||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
@@ -273,32 +293,72 @@ __dont__ include it again
|
||||
#define PNG_WRITE_FILLER_SUPPORTED /* This is the same as WRITE_STRIP_ALPHA */
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif /*PNG_WRITE_FULLY_SUPPORTED */
|
||||
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#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)
|
||||
#define PNG_TIME_RFC1152_SUPPORTED
|
||||
#define PNG_TIME_RFC1123_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* These are currently experimental features */
|
||||
#undef PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED /* very little testing */
|
||||
#undef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* very little testing */
|
||||
/* This adds extra functions in pngget.c for accessing data from the
|
||||
* info pointer (added in version 0.99)
|
||||
* png_get_image_width()
|
||||
* png_get_image_height()
|
||||
* png_get_bit_depth()
|
||||
* png_get_color_type()
|
||||
* png_get_compression_type()
|
||||
* png_get_filter_type()
|
||||
* png_get_interlace_type()
|
||||
* png_get_pixel_aspect_ratio()
|
||||
* png_get_pixels_per_meter()
|
||||
* png_get_x_offset_pixels()
|
||||
* png_get_y_offset_pixels()
|
||||
* png_get_x_offset_microns()
|
||||
* png_get_y_offset_microns()
|
||||
*/
|
||||
#if !defined(PNG_NO_EASY_ACCESS)
|
||||
#define PNG_EASY_ACCESS_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* These are currently experimental features, define them if you want */
|
||||
|
||||
/* very little testing */
|
||||
/*
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
*/
|
||||
|
||||
/* This is only for PowerPC big-endian and 680x0 systems */
|
||||
#undef PNG_READ_BIG_ENDIAN_SUPPORTED /* some testing */
|
||||
/* some testing */
|
||||
/*
|
||||
#define PNG_READ_BIG_ENDIAN_SUPPORTED
|
||||
*/
|
||||
|
||||
/* These functions are turned off by default, as they will be phased out. */
|
||||
#undef PNG_USELESS_TESTS_SUPPORTED
|
||||
#undef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
/*
|
||||
#define PNG_USELESS_TESTS_SUPPORTED
|
||||
#define PNG_CORRECT_PALETTE_SUPPORTED
|
||||
*/
|
||||
|
||||
/* Any chunks you are not interested in, you can undef here. The
|
||||
* ones that allocate memory may be expecially important (hIST,
|
||||
* tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
|
||||
* a bit smaller. OPT_PLTE only disables the optional palette in RGB
|
||||
* and RGBA images.
|
||||
* a bit smaller.
|
||||
*/
|
||||
|
||||
#ifdef PNG_READ_FULLY_SUPPORTED
|
||||
#ifndef PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_bKGD_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
@@ -312,9 +372,11 @@ __dont__ include it again
|
||||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#endif /* PNG_READ_FULLY_SUPPORTED */
|
||||
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
|
||||
/* PLTE chunk in RGB and RGBA images */
|
||||
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FULLY_SUPPORTED
|
||||
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_bKGD_SUPPORTED
|
||||
#define PNG_WRITE_cHRM_SUPPORTED
|
||||
#define PNG_WRITE_gAMA_SUPPORTED
|
||||
@@ -328,7 +390,7 @@ __dont__ include it again
|
||||
#define PNG_WRITE_tIME_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_zTXt_SUPPORTED
|
||||
#endif /* PNG_WRITE_FULLY_SUPPORTED */
|
||||
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||
|
||||
/* need the time information for reading tIME chunks */
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
@@ -454,7 +516,7 @@ typedef z_stream FAR * png_zstreamp;
|
||||
|
||||
/* allow for compilation as dll with BORLAND C++ 5.0 */
|
||||
#if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__)
|
||||
# define PNG_EXPORT(t,s) t _export s
|
||||
# define PNG_EXPORT(type,symbol) type _export symbol
|
||||
#endif
|
||||
|
||||
/* allow for compilation as shared lib under BeOS */
|
||||
@@ -463,7 +525,7 @@ typedef z_stream FAR * png_zstreamp;
|
||||
#endif
|
||||
|
||||
#ifndef PNG_EXPORT
|
||||
#define PNG_EXPORT(t,s) t s
|
||||
#define PNG_EXPORT(type,symbol) type symbol
|
||||
#endif
|
||||
|
||||
|
||||
@@ -475,8 +537,8 @@ typedef z_stream FAR * png_zstreamp;
|
||||
/* use this to make far-to-near assignments */
|
||||
# define CHECK 1
|
||||
# define NOCHECK 0
|
||||
# define CVT_PTR(ptr) (far_to_near(png_ptr,ptr,CHECK))
|
||||
# define CVT_PTR_NOCHECK(ptr) (far_to_near(png_ptr,ptr,NOCHECK))
|
||||
# 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_strlen _fstrlen
|
||||
# define png_memcmp _fmemcmp /* SJT: added */
|
||||
# define png_memcpy _fmemcpy
|
||||
|
||||
11
pngerror.c
11
pngerror.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
@@ -80,11 +81,11 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
|
||||
}
|
||||
|
||||
if (message == NULL)
|
||||
buffer[iout++] = 0;
|
||||
buffer[iout] = 0;
|
||||
else {
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
strncpy(buffer+iout, message, 64);
|
||||
png_memcpy(buffer+iout, message, 64);
|
||||
buffer[iout+63] = 0;
|
||||
}
|
||||
}
|
||||
@@ -166,7 +167,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_voidp
|
||||
png_get_error_ptr(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->error_ptr;
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
403
pngget.c
403
pngget.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -14,7 +15,7 @@
|
||||
png_uint_32
|
||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->valid & flag);
|
||||
else
|
||||
return(0);
|
||||
@@ -23,28 +24,307 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||
png_uint_32
|
||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->rowbytes);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
/* easy access to info, added in libpng-0.99 */
|
||||
png_uint_32
|
||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->width;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->height;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->bit_depth;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->color_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->filter_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->interlace_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_byte
|
||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
{
|
||||
return info_ptr->compression_type;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->y_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
float
|
||||
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
|
||||
if (info_ptr->x_pixels_per_unit == 0)
|
||||
return ((float)0.0);
|
||||
else
|
||||
return ((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return ((float)0.0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef PNG_INCH_CONVERSIONS
|
||||
png_uint_32
|
||||
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
|
||||
*.03937 +.5)
|
||||
}
|
||||
|
||||
float
|
||||
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
}
|
||||
|
||||
float
|
||||
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
|
||||
*.03937/1000000. +.5)
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
png_uint_32
|
||||
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL)
|
||||
{
|
||||
*res_x = info_ptr->x_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (res_y != NULL)
|
||||
{
|
||||
*res_y = info_ptr->y_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (unit_type != NULL)
|
||||
{
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
if(unit_type == 1)
|
||||
{
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * 39.37 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * 39.37 + .50);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->channels);
|
||||
else
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_bytep
|
||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (info_ptr != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->signature);
|
||||
else
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
@@ -52,8 +332,8 @@ png_uint_32
|
||||
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_bKGD &&
|
||||
background != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||
&& background != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "bKGD");
|
||||
*background = &(info_ptr->background);
|
||||
@@ -69,7 +349,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_cHRM)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "cHRM");
|
||||
if (white_x != NULL)
|
||||
@@ -98,8 +378,8 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32
|
||||
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA &&
|
||||
file_gamma != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||
&& file_gamma != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "gAMA");
|
||||
*file_gamma = (double)info_ptr->gamma;
|
||||
@@ -111,14 +391,13 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
png_uint_32
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, png_bytep
|
||||
file_srgb_intent)
|
||||
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB &&
|
||||
file_srgb_intent != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sRGB");
|
||||
*file_srgb_intent = info_ptr->srgb_intent;
|
||||
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
}
|
||||
return (0);
|
||||
@@ -129,7 +408,8 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, png_bytep
|
||||
png_uint_32
|
||||
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_hIST && hist != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
&& hist != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "hIST");
|
||||
*hist = info_ptr->hist;
|
||||
@@ -146,9 +426,12 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
int *filter_type)
|
||||
|
||||
{
|
||||
if (info_ptr != NULL && width != NULL && height != NULL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
|
||||
bit_depth != NULL && color_type != NULL)
|
||||
{
|
||||
int pixel_depth, channels;
|
||||
png_uint_32 rowbytes_per_pixel;
|
||||
|
||||
png_debug1(1, "in %s retrieval function\n", "IHDR");
|
||||
*width = info_ptr->width;
|
||||
*height = info_ptr->height;
|
||||
@@ -160,6 +443,23 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
*filter_type = info_ptr->filter_type;
|
||||
if (interlace_type != NULL)
|
||||
*interlace_type = info_ptr->interlace_type;
|
||||
|
||||
/* check for potential overflow of rowbytes */
|
||||
if (*color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
channels = 1;
|
||||
else if (*color_type & PNG_COLOR_MASK_COLOR)
|
||||
channels = 3;
|
||||
else
|
||||
channels = 1;
|
||||
if (*color_type & PNG_COLOR_MASK_ALPHA)
|
||||
channels++;
|
||||
pixel_depth = *bit_depth * channels;
|
||||
rowbytes_per_pixel = (pixel_depth + 7) >> 3;
|
||||
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Width too large for libpng to process image data.");
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
@@ -170,8 +470,8 @@ png_uint_32
|
||||
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs &&
|
||||
offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "oFFs");
|
||||
*offset_x = info_ptr->x_offset;
|
||||
@@ -189,7 +489,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
|
||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
@@ -214,12 +514,16 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "pHYs");
|
||||
if (res_x != NULL && res_y != NULL)
|
||||
if (res_x != NULL)
|
||||
{
|
||||
*res_x = info_ptr->x_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
if (res_y != NULL)
|
||||
{
|
||||
*res_y = info_ptr->y_pixels_per_unit;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
@@ -228,9 +532,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
return (0);
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -238,7 +541,8 @@ png_uint_32
|
||||
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
int *num_palette)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE && palette != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE &&
|
||||
palette != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
||||
*palette = info_ptr->palette;
|
||||
@@ -253,7 +557,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
|
||||
png_uint_32
|
||||
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT && sig_bit != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT &&
|
||||
sig_bit != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "sBIT");
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
@@ -268,10 +573,11 @@ png_uint_32
|
||||
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
int *num_text)
|
||||
{
|
||||
if ((info_ptr != NULL) || (info_ptr->num_text > 0))
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n",
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text" : png_ptr->chunk_name));
|
||||
(png_ptr->chunk_name[0] == '\0' ? "text"
|
||||
: (png_const_charp)png_ptr->chunk_name));
|
||||
if (text_ptr != NULL)
|
||||
*text_ptr = info_ptr->text;
|
||||
if (num_text != NULL)
|
||||
@@ -286,7 +592,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
|
||||
png_uint_32
|
||||
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME && mod_time != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME &&
|
||||
mod_time != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tIME");
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
@@ -301,25 +608,37 @@ png_uint_32
|
||||
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
|
||||
{
|
||||
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "tRNS");
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && trans != NULL)
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
*trans = info_ptr->trans;
|
||||
if (trans != NULL)
|
||||
{
|
||||
*trans = info_ptr->trans;
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
if (trans_values != NULL)
|
||||
*trans_values = &(info_ptr->trans_values);
|
||||
}
|
||||
else if (trans_values != NULL)
|
||||
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
|
||||
{
|
||||
*trans_values = &(info_ptr->trans_values);
|
||||
if (trans_values != NULL)
|
||||
{
|
||||
*trans_values = &(info_ptr->trans_values);
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
if(trans != NULL)
|
||||
*trans = NULL;
|
||||
}
|
||||
else
|
||||
if(num_trans != NULL)
|
||||
{
|
||||
return (0);
|
||||
*num_trans = info_ptr->num_trans;
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
*num_trans = info_ptr->num_trans;
|
||||
return (PNG_INFO_tRNS);
|
||||
}
|
||||
return (0);
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
90
pngmem.c
90
pngmem.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users which
|
||||
* need special memory handling are expected to modify the code in this file
|
||||
@@ -15,6 +16,16 @@
|
||||
#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 */
|
||||
@@ -32,7 +43,7 @@ png_create_struct(int type)
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = sizeof(png_struct);
|
||||
else
|
||||
return (png_voidp)NULL;
|
||||
return ((png_voidp)NULL);
|
||||
|
||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||
{
|
||||
@@ -48,7 +59,10 @@ void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
farfree (struct_ptr);
|
||||
struct_ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
@@ -71,11 +85,11 @@ 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)
|
||||
{
|
||||
png_voidp ret;
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return ((voidp)NULL);
|
||||
return ((png_voidp)NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
@@ -97,8 +111,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
png_byte huge * hptr;
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
farfree(ret);
|
||||
ret = NULL;
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
if (num_blocks < 1)
|
||||
@@ -114,7 +130,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (table == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
@@ -128,7 +144,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of memory");
|
||||
png_error(png_ptr, "Out Of memory.");
|
||||
}
|
||||
|
||||
hptr = (png_byte huge *)table;
|
||||
@@ -150,7 +166,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
}
|
||||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out of Memory.");
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
@@ -159,17 +175,17 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
|
||||
}
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* free a pointer allocated by png_malloc(). In the default
|
||||
/* free a pointer allocated by PNG_MALLOC(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
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;
|
||||
@@ -197,7 +213,10 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
farfree(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
@@ -216,7 +235,7 @@ png_create_struct(int type)
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = sizeof(png_struct);
|
||||
else
|
||||
return (png_voidp)NULL;
|
||||
return ((png_voidp)NULL);
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
|
||||
@@ -240,6 +259,7 @@ void
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
#else
|
||||
@@ -249,6 +269,7 @@ png_destroy_struct(png_voidp struct_ptr)
|
||||
free(struct_ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -259,11 +280,12 @@ 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)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
return ((png_voidp)NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
@@ -271,12 +293,12 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
#endif
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
ret = farmalloc((png_size_t)size);
|
||||
ret = farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
ret = halloc(size, 1);
|
||||
# else
|
||||
ret = malloc(size);
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -285,14 +307,14 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Free a pointer allocated by png_malloc(). In the default
|
||||
/* Free a pointer allocated by PNG_MALLOC(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
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;
|
||||
@@ -310,3 +332,29 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
png_voidp
|
||||
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_size_t size;
|
||||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memcpy_check.");
|
||||
|
||||
return(png_memcpy (s1, s2, size));
|
||||
}
|
||||
|
||||
png_voidp
|
||||
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_size_t size;
|
||||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memset_check.");
|
||||
|
||||
return (png_memset (s1, value, size));
|
||||
|
||||
}
|
||||
|
||||
75
pngpread.c
75
pngpread.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -465,7 +466,8 @@ png_push_save_buffer(png_structp png_ptr)
|
||||
|
||||
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
|
||||
old_buffer = png_ptr->save_buffer;
|
||||
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, new_max);
|
||||
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)new_max);
|
||||
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
@@ -526,7 +528,12 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
png_size_t save_size;
|
||||
|
||||
if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size)
|
||||
save_size = png_ptr->idat_size;
|
||||
{
|
||||
save_size = (png_size_t)png_ptr->idat_size;
|
||||
/* check for overflow */
|
||||
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||
}
|
||||
else
|
||||
save_size = png_ptr->save_buffer_size;
|
||||
|
||||
@@ -543,7 +550,12 @@ png_push_read_IDAT(png_structp png_ptr)
|
||||
png_size_t save_size;
|
||||
|
||||
if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size)
|
||||
save_size = png_ptr->idat_size;
|
||||
{
|
||||
save_size = (png_size_t)png_ptr->idat_size;
|
||||
/* check for overflow */
|
||||
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||
}
|
||||
else
|
||||
save_size = png_ptr->current_buffer_size;
|
||||
|
||||
@@ -618,6 +630,7 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_ptr->row_info.channels = png_ptr->channels;
|
||||
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
||||
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
||||
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
@@ -625,7 +638,8 @@ png_push_process_row(png_structp png_ptr)
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
||||
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr);
|
||||
@@ -760,7 +774,8 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
png_memset_check(png_ptr, png_ptr->prev_row, 0,
|
||||
png_ptr->rowbytes + 1);
|
||||
do
|
||||
{
|
||||
png_ptr->pass++;
|
||||
@@ -770,8 +785,10 @@ png_read_push_finish_row(png_structp png_ptr)
|
||||
png_pass_inc[png_ptr->pass] - 1 -
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
|
||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||
png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||
|
||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
png_ptr->num_rows = (png_ptr->height +
|
||||
@@ -792,7 +809,11 @@ void
|
||||
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||
png_error(png_ptr, "Out of place tEXt");
|
||||
{
|
||||
png_error(png_ptr, "Out of place tEXt");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->skip_length = 0; /* This may not be necessary */
|
||||
@@ -805,11 +826,12 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = length;
|
||||
png_ptr->current_text_left = length;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
||||
}
|
||||
|
||||
@@ -856,7 +878,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
||||
if (text != key + png_ptr->current_text_size)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->key = key;
|
||||
text_ptr->text = text;
|
||||
@@ -873,7 +895,11 @@ void
|
||||
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
|
||||
png_error(png_ptr, "Out of place zTXt");
|
||||
{
|
||||
png_error(png_ptr, "Out of place zTXt");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
/* We can't handle zTXt chunks > 64K, since we don't have enough space
|
||||
@@ -888,11 +914,12 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = length;
|
||||
png_ptr->current_text_left = length;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
png_ptr->current_text_left = (png_size_t)length;
|
||||
png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
||||
}
|
||||
|
||||
@@ -954,7 +981,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
||||
(text - key));
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
key_size = text - key;
|
||||
text_size = 0;
|
||||
@@ -977,8 +1004,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
if (text == NULL)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
||||
key_size + 1);
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
||||
key_size + 1));
|
||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
png_memcpy(text, key, key_size);
|
||||
@@ -991,8 +1018,9 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_charp tmp;
|
||||
|
||||
tmp = text;
|
||||
text = png_malloc(png_ptr, text_size +
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
|
||||
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||
+ 1));
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
png_memcpy(text + text_size, png_ptr->zbuf,
|
||||
@@ -1028,9 +1056,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
||||
png_free(png_ptr, key);
|
||||
key = text;
|
||||
text += key_size;
|
||||
text_size -= key_size;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text_ptr->key = key;
|
||||
text_ptr->text = text;
|
||||
@@ -1057,6 +1084,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
/* to quiet some compiler warnings */
|
||||
if(info_ptr == NULL) return;
|
||||
}
|
||||
|
||||
png_push_crc_skip(png_ptr, length);
|
||||
|
||||
39
pngread.c
39
pngread.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||
png_structp
|
||||
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warn_fn)
|
||||
{
|
||||
png_structp png_ptr;
|
||||
@@ -57,7 +58,8 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
png_ptr->zstream.zfree = png_zfree;
|
||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||
@@ -99,7 +101,8 @@ png_read_init(png_structp png_ptr)
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
png_ptr->zstream.zfree = png_zfree;
|
||||
png_ptr->zstream.opaque = (voidpf)png_ptr;
|
||||
@@ -406,14 +409,17 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_ptr->row_info.channels = png_ptr->channels;
|
||||
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
|
||||
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
{
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
|
||||
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
|
||||
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr);
|
||||
@@ -443,6 +449,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
png_combine_row(png_ptr, dsp_row, 0xff);
|
||||
}
|
||||
png_read_finish_row(png_ptr);
|
||||
|
||||
if (png_ptr->read_row_fn != NULL)
|
||||
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||
}
|
||||
|
||||
/* Read one or more rows of image data. If the image is interlaced,
|
||||
@@ -654,12 +663,18 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
*info_ptr_ptr = (png_infop)NULL;
|
||||
}
|
||||
|
||||
if (end_info_ptr != NULL)
|
||||
{
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
|
||||
png_free(png_ptr, end_info_ptr->text);
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)end_info_ptr);
|
||||
*end_info_ptr_ptr = (png_infop)NULL;
|
||||
}
|
||||
@@ -703,7 +718,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
|
||||
png_free(png_ptr, png_ptr->palette);
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_bKGD_SUPPORTED)
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
@@ -766,3 +781,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
}
|
||||
|
||||
void
|
||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||
{
|
||||
png_ptr->read_row_fn = read_row_fn;
|
||||
}
|
||||
|
||||
7
pngrio.c
7
pngrio.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
@@ -98,7 +99,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
{
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
|
||||
370
pngrtran.c
370
pngrtran.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@@ -21,35 +22,40 @@
|
||||
* many machines. However, it does take more operations than the corresponding
|
||||
* divide method, so it may be slower on some RISC systems. There are two
|
||||
* shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
|
||||
* The results may also be off by one for certain values.
|
||||
*
|
||||
* 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. :-) ]
|
||||
*/
|
||||
|
||||
/* pixel and background should be in gamma 1.0 space */
|
||||
#define png_composite(composite, pixel, trans, background) \
|
||||
{ png_uint_16 temp = ((png_uint_16)(pixel) * (png_uint_16)(trans) + \
|
||||
(png_uint_16)(background)*(png_uint_16)(255 - \
|
||||
(png_uint_16)(trans)) + (png_uint_16)127); \
|
||||
(composite) = (png_byte)(((temp >> 8) + temp) >> 8); }
|
||||
/* 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 */
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# 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 */
|
||||
|
||||
/* pixel and background should be in gamma 1.0 space */
|
||||
#define png_composite_16(composite, pixel, trans, background) \
|
||||
{ png_uint_32 temp = ((png_uint_32)(pixel) * (png_uint_32)(trans) + \
|
||||
(png_uint_32)(background)*(png_uint_32)(65535L - \
|
||||
(png_uint_32)(trans)) + (png_uint_32)32767); \
|
||||
(composite) = (png_uint_16)(((temp >> 16) + temp) >> 16); }
|
||||
#else
|
||||
/* pixel and background should be in gamma 1.0 space */
|
||||
#define png_composite(composite, pixel, trans, background) \
|
||||
(composite) = (png_byte)(((png_uint_16)(pixel) * (png_uint_16)(trans) + \
|
||||
(png_uint_16)(background) * (png_uint_16)(255 - (png_uint_16)(trans)) + \
|
||||
(png_uint_16)127) / 255)
|
||||
|
||||
/* pixel and background should be in gamma 1.0 space */
|
||||
#define png_composite_16(composite, pixel, trans, background) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(pixel) * (png_uint_32)(trans) + \
|
||||
(png_uint_32)(background)*(png_uint_32)(65535L - (png_uint_32)(trans)) + \
|
||||
(png_uint_32)32767) / (png_uint_32)65535L)
|
||||
#endif
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
void
|
||||
@@ -178,7 +184,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = (png_byte)i;
|
||||
}
|
||||
@@ -194,7 +200,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_bytep sort;
|
||||
|
||||
/* initialize an array to sort colors */
|
||||
sort = (png_bytep)png_malloc(png_ptr, num_palette * sizeof (png_byte));
|
||||
sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette
|
||||
* sizeof (png_byte)));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -237,11 +244,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
move the others */
|
||||
for (i = 0, j = num_palette; i < maximum_colors; i++)
|
||||
{
|
||||
if (sort[i] >= maximum_colors)
|
||||
if ((int)sort[i] >= maximum_colors)
|
||||
{
|
||||
do
|
||||
j--;
|
||||
while (sort[j] >= maximum_colors);
|
||||
while ((int)sort[j] >= maximum_colors);
|
||||
palette[i] = palette[j];
|
||||
}
|
||||
}
|
||||
@@ -255,13 +262,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
for (i = 0, j = num_palette; i < maximum_colors; i++)
|
||||
{
|
||||
/* only move the colors we need to */
|
||||
if (sort[i] >= maximum_colors)
|
||||
if ((int)sort[i] >= maximum_colors)
|
||||
{
|
||||
png_color tmp_color;
|
||||
|
||||
do
|
||||
j--;
|
||||
while (sort[j] >= maximum_colors);
|
||||
while ((int)sort[j] >= maximum_colors);
|
||||
|
||||
tmp_color = palette[j];
|
||||
palette[j] = palette[i];
|
||||
@@ -275,7 +282,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
/* find closest color for those colors we are not using */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
if (png_ptr->dither_index[i] >= maximum_colors)
|
||||
if ((int)png_ptr->dither_index[i] >= maximum_colors)
|
||||
{
|
||||
int min_d, k, min_k, d_index;
|
||||
|
||||
@@ -322,9 +329,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
/* initialize palette index arrays */
|
||||
index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -333,7 +340,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
palette_to_index[i] = (png_byte)i;
|
||||
}
|
||||
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, 769 * sizeof (png_dsortp));
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
|
||||
sizeof (png_dsortp)));
|
||||
for (i = 0; i < 769; i++)
|
||||
hash[i] = NULL;
|
||||
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
|
||||
@@ -366,7 +374,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_dsortp t;
|
||||
|
||||
t = png_malloc(png_ptr, sizeof (png_dsort));
|
||||
t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof
|
||||
(png_dsort)));
|
||||
t->next = hash[d];
|
||||
t->left = (png_byte)i;
|
||||
t->right = (png_byte)j;
|
||||
@@ -383,8 +392,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
for (p = hash[i]; p; p = p->next)
|
||||
{
|
||||
if (index_to_palette[p->left] < num_new_palette &&
|
||||
index_to_palette[p->right] < num_new_palette)
|
||||
if ((int)index_to_palette[p->left] < num_new_palette &&
|
||||
(int)index_to_palette[p->right] < num_new_palette)
|
||||
{
|
||||
int j, next_j;
|
||||
|
||||
@@ -411,7 +420,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
index_to_palette[j])
|
||||
png_ptr->dither_index[k] =
|
||||
index_to_palette[next_j];
|
||||
if (png_ptr->dither_index[k] ==
|
||||
if ((int)png_ptr->dither_index[k] ==
|
||||
num_new_palette)
|
||||
png_ptr->dither_index[k] =
|
||||
index_to_palette[j];
|
||||
@@ -482,11 +491,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
|
||||
num_entries * sizeof (png_byte));
|
||||
(png_uint_32)(num_entries * sizeof (png_byte)));
|
||||
|
||||
png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, num_entries * sizeof(png_byte));
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
sizeof(png_byte)));
|
||||
|
||||
png_memset(distance, 0xff, num_entries * sizeof(png_byte));
|
||||
|
||||
@@ -521,7 +531,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
dmax = ((dm > db) ? dm : db);
|
||||
d = dmax + dt + db;
|
||||
|
||||
if (d < distance[d_index])
|
||||
if (d < (int)distance[d_index])
|
||||
{
|
||||
distance[d_index] = (png_byte)d;
|
||||
png_ptr->palette_lookup[d_index] = (png_byte)i;
|
||||
@@ -543,13 +553,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
* also needlessly introduces small errors.
|
||||
*/
|
||||
void
|
||||
png_set_gamma(png_structp png_ptr, double screen_gamma, double file_gamma)
|
||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma\n");
|
||||
if (fabs(screen_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD)
|
||||
if (fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD)
|
||||
png_ptr->transformations |= PNG_GAMMA;
|
||||
png_ptr->gamma = (float)file_gamma;
|
||||
png_ptr->display_gamma = (float)screen_gamma;
|
||||
png_ptr->screen_gamma = (float)scrn_gamma;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -586,6 +596,18 @@ png_set_rgb_to_gray(png_structp png_ptr, int gray_bits)
|
||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||
png_ptr->transformations |= PNG_RGB_TO_GRAY;
|
||||
/* Need to do something with gray_bits here. */
|
||||
png_warning(png_ptr, "RGB to GRAY transformation is not yet implemented.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -638,6 +660,23 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
png_ptr->palette[png_ptr->background.index].green;
|
||||
png_ptr->background.blue =
|
||||
png_ptr->palette[png_ptr->background.index].blue;
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
{
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if (png_ptr->transformations & !PNG_EXPAND)
|
||||
#endif
|
||||
{
|
||||
/* invert the alpha channel (in tRNS) unless the pixels are
|
||||
going to be expanded, in which case leave it for later */
|
||||
int i;
|
||||
for (i=0; i<(int)png_ptr->num_trans; i++)
|
||||
png_ptr->trans[i] = 255 - png_ptr->trans[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -675,7 +714,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
double g;
|
||||
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma);
|
||||
|
||||
if (png_ptr->background_gamma_type==PNG_BACKGROUND_GAMMA_SCREEN||
|
||||
fabs(g - 1.0) < PNG_GAMMA_THRESHOLD)
|
||||
@@ -743,8 +782,9 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN)*/
|
||||
else
|
||||
/* color_type != PNG_COLOR_TYPE_PALETTE */
|
||||
{
|
||||
double g, gs, m;
|
||||
|
||||
@@ -755,22 +795,23 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
switch (png_ptr->background_gamma_type)
|
||||
{
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
g = (png_ptr->display_gamma);
|
||||
g = (png_ptr->screen_gamma);
|
||||
gs = 1.0;
|
||||
break;
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
gs = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
|
||||
break;
|
||||
case PNG_BACKGROUND_GAMMA_UNIQUE:
|
||||
g = 1.0 / (png_ptr->background_gamma);
|
||||
gs = 1.0 / (png_ptr->background_gamma *
|
||||
png_ptr->display_gamma);
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
}
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
/* RGB or RGBA */
|
||||
png_ptr->background_1.red = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.red / m, g) * m + .5);
|
||||
png_ptr->background_1.green = (png_uint_16)(pow(
|
||||
@@ -786,6 +827,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* GRAY or GRAY ALPHA */
|
||||
png_ptr->background_1.gray = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.gray / m, g) * m + .5);
|
||||
png_ptr->background.gray = (png_uint_16)(pow(
|
||||
@@ -794,6 +836,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
else
|
||||
/* transformation does not include PNG_BACKGROUND */
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
@@ -816,6 +859,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* No GAMMA transformation */
|
||||
if (png_ptr->transformations & PNG_BACKGROUND &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
@@ -828,7 +872,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
back.green = (png_byte)png_ptr->background.green;
|
||||
back.blue = (png_byte)png_ptr->background.blue;
|
||||
|
||||
for (i = 0; i < png_ptr->num_trans; i++)
|
||||
for (i = 0; i < (int)png_ptr->num_trans; i++)
|
||||
{
|
||||
if (png_ptr->trans[i] == 0)
|
||||
{
|
||||
@@ -948,7 +992,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
else
|
||||
info_ptr->channels = 1;
|
||||
|
||||
#if defined(PNG_STRIP_ALPHA_SUPPORTED)
|
||||
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
@@ -971,8 +1015,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
|
||||
info_ptr->rowbytes =
|
||||
(png_size_t)((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
/* Transform the row. The order of transformations is significant,
|
||||
@@ -1046,7 +1089,7 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
png_ptr->gamma_shift);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_RGB_TO_GRAY_SUPPORTED)
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_do_rgb_to_gray(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
@@ -1061,6 +1104,8 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->dither_index);
|
||||
if(png_ptr->row_info.rowbytes == (png_uint_32)0)
|
||||
png_error(png_ptr, "png_do_dither returned rowbytes=0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1101,6 +1146,11 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
(png_uint_32)png_ptr->filler, png_ptr->flags);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
@@ -1110,6 +1160,22 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if(png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* user read transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_uint_32 rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED)
|
||||
@@ -1198,7 +1264,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->rowbytes = (png_size_t)row_info->width * row_info->channels;
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1257,7 +1323,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
case 2:
|
||||
{
|
||||
png_bytep bp;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
|
||||
for (bp = row, i = 0; i < row_info->rowbytes; i++, bp++)
|
||||
{
|
||||
@@ -1270,7 +1336,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_byte mask;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
|
||||
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
(png_byte)((int)0xf >> shift[0]);
|
||||
@@ -1284,11 +1350,11 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
case 8:
|
||||
{
|
||||
png_bytep bp;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
|
||||
for (bp = row, i = 0; i < row_info->width; i++)
|
||||
{
|
||||
for (c = 0; c < row_info->channels; c++, bp++)
|
||||
for (c = 0; c < (int)row_info->channels; c++, bp++)
|
||||
{
|
||||
*bp >>= shift[c];
|
||||
}
|
||||
@@ -1302,7 +1368,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
|
||||
for (bp = row, i = 0; i < row_info->width; i++)
|
||||
{
|
||||
for (c = 0; c < row_info->channels; c++, bp += 2)
|
||||
for (c = 0; c < (int)row_info->channels; c++, bp += 2)
|
||||
{
|
||||
value = (png_uint_16)((*bp << 8) + *(bp + 1));
|
||||
value >>= shift[c];
|
||||
@@ -1344,6 +1410,16 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
*dp = (((((png_uint_32)(*sp) << 8) |
|
||||
(png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L;
|
||||
|
||||
|
||||
* GRR: no, I think this is what it really should be:
|
||||
*dp = (((((png_uint_32)(*sp) << 8) |
|
||||
(png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L;
|
||||
|
||||
* GRR: here's the exact calculation with shifts:
|
||||
temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L;
|
||||
*dp = (temp - (temp >> 8)) >> 8;
|
||||
|
||||
|
||||
* Approximate calculation with shift/add instead of multiply/divide:
|
||||
*dp = ((((png_uint_32)(*sp) << 8) |
|
||||
(png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8;
|
||||
@@ -1356,7 +1432,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
row_info->rowbytes = (png_size_t)row_info->width * row_info->channels;
|
||||
row_info->rowbytes = row_info->width * row_info->channels;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1452,6 +1528,87 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_read_invert_alpha\n");
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
if (row != NULL && row_info != NULL)
|
||||
#endif
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row + row_info->rowbytes;
|
||||
i < row_info->width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row + row_info->rowbytes;
|
||||
i < row_info->width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in GA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row + row_info->rowbytes;
|
||||
i < row_info->width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row + row_info->rowbytes;
|
||||
i < row_info->width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = 255 - *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* Add filler channel if we have RGB color */
|
||||
void
|
||||
@@ -1484,7 +1641,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
*(--dp) = (png_byte)filler;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = 32;
|
||||
row_info->rowbytes = (png_size_t)row_info->width * 4;
|
||||
row_info->rowbytes = row_info->width * 4;
|
||||
}
|
||||
/* This changes the data from RGB to XRGB */
|
||||
else
|
||||
@@ -1501,7 +1658,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = 32;
|
||||
row_info->rowbytes = (png_size_t)row_info->width * 4;
|
||||
row_info->rowbytes = row_info->width * 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1595,7 +1752,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
row_info->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = (png_size_t)((row_info->width *
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
}
|
||||
@@ -1677,7 +1834,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
double g;
|
||||
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma);
|
||||
|
||||
if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN ||
|
||||
fabs(g - 1.0) < PNG_GAMMA_THRESHOLD)
|
||||
@@ -1788,24 +1945,21 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int i;
|
||||
png_color back;
|
||||
|
||||
back.red = (png_byte)png_ptr->background.red;
|
||||
back.green = (png_byte)png_ptr->background.green;
|
||||
back.blue = (png_byte)png_ptr->background.blue;
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
for (i = 0; i < (int)png_ptr->num_trans; i++)
|
||||
{
|
||||
if (i >= (int)png_ptr->num_trans ||
|
||||
png_ptr->trans[i] == 0)
|
||||
if (png_ptr->trans[i] == 0)
|
||||
{
|
||||
palette[i].red = back.red;
|
||||
palette[i].green = back.green;
|
||||
palette[i].blue = back.blue;
|
||||
}
|
||||
else if (i < (int)png_ptr->num_trans ||
|
||||
png_ptr->trans[i] != 0xff)
|
||||
else if (png_ptr->trans[i] != 0xff)
|
||||
{
|
||||
png_composite(palette[i].red, png_ptr->palette[i].red,
|
||||
png_ptr->trans[i], back.red);
|
||||
@@ -1864,7 +2018,6 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
{
|
||||
/* We currently don't do gamma correction for 2 and 4 bit */
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
@@ -1873,7 +2026,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 7;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
if (((*sp >> shift) & 0x1) == trans_values->gray)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x1)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
@@ -1894,7 +2048,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 6;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
if (((*sp >> shift) & 0x3) == trans_values->gray)
|
||||
if ((png_uint_16)((*sp >> shift) & 0x3)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
@@ -1915,7 +2070,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
shift = 4;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
if (((*sp >> shift) & 0xf) == trans_values->gray)
|
||||
if ((png_uint_16)((*sp >> shift) & 0xf)
|
||||
== trans_values->gray)
|
||||
{
|
||||
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
|
||||
*sp |= (png_byte)(background->gray << shift);
|
||||
@@ -2423,7 +2579,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
row_info->channels--;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = (png_size_t)((row_info->width *
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
}
|
||||
@@ -2558,6 +2714,22 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
{
|
||||
if (row_info->bit_depth == 2)
|
||||
{
|
||||
for (i = 0, sp = row; i < row_info->width; i += 4)
|
||||
{
|
||||
int a = *sp & 0xc0;
|
||||
int b = *sp & 0x30;
|
||||
int c = *sp & 0x0c;
|
||||
int d = *sp & 0x03;
|
||||
|
||||
*sp = ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
|
||||
((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
|
||||
((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
|
||||
((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) );
|
||||
sp++;
|
||||
}
|
||||
}
|
||||
if (row_info->bit_depth == 4)
|
||||
{
|
||||
for (i = 0, sp = row; i < row_info->width; i += 2)
|
||||
@@ -2688,7 +2860,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = (png_size_t)row_info->width;
|
||||
row_info->rowbytes = row_info->width;
|
||||
}
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
@@ -2712,7 +2884,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 32;
|
||||
row_info->rowbytes = (png_size_t)row_info->width * 4;
|
||||
row_info->rowbytes = row_info->width * 4;
|
||||
row_info->color_type = 6;
|
||||
row_info->channels = 4;
|
||||
}
|
||||
@@ -2730,7 +2902,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 24;
|
||||
row_info->rowbytes = (png_size_t)row_info->width * 3;
|
||||
row_info->rowbytes = row_info->width * 3;
|
||||
row_info->color_type = 2;
|
||||
row_info->channels = 3;
|
||||
}
|
||||
@@ -2836,7 +3008,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = (png_size_t)row_info->width;
|
||||
row_info->rowbytes = row_info->width;
|
||||
}
|
||||
|
||||
if (trans_value != NULL)
|
||||
@@ -2879,7 +3051,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
|
||||
row_info->rowbytes =
|
||||
(png_size_t)((row_info->width * row_info->pixel_depth) >> 3);
|
||||
((row_info->width * row_info->pixel_depth) >> 3);
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
|
||||
@@ -2934,7 +3106,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
|
||||
row_info->rowbytes =
|
||||
(png_size_t)((row_info->width * row_info->pixel_depth) >> 3);
|
||||
((row_info->width * row_info->pixel_depth) >> 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2987,7 +3159,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
row_info->channels = 1;
|
||||
row_info->pixel_depth = row_info->bit_depth;
|
||||
row_info->rowbytes =
|
||||
((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||
palette_lookup != NULL && row_info->bit_depth == 8)
|
||||
@@ -3017,7 +3189,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
row_info->channels = 1;
|
||||
row_info->pixel_depth = row_info->bit_depth;
|
||||
row_info->rowbytes =
|
||||
(png_size_t)((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
((row_info->width * row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
dither_lookup && row_info->bit_depth == 8)
|
||||
@@ -3050,7 +3222,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
int i;
|
||||
double g;
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
|
||||
|
||||
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
@@ -3075,7 +3247,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g) * 255.0 + .5);
|
||||
}
|
||||
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->screen_gamma);
|
||||
|
||||
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
@@ -3128,10 +3300,10 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
|
||||
num = (1 << (8 - shift));
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
|
||||
|
||||
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p));
|
||||
(png_uint_32)(num * sizeof (png_uint_16p)));
|
||||
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND))
|
||||
@@ -3142,7 +3314,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
}
|
||||
|
||||
g = 1.0 / g;
|
||||
@@ -3172,7 +3344,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
for (j = 0; j < 256; j++)
|
||||
@@ -3190,12 +3362,12 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p ));
|
||||
(png_uint_32)(num * sizeof (png_uint_16p )));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
@@ -3206,15 +3378,15 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
65535.0, g) * 65535.0 + .5);
|
||||
}
|
||||
}
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
g = 1.0 / (png_ptr->screen_gamma);
|
||||
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p));
|
||||
(png_uint_32)(num * sizeof (png_uint_16p)));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
|
||||
268
pngrutil.c
268
pngrutil.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 0.99
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file contains routines which are only called from within
|
||||
* libpng itself during the course of reading an image.
|
||||
@@ -26,7 +27,7 @@ png_get_uint_32(png_bytep buf)
|
||||
((png_uint_32)(*(buf + 2)) << 8) +
|
||||
(png_uint_32)(*(buf + 3));
|
||||
|
||||
return i;
|
||||
return (i);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
@@ -43,7 +44,7 @@ png_get_int_32(png_bytep buf)
|
||||
((png_int_32)(*(buf + 2)) << 8) +
|
||||
(png_int_32)(*(buf + 3));
|
||||
|
||||
return i;
|
||||
return (i);
|
||||
}
|
||||
#endif /* PNG_READ_pCAL_SUPPORTED */
|
||||
|
||||
@@ -56,7 +57,7 @@ png_get_uint_16(png_bytep buf)
|
||||
i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1)));
|
||||
|
||||
return i;
|
||||
return (i);
|
||||
}
|
||||
#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
|
||||
|
||||
@@ -99,13 +100,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
||||
{
|
||||
png_chunk_error(png_ptr, "CRC error");
|
||||
}
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Compare the CRC stored in the PNG file with that calulated by libpng from
|
||||
/* Compare the CRC stored in the PNG file with that calculated by libpng from
|
||||
the data it has read thus far. */
|
||||
int
|
||||
png_crc_error(png_structp png_ptr)
|
||||
@@ -131,10 +132,10 @@ png_crc_error(png_structp png_ptr)
|
||||
if (need_crc)
|
||||
{
|
||||
crc = png_get_uint_32(crc_bytes);
|
||||
return (crc != png_ptr->crc);
|
||||
return ((int)(crc != png_ptr->crc));
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +226,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
/* set up other useful info */
|
||||
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
|
||||
png_ptr->channels);
|
||||
png_ptr->channels);
|
||||
png_ptr->rowbytes = ((png_ptr->width *
|
||||
(png_uint_32)png_ptr->pixel_depth + 7) >> 3);
|
||||
png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
|
||||
@@ -257,6 +258,20 @@ 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)
|
||||
{
|
||||
@@ -280,7 +295,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
num = (int)length / 3;
|
||||
palette = (png_colorp)png_zalloc(png_ptr, num, sizeof (png_color));
|
||||
palette = (png_colorp)png_zalloc(png_ptr, (uInt)num, sizeof (png_color));
|
||||
png_ptr->flags |= PNG_FLAG_FREE_PALETTE;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -297,10 +312,13 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
whatever the normal CRC configuration tells us. However, if we
|
||||
have an RGB image, the PLTE can be considered ancillary, so
|
||||
we will act as though it is. */
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#endif
|
||||
{
|
||||
png_crc_finish(png_ptr, 0);
|
||||
}
|
||||
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
|
||||
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
||||
{
|
||||
/* If we don't want to use the data from an ancillary chunk,
|
||||
@@ -317,7 +335,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_PALETTE;
|
||||
png_free(png_ptr, palette);
|
||||
png_zfree(png_ptr, palette);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +345,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||
@@ -341,6 +359,10 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
{
|
||||
png_error(png_ptr, "No image in file");
|
||||
|
||||
/* to quiet compiler warnings about unused info_ptr */
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
png_ptr->mode |= PNG_AFTER_IDAT | PNG_HAVE_IEND;
|
||||
@@ -373,7 +395,12 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
else if (png_ptr->mode & PNG_HAVE_PLTE)
|
||||
/* Should be an error, but we can cope with it */
|
||||
png_warning(png_ptr, "Out of place gAMA chunk");
|
||||
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA)
|
||||
|
||||
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
&& !(info_ptr->valid & PNG_INFO_sRGB)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
png_warning(png_ptr, "Duplicate gAMA chunk");
|
||||
png_crc_finish(png_ptr, length);
|
||||
@@ -397,27 +424,22 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
return;
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_HAVE_sRGB))
|
||||
if(igamma != (png_uint_32)50000L)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_HAVE_sRGB)
|
||||
if(igamma != (png_uint_32)50000L)
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
if(igamma != (png_uint_32)45000L)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr, "igamma = %lu\n", igamma);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
file_gamma = (float)igamma / (float)100000.0;
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_ptr->gamma = file_gamma;
|
||||
#endif
|
||||
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||
}
|
||||
#endif
|
||||
@@ -506,8 +528,12 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
else if (png_ptr->mode & PNG_HAVE_PLTE)
|
||||
/* Should be an error, but we can cope with it */
|
||||
png_warning(png_ptr, "Missing PLTE before cHRM");
|
||||
|
||||
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_cHRM
|
||||
&& !(info_ptr->valid & PNG_INFO_sRGB))
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
&& !(info_ptr->valid & PNG_INFO_sRGB)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
png_warning(png_ptr, "Duplicate cHRM chunk");
|
||||
png_crc_finish(png_ptr, length);
|
||||
@@ -589,7 +615,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
return;
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_HAVE_sRGB)
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
{
|
||||
if (fabs(white_x - (float).3127) > (float).001 ||
|
||||
fabs(white_y - (float).3290) > (float).001 ||
|
||||
@@ -598,10 +624,17 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
fabs(green_x - (float).3000) > (float).001 ||
|
||||
fabs(green_y - (float).6000) > (float).001 ||
|
||||
fabs( blue_x - (float).1500) > (float).001 ||
|
||||
fabs( blue_y - (float).6000) > (float).001)
|
||||
fabs( blue_y - (float).0600) > (float).001)
|
||||
{
|
||||
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect cHRM value when sRGB is also present");
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
|
||||
white_x, white_y, red_x, red_y);
|
||||
fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",
|
||||
green_x, green_y, blue_x, blue_y);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -616,10 +649,8 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
void
|
||||
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_byte intent;
|
||||
int intent;
|
||||
png_byte buf[1];
|
||||
float file_gamma;
|
||||
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||
|
||||
png_debug(1, "in png_handle_sRGB\n");
|
||||
|
||||
@@ -634,6 +665,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
else if (png_ptr->mode & PNG_HAVE_PLTE)
|
||||
/* Should be an error, but we can cope with it */
|
||||
png_warning(png_ptr, "Out of place sRGB chunk");
|
||||
|
||||
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB)
|
||||
{
|
||||
png_warning(png_ptr, "Duplicate sRGB chunk");
|
||||
@@ -654,34 +686,44 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
intent = buf[0];
|
||||
/* check for bad intent */
|
||||
if (intent > 3)
|
||||
if (intent >= PNG_sRGB_INTENT_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "Unknown sRGB intent");
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we really want to be paranoid we could check for
|
||||
already defined gamma and chrm with values that are
|
||||
inconsistent with sRGB -- for now, just ignore them */
|
||||
|
||||
file_gamma = (float)45000./(float)100000.;
|
||||
png_set_gAMA(png_ptr, info_ptr, file_gamma);
|
||||
|
||||
white_x = (float)31270./(float)100000.;
|
||||
white_y = (float)32900./(float)100000.;
|
||||
red_x = (float)64000./(float)100000.;
|
||||
red_y = (float)33000./(float)100000.;
|
||||
green_x = (float)30000./(float)100000.;
|
||||
green_y = (float)60000./(float)100000.;
|
||||
blue_x = (float)15000./(float)100000.;
|
||||
blue_y = (float) 6000./(float)100000.;
|
||||
|
||||
png_set_cHRM(png_ptr, info_ptr,
|
||||
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
}
|
||||
#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)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr,"gamma=%f\n",png_ptr->gamma);
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_gAMA_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_cHRM)
|
||||
if (fabs(info_ptr->x_white - (float).3127) > (float).001 ||
|
||||
fabs(info_ptr->y_white - (float).3290) > (float).001 ||
|
||||
fabs( info_ptr->x_red - (float).6400) > (float).001 ||
|
||||
fabs( info_ptr->y_red - (float).3300) > (float).001 ||
|
||||
fabs(info_ptr->x_green - (float).3000) > (float).001 ||
|
||||
fabs(info_ptr->y_green - (float).6000) > (float).001 ||
|
||||
fabs( info_ptr->x_blue - (float).1500) > (float).001 ||
|
||||
fabs( info_ptr->y_blue - (float).0600) > (float).001)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect cHRM value when sRGB is also present");
|
||||
}
|
||||
#endif /* PNG_READ_cHRM_SUPPORTED */
|
||||
|
||||
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
|
||||
}
|
||||
#endif /* PNG_READ_sRGB_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
void
|
||||
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
@@ -698,7 +740,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
png_warning(png_ptr, "Duplcate tRNS chunk");
|
||||
png_warning(png_ptr, "Duplicate tRNS chunk");
|
||||
png_crc_finish(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
@@ -885,7 +927,7 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
num = (int)length / 2;
|
||||
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16));
|
||||
(png_uint_32)(num * sizeof (png_uint_16)));
|
||||
png_ptr->flags |= PNG_FLAG_FREE_HIST;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -998,6 +1040,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_byte type, nparams;
|
||||
png_charp buf, units, endptr;
|
||||
png_charpp params;
|
||||
png_size_t slength;
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_handle_pCAL\n");
|
||||
@@ -1020,7 +1063,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_debug1(2, "Allocating and reading pCAL chunk data (%d bytes)\n",
|
||||
length + 1);
|
||||
purpose = (png_charp)png_malloc(png_ptr, length + 1);
|
||||
png_crc_read(png_ptr, (png_bytep)purpose, (png_size_t)length);
|
||||
slength = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)purpose, slength);
|
||||
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
{
|
||||
@@ -1028,13 +1072,13 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
|
||||
purpose[length] = '\0'; /* null terminate the last string */
|
||||
purpose[slength] = 0x00; /* null terminate the last string */
|
||||
|
||||
png_debug(3, "Finding end of pCAL purpose string\n");
|
||||
for (buf = purpose; *buf != '\0'; buf++)
|
||||
/* empty loop */;
|
||||
|
||||
endptr = purpose + length;
|
||||
endptr = purpose + slength;
|
||||
|
||||
/* We need to have at least 12 bytes after the purpose string
|
||||
in order to get the parameter information. */
|
||||
@@ -1070,19 +1114,20 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
/* Empty loop to move past the units string. */
|
||||
for (buf = units; *buf != '\0'; buf++);
|
||||
for (buf = units; *buf != 0x00; buf++);
|
||||
|
||||
png_debug(3, "Allocating pCAL parameters array\n");
|
||||
params = (png_charpp)png_malloc(png_ptr, nparams*sizeof(png_charp)) ;
|
||||
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
|
||||
*sizeof(png_charp))) ;
|
||||
|
||||
/* Get pointers to the start of each parameter string. */
|
||||
for (i = 0; i < nparams; i++)
|
||||
for (i = 0; i < (int)nparams; i++)
|
||||
{
|
||||
buf++; /* Skip the null string terminator from previous parameter. */
|
||||
|
||||
png_debug1(3, "Reading pCAL parameter %d\n", i);
|
||||
/* Empty loop to move past each paramter string */
|
||||
for (params[i] = buf; *buf != '\0' && buf <= endptr; buf++);
|
||||
for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++);
|
||||
|
||||
/* Make sure we haven't run out of data yet */
|
||||
if (buf > endptr)
|
||||
@@ -1154,6 +1199,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_charp key;
|
||||
png_charp text;
|
||||
png_uint_32 skip = 0;
|
||||
png_size_t slength;
|
||||
|
||||
png_debug(1, "in png_handle_tEXt\n");
|
||||
|
||||
@@ -1173,7 +1219,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif
|
||||
|
||||
key = (png_charp)png_malloc(png_ptr, length + 1);
|
||||
png_crc_read(png_ptr, (png_bytep)key, (png_size_t)length);
|
||||
slength = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)key, slength);
|
||||
|
||||
if (png_crc_finish(png_ptr, skip))
|
||||
{
|
||||
@@ -1181,15 +1228,15 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
|
||||
key[length] = '\0';
|
||||
key[slength] = 0x00;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
/* empty loop to find end of key */ ;
|
||||
|
||||
if (text != key + (png_size_t)length)
|
||||
if (text != key + slength)
|
||||
text++;
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr->key = key;
|
||||
text_ptr->text = text;
|
||||
@@ -1210,6 +1257,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_charp key;
|
||||
png_charp text;
|
||||
int comp_type = PNG_TEXT_COMPRESSION_NONE;
|
||||
png_size_t slength;
|
||||
|
||||
png_debug(1, "in png_handle_zTXt\n");
|
||||
|
||||
@@ -1231,20 +1279,21 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif
|
||||
|
||||
key = (png_charp)png_malloc(png_ptr, length + 1);
|
||||
png_crc_read(png_ptr, (png_bytep)key, (png_size_t)length);
|
||||
slength = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)key, slength);
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
{
|
||||
png_free(png_ptr, key);
|
||||
return;
|
||||
}
|
||||
|
||||
key[length] = '\0';
|
||||
key[slength] = 0x00;
|
||||
|
||||
for (text = key; *text; text++)
|
||||
/* empty loop */ ;
|
||||
|
||||
/* zTXt must have some text after the keyword */
|
||||
if (text == key + (png_size_t)length)
|
||||
if (text == key + slength)
|
||||
{
|
||||
png_warning(png_ptr, "Zero length zTXt chunk");
|
||||
}
|
||||
@@ -1256,9 +1305,9 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_ptr->zstream.next_in = (png_bytep)text;
|
||||
png_ptr->zstream.avail_in = (uInt)(length - (text - key));
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
|
||||
key_size = text - key;
|
||||
key_size = (png_size_t)(text - key);
|
||||
text_size = 0;
|
||||
text = NULL;
|
||||
|
||||
@@ -1279,14 +1328,14 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (text == NULL)
|
||||
{
|
||||
text_size = key_size + sizeof(msg) + 1;
|
||||
text = (png_charp)png_malloc(png_ptr, text_size);
|
||||
text = (png_charp)png_malloc(png_ptr, (png_uint_32)text_size);
|
||||
png_memcpy(text, key, key_size);
|
||||
}
|
||||
|
||||
text[text_size - 1] = '\0';
|
||||
text[text_size - 1] = 0x00;
|
||||
|
||||
/* Copy what we can of the error message into the text chunk */
|
||||
text_size = length - (text - key) - 1;
|
||||
text_size = (png_size_t)(slength - (text - key) - 1);
|
||||
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
|
||||
png_memcpy(text + key_size, msg, text_size + 1);
|
||||
break;
|
||||
@@ -1296,28 +1345,28 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (text == NULL)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out +
|
||||
key_size + 1);
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||
+ key_size + 1));
|
||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
png_memcpy(text, key, key_size);
|
||||
text_size = key_size + png_ptr->zbuf_size -
|
||||
png_ptr->zstream.avail_out;
|
||||
*(text + text_size) = '\0';
|
||||
*(text + text_size) = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
png_charp tmp;
|
||||
|
||||
tmp = text;
|
||||
text = png_malloc(png_ptr, text_size +
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
|
||||
text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
png_memcpy(text + text_size, png_ptr->zbuf,
|
||||
(png_ptr->zbuf_size - png_ptr->zstream.avail_out));
|
||||
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
|
||||
*(text + text_size) = '\0';
|
||||
*(text + text_size) = 0x00;
|
||||
}
|
||||
if (ret != Z_STREAM_END)
|
||||
{
|
||||
@@ -1337,7 +1386,6 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_free(png_ptr, key);
|
||||
key = text;
|
||||
text += key_size;
|
||||
text_size -= key_size;
|
||||
}
|
||||
else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */
|
||||
{
|
||||
@@ -1352,12 +1400,12 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif
|
||||
|
||||
/* Copy what we can of the error message into the text chunk */
|
||||
text_size = (png_size_t)length - (text - key) - 1;
|
||||
text_size = (png_size_t)(slength - (text - key) - 1);
|
||||
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
|
||||
png_memcpy(text, msg, text_size + 1);
|
||||
}
|
||||
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
|
||||
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
|
||||
text_ptr->compression = comp_type;
|
||||
text_ptr->key = key;
|
||||
text_ptr->text = text;
|
||||
@@ -1385,12 +1433,17 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
/* to quiet compiler warnings about unused info_ptr */
|
||||
if (info_ptr == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
||||
}
|
||||
|
||||
/* This function is called to verify that a chunk name is valid.
|
||||
@@ -1710,13 +1763,13 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
int s_start, s_end, s_inc;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 2);
|
||||
dp = row + (png_size_t)((final_width - 1) >> 2);
|
||||
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)
|
||||
{
|
||||
sshift = (png_size_t)(((row_info->width + 3) & 3) << 1);
|
||||
dshift = (png_size_t)(((final_width + 3) & 3) << 1);
|
||||
sshift = (int)(((row_info->width + 3) & 3) << 1);
|
||||
dshift = (int)(((final_width + 3) & 3) << 1);
|
||||
s_start = 6;
|
||||
s_end = 0;
|
||||
s_inc = -2;
|
||||
@@ -1724,8 +1777,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1);
|
||||
dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1);
|
||||
sshift = (int)((3 - ((row_info->width + 3) & 3)) << 1);
|
||||
dshift = (int)((3 - ((final_width + 3) & 3)) << 1);
|
||||
s_start = 0;
|
||||
s_end = 6;
|
||||
s_inc = 2;
|
||||
@@ -1771,8 +1824,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (transformations & PNG_PACKSWAP)
|
||||
{
|
||||
sshift = (png_size_t)(((row_info->width + 1) & 1) << 2);
|
||||
dshift = (png_size_t)(((final_width + 1) & 1) << 2);
|
||||
sshift = (int)(((row_info->width + 1) & 1) << 2);
|
||||
dshift = (int)(((final_width + 1) & 1) << 2);
|
||||
s_start = 4;
|
||||
s_end = 0;
|
||||
s_inc = -4;
|
||||
@@ -1780,8 +1833,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2);
|
||||
sshift = (int)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
dshift = (int)((1 - ((final_width + 1) & 1)) << 2);
|
||||
s_start = 0;
|
||||
s_end = 4;
|
||||
s_inc = 4;
|
||||
@@ -1823,8 +1876,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
|
||||
pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
|
||||
sp = row + (row_info->width - 1) * pixel_bytes;
|
||||
dp = row + (final_width - 1) * pixel_bytes;
|
||||
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--)
|
||||
{
|
||||
png_byte v[8];
|
||||
@@ -1855,6 +1908,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
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:
|
||||
@@ -1968,7 +2022,7 @@ png_read_finish_row(png_structp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
do
|
||||
{
|
||||
png_ptr->pass++;
|
||||
@@ -1978,8 +2032,9 @@ png_read_finish_row(png_structp png_ptr)
|
||||
png_pass_inc[png_ptr->pass] - 1 -
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||
png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||
(png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
|
||||
|
||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
png_ptr->num_rows = (png_ptr->height +
|
||||
@@ -2080,8 +2135,12 @@ png_read_start_row(png_structp png_ptr)
|
||||
png_pass_inc[png_ptr->pass] - 1 -
|
||||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
png_ptr->irowbytes = ((png_ptr->iwidth *
|
||||
png_ptr->pixel_depth + 7) >> 3) + 1;
|
||||
|
||||
rowbytes = ((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_error(png_ptr, "Rowbytes overflow in png_read_start_row");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2170,9 +2229,10 @@ png_read_start_row(png_structp png_ptr)
|
||||
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
|
||||
png_error(png_ptr, "This image requires a row greater than 64KB");
|
||||
#endif
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
|
||||
png_ptr->rowbytes + 1));
|
||||
|
||||
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
||||
png_debug1(3, "width = %d,\n", png_ptr->width);
|
||||
png_debug1(3, "height = %d,\n", png_ptr->height);
|
||||
|
||||
74
pngset.c
74
pngset.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* The functions here are used during reads to store data from the file
|
||||
* into the info struct, and during writes to store application data
|
||||
@@ -21,7 +22,7 @@ void
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "bKGD");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->background), background, sizeof(png_color_16));
|
||||
@@ -36,7 +37,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "cHRM");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->x_white = (float)white_x;
|
||||
@@ -56,7 +57,7 @@ void
|
||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "gAMA");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->gamma = (float)file_gamma;
|
||||
@@ -69,7 +70,7 @@ void
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "hIST");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->hist = hist;
|
||||
@@ -83,8 +84,9 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
int filter_type)
|
||||
{
|
||||
int rowbytes_per_pixel;
|
||||
png_debug1(1, "in %s storage function\n", "IHDR");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->width = width;
|
||||
@@ -103,7 +105,16 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info_ptr->channels++;
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
|
||||
/* 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))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Width too large to process image data; rowbytes will overflow.");
|
||||
info_ptr->rowbytes = (png_size_t)0;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
@@ -112,7 +123,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "oFFs");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->x_offset = offset_x;
|
||||
@@ -128,17 +139,17 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
|
||||
png_charp units, png_charpp params)
|
||||
{
|
||||
png_size_t length;
|
||||
png_uint_32 length;
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", "pCAL");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
length = png_strlen(purpose) + 1;
|
||||
png_debug1(3, "allocating purpose for info (%d bytes)\n", length);
|
||||
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_purpose, purpose, length);
|
||||
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
|
||||
|
||||
png_debug(3, "storing X0, X1, type, and nparams in info\n");
|
||||
info_ptr->pcal_X0 = X0;
|
||||
@@ -149,10 +160,10 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
length = png_strlen(units) + 1;
|
||||
png_debug1(3, "allocating units for info (%d bytes)\n", length);
|
||||
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_units, units, length);
|
||||
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
|
||||
|
||||
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
|
||||
(nparams + 1) * sizeof(png_charp));
|
||||
(png_uint_32)((nparams + 1) * sizeof(png_charp)));
|
||||
info_ptr->pcal_params[nparams] = NULL;
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
@@ -160,7 +171,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
length = png_strlen(params[i]) + 1;
|
||||
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length);
|
||||
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
|
||||
png_memcpy(info_ptr->pcal_params[i], params[i], length);
|
||||
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
|
||||
}
|
||||
|
||||
info_ptr->valid |= PNG_INFO_pCAL;
|
||||
@@ -173,7 +184,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "pHYs");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->x_pixels_per_unit = res_x;
|
||||
@@ -188,7 +199,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp palette, int num_palette)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "PLTE");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->palette = palette;
|
||||
@@ -202,7 +213,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_8p sig_bit)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "sBIT");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8));
|
||||
@@ -212,18 +223,18 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
void
|
||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, png_byte intent)
|
||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "sRGB");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
info_ptr->srgb_intent = intent;
|
||||
info_ptr->srgb_intent = (png_byte)intent;
|
||||
info_ptr->valid |= PNG_INFO_sRGB;
|
||||
}
|
||||
void
|
||||
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
png_byte intent)
|
||||
int intent)
|
||||
{
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
float file_gamma;
|
||||
@@ -232,7 +243,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||
#endif
|
||||
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_sRGB(png_ptr, info_ptr, intent);
|
||||
@@ -268,9 +279,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
|
||||
"text" : png_ptr->chunk_name));
|
||||
"text" : (png_const_charp)png_ptr->chunk_name));
|
||||
|
||||
if (info_ptr == NULL || num_text == 0)
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||
return;
|
||||
|
||||
/* Make sure we have enough space in the "text" array in info_struct
|
||||
@@ -287,8 +298,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
||||
old_text = info_ptr->text;
|
||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||
info_ptr->max_text * sizeof (png_text));
|
||||
png_memcpy(info_ptr->text, old_text, old_max * sizeof(png_text));
|
||||
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
|
||||
sizeof(png_text)));
|
||||
png_free(png_ptr, old_text);
|
||||
}
|
||||
else
|
||||
@@ -296,7 +308,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
info_ptr->max_text = num_text + 8;
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc(png_ptr,
|
||||
info_ptr->max_text * sizeof (png_text));
|
||||
(png_uint_32)(info_ptr->max_text * sizeof (png_text)));
|
||||
}
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text\n",
|
||||
info_ptr->max_text);
|
||||
@@ -307,7 +319,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
|
||||
if (text_ptr[i].text == NULL)
|
||||
text_ptr[i].text = "";
|
||||
text_ptr[i].text = (png_charp)"";
|
||||
|
||||
if (text_ptr[i].text[0] == '\0')
|
||||
{
|
||||
@@ -332,7 +344,7 @@ 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 (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
|
||||
@@ -346,7 +358,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
||||
{
|
||||
png_debug1(1, "in %s storage function\n", "tRNS");
|
||||
if (info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (trans != NULL)
|
||||
|
||||
499
pngtest.c
499
pngtest.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* 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
|
||||
@@ -31,11 +32,13 @@
|
||||
|
||||
/* Makes pngtest verbose so we can find problems (needs to be before png.h) */
|
||||
#ifndef PNG_DEBUG
|
||||
#define PNG_DEBUG 0
|
||||
#endif
|
||||
#define PNG_DEBUG 0
|
||||
|
||||
#include "png.h"
|
||||
|
||||
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#endif
|
||||
@@ -44,16 +47,141 @@
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* for DOS */
|
||||
|
||||
/* example of using row callbacks to make a simple progress meter */
|
||||
static int status_pass=1;
|
||||
static int status_dots_requested=0;
|
||||
static int status_dots=1;
|
||||
void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
|
||||
void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||
{
|
||||
if(png_ptr == NULL || row_number > 0x3fffffffL) return;
|
||||
if(status_pass != pass)
|
||||
{
|
||||
fprintf(stdout,"\n Pass %d: ",pass);
|
||||
status_pass = pass;
|
||||
status_dots = 30;
|
||||
}
|
||||
status_dots--;
|
||||
if(status_dots == 0)
|
||||
{
|
||||
fprintf(stdout, "\n ");
|
||||
status_dots=30;
|
||||
}
|
||||
fprintf(stdout, "r");
|
||||
}
|
||||
void write_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;
|
||||
fprintf(stdout, "w");
|
||||
}
|
||||
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
/* example of using user transform callback (we don't transform anything,
|
||||
but merely count the black pixels) */
|
||||
|
||||
static png_uint_32 black_pixels;
|
||||
void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
|
||||
png_bytep data);
|
||||
void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
|
||||
png_bytep data)
|
||||
{
|
||||
png_bytep dp = data;
|
||||
if(png_ptr == NULL)return;
|
||||
|
||||
/* contents of row_info:
|
||||
* png_uint_32 width width of row
|
||||
* png_uint_32 rowbytes number of bytes in row
|
||||
* png_byte color_type color type of pixels
|
||||
* png_byte bit_depth bit depth of samples
|
||||
* png_byte channels number of channels (1-4)
|
||||
* png_byte pixel_depth bits per pixel (depth*channels)
|
||||
*/
|
||||
|
||||
/* counts the number of black pixels (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++)
|
||||
{
|
||||
if(row_info->bit_depth == 1)
|
||||
if(((*dp << pos++ )& 0x80) == 0) black_pixels++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
dp++;
|
||||
}
|
||||
if(row_info->bit_depth == 2)
|
||||
if(((*dp << (pos+=2))& 0xc0) == 0) black_pixels++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
dp++;
|
||||
}
|
||||
if(row_info->bit_depth == 4)
|
||||
if(((*dp << (pos+=4))& 0xf0) == 0) black_pixels++;
|
||||
if(pos == 8)
|
||||
{
|
||||
pos=0;
|
||||
dp++;
|
||||
}
|
||||
if(row_info->bit_depth == 8)
|
||||
if(*dp++ == 0) black_pixels++;
|
||||
if(row_info->bit_depth == 16)
|
||||
{
|
||||
if((*dp | *(dp+1)) == 0) black_pixels++;
|
||||
dp+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* other color types */
|
||||
{
|
||||
png_uint_32 n;
|
||||
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 (channel = 0; channel < color_channels; channel++)
|
||||
{
|
||||
if(row_info->bit_depth == 8)
|
||||
if(*dp++ == 0) black_pixels++;
|
||||
if(row_info->bit_depth == 16)
|
||||
{
|
||||
if((*dp | *(dp+1)) == 0) black_pixels++;
|
||||
dp+=2;
|
||||
}
|
||||
}
|
||||
if(row_info->color_type > 3)
|
||||
{
|
||||
dp++;
|
||||
if(row_info->bit_depth == 16)dp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ|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. */
|
||||
#if defined(PNG_NO_STDIO)
|
||||
/* This is the function which does the actual reading of data. If you are
|
||||
not reading from a standard C stream, you should create a replacement
|
||||
read_data function and use it at run time with png_set_read_fn(), rather
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
@@ -78,6 +206,8 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -117,10 +247,12 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
static void
|
||||
png_default_flush(png_structp png_ptr);
|
||||
static void
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
FILE *io_ptr;
|
||||
@@ -136,6 +268,8 @@ png_default_flush(png_structp png_ptr)
|
||||
than changing the library. */
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
@@ -155,6 +289,8 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
|
||||
static void
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
@@ -195,7 +331,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
/* 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
|
||||
@@ -223,13 +359,114 @@ png_default_error(png_structp png_ptr, png_const_charp message)
|
||||
/* We can return because png_error calls the default handler which is
|
||||
* actually ok in this case. */
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_NO_STDIO */
|
||||
/* END of code to validate stdio-free compilation */
|
||||
|
||||
/* Test one file */
|
||||
int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
/* 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
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
64K. However, zlib may allocate more then 64K if you don't tell
|
||||
it not to. See zconf.h and png.h for more information. zlib does
|
||||
need to allocate exactly 64K, so whatever you call here must
|
||||
have the ability to do that.
|
||||
|
||||
This piece of code can be compiled to validate max 64K allocations
|
||||
by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
|
||||
typedef struct memory_information {
|
||||
png_uint_32 size;
|
||||
png_voidp pointer;
|
||||
struct memory_information FAR *next;
|
||||
} memory_information;
|
||||
typedef memory_information FAR *memory_infop;
|
||||
|
||||
static memory_infop pinformation = NULL;
|
||||
static int current_allocation = 0;
|
||||
static int maximum_allocation = 0;
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
pinfo->size = size;
|
||||
current_allocation += size;
|
||||
if (current_allocation > maximum_allocation)
|
||||
maximum_allocation = current_allocation;
|
||||
pinfo->pointer = png_debug_malloc(png_ptr, size);
|
||||
pinfo->next = pinformation;
|
||||
pinformation = pinfo;
|
||||
/* Make sure the caller isn't assuming zeroed memory. */
|
||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||
return (png_voidp)(pinfo->pointer);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free a pointer. It is removed from the list at the same time. */
|
||||
void
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
FILE *fpin, *fpout;
|
||||
if (png_ptr == NULL)
|
||||
fprintf(STDERR, "NULL pointer to memory allocator\n");
|
||||
if (ptr == 0) {
|
||||
#if 0 /* This happens all the time. */
|
||||
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Unlink the element from the list. */
|
||||
{
|
||||
memory_infop FAR *ppinfo = &pinformation;
|
||||
for (;;) {
|
||||
memory_infop pinfo = *ppinfo;
|
||||
if (pinfo->pointer == ptr) {
|
||||
*ppinfo = pinfo->next;
|
||||
current_allocation -= pinfo->size;
|
||||
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. */
|
||||
memset(ptr, 0x55, pinfo->size);
|
||||
png_debug_free(png_ptr, pinfo);
|
||||
break;
|
||||
}
|
||||
if (pinfo->next == NULL) {
|
||||
fprintf(STDERR, "Pointer %x not found\n", ptr);
|
||||
break;
|
||||
}
|
||||
ppinfo = &pinfo->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally free the data. */
|
||||
png_debug_free(png_ptr, ptr);
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
#endif
|
||||
/* END of code to test memory allocation/deallocation */
|
||||
|
||||
/* Test one file */
|
||||
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
static FILE *fpin, *fpout; /* "static" prevents setjmp corruption */
|
||||
png_structp read_ptr, write_ptr;
|
||||
png_infop read_info_ptr, write_info_ptr, end_info_ptr;
|
||||
png_bytep row_buf;
|
||||
@@ -248,30 +485,32 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Could not find input file %s\n", inname);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((fpout = fopen(outname, "wb")) == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Could not open output file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
png_debug(0, "Allocating read and write structures\n");
|
||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
#if defined(PNG_NO_STDIO)
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error, png_default_warning);
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error,
|
||||
png_default_warning);
|
||||
#endif
|
||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
#if defined(PNG_NO_STDIO)
|
||||
png_set_error_fn(write_ptr, (png_voidp)inname, png_default_error, png_default_warning);
|
||||
png_set_error_fn(write_ptr, (png_voidp)inname, png_default_error,
|
||||
png_default_warning);
|
||||
#endif
|
||||
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
write_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);
|
||||
|
||||
png_debug(0, "Setting jmpbuf for read struct\n");
|
||||
@@ -286,7 +525,7 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
png_debug(0, "Setting jmpbuf for write struct\n");
|
||||
@@ -302,7 +541,7 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
@@ -320,6 +559,22 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#else
|
||||
NULL);
|
||||
#endif
|
||||
#endif
|
||||
if(status_dots_requested == 1)
|
||||
{
|
||||
png_set_write_status_fn(write_ptr, write_row_callback);
|
||||
png_set_read_status_fn(read_ptr, read_row_callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_set_write_status_fn(write_ptr, NULL);
|
||||
png_set_read_status_fn(read_ptr, NULL);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
black_pixels=0;
|
||||
png_set_write_user_transform_fn(write_ptr, count_black_pixels);
|
||||
#endif
|
||||
|
||||
png_debug(0, "Reading info struct\n");
|
||||
@@ -333,7 +588,11 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
&color_type, &interlace_type, &compression_type, &filter_type))
|
||||
{
|
||||
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
color_type, interlace_type, compression_type, filter_type);
|
||||
#else
|
||||
color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED) && defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
@@ -370,7 +629,7 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) && defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
{
|
||||
png_byte intent;
|
||||
int intent;
|
||||
|
||||
if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
|
||||
{
|
||||
@@ -485,6 +744,7 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_debug(0, "\nWriting info struct\n");
|
||||
png_write_info(write_ptr, write_info_ptr);
|
||||
|
||||
png_debug(0, "\nAllocating row buffer \n");
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
if (row_buf == NULL)
|
||||
@@ -494,14 +754,16 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
png_debug(0, "Writing row data\n");
|
||||
|
||||
num_pass = png_set_interlace_handling(read_ptr);
|
||||
png_set_interlace_handling(write_ptr);
|
||||
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
{
|
||||
png_debug1(0, "Writing row data for pass %d\n",pass);
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1);
|
||||
@@ -512,28 +774,38 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_debug(0, "Reading and writing end_info data\n");
|
||||
png_read_end(read_ptr, end_info_ptr);
|
||||
png_write_end(write_ptr, end_info_ptr);
|
||||
|
||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||
if(verbose)
|
||||
{
|
||||
png_uint_32 iwidth, iheight;
|
||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
||||
iwidth, iheight);
|
||||
}
|
||||
#endif
|
||||
|
||||
png_debug(0, "Destroying data structs\n");
|
||||
png_free(read_ptr, row_buf);
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
|
||||
png_free(read_ptr, row_buf);
|
||||
|
||||
png_debug(0, "Opening files for comparison\n");
|
||||
if ((fpin = fopen(inname, "rb")) == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Could not find file %s\n", inname);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((fpout = fopen(outname, "rb")) == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Could not find file %s\n", outname);
|
||||
fclose(fpin);
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
while (1)
|
||||
@@ -547,9 +819,20 @@ int test(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
fprintf(STDERR, "Files %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
if(wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same chunk size (8k),",inname);
|
||||
fprintf(STDERR,
|
||||
" filtering\n heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question=1;
|
||||
}
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!num_in)
|
||||
@@ -558,25 +841,36 @@ int test(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);
|
||||
if(wrote_question == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same chunk size (8k),",inname);
|
||||
fprintf(STDERR,
|
||||
" filtering\n heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default)\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question=1;
|
||||
}
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
return 1;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fpin);
|
||||
fclose(fpout);
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* input and output filenames */
|
||||
#ifdef RISCOS
|
||||
PNG_CONST char *inname = "pngtest_png";
|
||||
PNG_CONST char *outname = "pngout_png";
|
||||
PNG_CONST char *inname = "pngtest/png";
|
||||
PNG_CONST char *outname = "pngout/png";
|
||||
#else
|
||||
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";
|
||||
#endif
|
||||
|
||||
int
|
||||
@@ -586,6 +880,19 @@ main(int argc, char *argv[])
|
||||
int ierror = 0;
|
||||
|
||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||
|
||||
/* Do some consistency checking on the memory allocation settings, I'm
|
||||
not sure this matters, but it is nice to know, the first of these
|
||||
tests should be impossible because of the way the macros are set
|
||||
in pngconf.h */
|
||||
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
||||
fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
|
||||
#endif
|
||||
/* I think the following can happen. */
|
||||
#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
|
||||
fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n");
|
||||
#endif
|
||||
|
||||
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
|
||||
{
|
||||
@@ -598,38 +905,144 @@ main(int argc, char *argv[])
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "-m") == 0)
|
||||
multiple = 1;
|
||||
else
|
||||
inname = argv[1];
|
||||
if (strcmp(argv[1], "-m") == 0)
|
||||
{
|
||||
multiple = 1;
|
||||
status_dots_requested = 0;
|
||||
}
|
||||
else if (strcmp(argv[1], "-mv") == 0 ||
|
||||
strcmp(argv[1], "-vm") == 0 )
|
||||
{
|
||||
multiple = 1;
|
||||
verbose = 1;
|
||||
status_dots_requested = 1;
|
||||
}
|
||||
else if (strcmp(argv[1], "-v") == 0)
|
||||
{
|
||||
verbose = 1;
|
||||
status_dots_requested = 1;
|
||||
inname = argv[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
inname = argv[1];
|
||||
status_dots_requested = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!multiple && argc == 3)
|
||||
outname = argv[2];
|
||||
if (!multiple && argc == 3+verbose)
|
||||
outname = argv[2+verbose];
|
||||
|
||||
if (!multiple && argc > 3 || multiple && argc < 2)
|
||||
if ((!multiple && argc > 3+verbose) || (multiple && argc < 2))
|
||||
{
|
||||
fprintf(STDERR, "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
|
||||
fprintf(STDERR,
|
||||
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
|
||||
argv[0], argv[0]);
|
||||
fprintf(STDERR, " reads/writes one PNG file (without -m) or multiple files (-m)\n");
|
||||
fprintf(STDERR, " with -m %s is used as a temporary file\n", outname);
|
||||
fprintf(STDERR,
|
||||
" reads/writes one PNG file (without -m) or multiple files (-m)\n");
|
||||
fprintf(STDERR,
|
||||
" with -m %s is used as a temporary file\n", outname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (multiple)
|
||||
{
|
||||
int i;
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
int allocation_now = current_allocation;
|
||||
#endif
|
||||
for (i=2; i<argc; ++i)
|
||||
ierror += test(argv[i], outname);
|
||||
{
|
||||
int kerror;
|
||||
fprintf(STDERR, "Testing %s:",argv[i]);
|
||||
kerror = test_one_file(argv[i], outname);
|
||||
if (kerror == 0)
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
else {
|
||||
fprintf(STDERR, " FAIL\n");
|
||||
ierror += kerror;
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||
maximum_allocation);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ierror += test(inname, outname);
|
||||
int i;
|
||||
for (i=0; i<3; ++i) {
|
||||
int kerror;
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
int allocation_now = current_allocation;
|
||||
#endif
|
||||
if (i == 1) status_dots_requested = 1;
|
||||
else if(verbose == 0)status_dots_requested = 0;
|
||||
if (i == 0 || verbose == 1 || ierror != 0)
|
||||
fprintf(STDERR, "Testing %s:",inname);
|
||||
kerror = test_one_file(inname, outname);
|
||||
if(kerror == 0)
|
||||
{
|
||||
if(verbose == 1 || i == 2)
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
fprintf(STDERR, " PASS (%lu black pixels)\n",black_pixels);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose == 0 && i != 2)
|
||||
fprintf(STDERR, "Testing %s:",inname);
|
||||
fprintf(STDERR, " FAIL\n");
|
||||
ierror += kerror;
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation-allocation_now);
|
||||
if (current_allocation != 0) {
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
while (pinfo != NULL) {
|
||||
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef PNGTEST_MEMORY_DEBUG
|
||||
fprintf(STDERR, "Maximum memory allocation: %d bytes\n",
|
||||
maximum_allocation);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ierror == 0)
|
||||
fprintf(STDERR, "libpng passes test\n");
|
||||
else
|
||||
fprintf(STDERR, "libpng FAILS test\n");
|
||||
return ierror != 0;
|
||||
return (int)(ierror != 0);
|
||||
}
|
||||
|
||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
24
pngtrans.c
24
pngtrans.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -67,7 +68,8 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
int
|
||||
png_set_interlace_handling(png_structp png_ptr)
|
||||
{
|
||||
@@ -75,10 +77,10 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return 7;
|
||||
return (7);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -117,6 +119,16 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
|
||||
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
png_set_invert_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha\n");
|
||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
void
|
||||
png_set_invert_mono(png_structp png_ptr)
|
||||
@@ -288,7 +300,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
png_debug(1, "in png_do_packswap\n");
|
||||
if (
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
row != NULL && row_info != NULL
|
||||
row != NULL && row_info != NULL &&
|
||||
#endif
|
||||
row_info->bit_depth < 8)
|
||||
{
|
||||
|
||||
9
pngwio.c
9
pngwio.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*
|
||||
* This file provides a location for all output. Users which need
|
||||
* special handling are expected to write functions which have the same
|
||||
@@ -179,7 +180,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
|
||||
#if defined(USE_FAR_KEYWORD)
|
||||
#if defined(_MSC_VER)
|
||||
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
@@ -191,7 +192,7 @@ void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
return(near_ptr);
|
||||
}
|
||||
# else
|
||||
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
|
||||
125
pngwrite.c
125
pngwrite.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
/* get internal access to png.h */
|
||||
@@ -33,7 +34,12 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
/* write IHDR information. */
|
||||
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
|
||||
info_ptr->filter_type, info_ptr->interlace_type);
|
||||
info_ptr->filter_type,
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
info_ptr->interlace_type);
|
||||
#else
|
||||
0);
|
||||
#endif
|
||||
/* the rest of these check to see if the valid field has the appropriate
|
||||
flag set, and if it does, writes the chunk. */
|
||||
#if defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
@@ -42,7 +48,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
png_write_sRGB(png_ptr, info_ptr->srgb_intent);
|
||||
png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_sBIT_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||
@@ -61,10 +67,23 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
(png_uint_32)info_ptr->num_palette);
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_error(png_ptr, "Valid palette required for paletted images\n");
|
||||
|
||||
#if defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel (in tRNS) */
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
for (j=0; j<(int)info_ptr->num_trans; j++)
|
||||
info_ptr->trans[j] = 255 - info_ptr->trans[j];
|
||||
}
|
||||
#endif
|
||||
png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
|
||||
info_ptr->num_trans, info_ptr->color_type);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_bKGD_SUPPORTED)
|
||||
if (info_ptr->valid & PNG_INFO_bKGD)
|
||||
@@ -199,19 +218,20 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
png_write_IEND(png_ptr);
|
||||
}
|
||||
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
/* Convert the supplied time into an RFC 1152 string suitable for use in
|
||||
#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_rfc1152(png_structp png_ptr, png_timep ptime)
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
{
|
||||
const char *short_months[12] = {"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, 29*sizeof(char));
|
||||
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||
sizeof(char)));
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
@@ -230,9 +250,9 @@ png_convert_to_rfc1152(png_structp png_ptr, png_timep ptime)
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
#endif
|
||||
return png_ptr->time_buffer;
|
||||
return ((png_charp)png_ptr->time_buffer);
|
||||
}
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
void
|
||||
@@ -270,7 +290,7 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
png_debug(1, "in png_create_write_struct\n");
|
||||
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
|
||||
{
|
||||
return (png_structp)NULL;
|
||||
return ((png_structp)NULL);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
@@ -280,7 +300,7 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
{
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_destroy_struct(png_ptr);
|
||||
return (png_structp)NULL;
|
||||
return ((png_structp)NULL);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
|
||||
@@ -301,7 +321,8 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
|
||||
@@ -310,7 +331,7 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
|
||||
1, NULL, NULL);
|
||||
#endif
|
||||
|
||||
return (png_ptr);
|
||||
return ((png_structp)png_ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -332,7 +353,8 @@ png_write_init(png_structp png_ptr)
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_set_write_fn(png_ptr, NULL, NULL, NULL);
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@@ -372,9 +394,13 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
png_bytepp rp; /* points to current row */
|
||||
|
||||
png_debug(1, "in png_write_image\n");
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
/* intialize interlace handling. If image is not interlaced,
|
||||
this will set pass to 1 */
|
||||
num_pass = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
num_pass = 1;
|
||||
#endif
|
||||
/* loop through passes */
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
{
|
||||
@@ -464,6 +490,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
|
||||
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
|
||||
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
|
||||
|
||||
@@ -475,7 +502,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes);
|
||||
|
||||
/* Copy user's row into buffer, leaving room for filter byte. */
|
||||
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
|
||||
png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row,
|
||||
png_ptr->row_info.rowbytes);
|
||||
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
/* handle interlacing */
|
||||
@@ -499,6 +527,9 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
||||
|
||||
/* Find a filter if necessary, filter the row and write it out. */
|
||||
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
||||
|
||||
if (png_ptr->write_row_fn != NULL)
|
||||
(*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||
@@ -581,6 +612,19 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
#ifdef PNG_WRITE_tEXt_SUPPORTED
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
png_free(png_ptr, info_ptr->pcal_purpose);
|
||||
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]);
|
||||
}
|
||||
png_free(png_ptr, info_ptr->pcal_params);
|
||||
}
|
||||
#endif
|
||||
png_destroy_struct((png_voidp)info_ptr);
|
||||
*info_ptr_ptr = (png_infop)NULL;
|
||||
@@ -616,9 +660,9 @@ png_write_destroy(png_structp png_ptr)
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
png_free(png_ptr, png_ptr->avg_row);
|
||||
png_free(png_ptr, png_ptr->paeth_row);
|
||||
#if defined(PNG_TIME_RFC1152_SUPPORTED)
|
||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->time_buffer);
|
||||
#endif /* PNG_TIME_RFC1152_SUPPORTED */
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->prev_filters);
|
||||
png_free(png_ptr, png_ptr->filter_weights);
|
||||
@@ -678,7 +722,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB && png_ptr->sub_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
@@ -692,7 +736,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
}
|
||||
@@ -707,7 +751,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
else
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
}
|
||||
@@ -722,8 +766,8 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
}
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
@@ -779,7 +823,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
if (png_ptr->prev_filters == NULL)
|
||||
{
|
||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
||||
sizeof(png_byte) * num_weights);
|
||||
(png_uint_32)(sizeof(png_byte) * num_weights));
|
||||
|
||||
/* To make sure that the weighting starts out fairly */
|
||||
for (i = 0; i < num_weights; i++)
|
||||
@@ -790,11 +834,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
|
||||
if (png_ptr->filter_weights == NULL)
|
||||
{
|
||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
sizeof(png_uint_16) * num_weights);
|
||||
png_ptr->filter_weights = (png_uint_16p) png_malloc(png_ptr,
|
||||
(png_uint_32)(sizeof(png_uint_16) * num_weights));
|
||||
|
||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
||||
sizeof(png_uint_16) * num_weights);
|
||||
png_ptr->inv_filter_weights = (png_uint_16p) png_malloc(png_ptr,
|
||||
(png_uint_32)(sizeof(png_uint_16) * num_weights));
|
||||
|
||||
for (i = 0; i < num_weights; i++)
|
||||
{
|
||||
@@ -825,11 +869,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
*/
|
||||
if (png_ptr->filter_costs == NULL)
|
||||
{
|
||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST);
|
||||
png_ptr->filter_costs = (png_uint_16p) png_malloc(png_ptr,
|
||||
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||
|
||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
||||
sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST);
|
||||
png_ptr->inv_filter_costs = (png_uint_16p) png_malloc(png_ptr,
|
||||
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
|
||||
|
||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
||||
{
|
||||
@@ -906,3 +950,20 @@ png_set_compression_method(png_structp png_ptr, int method)
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
|
||||
void
|
||||
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
|
||||
{
|
||||
png_ptr->write_row_fn = write_row_fn;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
void
|
||||
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
write_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_write_user_transform_fn\n");
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->write_user_transform_fn = write_user_transform_fn;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
106
pngwtran.c
106
pngwtran.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -18,11 +19,30 @@ void
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations\n");
|
||||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if(png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* user write transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_uint_32 rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->flags);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
@@ -37,6 +57,10 @@ png_do_write_transformations(png_structp png_ptr)
|
||||
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);
|
||||
#endif
|
||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
@@ -218,7 +242,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
channels++;
|
||||
}
|
||||
|
||||
/* with low row dephts, could only be grayscale, so one channel */
|
||||
/* with low row depths, could only be grayscale, so one channel */
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep bp;
|
||||
@@ -393,3 +417,79 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
void
|
||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_do_write_invert_alpha\n");
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
if (row != NULL && row_info != NULL)
|
||||
#endif
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in GA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_info->width; i++)
|
||||
{
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
*(dp++) = 255 - *(sp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
118
pngwutil.c
118
pngwutil.c
@@ -1,11 +1,12 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.00.97
|
||||
* libpng 1.00
|
||||
* 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
|
||||
* May 28, 1997
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* March 7, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -199,12 +200,16 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
filter_type = PNG_FILTER_TYPE_BASE;
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
if (interlace_type != PNG_INTERLACE_NONE &&
|
||||
interlace_type != PNG_INTERLACE_ADAM7)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid interlace type specified");
|
||||
interlace_type = PNG_INTERLACE_ADAM7;
|
||||
}
|
||||
#else
|
||||
interlace_type=PNG_INTERLACE_NONE;
|
||||
#endif
|
||||
|
||||
/* save off the relevent information */
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
@@ -345,15 +350,15 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
|
||||
#if defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
/* write a sRGB chunk */
|
||||
void
|
||||
png_write_sRGB(png_structp png_ptr, png_byte srgb_intent)
|
||||
png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
||||
{
|
||||
png_byte buf[1];
|
||||
|
||||
png_debug(1, "in png_write_sRGB\n");
|
||||
if(srgb_intent > 3)
|
||||
if(srgb_intent >= PNG_sRGB_INTENT_LAST)
|
||||
png_warning(png_ptr,
|
||||
"Invalid sRGB rendering intent specified");
|
||||
buf[0]=srgb_intent;
|
||||
buf[0]=(png_byte)srgb_intent;
|
||||
png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
|
||||
}
|
||||
#endif
|
||||
@@ -370,7 +375,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
||||
/* make sure we don't depend upon the order of PNG_COLOR_8 */
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
int maxbits;
|
||||
png_byte maxbits;
|
||||
|
||||
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8:png_ptr->usr_bit_depth;
|
||||
if (sbit->red == 0 || sbit->red > maxbits ||
|
||||
@@ -481,7 +486,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
||||
png_debug(1, "in png_write_tRNS\n");
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (num_trans <= 0 || num_trans > png_ptr->num_palette)
|
||||
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
|
||||
{
|
||||
png_warning(png_ptr,"Invalid number of transparent colors specified");
|
||||
return;
|
||||
@@ -505,7 +510,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
||||
}
|
||||
else
|
||||
{
|
||||
png_warning(png_ptr, "Can't write tRNS with and alpha channel");
|
||||
png_warning(png_ptr, "Can't write tRNS with an alpha channel");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -546,13 +551,13 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
#if defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
/* write the histogram */
|
||||
void
|
||||
png_write_hIST(png_structp png_ptr, png_uint_16p hist, png_uint_32 num_hist)
|
||||
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
{
|
||||
png_uint_32 i;
|
||||
int i;
|
||||
png_byte buf[3];
|
||||
|
||||
png_debug(1, "in png_write_hIST\n");
|
||||
if (num_hist > png_ptr->num_palette)
|
||||
if (num_hist > (int)png_ptr->num_palette)
|
||||
{
|
||||
png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist,
|
||||
png_ptr->num_palette);
|
||||
@@ -560,7 +565,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, png_uint_32 num_hist)
|
||||
return;
|
||||
}
|
||||
|
||||
png_write_chunk_start(png_ptr, png_hIST, num_hist * 2);
|
||||
png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
|
||||
for (i = 0; i < num_hist; i++)
|
||||
{
|
||||
png_save_uint_16(buf, hist[i]);
|
||||
@@ -594,12 +599,12 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
if (key == NULL || (key_len = png_strlen(key)) == 0)
|
||||
{
|
||||
png_chunk_warning(png_ptr, "zero length keyword");
|
||||
return 0;
|
||||
return ((png_size_t)0);
|
||||
}
|
||||
|
||||
png_debug1(2, "Keyword to be checked is '%s'\n", key);
|
||||
|
||||
*new_key = (png_charp)png_malloc(png_ptr, key_len + 1);
|
||||
*new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 1));
|
||||
|
||||
/* Replace non-printing characters with a blank and print a warning */
|
||||
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
|
||||
@@ -683,7 +688,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
key_len = 79;
|
||||
}
|
||||
|
||||
return key_len;
|
||||
return (key_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -810,17 +815,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
|
||||
old_ptr = output_ptr;
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charpp));
|
||||
(png_uint_32)(max_output_ptr * sizeof (png_charpp)));
|
||||
png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
|
||||
png_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charp));
|
||||
(png_uint_32)(max_output_ptr * sizeof (png_charp)));
|
||||
}
|
||||
|
||||
/* save the data */
|
||||
output_ptr[num_output_ptr] = png_malloc(png_ptr, png_ptr->zbuf_size);
|
||||
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
num_output_ptr++;
|
||||
@@ -863,18 +869,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
old_ptr = output_ptr;
|
||||
/* This could be optimized to realloc() */
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charpp));
|
||||
(png_uint_32)(max_output_ptr * sizeof (png_charpp)));
|
||||
png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
|
||||
png_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
max_output_ptr * sizeof (png_charp));
|
||||
(png_uint_32)(max_output_ptr * sizeof (png_charp)));
|
||||
}
|
||||
|
||||
/* save off the data */
|
||||
output_ptr[num_output_ptr] = png_malloc(png_ptr,
|
||||
png_ptr->zbuf_size);
|
||||
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
num_output_ptr++;
|
||||
@@ -962,7 +968,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
png_debug1(3, "pCAL units length = %d\n", units_len);
|
||||
total_len = purpose_len + units_len + 10;
|
||||
|
||||
params_len = (png_uint_32p)png_malloc(png_ptr, nparams*sizeof(png_uint_32));
|
||||
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
|
||||
*sizeof(png_uint_32)));
|
||||
|
||||
/* Find the length of each parameter, making sure we don't count the
|
||||
null terminator for the last parameter. */
|
||||
@@ -974,7 +981,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
}
|
||||
|
||||
png_debug1(3, "pCAL total length = %d\n", total_len);
|
||||
png_write_chunk_start(png_ptr, png_pCAL, total_len);
|
||||
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
|
||||
png_save_int_32(buf, X0);
|
||||
png_save_int_32(buf + 4, X1);
|
||||
@@ -991,6 +998,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
(png_size_t)params_len[i]);
|
||||
}
|
||||
|
||||
png_free(png_ptr, params_len);
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
#endif
|
||||
@@ -1056,14 +1064,14 @@ png_write_start_row(png_structp png_ptr)
|
||||
png_ptr->usr_bit_depth + 7) >> 3) + 1);
|
||||
|
||||
/* set up row buffer */
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
||||
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
|
||||
|
||||
/* set up filtering buffer, if using this filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
@@ -1071,31 +1079,32 @@ png_write_start_row(png_structp png_ptr)
|
||||
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
{
|
||||
/* set up previous row buffer */
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, buf_size);
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
||||
png_memset(png_ptr->prev_row, 0, buf_size);
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||
{
|
||||
png_ptr->up_row = (png_bytep )png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG)
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep )png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* if interlaced, we need to set up width and height of pass */
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
@@ -1113,6 +1122,7 @@ png_write_start_row(png_structp png_ptr)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_ptr->num_rows = png_ptr->height;
|
||||
png_ptr->usr_width = png_ptr->width;
|
||||
@@ -1135,6 +1145,7 @@ png_write_finish_row(png_structp png_ptr)
|
||||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* if interlaced, go to next pass */
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
@@ -1176,6 +1187,7 @@ png_write_finish_row(png_structp png_ptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if we get here, we've just written the last row, so we need
|
||||
to flush the compressor */
|
||||
@@ -1346,7 +1358,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
i += png_pass_inc[pass])
|
||||
{
|
||||
/* find out where the original pixel is */
|
||||
sp = row + i * pixel_bytes;
|
||||
sp = row + (png_size_t)i * pixel_bytes;
|
||||
/* move the pixel */
|
||||
if (dp != sp)
|
||||
png_memcpy(dp, sp, pixel_bytes);
|
||||
@@ -1361,9 +1373,8 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
png_pass_inc[pass] - 1 -
|
||||
png_pass_start[pass]) /
|
||||
png_pass_inc[pass];
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
|
||||
row_info->rowbytes = ((row_info->width *
|
||||
row_info->pixel_depth + 7) >> 3);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1394,7 +1405,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
* smallest value when summing the absolute values of the distances
|
||||
* from zero using anything >= 128 as negative numbers. This is known
|
||||
* as the "minimum sum of absolute differences" heuristic. Other
|
||||
* heruistics are the "weighted minumum sum of absolute differences"
|
||||
* heuristics are the "weighted minumum 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
|
||||
@@ -1410,7 +1421,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 sum = 0;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
for (i = 0, rp = row_buf + 1; i < row_info->rowbytes; i++, rp++)
|
||||
@@ -1427,7 +1438,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
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_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
|
||||
{
|
||||
@@ -1461,7 +1472,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@@ -1475,7 +1486,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
@@ -1505,7 +1516,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
}
|
||||
for (lp = row_buf + 1; i < row_info->rowbytes; i++, rp++, lp++, dp++)
|
||||
for (lp = row_buf + 1; i < row_info->rowbytes;
|
||||
i++, rp++, lp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||
|
||||
@@ -1522,7 +1534,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
|
||||
{
|
||||
@@ -1557,7 +1569,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@@ -1567,7 +1579,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
|
||||
{
|
||||
@@ -1591,7 +1603,8 @@ 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_info->rowbytes;
|
||||
i++, rp++, pp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
|
||||
@@ -1608,7 +1621,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
sumlo = sum & PNG_LOMASK;
|
||||
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_UP)
|
||||
{
|
||||
@@ -1643,7 +1656,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@@ -1653,7 +1666,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
lmlo = lmins & PNG_LOMASK;
|
||||
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
|
||||
|
||||
for (i = 0; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_AVG)
|
||||
{
|
||||
@@ -1736,7 +1749,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
png_size_t i;
|
||||
png_uint_32 i;
|
||||
int v;
|
||||
|
||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||
@@ -1770,7 +1783,7 @@ 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; i < bpp; i++, rp++, pp++, dp++)
|
||||
pp = prev_row + 1; (unsigned)i < bpp; i++, rp++, pp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
|
||||
@@ -1848,9 +1861,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||
/* Save the type of filter we picked this time for future calculations */
|
||||
if (png_ptr->num_prev_filters > 0)
|
||||
{
|
||||
png_byte i;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < png_ptr->num_prev_filters; i++)
|
||||
for (i = 1; i < (int)png_ptr->num_prev_filters; i++)
|
||||
{
|
||||
png_ptr->prev_filters[i] = png_ptr->prev_filters[i - 1];
|
||||
}
|
||||
@@ -1919,4 +1932,3 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
|
||||
}
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# makefile for libpng on (linux) ELF
|
||||
# makefile for libpng on Linux ELF with gcc
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1998 Greg Roelofs
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
CC=gcc
|
||||
@@ -13,14 +14,17 @@ ZLIBINC=../zlib
|
||||
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 -fPIC #$(WARNMORE) -g -DPNG_DEBUG=5
|
||||
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -malign-loops=2 \
|
||||
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
RANLIB=ranlib
|
||||
#RANLIB=echo
|
||||
|
||||
PNGMAJ = 1
|
||||
PNGMIN = 1.0
|
||||
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
|
||||
# have to change it.
|
||||
PNGMAJ = 2
|
||||
PNGMIN = 1.00
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
@@ -32,10 +36,17 @@ 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.so pngtest
|
||||
OBJSDLL = $(OBJS:.o=.pic.o)
|
||||
|
||||
.SUFFIXES: .c .o .pic.o
|
||||
|
||||
.c.pic.o:
|
||||
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
|
||||
|
||||
all: libpng.a libpng.so pngtest
|
||||
|
||||
libpng.a: $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
ar rc $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
libpng.so: libpng.so.$(PNGMAJ)
|
||||
@@ -44,43 +55,45 @@ libpng.so: libpng.so.$(PNGMAJ)
|
||||
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJS)
|
||||
gcc -shared -Wl,-soname,libpng.so.$(PNGMAJ) $(OBJS) -o libpng.so.$(PNGVER)
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
gcc -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
|
||||
$(OBJSDLL)
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
|
||||
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
install: libpng.so.$(PNGVER)
|
||||
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.so.$(PNGVER) $(LIBPATH)
|
||||
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
|
||||
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
|
||||
-@/bin/rm $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
|
||||
-@/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:
|
||||
rm -f *.o libpng.a libpng.so* pngtest pngout.png
|
||||
/bin/rm -f *.o libpng.a libpng.so* 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
|
||||
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
|
||||
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
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
# ------------- Microsoft C 5.1 and later -------------
|
||||
MODEL=-AL
|
||||
CFLAGS=-Oait -Gs -nologo -W2 $(MODEL) -I..\zlib
|
||||
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) -I..\zlib
|
||||
#-Ox generates bad code with MSC 5.1
|
||||
CC=cl
|
||||
LD=link
|
||||
69
scripts/makefile.os2
Normal file
69
scripts/makefile.os2
Normal file
@@ -0,0 +1,69 @@
|
||||
# makefile for libpng on OS/2 with gcc
|
||||
# For conditions of distribution and use, see copyright notice in png.h
|
||||
|
||||
# Related files: pngos2.def
|
||||
|
||||
CC=gcc -Zomf -s
|
||||
|
||||
# Where the zlib library and include files are located
|
||||
ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wmissing-declarations -Wtraditional -Wcast-align \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \
|
||||
-malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll
|
||||
AR=emxomfar
|
||||
|
||||
PNGLIB=png.lib
|
||||
IMPLIB=emximp
|
||||
SHAREDLIB=png.dll
|
||||
SHAREDLIBIMP=pngdll.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
|
||||
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
all: $(PNGLIB) $(SHAREDLIB) $(SHAREDLIBIMP)
|
||||
|
||||
$(PNGLIB): $(OBJS)
|
||||
$(AR) rc $@ $(OBJS)
|
||||
|
||||
$(SHAREDLIB): $(OBJS) pngos2.def
|
||||
$(CC) $(LDFLAGS) -Zdll -o $@ $^
|
||||
|
||||
$(SHAREDLIBIMP): pngos2.def
|
||||
$(IMPLIB) -o $@ $^
|
||||
|
||||
pngtest.exe: pngtest.o png.dll pngdll.lib
|
||||
$(CC) -o $@ $(CFLAGS) $< $(LDFLAGS)
|
||||
|
||||
test: pngtest.exe
|
||||
./pngtest.exe
|
||||
|
||||
clean:
|
||||
rm -f *.o $(PNGLIB) png.dll pngdll.lib pngtest.exe pngout.png
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h
|
||||
|
||||
pngtest.o: png.h pngconf.h
|
||||
98
scripts/makefile.s2x
Normal file
98
scripts/makefile.s2x
Normal file
@@ -0,0 +1,98 @@
|
||||
makefile for libpng on Solaris 2.x with gcc
|
||||
# Contributed by William L. Sebok, based on makefile.lnx
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1998 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
|
||||
|
||||
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
|
||||
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(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.00
|
||||
PNGVER = $(PNGMAJ).$(PNGMIN)
|
||||
|
||||
# where make install puts libpng.a, libpng.so*, and png.h
|
||||
prefix=/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:.o=.pic.o)
|
||||
|
||||
.SUFFIXES: .c .o .pic.o
|
||||
|
||||
.c.pic.o:
|
||||
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
|
||||
|
||||
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
|
||||
|
||||
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
|
||||
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
|
||||
|
||||
libpng.so.$(PNGVER): $(OBJSDLL)
|
||||
$(LD) -G -L$(LIBPATH) -R$(LIBPATH) -h libpng.so.$(PNGMAJ) \
|
||||
-o libpng.so.$(PNGVER) $(OBJSDLL) -lz
|
||||
|
||||
pngtest: pngtest.o libpng.so
|
||||
$(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 -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
|
||||
@@ -9,11 +9,12 @@ ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
CC=cc
|
||||
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -O -fullwarn # -g -DPNG_DEBUG=1
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
#RANLIB=echo
|
||||
RANLIB=ranlib
|
||||
RANLIB=echo
|
||||
#RANLIB=ranlib
|
||||
|
||||
# where make install puts libpng.a and png.h
|
||||
prefix=/usr/local
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for libpng
|
||||
# TurboC++ 3.0 (Note: All modules are compiled in C mode)
|
||||
|
||||
# To use, do "make -fmakefile.tc"
|
||||
# To use, do "make -fmakefile.tc3"
|
||||
|
||||
# ------------- Turbo C++ 3.0 -------------
|
||||
MODEL=-ml
|
||||
@@ -9,18 +9,22 @@ CFLAGS=-O2 -Z $(MODEL) -I..\zlib
|
||||
CC=tcc
|
||||
LD=tcc
|
||||
LIB=tlib
|
||||
LDFLAGS=$(MODEL)
|
||||
LDFLAGS=$(MODEL) -L..\zlib
|
||||
O=.obj
|
||||
E=.exe
|
||||
|
||||
# variables
|
||||
OBJS1 = png$(O) pngset$(O) pngget$(O) pngrutil$(O) pngtrans$(O) pngwutil$(O)
|
||||
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)
|
||||
OBJSL1 = +png$(O) +pngset$(O) +pngget$(O) +pngrutil$(O) +pngtrans$(O)
|
||||
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O) +pngerror$(O)
|
||||
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O) +pngwio$(O)
|
||||
OBJSL2 = +pngwutil$(O) +pngmem$(O) +pngpread$(O) +pngread$(O)
|
||||
+pngerror$(O)
|
||||
OBJSL3 = +pngwrite$(O) +pngrtran$(O) +pngwtran$(O) +pngrio$(O)
|
||||
+pngwio$(O)
|
||||
|
||||
all: libpng.lib
|
||||
all: libpng.lib pngtest.exe
|
||||
|
||||
png$(O): png.h pngconf.h
|
||||
$(CC) -c $(CFLAGS) $*.c
|
||||
@@ -75,4 +79,7 @@ libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
|
||||
$(LIB) libpng +$(OBJSL2)
|
||||
$(LIB) libpng +$(OBJSL3)
|
||||
|
||||
# End of makefile for libpng
|
||||
pngtest$(E): pngtest$(O) libpng.lib
|
||||
$(CC) $(LDFLAGS) pngtest.obj libpng.lib zlib.lib
|
||||
|
||||
# End of makefile for libpng
|
||||
88
scripts/makefile.wat
Normal file
88
scripts/makefile.wat
Normal file
@@ -0,0 +1,88 @@
|
||||
# Makefile for libpng
|
||||
# Watcom 10a+ 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"
|
||||
|
||||
# ------------- Watcom 10a+ -------------
|
||||
MODEL=-mf
|
||||
CFLAGS= $(MODEL) -fpi87 -fp5 -5r -oaeilmnrt -s -i=..\zlib
|
||||
CC=wcc386
|
||||
LD=wcl386
|
||||
LIB=wlib -b -c
|
||||
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)
|
||||
|
||||
all: test
|
||||
|
||||
png$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngset$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngget$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngread$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngpread$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrtran$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrutil$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngerror$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngmem$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngrio$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwio$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtest$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngtrans$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwrite$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
pngwtran$(O): png.h pngconf.h
|
||||
$(CC) $(CFLAGS) $*.c $(ERRFILE)
|
||||
|
||||
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)
|
||||
|
||||
pngtest.exe: pngtest.obj libpng.lib
|
||||
$(LD) $(LDFLAGS) pngtest.obj libpng.lib ..\zlib\zlib.lib
|
||||
|
||||
test: pngtest.exe
|
||||
pngtest
|
||||
|
||||
# End of makefile for libpng
|
||||
286
scripts/pngos2.def
Normal file
286
scripts/pngos2.def
Normal file
@@ -0,0 +1,286 @@
|
||||
;----------------------------------------
|
||||
; PNGLIB module definition file for OS/2
|
||||
;----------------------------------------
|
||||
|
||||
LIBRARY PNG
|
||||
DESCRIPTION "PNG image compression library for OS/2"
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
|
||||
EXPORTS
|
||||
png_set_sig_bytes
|
||||
png_sig_cmp
|
||||
png_check_sig
|
||||
png_create_read_struct
|
||||
png_create_write_struct
|
||||
png_write_chunk
|
||||
png_write_chunk_start
|
||||
png_write_chunk_data
|
||||
png_write_chunk_end
|
||||
png_create_info_struct
|
||||
png_info_init
|
||||
png_write_info
|
||||
png_read_info
|
||||
png_convert_to_rfc1123
|
||||
png_convert_from_struct_tm
|
||||
png_convert_from_time_t
|
||||
png_set_expand
|
||||
png_set_bgr
|
||||
png_set_gray_to_rgb
|
||||
; png_set_rgb_to_gray
|
||||
png_build_grayscale_palette
|
||||
png_set_strip_alpha
|
||||
png_set_swap_alpha
|
||||
png_set_invert_alpha
|
||||
png_set_filler
|
||||
png_set_swap
|
||||
png_set_packing
|
||||
png_set_packswap
|
||||
png_set_shift
|
||||
png_set_interlace_handling
|
||||
png_set_invert_mono
|
||||
png_set_background
|
||||
png_set_strip_16
|
||||
png_set_dither
|
||||
png_set_gamma
|
||||
png_set_flush
|
||||
png_write_flush
|
||||
png_start_read_image
|
||||
png_read_update_info
|
||||
png_read_rows
|
||||
png_read_row
|
||||
png_read_image
|
||||
png_write_row
|
||||
png_write_rows
|
||||
png_write_image
|
||||
png_write_end
|
||||
png_read_end
|
||||
png_destroy_info_struct
|
||||
png_destroy_read_struct
|
||||
png_read_destroy
|
||||
png_destroy_write_struct
|
||||
; png_write_destroy_info
|
||||
png_write_destroy
|
||||
png_set_crc_action
|
||||
png_set_filter
|
||||
png_set_filter_heuristics
|
||||
png_set_compression_level
|
||||
png_set_compression_mem_level
|
||||
png_set_compression_strategy
|
||||
png_set_compression_window_bits
|
||||
png_set_compression_method
|
||||
png_init_io
|
||||
png_set_error_fn
|
||||
png_get_error_ptr
|
||||
png_set_write_fn
|
||||
png_set_read_fn
|
||||
png_set_write_status_fn
|
||||
png_set_read_status_fn
|
||||
png_get_io_ptr
|
||||
png_set_progressive_read_fn
|
||||
png_set_read_status_fn
|
||||
png_set_read_user_transform_fn
|
||||
png_set_write_status_fn
|
||||
png_set_write_user_transform_fn
|
||||
png_get_progressive_ptr
|
||||
png_process_data
|
||||
png_progressive_combine_row
|
||||
png_malloc
|
||||
png_free
|
||||
png_memcpy_check
|
||||
png_memset_check
|
||||
; png_debug_malloc
|
||||
; png_debug_free
|
||||
; png_far_to_near
|
||||
png_error
|
||||
png_chunk_error
|
||||
png_warning
|
||||
png_chunk_warning
|
||||
png_get_valid
|
||||
png_get_rowbytes
|
||||
png_get_channels
|
||||
png_get_image_width
|
||||
png_get_image_height
|
||||
png_get_bit_depth
|
||||
png_get_color_type
|
||||
png_get_filter_type
|
||||
png_get_interlace_type
|
||||
png_get_compression_type
|
||||
png_get_pixels_per_meter
|
||||
png_get_pixel_aspect_ratio
|
||||
png_get_x_offset_pixels
|
||||
png_get_y_offset_pixels
|
||||
png_get_x_offset_microns
|
||||
png_get_y_offset_microns
|
||||
png_get_signature
|
||||
png_get_bKGD
|
||||
png_set_bKGD
|
||||
png_get_cHRM
|
||||
png_set_cHRM
|
||||
png_get_gAMA
|
||||
png_set_gAMA
|
||||
png_get_hIST
|
||||
png_set_hIST
|
||||
png_get_IHDR
|
||||
png_set_IHDR
|
||||
png_get_oFFs
|
||||
png_set_oFFs
|
||||
png_get_pCAL
|
||||
png_set_pCAL
|
||||
png_get_pHYs
|
||||
png_set_pHYs
|
||||
png_get_PLTE
|
||||
png_set_PLTE
|
||||
png_get_sBIT
|
||||
png_set_sBIT
|
||||
png_get_sRGB
|
||||
png_set_sRGB
|
||||
png_set_sRGB_gAMA_and_cHRM
|
||||
png_get_text
|
||||
png_set_text
|
||||
png_get_tIME
|
||||
png_set_tIME
|
||||
png_get_tRNS
|
||||
png_set_tRNS
|
||||
|
||||
png_create_struct
|
||||
png_destroy_struct
|
||||
png_info_destroy
|
||||
png_zalloc
|
||||
png_zfree
|
||||
png_reset_crc
|
||||
png_write_data
|
||||
png_read_data
|
||||
png_crc_read
|
||||
png_crc_finish
|
||||
png_crc_error
|
||||
png_calculate_crc
|
||||
png_flush
|
||||
png_save_uint_32
|
||||
png_save_int_32
|
||||
png_save_uint_16
|
||||
png_write_sig
|
||||
png_write_IHDR
|
||||
png_write_PLTE
|
||||
png_write_IDAT
|
||||
png_write_IEND
|
||||
png_write_gAMA
|
||||
png_write_sBIT
|
||||
png_write_cHRM
|
||||
png_write_sRGB
|
||||
png_write_tRNS
|
||||
png_write_bKGD
|
||||
png_write_hIST
|
||||
png_check_keyword
|
||||
png_write_tEXt
|
||||
png_write_zTXt
|
||||
png_write_oFFs
|
||||
png_write_pCAL
|
||||
png_write_pHYs
|
||||
png_write_tIME
|
||||
png_write_finish_row
|
||||
png_write_start_row
|
||||
png_build_gamma_table
|
||||
png_combine_row
|
||||
png_do_read_interlace
|
||||
png_do_write_interlace
|
||||
png_read_filter_row
|
||||
png_write_find_filter
|
||||
png_write_filtered_row
|
||||
png_read_finish_row
|
||||
png_read_start_row
|
||||
png_read_transform_info
|
||||
png_do_read_filler
|
||||
png_do_read_swap_alpha
|
||||
png_do_write_swap_alpha
|
||||
png_do_read_invert_alpha
|
||||
png_do_write_invert_alpha
|
||||
png_do_strip_filler
|
||||
png_do_swap
|
||||
png_do_packswap
|
||||
; png_do_rgb_to_gray
|
||||
png_do_gray_to_rgb
|
||||
png_do_unpack
|
||||
png_do_unshift
|
||||
png_do_invert
|
||||
png_do_chop
|
||||
png_do_dither
|
||||
; png_correct_palette
|
||||
png_do_bgr
|
||||
png_do_pack
|
||||
png_do_shift
|
||||
png_do_background
|
||||
png_do_gamma
|
||||
png_do_expand_palette
|
||||
png_do_expand
|
||||
png_handle_IHDR
|
||||
png_handle_PLTE
|
||||
png_handle_IEND
|
||||
png_handle_gAMA
|
||||
png_handle_sBIT
|
||||
png_handle_cHRM
|
||||
png_handle_sRGB
|
||||
png_handle_tRNS
|
||||
png_handle_bKGD
|
||||
png_handle_hIST
|
||||
png_handle_oFFs
|
||||
png_handle_pCAL
|
||||
png_handle_pHYs
|
||||
png_handle_tIME
|
||||
png_handle_tEXt
|
||||
png_handle_zTXt
|
||||
png_handle_unknown
|
||||
png_check_chunk_name
|
||||
png_do_read_transformations
|
||||
png_do_write_transformations
|
||||
png_init_read_transformations
|
||||
png_push_read_chunk
|
||||
png_push_read_sig
|
||||
; png_push_check_crc
|
||||
png_push_crc_skip
|
||||
png_push_crc_finish
|
||||
png_push_fill_buffer
|
||||
png_push_save_buffer
|
||||
png_push_restore_buffer
|
||||
png_push_read_IDAT
|
||||
png_process_IDAT_data
|
||||
png_push_process_row
|
||||
png_push_handle_unknown
|
||||
png_push_have_info
|
||||
png_push_have_end
|
||||
png_push_have_row
|
||||
; png_push_read_end
|
||||
png_process_some_data
|
||||
png_read_push_finish_row
|
||||
png_push_handle_tEXt
|
||||
png_push_read_tEXt
|
||||
png_push_handle_zTXt
|
||||
png_push_read_zTXt
|
||||
|
||||
png_libpng_ver
|
||||
png_pass_start
|
||||
png_pass_inc
|
||||
png_pass_ystart
|
||||
png_pass_yinc
|
||||
png_pass_mask
|
||||
png_pass_dsp_mask
|
||||
; png_pass_width
|
||||
; png_pass_height
|
||||
|
||||
png_IHDR
|
||||
png_IDAT
|
||||
png_IEND
|
||||
png_PLTE
|
||||
png_bKGD
|
||||
png_cHRM
|
||||
png_gAMA
|
||||
png_hIST
|
||||
png_oFFs
|
||||
png_pCAL
|
||||
png_pHYs
|
||||
png_sBIT
|
||||
png_sRGB
|
||||
png_tEXt
|
||||
png_tIME
|
||||
png_tRNS
|
||||
png_zTXt
|
||||
Reference in New Issue
Block a user