提交 61c32d9e 编写于 作者: G Glenn Randers-Pehrson

Imported from libpng-1.0.5q.tar

上级 166c5a39
Libpng 1.0.5h - December 10, 1999
Libpng 1.0.5q - February 5, 2000
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
......@@ -73,13 +73,72 @@ version libpng-1.0.5g December 7, 1999
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
Added "translated_key" to png_text structure and png_write_iTXt().
Added code in pngwrite.c to work around a newly discovered zlib bug.
version 1.0.5h [December 10, 1999]
NOTE: regarding the not for version 1.0.5e, the following must also
version libpng-1.0.5h December 10, 1999
NOTE: regarding the note for version 1.0.5e, the following must also
be included in your code:
png_text[i].translated_key = NULL;
Unknown chunk handling is now supported.
Option to eliminate all floating point support was added. Some new
fixed-point functions such as png_set_gAMA_fixed() were added.
version libpng-1.0.5i December 13, 1999
Added some type casts to silence compiler warnings.
Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
Removed leading blanks from a #define in pngvcrd.c
Added some parameters to the new png_set_keep_unknown_chunks() function,
and relocated it in pngset.c
Added a test for up->location != 0 in the first instance of writing
unknown chunks in pngwrite.c
Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
prevent recursion.
Added png_free_hIST() function.
Various patches to fix bugs in the sCAL and integer cHRM processing,
and to add some convenience macros for use with sCAL.
version libpng-1.0.5j December 21, 1999
Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
around buggy compilers.
Added new type "png_fixed_point" for integers that hold float*100000 values
Restored backward compatibility of tEXt/zTXt chunk processing:
Added members "lang_key" and "itxt_length" to png_text struct. Set
text_length=0 when "text" contains iTXt data. Use the "compression"
member to distinguish among tEXt/zTXt/iTXt types. Restored the first
four members of png_text to the same order as v.1.0.5d. The "Note" above,
about backward incompatibility of libpng-1.0.5e, no longer applies.
Added PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
Fixed png_read|write_iTXt() to read|write parameters in the right order.
and to write the iTXt chunk after IDAT if it appears in the end_ptr.
Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
Reversed the order of trying to write floating-point and fixed-point gAMA.
version libpng-1.0.5k December 27, 1999
Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
Added png_handle_as_unknown()
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
of png_ptr.
Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
version libpng-1.0.5l January 1, 2000
Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
for setting a callback function to handle unknown chunks and for
retrieving the associated user pointer (Glenn).
version 1.0.5m [January 7, 2000]
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
version 1.0.5n [January 9, 2000]
Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
own memory for info_ptr->palette. This makes it safe for the calling
application to free its copy of the palette any time after it calls
png_set_PLTE().
version 1.0.5o [January 20, 2000]
Cosmetic changes only (removed some trailing blanks and TABs)
version 1.0.5p [January 31, 2000]
Renamed pngdll.mak to makefile.bd32
Cosmetic changes in pngtest.c
version 1.0.5q [February 5, 2000]
Relocated the makefile.solaris warning about PATH problems.
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
Revised makefile.gcmmx
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
......
......@@ -517,7 +517,7 @@ version 1.0.5e [November 30, 1999]
with trailing compressed parts easier in the future, and added new functions
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
NOTE: Applications that write text chunks MUST define png_text->lang and
NOTE: Applications that write text chunks MUST define png_text->lang
before calling png_set_text(). It must be set to NULL if you want to
write tEXt or zTXt chunks. If you want your application to be able to
run with older versions of libpng, use
......@@ -544,9 +544,70 @@ version 1.0.5g [December 7, 1999]
Added "translated_key" to png_text structure and png_write_iTXt().
Added code in pngwrite.c to work around a newly discovered zlib bug.
version 1.0.5h [December 10, 1999]
NOTE: regarding the not for version 1.0.5e, the following must also
NOTE: regarding the note for version 1.0.5e, the following must also
be included in your code:
png_text[i].translated_key = NULL;
Unknown chunk handling is now supported.
Option to eliminate all floating point support was added. Some new
fixed-point functions such as png_set_gAMA_fixed() were added.
Expanded tabs and removed trailing blanks in source files.
version 1.0.5i [December 13, 1999]
Added some type casts to silence compiler warnings.
Renamed "png_free_spalette" to "png_free_spalettes" for consistency.
Removed leading blanks from a #define in pngvcrd.c
Added some parameters to the new png_set_keep_unknown_chunks() function.
Added a test for up->location != 0 in the first instance of writing
unknown chunks in pngwrite.c
Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to
prevent recursion.
Added png_free_hIST() function.
Various patches to fix bugs in the sCAL and integer cHRM processing,
and to add some convenience macros for use with sCAL.
version 1.0.5j [December 21, 1999]
Changed "unit" parameter of png_write_sCAL from png_byte to int, to work
around buggy compilers.
Added new type "png_fixed_point" for integers that hold float*100000 values
Restored backward compatibility of tEXt/zTXt chunk processing:
Restored the first four members of png_text to the same order as v.1.0.5d.
Added members "lang_key" and "itxt_length" to png_text struct. Set
text_length=0 when "text" contains iTXt data. Use the "compression"
member to distinguish among tEXt/zTXt/iTXt types. Added
PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros.
The "Note" above, about backward incompatibility of libpng-1.0.5e, no
longer applies.
Fixed png_read|write_iTXt() to read|write parameters in the right order,
and to write the iTXt chunk after IDAT if it appears in the end_ptr.
Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs)
Reversed the order of trying to write floating-point and fixed-point gAMA.
version 1.0.5k [December 27, 1999]
Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))"
Added png_handle_as_unknown() function (Glenn)
Added png_free_chunk_list() function and chunk_list and num_chunk_list members
of png_ptr.
Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE.
Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings
about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored)
Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR).
Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is.
Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP().
version 1.0.5l [January 1, 2000]
Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr()
for setting a callback function to handle unknown chunks and for
retrieving the associated user pointer (Glenn).
version 1.0.5m [January 7, 2000]
Added high-level functions png_read_png(), png_write_png(), png_free_pixels().
version 1.0.5n [January 9, 2000]
Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its
own memory for info_ptr->palette. This makes it safe for the calling
application to free its copy of the palette any time after it calls
png_set_PLTE().
version 1.0.5o [January 20, 2000]
Cosmetic changes only (removed some trailing blanks and TABs)
version 1.0.5p [January 31, 2000]
Renamed pngdll.mak to makefile.bd32
Cosmetic changes in pngtest.c
version 1.0.5q [February 5, 2000]
Relocated the makefile.solaris warning about PATH problems.
Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg)
Revised makefile.gcmmx
Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros
Installing libpng version 1.0.5h - December 10, 1999
Installing libpng version 1.0.5q - February 5, 2000
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be
......@@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.0.5h" or "lpng103" and "zlib-1.1.3"
might be called "libpng-1.0.5q" or "lpng103" and "zlib-1.1.3"
or "zlib113") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
......@@ -36,6 +36,10 @@ Your directory structure should look like this:
contrib
etc.
If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats.
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.
......@@ -51,8 +55,10 @@ include
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5h)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5h)
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5q)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5q)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5q,
uses assembler code tuned for Intel MMX platform)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
......@@ -61,20 +67,20 @@ include
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.borland => Borland makefile
makefile.borland => Borland makefile (uses bcc)
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
makefile.turboc3 => Turbo C 3.0 makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and later (uses
assembler code)
assembler code tuned for Intel MMX platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later (does
not use assembler code)
makefile.turboc3 => Turbo C 3.0 makefile
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
......
......@@ -38,6 +38,9 @@ Known bugs and suggested enhancements in libpng-1.0.5
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
functions will be needed.
Much of this was completed in libpng-1.0.5h, but gamma compensation
is not yet done in fixed-point arithmetic.
4. October 1999 -- BUG
pngvcrd.c is failing for interlaced PNGs that have empty passes.
......@@ -64,4 +67,10 @@ Known bugs and suggested enhancements in libpng-1.0.5
is not backward compatible (the lang member was added, and the
translated_key member was added to libpng-1.0.5g)
STATUS: Will be fixed before the next public release.
STATUS: Fixed in libpng-1.0.5j/1.1.0
7. December 1999 -- BUG
The new pnggccrd.c has syntax errors when compiled with gcc.
STATUS: Under investigation.
......@@ -4,8 +4,8 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
(libpng versions 0.5, May 1995, through 0.89c, May 1996)
Copyright (c) 1996, 1997 Andreas Dilger
(libpng versions 0.90, December 1996, through 0.96, May 1997)
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
(libpng versions 0.97, January 1998, through 1.0.5h, December 10, 1999)
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
(libpng versions 0.97, January 1998, through 1.0.5q, February 5, 2000)
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
......@@ -63,9 +63,9 @@ boxes and the like:
Also, the PNG logo (in PNG format, of course) is supplied in the
file "pngnow.png".
Libpng is OSI Certified Open Source Software. OSI Certified is a
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
randeg@alum.rpi.edu
December 10, 1999
February 5, 2000
README for libpng 1.0.5h - December 10, 1999 (shared library 2.1)
README for libpng 1.0.5q - February 5, 2000 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
Libpng comes in two distribution formats. Get libpng-*.tar.gz if you
want UNIX-style line endings in the text files, or lpng*.zip if you want
DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in
extensive use and testing since mid-1995. By late 1997 it had
......@@ -171,9 +175,12 @@ Files in this distribution:
makefile.sgi => Silicon Graphics IRIX makefile
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng.so.2.1.0.5h)
(gcc, creates libpng.so.2.1.0.5q)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng.so.2.1.0.5h)
(gcc, creates libpng.so.2.1.0.5q)
makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.5q, uses assembler code
tuned for Intel MMX platform)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
......@@ -183,20 +190,21 @@ Files in this distribution:
scripts/SCOPTIONS.ppc)
makefile.atari => Atari makefile
makefile.beos => BEOS makefile for X86
makefile.borland => Borland makefile
makefile.borland => Borland makefile (uses bcc)
makefile.bd32 => To make a png32bd.dll with Borland C++ 4.5
makefile.turboc3 => Turbo C 3.0 makefile
build.bat => MS-DOS batch file for Borland compiler
makefile.dj2 => DJGPP 2 makefile
makefile.msc => Microsoft C makefile
makefile.vcawin32 => makefile for Microsoft Visual C++ 5.0 and
later (uses assembler code)
later (uses assembler code tuned for Intel MMX
platform)
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
later (does not use assembler code)
makefile.turboc3 => Turbo C 3.0 makefile
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
pngos2.def => OS/2 module definition file used by makefile.os2
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
makevms.com => VMS build script
pngdll.mak => To make a png32bd.dll with Borland C++ 4.5
pngdef.pas => Defines for a png32bd.dll with Borland C++ 4.5
SCOPTIONS.ppc => Used with smakefile.ppc
......
TODO - list of things to do for libpng:
Final bug fixes.
Fix problem with C++ and EXTERN "C".
Finish work on the no-floating-point version (including gamma compensation)
Better C++ wrapper/full C++ implementation?
Keep up with public chunks.
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Support for application-defined chunk handlers.
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
High-level API for reading images.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
......@@ -19,4 +17,3 @@ Better filter selection
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr.
Make a no-floating-point version.
Y2K compliance in libpng:
=========================
December 10, 1999
February 5, 2000
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.5h are Y2K compliant. It is my belief that earlier
upward through 1.0.5q are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer
that will hold years up to 65535. The other two hold the date in text
format, and will hold years up to 9999.
The integer is
"png_uint_16 year" in png_time_struct.
The strings are
"png_charp time_buffer" in png_struct and
"near_time_buffer", which is a local character string in png.c.
There are seven time-related functions:
png_convert_to_rfc_1123() in png.c
png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
png_convert_from_time_t() in pngwrite.c
......@@ -31,8 +31,8 @@
png_handle_tIME() in pngrutil.c, called in pngread.c
png_set_tIME() in pngset.c
png_write_tIME() in pngwutil.c, called in pngwrite.c
All appear to handle dates properly in a Y2K environment. The
All appear to handle dates properly in a Y2K environment. The
png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
......@@ -42,14 +42,14 @@
but this is not under our control. The libpng documentation has always
stated that it works with 4-digit years, and the APIs have been
documented as such.
The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
integer to hold the year, and can hold years as large as 65535.
zlib, upon which libpng depends, is also Y2K compliant. It contains
no date-related code.
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group
# Makefile for PngMinus (png2pnm and pnm2png)
# Linux / Unix
CC=cc -O -n32
LD=cc -O -n32
#CC=gcc -O
#LD=gcc -O
LB=ar
RM=rm
CP=cp
PNGPATH = /usr/local
PNGINC = $(PNGPATH)/include
PNGLIB = $(PNGPATH)/lib -lpng
# PNGLIB = $(PNGPATH)/libpng.a
ZPATH = /usr/local
ZINC = $(ZPATH)/include
ZLIB = $(ZPATH)/lib -lz
# ZLIB = $(ZPATH)/libz.a
CCFLAGS=-I$(PNGINC) -I$(ZINC)
LDFLAGS=-L$(PNGLIB) -L$(ZLIB) -lm
C=.c
O=.o
L=.a
E=
# dependencies
all: png2pnm$(E) pnm2png$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CCFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS)
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CCFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS)
clean:
$(RM) png2pnm$(O)
$(RM) pnm2png$(O)
$(RM) png2pnm$(E)
$(RM) pnm2png$(E)
# End of makefile for png2pnm / pnm2png
......@@ -77,7 +77,8 @@ int main(int argc, char *argv[])
if ((fp_al = fopen (argv[argi], "rb")) == NULL)
{
fprintf (stderr, "PNM2PNG\n");
fprintf (stderr, "Error: alpha-channel file %s does not exist\n", argv[argi]);
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
argv[argi]);
exit (1);
}
break;
......@@ -511,8 +512,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
for (i = 0; i < depth; i++)
mask = (mask << 1) | 0x01;
get_token (pnm_file, token);
sscanf (token, "%lu", &ret_value);
get_token (pnm_file, (char *) token);
sscanf ((const char *) token, "%lu", &ret_value);
ret_value &= mask;
......
......@@ -136,6 +136,19 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* If we have already read some of the signature */
png_set_sig_bytes(png_ptr, sig_read);
#ifdef hilevel
/*
* If you have enough memory to read in the entire image at once,
* and you need to specify only transforms that can be controlled
* with one of the PNG_TRANSFORM_* bits (this presently excludes
* dithering, filling, setting background, and doing gamma
* adjustment), then you can read the entire image (including
* pixels) into the info structure with this call:
*/
png_read_png(png_ptr, info_ptr, png_transforms, NULL);
#else
/* OK, you're doing it the hard way, with the lower-level functions */
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk). REQUIRED
*/
......@@ -275,7 +288,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
*/
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{
png_color8p sig_bit;
png_color_8p sig_bit;
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_shift(png_ptr, sig_bit);
......@@ -350,6 +363,9 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
#endif hilevel
/* At this point you have read the entire image */
/* clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
......@@ -530,7 +546,7 @@ void write_png(char *file_name /* , ... other image information ... */)
}
/* Set error handling. REQUIRED if you aren't supplying your own
* error hadnling functions in the png_create_write_struct() call.
* error handling functions in the png_create_write_struct() call.
*/
if (setjmp(png_ptr->jmpbuf))
{
......@@ -552,6 +568,15 @@ void write_png(char *file_name /* , ... other image information ... */)
/* where user_io_ptr is a structure you want available to the callbacks */
#endif no_streams /* only use one initialization method */
#ifdef hilevel
/* This is the easy way. Use it if you already have all the
* image info living info in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here.
*/
png_write_png(png_ptr, info_ptr, png_transforms, NULL);
#else
/* This is the hard way */
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
......@@ -567,6 +592,11 @@ void write_png(char *file_name /* , ... other image information ... */)
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, 256);
/* You can free the palette here if you like, since libpng has made its
own copy. In versions of libpng earlier than version 1.0.5n, it was
necessary to keep the palette until after png_write_end(), because
libpng was using the caller's copy. */
free(palette);
/* optional significant bit chunk */
/* if we are dealing with a grayscale image then */
......@@ -615,6 +645,9 @@ void write_png(char *file_name /* , ... other image information ... */)
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
* write_my_chunk();
* png_write_info(png_ptr, info_ptr);
*
* However, given the level of known- and unknown-chunk support in 1.1.0
* and up, this should no longer be necessary.
*/
/* Once we write out the header, the compression type on the text
......@@ -695,14 +728,20 @@ void write_png(char *file_name /* , ... other image information ... */)
#endif no_entire /* use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well.
* as well. Shouldn't be necessary in 1.1.0 and up as all the public
* chunks are supported and you can use png_set_unknown_chunks() to
* register unknown chunks into the info structure to be written out.
*/
/* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr);
#endif hilevel
/* if you malloced the palette, free it here */
free(info_ptr->palette);
/* if you malloced a palette and have not already freed it, free it
here (do *not* free libpng's copy of the palette in info_ptr->palette,
as recommended in versions 1.0.5m and earlier of this example; libpng
now takes care of that automatically). */
free(palette);
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
......
此差异已折叠。
此差异已折叠。
.TH LIBPNGPF 3 December 10, 1999
.TH LIBPNGPF 3 February 5, 2000
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5q
(private functions)
.SH SYNOPSIS
\fB#include <png.h>\fP
......@@ -187,6 +187,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
\fI\fB
\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
\fI\fB
\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
......@@ -505,9 +509,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
\fI\fB
\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, \fIpng_spalette_p
\fI\fBpalette\fP\fB);\fP
\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP
\fI\fB
......
.TH PNG 5 "December 10, 1999"
.TH PNG 5 "February 5, 2000"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
......@@ -20,7 +20,7 @@ platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
.LP
PNG 1.1 specification, January 1999:
PNG 1.2 specification, July 1999:
.IP
.br
http://www.cdrom.com/pub/png
......
/* png.c - location for general purpose libpng functions
*
* libpng version 1.0.5h - December 10, 1999
* libpng version 1.0.5q - February 5, 2000
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
*/
#define PNG_INTERNAL
#define PNG_NO_EXTERN
#include <assert.h>
#include "png.h"
/* Version information for C files. This had better match the version
......@@ -18,7 +19,7 @@
#ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */
char png_libpng_ver[12] = "1.0.5h";
char png_libpng_ver[12] = "1.0.5q";
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
......@@ -263,27 +264,43 @@ png_info_init(png_infop info_ptr)
void
png_free_text(png_structp png_ptr, png_infop info_ptr, int num)
{
if (num != -1)
{
if (info_ptr->text[num].key)
{
png_free(png_ptr, info_ptr->text[num].key);
info_ptr->text[num].key = NULL;
}
if (info_ptr->text[num].lang)
{
png_free(png_ptr, info_ptr->text[num].lang);
info_ptr->text[num].lang = NULL;
}
}
else if (info_ptr->text != NULL)
{
int i;
for (i = 0; i < info_ptr->num_text; i++)
png_free_text(png_ptr, info_ptr, i);
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
}
if (png_ptr == NULL || info_ptr == NULL)
return;
if (num != -1)
{
if (info_ptr->text[num].key)
{
png_free(png_ptr, info_ptr->text[num].key);
info_ptr->text[num].key = NULL;
}
}
else if (info_ptr->text != NULL)
{
int i;
if(info_ptr->text != NULL)
{
for (i = 0; i < info_ptr->num_text; i++)
png_free_text(png_ptr, info_ptr, i);
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
}
info_ptr->num_text=0;
}
}
#endif
#if defined(PNG_tRNS_SUPPORTED)
/* free any tRNS entry */
void
png_free_tRNS(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_tRNS)
{
png_free(png_ptr, info_ptr->trans);
info_ptr->valid &= ~PNG_INFO_tRNS;
}
}
#endif
......@@ -292,14 +309,18 @@ png_free_text(png_structp png_ptr, png_infop info_ptr, int num)
void
png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_sCAL)
{
png_free(png_ptr, info_ptr->scal_unit);
#ifdef PNG_FIXED_POINT_SUPPORTED
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, info_ptr->scal_s_width);
png_free(png_ptr, info_ptr->scal_s_height);
#else
if(png_ptr != NULL)
/* silence a compiler warning */ ;
#endif
info_ptr->valid &= ~PNG_INFO_sCAL;
info_ptr->valid &= ~PNG_INFO_sCAL;
}
}
#endif
......@@ -309,6 +330,8 @@ png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
void
png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_pCAL)
{
png_free(png_ptr, info_ptr->pcal_purpose);
......@@ -317,9 +340,9 @@ png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
{
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[i]);
}
png_free(png_ptr, info_ptr->pcal_params);
}
info_ptr->valid &= ~PNG_INFO_pCAL;
......@@ -328,10 +351,12 @@ png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
#endif
#if defined(PNG_iCCP_SUPPORTED)
/* free any pCAL entry */
/* free any iCCP entry */
void
png_free_iCCP(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_iCCP)
{
png_free(png_ptr, info_ptr->iccp_name);
......@@ -344,19 +369,25 @@ png_free_iCCP(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_sPLT_SUPPORTED)
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
void
png_free_spalette(png_structp png_ptr, png_infop info_ptr, int num)
png_free_spalettes(png_structp png_ptr, png_infop info_ptr, int num)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (num != -1)
{
png_free(png_ptr, info_ptr->splt_palettes[num].name);
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
info_ptr->valid &= ~PNG_INFO_sPLT;
}
else
{
png_uint_32 i;
int i;
if(info_ptr->splt_palettes_num == 0)
return;
for (i = 0; i < info_ptr->splt_palettes_num; i++)
png_free_spalette(png_ptr, info_ptr, num);
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
png_free_spalettes(png_ptr, info_ptr, i);
png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes_num = 0;
......@@ -366,8 +397,10 @@ png_free_spalette(png_structp png_ptr, png_infop info_ptr, int num)
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
void
png_free_unknown_chunk(png_structp png_ptr, png_infop info_ptr, int num)
png_free_unknown_chunks(png_structp png_ptr, png_infop info_ptr, int num)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (num != -1)
{
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
......@@ -375,15 +408,78 @@ png_free_unknown_chunk(png_structp png_ptr, png_infop info_ptr, int num)
}
else
{
png_uint_32 i;
int i;
if(info_ptr->unknown_chunks_num == 0)
return;
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
png_free_unknown_chunk(png_ptr, info_ptr, num);
for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
png_free_unknown_chunks(png_ptr, info_ptr, i);
png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks_num = 0;
}
}
void
png_free_chunk_list(png_structp png_ptr)
{
if (png_ptr == NULL)
return;
if (png_ptr->num_chunk_list)
{
png_free(png_ptr, png_ptr->chunk_list);
png_ptr->num_chunk_list=0;
}
}
#endif
#if defined(PNG_hIST_SUPPORTED)
/* free any hIST entry */
void
png_free_hIST(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_hIST)
{
png_free(png_ptr, info_ptr->hist);
info_ptr->valid &= ~PNG_INFO_hIST;
}
}
#endif
/* free any PLTE entry that was internally allocated */
void
png_free_PLTE(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_PLTE)
{
if (info_ptr->valid & PNG_ALLOCATED_INFO_PLTE)
png_zfree(png_ptr, info_ptr->palette);
info_ptr->valid &= ~(PNG_INFO_PLTE|PNG_ALLOCATED_INFO_PLTE);
info_ptr->num_palette = 0;
}
}
#if defined(PNG_INFO_IMAGE_SUPPORTED)
/* free any image bits attached to the info structure */
void
png_free_pixels(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->valid & PNG_INFO_IDAT)
{
int row;
for (row = 0; row < (int)info_ptr->height; row++)
png_free(png_ptr, info_ptr->row_pointers[row]);
png_free(png_ptr, info_ptr->row_pointers);
info_ptr->valid &= ~PNG_INFO_IDAT;
}
}
#endif
/* This is an internal routine to free any memory that the info struct is
......@@ -397,6 +493,9 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_TEXT_SUPPORTED)
png_free_text(png_ptr, info_ptr, -1);
#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
png_free_tRNS(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
png_free_sCAL(png_ptr, info_ptr);
#endif
......@@ -407,10 +506,18 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
png_free_iCCP(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
png_free_spalette(png_ptr, info_ptr, -1);
png_free_spalettes(png_ptr, info_ptr, -1);
#endif
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_free_unknown_chunk(png_ptr, info_ptr, -1);
png_free_unknown_chunks(png_ptr, info_ptr, -1);
png_free_chunk_list(png_ptr);
#endif
#if defined(PNG_hIST_SUPPORTED)
png_free_hIST(png_ptr, info_ptr);
#endif
png_free_PLTE(png_ptr, info_ptr);
#if defined(PNG_INFO_IMAGE_SUPPORTED)
png_free_pixels(png_ptr, info_ptr);
#endif
png_info_init(info_ptr);
}
......@@ -489,10 +596,10 @@ png_charp
png_get_copyright(png_structp png_ptr)
{
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
return ("\n libpng version 1.0.5h - December 10, 1999\n\
return ("\n libpng version 1.0.5q - February 5, 2000\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
return ("");
}
......@@ -507,8 +614,8 @@ png_get_libpng_ver(png_structp png_ptr)
{
/* Version of *.c files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return("1.0.5h");
return("1.0.5h");
return("1.0.5q");
return("1.0.5q");
}
png_charp
......@@ -532,8 +639,25 @@ png_get_header_version(png_structp png_ptr)
/* Generate a compiler error if there is an old png.h in the search path. */
void
png_check_version
(version_1_0_5h png_h_is_not_version_1_0_5h)
(version_1_0_5q png_h_is_not_version_1_0_5q)
{
if(png_h_is_not_version_1_0_5h == NULL)
if(png_h_is_not_version_1_0_5q == NULL)
return;
}
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
{
/* check chunk_name and return "keep" value if it's on the list, else 0 */
int i;
png_bytep p;
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
return 0;
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
if (!png_memcmp(chunk_name, p, 4))
return ((int)*(p+4));
return 0;
}
#endif
此差异已折叠。
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1999 Glenn Randers-Pehrson
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
*
*/
......@@ -21,7 +21,7 @@
/* Set this in the makefile for gcc on Pentium, not in pngconf.h */
#ifdef PNG_USE_PNGGCCRD
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c
* (not available in libpng 1.0.5h).
* (not available in libpng 1.0.5q).
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
......
/* pngconf.h - machine configurable file for libpng
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
/* Any machine specific code is near the front of this file, so if you
......@@ -111,29 +111,35 @@
#include <sys/types.h>
#endif
#ifndef PNG_SETJMP_NOT_SUPPORTED
# define PNG_SETJMP_SUPPORTED
#endif
#ifdef PNG_SETJMP_SUPPORTED
/* This is an attempt to force a single setjmp behaviour on Linux. If
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
*/
#ifdef __linux__
#ifdef _BSD_SOURCE
#define _PNG_SAVE_BSD_SOURCE
#undef _BSD_SOURCE
#endif
#ifdef _SETJMP_H
__png.h__ already includes setjmp.h
__dont__ include it again
#endif
# ifdef __linux__
# ifdef _BSD_SOURCE
# define _PNG_SAVE_BSD_SOURCE
# undef _BSD_SOURCE
# endif
# ifdef _SETJMP_H
__png.h__ already includes setjmp.h
__dont__ include it again
# endif
#endif /* __linux__ */
/* include setjmp.h for error handling */
#include <setjmp.h>
#ifdef __linux__
#ifdef _PNG_SAVE_BSD_SOURCE
#define _BSD_SOURCE
#undef _PNG_SAVE_BSD_SOURCE
#endif
#endif /* __linux__ */
# ifdef __linux__
# ifdef _PNG_SAVE_BSD_SOURCE
# define _BSD_SOURCE
# undef _PNG_SAVE_BSD_SOURCE
# endif
# endif /* __linux__ */
#endif /* PNG_SETJMP_SUPPORTED */
#ifdef BSD
#include <strings.h>
......@@ -158,6 +164,7 @@ __dont__ include it again
* them inside an appropriate ifdef/endif pair for portability.
*/
#if !defined(PNG_NO_FLOATING_POINT_SUPPORTED)
#if defined(MACOS)
/* We need to check that <math.h> hasn't already been included earlier
* as it seems it doesn't agree with <fp.h>, yet we should really use
......@@ -169,6 +176,7 @@ __dont__ include it again
#else
#include <math.h>
#endif
#endif
/* Codewarrior on NT has linking problems without this. */
#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
......@@ -473,209 +481,246 @@ __dont__ include it again
#endif
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#ifdef PNG_NO_READ_TEXT
# define PNG_NO_READ_iTXt
# define PNG_NO_READ_tEXt
# define PNG_NO_READ_zTXt
#endif
#ifndef PNG_NO_READ_bKGD
#define PNG_READ_bKGD_SUPPORTED
#define PNG_bKGD_SUPPORTED
# define PNG_READ_bKGD_SUPPORTED
# define PNG_bKGD_SUPPORTED
#endif
#ifndef PNG_NO_READ_cHRM
#define PNG_READ_cHRM_SUPPORTED
#define PNG_cHRM_SUPPORTED
# define PNG_READ_cHRM_SUPPORTED
# define PNG_cHRM_SUPPORTED
#endif
#ifndef PNG_NO_READ_gAMA
#define PNG_READ_gAMA_SUPPORTED
#define PNG_gAMA_SUPPORTED
# define PNG_READ_gAMA_SUPPORTED
# define PNG_gAMA_SUPPORTED
#endif
#ifndef PNG_NO_READ_hIST
#define PNG_READ_hIST_SUPPORTED
#define PNG_hIST_SUPPORTED
# define PNG_READ_hIST_SUPPORTED
# define PNG_hIST_SUPPORTED
#endif
#ifndef PNG_NO_READ_iCCP
#define PNG_READ_iCCP_SUPPORTED
#define PNG_iCCP_SUPPORTED
# define PNG_READ_iCCP_SUPPORTED
# define PNG_iCCP_SUPPORTED
#endif
#ifndef PNG_NO_READ_iTXt
#define PNG_READ_iTXt_SUPPORTED
#define PNG_iTXt_SUPPORTED
# define PNG_READ_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_oFFs
#define PNG_READ_oFFs_SUPPORTED
#define PNG_oFFs_SUPPORTED
# define PNG_READ_oFFs_SUPPORTED
# define PNG_oFFs_SUPPORTED
#endif
#ifndef PNG_NO_READ_pCAL
#define PNG_READ_pCAL_SUPPORTED
#define PNG_pCAL_SUPPORTED
# define PNG_READ_pCAL_SUPPORTED
# define PNG_pCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_sCAL
#define PNG_READ_sCAL_SUPPORTED
#define PNG_sCAL_SUPPORTED
# define PNG_READ_sCAL_SUPPORTED
# define PNG_sCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_pHYs
#define PNG_READ_pHYs_SUPPORTED
#define PNG_pHYs_SUPPORTED
# define PNG_READ_pHYs_SUPPORTED
# define PNG_pHYs_SUPPORTED
#endif
#ifndef PNG_NO_READ_sBIT
#define PNG_READ_sBIT_SUPPORTED
#define PNG_sBIT_SUPPORTED
# define PNG_READ_sBIT_SUPPORTED
# define PNG_sBIT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sPLT
#define PNG_READ_sPLT_SUPPORTED
#define PNG_sPLT_SUPPORTED
# define PNG_READ_sPLT_SUPPORTED
# define PNG_sPLT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sRGB
#define PNG_READ_sRGB_SUPPORTED
#define PNG_sRGB_SUPPORTED
# define PNG_READ_sRGB_SUPPORTED
# define PNG_sRGB_SUPPORTED
#endif
#ifndef PNG_NO_READ_tEXt
#define PNG_READ_tEXt_SUPPORTED
#define PNG_tEXt_SUPPORTED
# define PNG_READ_tEXt_SUPPORTED
# define PNG_tEXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_tIME
#define PNG_READ_tIME_SUPPORTED
#define PNG_tIME_SUPPORTED
# define PNG_READ_tIME_SUPPORTED
# define PNG_tIME_SUPPORTED
#endif
#ifndef PNG_NO_READ_tRNS
#define PNG_READ_tRNS_SUPPORTED
#define PNG_tRNS_SUPPORTED
# define PNG_READ_tRNS_SUPPORTED
# define PNG_tRNS_SUPPORTED
#endif
#ifndef PNG_NO_READ_zTXt
#define PNG_READ_zTXt_SUPPORTED
#define PNG_zTXt_SUPPORTED
# define PNG_READ_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_USER_CHUNKS
# define PNG_READ_USER_CHUNKS_SUPPORTED
# define PNG_USER_CHUNKS_SUPPORTED
# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
# undef PNG_NO_READ_UNKNOWN_CHUNKS
# endif
# ifdef PNG_NO_HANDLE_AS_UNKNOWN
# undef PNG_NO_HANDLE_AS_UNKNOWN
# endif
#endif
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#ifndef PNG_NO_READ_OPT_PLTE
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
#endif /* PLTE chunk in RGB and RGBA images */
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
#endif /* optional PLTE chunk in RGB and RGBA images */
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
defined(PNG_READ_zTXt_SUPPORTED)
#define PNG_READ_TEXT_SUPPORTED
#define PNG_TEXT_SUPPORTED
# define PNG_READ_TEXT_SUPPORTED
# define PNG_TEXT_SUPPORTED
#endif
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_WRITE_bKGD
#define PNG_WRITE_bKGD_SUPPORTED
#ifndef PNG_bKGD_SUPPORTED
# define PNG_bKGD_SUPPORTED
#ifdef PNG_NO_WRITE_TEXT
# define PNG_NO_WRITE_iTXt
# define PNG_NO_WRITE_tEXt
# define PNG_NO_WRITE_zTXt
#endif
#ifndef PNG_NO_WRITE_bKGD
# define PNG_WRITE_bKGD_SUPPORTED
# ifndef PNG_bKGD_SUPPORTED
# define PNG_bKGD_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_cHRM
#define PNG_WRITE_cHRM_SUPPORTED
#ifndef PNG_cHRM_SUPPORTED
# define PNG_cHRM_SUPPORTED
#endif
# define PNG_WRITE_cHRM_SUPPORTED
# ifndef PNG_cHRM_SUPPORTED
# define PNG_cHRM_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_gAMA
#define PNG_WRITE_gAMA_SUPPORTED
#ifndef PNG_gAMA_SUPPORTED
# define PNG_gAMA_SUPPORTED
#endif
# define PNG_WRITE_gAMA_SUPPORTED
# ifndef PNG_gAMA_SUPPORTED
# define PNG_gAMA_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_hIST
#define PNG_WRITE_hIST_SUPPORTED
#ifndef PNG_hIST_SUPPORTED
# define PNG_hIST_SUPPORTED
#endif
# define PNG_WRITE_hIST_SUPPORTED
# ifndef PNG_hIST_SUPPORTED
# define PNG_hIST_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_iCCP
#define PNG_WRITE_iCCP_SUPPORTED
#ifndef PNG_iCCP_SUPPORTED
# define PNG_iCCP_SUPPORTED
#endif
# define PNG_WRITE_iCCP_SUPPORTED
# ifndef PNG_iCCP_SUPPORTED
# define PNG_iCCP_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_iTXt
#define PNG_WRITE_iTXt_SUPPORTED
#ifndef PNG_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED
#endif
# define PNG_WRITE_iTXt_SUPPORTED
# ifndef PNG_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_oFFs
#define PNG_WRITE_oFFs_SUPPORTED
#ifndef PNG_oFFs_SUPPORTED
# define PNG_oFFs_SUPPORTED
#endif
# define PNG_WRITE_oFFs_SUPPORTED
# ifndef PNG_oFFs_SUPPORTED
# define PNG_oFFs_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_pCAL
#define PNG_WRITE_pCAL_SUPPORTED
#ifndef PNG_pCAL_SUPPORTED
# define PNG_pCAL_SUPPORTED
#endif
# define PNG_WRITE_pCAL_SUPPORTED
# ifndef PNG_pCAL_SUPPORTED
# define PNG_pCAL_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_sCAL
#define PNG_WRITE_sCAL_SUPPORTED
#ifndef PNG_sCAL_SUPPORTED
# define PNG_sCAL_SUPPORTED
#endif
# define PNG_WRITE_sCAL_SUPPORTED
# ifndef PNG_sCAL_SUPPORTED
# define PNG_sCAL_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_pHYs
#define PNG_WRITE_pHYs_SUPPORTED
#ifndef PNG_pHYs_SUPPORTED
# define PNG_pHYs_SUPPORTED
#endif
# define PNG_WRITE_pHYs_SUPPORTED
# ifndef PNG_pHYs_SUPPORTED
# define PNG_pHYs_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_sBIT
#define PNG_WRITE_sBIT_SUPPORTED
#ifndef PNG_sBIT_SUPPORTED
# define PNG_sBIT_SUPPORTED
#endif
# define PNG_WRITE_sBIT_SUPPORTED
# ifndef PNG_sBIT_SUPPORTED
# define PNG_sBIT_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_sPLT
#define PNG_WRITE_sPLT_SUPPORTED
#ifndef PNG_sPLT_SUPPORTED
# define PNG_sPLT_SUPPORTED
#endif
# define PNG_WRITE_sPLT_SUPPORTED
# ifndef PNG_sPLT_SUPPORTED
# define PNG_sPLT_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_sRGB
#define PNG_WRITE_sRGB_SUPPORTED
#ifndef PNG_sRGB_SUPPORTED
# define PNG_sRGB_SUPPORTED
#endif
# define PNG_WRITE_sRGB_SUPPORTED
# ifndef PNG_sRGB_SUPPORTED
# define PNG_sRGB_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_tEXt
#define PNG_WRITE_tEXt_SUPPORTED
#ifndef PNG_tEXt_SUPPORTED
# define PNG_tEXt_SUPPORTED
#endif
# define PNG_WRITE_tEXt_SUPPORTED
# ifndef PNG_tEXt_SUPPORTED
# define PNG_tEXt_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_tIME
#define PNG_WRITE_tIME_SUPPORTED
#ifndef PNG_tIME_SUPPORTED
# define PNG_tIME_SUPPORTED
#endif
# define PNG_WRITE_tIME_SUPPORTED
# ifndef PNG_tIME_SUPPORTED
# define PNG_tIME_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_tRNS
#define PNG_WRITE_tRNS_SUPPORTED
#ifndef PNG_tRNS_SUPPORTED
# define PNG_tRNS_SUPPORTED
#endif
# define PNG_WRITE_tRNS_SUPPORTED
# ifndef PNG_tRNS_SUPPORTED
# define PNG_tRNS_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_zTXt
#define PNG_WRITE_zTXt_SUPPORTED
#ifndef PNG_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED
#endif
# define PNG_WRITE_zTXt_SUPPORTED
# ifndef PNG_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED
# endif
#endif
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
#endif
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
# endif
#endif
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_WRITE_zTXt_SUPPORTED)
#define PNG_WRITE_TEXT_SUPPORTED
#ifndef PNG_TEXT_SUPPORTED
# define PNG_TEXT_SUPPORTED
#endif
# define PNG_WRITE_TEXT_SUPPORTED
# ifndef PNG_TEXT_SUPPORTED
# define PNG_TEXT_SUPPORTED
# endif
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
/* Turn this off to disable png_read_png() and
* png_write_png() and leave the image_bits member
* out of the info structure.
*/
#ifndef PNG_NO_INFO_IMAGE
# define PNG_INFO_IMAGE_SUPPORTED
#endif
/* need the time information for reading tIME chunks */
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
#include <time.h>
#if defined(PNG_tIME_SUPPORTED)
# include <time.h>
#endif
/* Some typedefs to get us started. These should be safe on most of the
......@@ -758,6 +803,10 @@ typedef size_t png_size_t;
#define FARDATA
#endif
/* Typedef for floating-point numbers that are converted
to fixed-point with a multiple of 100,000, e.g., int_gamma */
typedef png_int_32 png_fixed_point;
/* Add typedefs for pointers */
typedef void FAR * png_voidp;
typedef png_byte FAR * png_bytep;
......@@ -767,6 +816,7 @@ typedef png_uint_16 FAR * png_uint_16p;
typedef png_int_16 FAR * png_int_16p;
typedef PNG_CONST char FAR * png_const_charp;
typedef char FAR * png_charp;
typedef png_fixed_point FAR * png_fixed_point_p;
#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * png_doublep;
#endif
......@@ -779,6 +829,7 @@ typedef png_uint_16 FAR * FAR * png_uint_16pp;
typedef png_int_16 FAR * FAR * png_int_16pp;
typedef PNG_CONST char FAR * FAR * png_const_charpp;
typedef char FAR * FAR * png_charpp;
typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * FAR * png_doublepp;
#endif
......@@ -848,6 +899,10 @@ typedef z_stream FAR * png_zstreamp;
* that are passed far data must be model independent.
*/
#ifndef PNG_ABORT
# define PNG_ABORT() abort()
#endif
#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
/* use this to make far-to-near assignments */
# define CHECK 1
......
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all error handling. Users who
* need special error handling are expected to write replacement functions
......@@ -67,21 +67,26 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
{
int iout = 0, iin = 0;
while (iin < 4) {
while (iin < 4)
{
int c = png_ptr->chunk_name[iin++];
if (isnonalpha(c)) {
if (isnonalpha(c))
{
buffer[iout++] = '[';
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
buffer[iout++] = png_digit[c & 0xf];
buffer[iout++] = png_digit[c & 0x0f];
buffer[iout++] = ']';
} else {
}
else
{
buffer[iout++] = (png_byte)c;
}
}
if (message == NULL)
buffer[iout] = 0;
else {
else
{
buffer[iout++] = ':';
buffer[iout++] = ' ';
png_memcpy(buffer+iout, message, 64);
......@@ -117,14 +122,18 @@ png_default_error(png_structp png_ptr, png_const_charp message)
fprintf(stderr, "libpng error: %s\n", message);
#endif
#ifdef USE_FAR_KEYWORD
#ifdef PNG_SETJMP_SUPPORTED
# ifdef USE_FAR_KEYWORD
{
jmp_buf jmpbuf;
png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf));
longjmp(jmpbuf, 1);
}
#else
# else
longjmp(png_ptr->jmpbuf, 1);
# endif
#else
PNG_ABORT();
#endif
}
......
此差异已折叠。
/* pngget.c - retrieval of values from info struct
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
......@@ -277,7 +277,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
{
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL)
......@@ -304,7 +304,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
return (retval);
}
#endif /* PNG_READ_pHYs_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS $$ PNG_FLOATING_POINT_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
/* png_get_channels really belongs in here, too, but it's been around longer */
......@@ -378,9 +378,9 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *white_x, png_uint_32 *white_y, png_uint_32 *red_x,
png_uint_32 *red_y, png_uint_32 *green_x, png_uint_32 *green_y,
png_uint_32 *blue_x, png_uint_32 *blue_y)
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
png_fixed_point *blue_x, png_fixed_point *blue_y)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
{
......@@ -423,10 +423,9 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
return (0);
}
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *int_file_gamma)
png_fixed_point *int_file_gamma)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& int_file_gamma != NULL)
......@@ -438,7 +437,6 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
return (0);
}
#endif
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
png_uint_32
......@@ -459,7 +457,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_uint_32
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charpp name, int *compression_type,
png_charpp profile, png_int_32 *proflen)
png_charpp profile, png_uint_32 *proflen)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
&& name != NULL && profile != NULL && proflen != NULL)
......@@ -477,7 +475,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
}
#endif
#if defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
#if defined(PNG_READ_sPLT_SUPPORTED)
png_uint_32
png_get_spalettes(png_structp png_ptr, png_infop info_ptr,
png_spalette_pp spalettes)
......@@ -573,8 +571,8 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
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)
{
png_debug1(1, "in %s retrieval function\n", "pCAL");
......@@ -595,9 +593,10 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
png_charpp unit, double *width, double *height)
int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL))
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_pixel_width;
......@@ -606,12 +605,14 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
}
return(0);
}
#endif
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_charpp unit, png_charpp width, png_charpp height)
int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL))
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width;
......@@ -621,6 +622,8 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
return(0);
}
#endif
#endif
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
png_uint_32
......@@ -629,7 +632,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
{
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL)
......@@ -656,8 +660,8 @@ png_uint_32
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
int *num_palette)
{
if (png_ptr != NULL && 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;
......@@ -672,8 +676,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 (png_ptr != NULL && 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);
......@@ -707,8 +711,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 (png_ptr != NULL && 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);
......@@ -724,7 +728,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
{
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
{
png_debug1(1, "in %s retrieval function\n", "tRNS");
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
......@@ -775,3 +779,12 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
return png_ptr->rgb_to_gray_status;
}
#endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
png_voidp
png_get_user_chunk_ptr(png_structp png_ptr)
{
return (png_ptr->user_chunk_ptr);
}
#endif
/* pngmem.c - stub functions for memory allocation
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all memory allocation. Users who
* need special memory handling are expected to supply replacement
......
pngnow.png

2.0 KB | W: | H:

pngnow.png

2.0 KB | W: | H:

pngnow.png
pngnow.png
pngnow.png
pngnow.png
  • 2-up
  • Swipe
  • Onion skin
/* pngpread.c - read a png file in push mode
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
......@@ -151,27 +151,30 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_hIST_SUPPORTED)
PNG_hIST;
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
PNG_iCCP;
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
PNG_iTXt;
#endif
#if defined(PNG_READ_oFFs_SUPPORTED)
PNG_oFFs;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
PNG_pCAL;
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
PNG_pHYs;
#endif
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
PNG_iCCP;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
PNG_sPLT;
#endif
......@@ -447,7 +450,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
}
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
{
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
}
......@@ -1023,6 +1026,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->lang = (char *)NULL;
text_ptr->key = key;
text_ptr->lang_key = (char *)NULL;
text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
......@@ -1201,8 +1205,9 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->lang = (char *)NULL;
text_ptr->key = key;
text_ptr->lang = (char *)NULL;
text_ptr->lang_key = (char *)NULL;
text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
......@@ -1246,6 +1251,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
void
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->buffer_size && png_ptr->current_text_left)
{
png_size_t text_size;
......@@ -1261,9 +1267,11 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
if (!(png_ptr->current_text_left))
{
png_textp text_ptr;
png_charp text;
png_charp lang;
png_charp key;
int comp_flag = 0;
png_charp lang;
png_charp lang_key;
png_charp text;
if (png_ptr->buffer_size < 4)
{
......@@ -1278,26 +1286,36 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
return;
#endif
lang = png_ptr->current_text;
key = png_ptr->current_text;
png_ptr->current_text = 0;
for (key = lang; *key; key++)
for (lang = key; *lang; lang++)
/* empty loop */ ;
if (key != lang + png_ptr->current_text_size)
key++;
if (lang != key + png_ptr->current_text_size)
lang++;
for (text = key; *text; text++)
comp_flag = *lang++;
lang++; /* skip comp_type, always zero */
for (lang_key = lang; *lang_key; lang_key++)
/* empty loop */ ;
lang_key++; /* skip NUL separator */
for (text = lang_key; *text; text++)
/* empty loop */ ;
if (text != key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->lang = lang;
text_ptr->compression = comp_flag + 2;
text_ptr->key = key;
text_ptr->lang = lang;
text_ptr->lang_key = lang_key;
text_ptr->text = text;
text_ptr->text_length = 0;
text_ptr->itxt_length = png_strlen(text);
png_set_text(png_ptr, info_ptr, text_ptr, 1);
......@@ -1307,25 +1325,70 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
#endif
/* This function is called when we haven't found a handler for this
* chunk. In the future we will have code here that can handle
* user-defined callback functions for unknown chunks before they are
* ignored or cause an error. If there isn't a problem with the
* chunk itself (ie a bad chunk name or a critical chunk), the chunk
* is (currently) silently ignored.
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk
* name or a critical chunk), the chunk is (currently) silently ignored.
*/
void
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_uint_32 skip=0;
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
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;
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
#endif
)
png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
}
png_push_crc_skip(png_ptr, length);
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
{
png_unknown_chunk chunk;
#ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr, "unknown chunk too large to fit in memory");
skip = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
#endif
strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length);
chunk.size = length;
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL)
{
/* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
png_free(png_ptr, chunk.data);
}
else
#endif
skip=length;
png_push_crc_skip(png_ptr, skip);
}
void
......
/* pngread.c - read a PNG file
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file contains routines that an application calls directly to
* read a PNG file or stream.
......@@ -34,9 +34,13 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif /* PNG_USER_MEM_SUPPORTED */
png_structp png_ptr;
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
jmp_buf jmpbuf;
#endif
#endif
png_debug(1, "in png_create_read_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
......@@ -47,6 +51,8 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
{
return (png_structp)NULL;
}
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
#else
......@@ -60,6 +66,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef USE_FAR_KEYWORD
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#endif
#endif
#ifdef PNG_USER_MEM_SUPPORTED
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
......@@ -110,17 +117,24 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
void
png_read_init(png_structp png_ptr)
{
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */
#endif
png_debug(1, "in png_read_init\n");
#ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif
/* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct));
#ifdef PNG_SETJMP_SUPPORTED
/* restore jump buffer */
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
#endif
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
......@@ -214,7 +228,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
......@@ -253,10 +267,29 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
*/
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_handle_PLTE(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
png_handle_IEND(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
png_ptr->mode |= PNG_HAVE_IDAT;
png_handle_unknown(png_ptr, info_ptr, length);
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_ptr->mode |= PNG_HAVE_PLTE;
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before IDAT");
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
!(png_ptr->mode & PNG_HAVE_PLTE))
png_error(png_ptr, "Missing PLTE before IDAT");
break;
}
}
#endif
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_handle_PLTE(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
if (!(png_ptr->mode & PNG_HAVE_IHDR))
......@@ -421,7 +454,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
switch (png_ptr->pass)
{
case 0:
if (png_ptr->row_number & 7)
if (png_ptr->row_number & 0x07)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
......@@ -431,7 +464,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
}
break;
case 1:
if ((png_ptr->row_number & 7) || png_ptr->width < 5)
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
if (dsp_row != NULL)
png_combine_row(png_ptr, dsp_row,
......@@ -441,7 +474,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
}
break;
case 2:
if ((png_ptr->row_number & 7) != 4)
if ((png_ptr->row_number & 0x07) != 4)
{
if (dsp_row != NULL && (png_ptr->row_number & 4))
png_combine_row(png_ptr, dsp_row,
......@@ -546,6 +579,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
if(png_ptr->row_buf[0])
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]));
......@@ -607,7 +641,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5q.
*/
void
......@@ -656,7 +690,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead.
*
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5q.
*/
void
png_read_image(png_structp png_ptr, png_bytepp image)
......@@ -743,7 +777,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_sBIT_SUPPORTED)
PNG_sBIT;
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
#if defined(PNG_READ_sCAL_SUPPORTED)
PNG_sCAL;
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
......@@ -776,6 +810,23 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
png_handle_IEND(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
png_error(png_ptr, "Too many IDAT's found");
}
else
png_ptr->mode |= PNG_AFTER_IDAT;
png_handle_unknown(png_ptr, info_ptr, length);
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_ptr->mode |= PNG_HAVE_PLTE;
}
#endif
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
/* Zero length IDATs are legal after the last IDAT has been
......@@ -788,8 +839,6 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
}
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_handle_PLTE(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
png_handle_IEND(png_ptr, info_ptr, length);
#if defined(PNG_READ_bKGD_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
png_handle_bKGD(png_ptr, info_ptr, length);
......@@ -933,7 +982,9 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
void
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
{
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp;
#endif
png_error_ptr error_fn;
png_error_ptr warning_fn;
png_voidp error_ptr;
......@@ -1020,7 +1071,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
/* Save the important info out of the png_struct, in case it is
* being used again.
*/
#ifdef PNG_SETJMP_SUPPORTED
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif
error_fn = png_ptr->error_fn;
warning_fn = png_ptr->warning_fn;
......@@ -1038,7 +1091,10 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_ptr->free_fn = free_fn;
#endif
#ifdef PNG_SETJMP_SUPPORTED
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
#endif
}
void
......@@ -1046,3 +1102,131 @@ png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
{
png_ptr->read_row_fn = read_row_fn;
}
#if defined(PNG_INFO_IMAGE_SUPPORTED)
void png_read_png(png_structp png_ptr, png_infop info_ptr,
int transforms,
voidp params)
{
int row;
if(transforms == 0 || params == (voidp)NULL)
/* quiet compiler warnings */ ;
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
/* invert the alpha channel from opacity to transparency */
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
png_set_invert_alpha(png_ptr);
#endif
/* The call to png_read_info() gives us all of the information from the
* PNG file before the first IDAT (image data chunk).
*/
png_read_info(png_ptr, info_ptr);
/* -------------- image transformations start here ------------------- */
#if defined(PNG_READ_16_TO_8_SUPPORTED)
/* tell libpng to strip 16 bit/color files down to 8 bits/color */
if (transforms & PNG_TRANSFORM_STRIP_16)
png_set_strip_16(png_ptr);
#endif
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* Strip alpha bytes from the input data without combining with the
* background (not recommended).
*/
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
png_set_strip_alpha(png_ptr);
#endif
#if defined(PNG_READ_PACK_SUPPORTED)
/* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
if (transforms & PNG_TRANSFORM_PACKING)
png_set_packing(png_ptr);
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
/* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing). */
if (transforms & PNG_TRANSFORM_PACKSWAP)
png_set_packswap(png_ptr);
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand paletted colors into true RGB triplets
* Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
* Expand paletted or RGB images with transparency to full alpha
* channels so the data will be available as RGBA quartets.
*/
if (transforms & PNG_TRANSFORM_EXPAND)
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr);
#endif
/* We don't handle background color or gamma transformation or dithering. */
#if defined(PNG_READ_INVERT_SUPPORTED)
/* invert monochrome files to have 0 as white and 1 as black */
if (transforms & PNG_TRANSFORM_INVERT_MONO)
png_set_invert_mono(png_ptr);
#endif
#if defined(PNG_READ_SHIFT_SUPPORTED)
/* If you want to shift the pixel values from the range [0,255] or
* [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
if ((transforms & PNG_TRANSFORM_SHIFT)
&& png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
{
png_color_8p sig_bit;
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
png_set_shift(png_ptr, sig_bit);
}
#endif
#if defined(PNG_READ_BGR_SUPPORTED)
/* flip the RGB pixels to BGR (or RGBA to BGRA) */
if (transforms & PNG_TRANSFORM_BGR)
png_set_bgr(png_ptr);
#endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
png_set_swap_alpha(png_ptr);
#endif
#if defined(PNG_READ_SWAP_SUPPORTED)
/* swap bytes of 16 bit files to least significant byte first */
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
png_set_swap(png_ptr);
#endif
/* We don't handle adding filler bytes */
/* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
*/
png_read_update_info(png_ptr, info_ptr);
/* -------------- image transformations end here ------------------- */
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
info_ptr->height * sizeof(png_bytep));
for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));
png_read_image(png_ptr, info_ptr->row_pointers);
info_ptr->valid |= PNG_INFO_IDAT;
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
}
#endif
/* pngrio.c - functions for data input
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all input. Users who need
* special handling are expected to write a function that has the same
......
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG.
......@@ -367,7 +367,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
{
int j, next_j;
if (num_new_palette & 1)
if (num_new_palette & 0x01)
{
j = p->left;
next_j = p->right;
......@@ -897,8 +897,8 @@ png_init_read_transformations(png_structp png_ptr)
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
/* No GAMMA transformation */
if (png_ptr->transformations & PNG_BACKGROUND &&
color_type == PNG_COLOR_TYPE_PALETTE)
if ((png_ptr->transformations & PNG_BACKGROUND) &&
(color_type == PNG_COLOR_TYPE_PALETTE))
{
int i;
int istop = (int)png_ptr->num_trans;
......@@ -931,7 +931,7 @@ png_init_read_transformations(png_structp png_ptr)
#if defined(PNG_READ_SHIFT_SUPPORTED)
if ((png_ptr->transformations & PNG_SHIFT) &&
color_type == PNG_COLOR_TYPE_PALETTE)
(color_type == PNG_COLOR_TYPE_PALETTE))
{
png_uint_16 i;
png_uint_16 istop = png_ptr->num_palette;
......@@ -1009,7 +1009,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#endif
#if defined(PNG_READ_16_TO_8_SUPPORTED)
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
info_ptr->bit_depth = 8;
#endif
......@@ -1026,7 +1026,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#endif
#if defined(PNG_READ_PACK_SUPPORTED)
if ((png_ptr->transformations & PNG_PACK) && info_ptr->bit_depth < 8)
if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
info_ptr->bit_depth = 8;
#endif
......@@ -1057,9 +1057,9 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_FILLER_SUPPORTED)
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
if (png_ptr->transformations & PNG_FILLER &&
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
if ((png_ptr->transformations & PNG_FILLER) &&
((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
(info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
info_ptr->channels++;
#endif
......@@ -1177,7 +1177,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* if gray -> RGB, do so now only if background is non-gray; else do later
* for performance reasons */
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
!(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
......@@ -1251,8 +1251,8 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* if gray -> RGB, do so now only if we did not do so above */
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
png_ptr->mode & PNG_BACKGROUND_IS_GRAY)
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
......@@ -1330,10 +1330,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
{
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = 7 - (int)((row_width + 7) & 7);
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0x1);
*dp = (png_byte)((*sp >> shift) & 0x01);
if (shift == 7)
{
shift = 0;
......@@ -1351,10 +1351,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = (int)((3 - ((row_width + 3) & 3)) << 1);
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0x3);
*dp = (png_byte)((*sp >> shift) & 0x03);
if (shift == 6)
{
shift = 0;
......@@ -1371,10 +1371,10 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
{
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = (int)((1 - ((row_width + 1) & 1)) << 2);
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0xf);
*dp = (png_byte)((*sp >> shift) & 0x0f);
if (shift == 4)
{
shift = 0;
......@@ -1674,9 +1674,15 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
*(--dp) = (png_byte)(255 - *(--sp));
/* This does nothing:
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
We can replace it with:
*/
sp-=3;
dp=sp;
}
}
/* This inverts the alpha channel in RRGGBBAA */
......@@ -1690,12 +1696,18 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(255 - *(--sp));
/* This does nothing:
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
We can replace it with:
*/
sp-=6;
dp=sp;
}
}
}
......@@ -1725,8 +1737,12 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{
*(--dp) = (png_byte)(255 - *(--sp));
*(--dp) = (png_byte)(255 - *(--sp));
/*
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*/
sp-=2;
dp=sp;
}
}
}
......@@ -2518,7 +2534,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 7;
for (i = 0; i < row_width; i++)
{
if ((png_uint_16)((*sp >> shift) & 0x1)
if ((png_uint_16)((*sp >> shift) & 0x01)
== trans_values->gray)
{
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
......@@ -2543,7 +2559,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 6;
for (i = 0; i < row_width; i++)
{
if ((png_uint_16)((*sp >> shift) & 0x3)
if ((png_uint_16)((*sp >> shift) & 0x03)
== trans_values->gray)
{
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
......@@ -2551,9 +2567,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
else
{
png_byte p = (png_byte)((*sp >> shift) & 0x3);
png_byte p = (png_byte)((*sp >> shift) & 0x03);
png_byte g = (png_byte)((gamma_table [p | (p << 2) |
(p << 4) | (p << 6)] >> 6) & 0x3);
(p << 4) | (p << 6)] >> 6) & 0x03);
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
*sp |= (png_byte)(g << shift);
}
......@@ -2573,7 +2589,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 6;
for (i = 0; i < row_width; i++)
{
if ((png_uint_16)((*sp >> shift) & 0x3)
if ((png_uint_16)((*sp >> shift) & 0x03)
== trans_values->gray)
{
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
......@@ -2599,7 +2615,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 4;
for (i = 0; i < row_width; i++)
{
if ((png_uint_16)((*sp >> shift) & 0xf)
if ((png_uint_16)((*sp >> shift) & 0x0f)
== trans_values->gray)
{
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
......@@ -2607,9 +2623,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
else
{
png_byte p = (png_byte)((*sp >> shift) & 0xf);
png_byte p = (png_byte)((*sp >> shift) & 0x0f);
png_byte g = (png_byte)((gamma_table[p |
(p << 4)] >> 4) & 0xf);
(p << 4)] >> 4) & 0x0f);
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
*sp |= (png_byte)(g << shift);
}
......@@ -2629,7 +2645,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 4;
for (i = 0; i < row_width; i++)
{
if ((png_uint_16)((*sp >> shift) & 0xf)
if ((png_uint_16)((*sp >> shift) & 0x0f)
== trans_values->gray)
{
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
......@@ -3362,10 +3378,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
{
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 7);
shift = 7 - (int)((row_width + 7) & 0x07);
for (i = 0; i < row_width; i++)
{
if ((*sp >> shift) & 0x1)
if ((*sp >> shift) & 0x01)
*dp = 1;
else
*dp = 0;
......@@ -3385,10 +3401,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
{
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0x3;
value = (*sp >> shift) & 0x03;
*dp = (png_byte)value;
if (shift == 6)
{
......@@ -3406,10 +3422,10 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
{
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
shift = (int)((row_width & 1) << 2);
shift = (int)((row_width & 0x01) << 2);
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0xf;
value = (*sp >> shift) & 0x0f;
*dp = (png_byte)value;
if (shift == 4)
{
......@@ -3508,10 +3524,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
gray = (png_uint_16)(gray*0xff);
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 7);
shift = 7 - (int)((row_width + 7) & 0x07);
for (i = 0; i < row_width; i++)
{
if ((*sp >> shift) & 0x1)
if ((*sp >> shift) & 0x01)
*dp = 0xff;
else
*dp = 0;
......@@ -3532,10 +3548,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
gray = (png_uint_16)(gray*0x55);
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0x3;
value = (*sp >> shift) & 0x03;
*dp = (png_byte)(value | (value << 2) | (value << 4) |
(value << 6));
if (shift == 6)
......@@ -3555,10 +3571,10 @@ png_do_expand(png_row_infop row_info, png_bytep row,
gray = (png_uint_16)(gray*0x11);
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
shift = (int)((1 - ((row_width + 1) & 1)) << 2);
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
for (i = 0; i < row_width; i++)
{
value = (*sp >> shift) & 0xf;
value = (*sp >> shift) & 0x0f;
*dp = (png_byte)(value | (value << 4));
if (shift == 4)
{
......@@ -3809,7 +3825,7 @@ png_build_gamma_table(png_structp png_ptr)
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
{
g = 1.0 / (png_ptr->gamma);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
......
/* pngtypes.h - array of chunk-types for libpng
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
/* Constant strings for known chunk types. If you need to add a chunk,
......@@ -25,6 +25,7 @@ PNG_oFFs;
PNG_pCAL;
PNG_pHYs;
PNG_sBIT;
PNG_sCAL;
PNG_sPLT;
PNG_sRGB;
PNG_tEXt;
......
......@@ -2,10 +2,10 @@
*
* For Intel x86 CPU and Microsoft Visual C++ compiler
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998, Intel Corporation
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* Contributed by Nirav Chhatrapati, Intel Corporation, 1998
* Interface to libpng contributed by Gilles Vollant, 1999
......@@ -33,6 +33,9 @@ static int mmxsupport()
{
int mmx_supported_local = 0;
_asm {
push ebx //CPUID will trash these
push ecx
push edx
pushfd //Save Eflag to stack
pop eax //Get Eflag from stack into eax
mov ecx, eax //Make another copy of Eflag in ecx
......@@ -70,7 +73,9 @@ static int mmxsupport()
NOT_SUPPORTED:
mov eax, mmx_supported_local //move return value to eax
pop edx //CPUID trashed these
pop ecx
pop ebx
}
//mmx_supported_local=0; // test code for force don't support MMX
......@@ -3653,7 +3658,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
#ifdef PNG_DEBUG
char filnm[6];
#endif
#define UseMMX 1
#define UseMMX 1
if (mmx_supported == 2)
mmx_supported = mmxsupport();
......
/* pngwio.c - functions for data output
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*
* This file provides a location for all output. Users who need
* special handling are expected to write functions that have the same
......
此差异已折叠。
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 1.0.5h - December 10, 1999
* libpng 1.0.5q - February 5, 2000
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
*/
#define PNG_INTERNAL
......@@ -140,7 +140,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
{
png_byte value;
value = (png_byte)(*sp & 0x3);
value = (png_byte)(*sp & 0x03);
v |= (value << shift);
if (shift == 0)
{
......@@ -172,7 +172,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
{
png_byte value;
value = (png_byte)(*sp & 0xf);
value = (png_byte)(*sp & 0x0f);
v |= (value << shift);
if (shift == 0)
......
此差异已折叠。
......@@ -31,7 +31,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.5h
PNGMIN = 1.0.5q
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
......
......@@ -14,7 +14,7 @@ ZLIBINC=../zlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.5h
PNGMIN = 1.0.5q
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=cc
......
此差异已折叠。
......@@ -34,7 +34,7 @@ RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.5h
PNGMIN = 1.0.5q
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
......
......@@ -25,7 +25,7 @@ RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.5h
PNGMIN = 1.0.5q
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
......
此差异已折叠。
......@@ -81,6 +81,7 @@ pngwutil$(O): png.h pngconf.h
$(CC) -c $(CFLAGS) $*.c $(ERRFILE)
libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3)
echo something to del > libpng.lib
del libpng.lib
lib /OUT:libpng.lib $(OBJS1) $(OBJS2) $(OBJS3)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册