summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ANNOUNCE45
-rw-r--r--CHANGES41
-rw-r--r--INSTALL8
-rw-r--r--KNOWNBUG16
-rw-r--r--LICENSE5
-rw-r--r--README6
-rw-r--r--TODO2
-rw-r--r--Y2KINFO4
-rw-r--r--contrib/gregbook/makefile.w322
-rw-r--r--contrib/gregbook/makevms.com12
-rw-r--r--contrib/gregbook/readpng.c6
-rw-r--r--contrib/gregbook/readpng2.c14
-rw-r--r--contrib/gregbook/readpng2.h2
-rw-r--r--contrib/gregbook/rpng-win.c32
-rw-r--r--contrib/gregbook/rpng-x.c26
-rw-r--r--contrib/gregbook/rpng2-win.c132
-rw-r--r--contrib/gregbook/rpng2-x.c104
-rw-r--r--contrib/gregbook/wpng.c44
-rw-r--r--contrib/gregbook/writepng.c8
-rw-r--r--contrib/pngminus/README4
-rw-r--r--contrib/pngminus/makevms.com8
-rw-r--r--contrib/pngminus/png2pnm.c12
-rw-r--r--contrib/pngminus/pnm2png.c14
-rw-r--r--example.c7
-rw-r--r--libpng.3247
-rw-r--r--libpng.txt163
-rw-r--r--libpngpf.352
-rw-r--r--png.52
-rw-r--r--png.c194
-rw-r--r--png.h697
-rw-r--r--pngasmrd.h4
-rw-r--r--pngconf.h133
-rw-r--r--pngerror.c2
-rw-r--r--pngget.c153
-rw-r--r--pngmem.c2
-rw-r--r--pngpread.c181
-rw-r--r--pngread.c74
-rw-r--r--pngrio.c4
-rw-r--r--pngrtran.c45
-rw-r--r--pngrutil.c796
-rw-r--r--pngset.c276
-rw-r--r--pngtest.c126
-rw-r--r--pngtrans.c2
-rw-r--r--pngtypes.h5
-rw-r--r--pngvcrd.c26
-rw-r--r--pngwio.c2
-rw-r--r--pngwrite.c171
-rw-r--r--pngwtran.c5
-rw-r--r--pngwutil.c710
-rw-r--r--scripts/makefile.beos2
-rw-r--r--scripts/makefile.dec2
-rw-r--r--scripts/makefile.hpux4
-rw-r--r--scripts/makefile.knr4
-rw-r--r--scripts/makefile.linux6
-rw-r--r--scripts/makefile.mips4
-rw-r--r--scripts/makefile.sco6
-rw-r--r--scripts/makefile.sgi4
-rw-r--r--scripts/makefile.solaris21
-rw-r--r--scripts/makefile.std4
-rw-r--r--scripts/makefile.sunos4
-rw-r--r--scripts/pngdef.pas44
-rw-r--r--scripts/pngos2.def14
62 files changed, 3720 insertions, 1025 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index a3acc589d..6b07d33d8 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
-Libpng 1.0.5d - November 29, 1999
+Libpng 1.0.5h - December 10, 1999
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.
@@ -33,14 +33,53 @@ version libpng-1.0.5c November 26, 1999
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
Removed some extraneous "-I" from contrib/pngminus/makefile.std
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
- Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
-version 1.0.5d [November 29, 1999]
+ Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
+version libpng-1.0.5d November 29, 1999
Add type cast (png_const_charp) two places in png.c
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
to applications a macro "PNG_USE_LOCAL_ARRAYS".
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
+version libpng-1.0.5e November 30, 1999
+ Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
+ structure; refactored the inflate/deflate support to make adding new chunks
+ 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. 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
+
+ #ifdef PNG_iTXt_SUPPORTED
+ png_text[i].lang = NULL;
+ #endif
+
+ Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
+ offsets (Eric S. Raymond).
+ Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
+ PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
+ macros, leaving the separate macros also available.
+ Removed comments on #endifs at the end of many short, non-nested #if-blocks.
+version libpng-1.0.5f December 6, 1999
+ Changed makefile.solaris to issue a warning about potential problems when
+ the ucb "ld" is in the path ahead of the ccs "ld".
+ Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
+ Added sCAL chunk support (Eric S. Raymond).
+version libpng-1.0.5g December 7, 1999
+ Fixed "png_free_spallettes" typo in png.h
+ Added code to handle new chunks in pngpread.c
+ 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
+ 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.
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index cb0443452..fef04733d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -503,7 +503,7 @@ version 1.0.5c [November 26, 1999]
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
Removed some extraneous "-I" from contrib/pngminus/makefile.std
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
- Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
+ Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
version 1.0.5d [November 29, 1999]
Add type cast (png_const_charp) two places in png.c
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
@@ -511,3 +511,42 @@ version 1.0.5d [November 29, 1999]
to applications a macro "PNG_USE_LOCAL_ARRAYS".
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
+version 1.0.5e [November 30, 1999]
+ Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
+ structure; refactored the inflate/deflate support to make adding new chunks
+ 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
+ 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
+
+ #ifdef PNG_iTXt_SUPPORTED
+ png_text[i].lang = NULL;
+ #endif
+
+ Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
+ offsets (Eric S. Raymond).
+ Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
+ PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
+ macros, leaving the separate macros also available.
+ Removed comments on #endifs at the end of many short, non-nested #if-blocks.
+version 1.0.5f [December 6, 1999]
+ Changed makefile.solaris to issue a warning about potential problems when
+ the ucb "ld" is in the path ahead of the ccs "ld".
+ Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
+ Added sCAL chunk support (Eric S. Raymond).
+version 1.0.5g [December 7, 1999]
+ Fixed "png_free_spallettes" typo in png.h
+ Added code to handle new chunks in pngpread.c
+ 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
+ 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.
diff --git a/INSTALL b/INSTALL
index b11bfe11b..73fac6cde 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
-Installing libpng version 1.0.5d - November 29, 1999
+Installing libpng version 1.0.5h - December 10, 1999
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.5d" or "lpng103" and "zlib-1.1.3"
+might be called "libpng-1.0.5h" 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:
@@ -51,8 +51,8 @@ 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.5d)
- makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5d)
+ 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.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
diff --git a/KNOWNBUG b/KNOWNBUG
index 7ac94d790..7dc036d00 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -14,8 +14,8 @@ Known bugs and suggested enhancements in libpng-1.0.5
Question whether i-- or --i is better.
STATUS: Under investigation, postponed until after
- libpng-1.0.5. About 160 loops will be turned around
- in libpng-1.0.Nn, for testing.
+ libpng-1.1.0. About 160 loops will be turned around
+ in libpng-1.1.Nn, for testing.
2. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
@@ -43,7 +43,7 @@ Known bugs and suggested enhancements in libpng-1.0.5
pngvcrd.c is failing for interlaced PNGs that have empty passes.
STATUS: A check for "width != 0" is required in several places.
- Fixed in libpng-1.0.5a/1.0.6
+ Fixed in libpng-1.0.5a/1.1.0
5. October 1999 -- BUG
@@ -56,4 +56,12 @@ Known bugs and suggested enhancements in libpng-1.0.5
text->key strings. Fix for the latter problem is to duplicate code
from png.c.
- Fixed in libpng-1.0.5a/1.0.6
+ Fixed in libpng-1.0.5a/1.1.0
+
+6. December 1999 -- new BUG
+
+ The png_text structure was modified in libpng-1.0.5e in a manner that
+ 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.
diff --git a/LICENSE b/LICENSE
index e9660329c..d6cc5ec85 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
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.5d, November 29, 1999)
+(libpng versions 0.97, January 1998, through 1.0.5h, December 10, 1999)
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
@@ -18,6 +18,7 @@ is defined as the following set of individuals:
Tom Lane
Dave Martindale
Glenn Randers-Pehrson
+ Eric S. Raymond
Greg Roelofs
Guy Eric Schalnat
Paul Schmidt
@@ -67,4 +68,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
randeg@alum.rpi.edu
-November 29, 1999
+December 10, 1999
diff --git a/README b/README
index c38cecea1..be96b14f7 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.5d - November 29, 1999 (shared library 2.1)
+README for libpng 1.0.5h - December 10, 1999 (shared library 2.1)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@@ -171,9 +171,9 @@ 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.5d)
+ (gcc, creates libpng.so.2.1.0.5h)
makefile.linux => Linux/ELF makefile
- (gcc, creates libpng.so.2.1.0.5d)
+ (gcc, creates libpng.so.2.1.0.5h)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile
diff --git a/TODO b/TODO
index 9c420bca5..b0cff064b 100644
--- a/TODO
+++ b/TODO
@@ -4,7 +4,6 @@ Final bug fixes.
Fix problem with C++ and EXTERN "C".
Better C++ wrapper/full C++ implementation?
Keep up with public chunks.
-sPLT chunk handling.
cHRM transformation.
Support for application-defined chunk handlers.
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
@@ -17,7 +16,6 @@ Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
-Optional palette (sPLT) creation.
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr.
diff --git a/Y2KINFO b/Y2KINFO
index 200ae083a..20554fe39 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
Y2K compliance in libpng:
=========================
- November 29, 1999
+ December 10, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
- upward through 1.0.5d are Y2K compliant. It is my belief that earlier
+ upward through 1.0.5h 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
diff --git a/contrib/gregbook/makefile.w32 b/contrib/gregbook/makefile.w32
index dbcec3b0b..e520ae75c 100644
--- a/contrib/gregbook/makefile.w32
+++ b/contrib/gregbook/makefile.w32
@@ -17,7 +17,7 @@
# "c:\windows\command.com /e:4096" as the program command line and set the
# working directory to this directory. Then double-click to open the new
# DOS-prompt window with a bigger environment and retry the commands above.
-#
+#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are in subdirectories at the same level as the current subdirectory
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
diff --git a/contrib/gregbook/makevms.com b/contrib/gregbook/makevms.com
index 5f7a9c6ca..2ee2eb694 100644
--- a/contrib/gregbook/makevms.com
+++ b/contrib/gregbook/makevms.com
@@ -45,20 +45,20 @@ $ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" -
$ write sys$output "Building rpng-x..."
$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" -
rpng-x.c readpng.h
-$ call make rpng-x.exe -
- "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
+$ call make rpng-x.exe -
+ "LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
rpng-x.obj readpng.obj
$ write sys$output "Building rpng2-x..."
$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" -
rpng2-x.c readpng2.h
-$ call make rpng2-x.exe -
- "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
+$ call make rpng2-x.exe -
+ "LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
rpng2-x.obj readpng2.obj
$ write sys$output "Building wpng..."
$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" -
wpng.c writepng.h
-$ call make wpng.exe -
- "LINK wpng,writepng,lib.opt/opt" -
+$ call make wpng.exe -
+ "LINK wpng,writepng,lib.opt/opt" -
wpng.obj writepng.obj
$ exit
$!
diff --git a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c
index 2d584fdcd..6dd720f24 100644
--- a/contrib/gregbook/readpng.c
+++ b/contrib/gregbook/readpng.c
@@ -32,8 +32,8 @@
#include <stdio.h>
#include <stdlib.h>
-#include "png.h" /* libpng header; includes zlib.h */
-#include "readpng.h" /* typedefs, common macros, public prototypes */
+#include "png.h" /* libpng header; includes zlib.h */
+#include "readpng.h" /* typedefs, common macros, public prototypes */
static png_structp png_ptr = NULL;
@@ -50,7 +50,7 @@ void readpng_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
-}
+}
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
diff --git a/contrib/gregbook/readpng2.c b/contrib/gregbook/readpng2.c
index fe7b0fabb..ee2d3d2da 100644
--- a/contrib/gregbook/readpng2.c
+++ b/contrib/gregbook/readpng2.c
@@ -30,10 +30,10 @@
---------------------------------------------------------------------------*/
-#include <stdlib.h> /* for exit() prototype */
+#include <stdlib.h> /* for exit() prototype */
-#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
-#include "readpng2.h" /* typedefs, common macros, public prototypes */
+#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
+#include "readpng2.h" /* typedefs, common macros, public prototypes */
/* local prototypes */
@@ -53,7 +53,7 @@ void readpng2_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
-}
+}
@@ -70,7 +70,7 @@ int readpng2_check_sig(uch *sig, int num)
int readpng2_init(mainprog_info *mainprog_ptr)
{
- png_structp png_ptr; /* note: temporary variables! */
+ png_structp png_ptr; /* note: temporary variables! */
png_infop info_ptr;
@@ -176,7 +176,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
mainprog_ptr = png_get_progressive_ptr(png_ptr);
- if (mainprog_ptr == NULL) { /* we be hosed */
+ if (mainprog_ptr == NULL) { /* we be hosed */
fprintf(stderr,
"readpng2 error: main struct not recoverable in info_callback.\n");
fflush(stderr);
@@ -408,7 +408,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
fflush(stderr);
mainprog_ptr = png_get_error_ptr(png_ptr);
- if (mainprog_ptr == NULL) { /* we are completely hosed now */
+ if (mainprog_ptr == NULL) { /* we are completely hosed now */
fprintf(stderr,
"readpng2 severe error: jmpbuf not recoverable; terminating.\n");
fflush(stderr);
diff --git a/contrib/gregbook/readpng2.h b/contrib/gregbook/readpng2.h
index 9d2244414..2ffd77635 100644
--- a/contrib/gregbook/readpng2.h
+++ b/contrib/gregbook/readpng2.h
@@ -61,7 +61,7 @@ typedef struct _mainprog_info {
uch *image_data;
uch **row_pointers;
jmp_buf jmpbuf;
- int passes; /* not used */
+ int passes; /* not used */
int rowbytes;
int channels;
int need_bgcolor;
diff --git a/contrib/gregbook/rpng-win.c b/contrib/gregbook/rpng-win.c
index 346013201..a75e609fa 100644
--- a/contrib/gregbook/rpng-win.c
+++ b/contrib/gregbook/rpng-win.c
@@ -53,7 +53,7 @@
/* #define DEBUG : this enables the Trace() macros */
-#include "readpng.h" /* typedefs, common macros, readpng prototypes */
+#include "readpng.h" /* typedefs, common macros, readpng prototypes */
/* could just include png.h, but this macro is the only thing we need
@@ -61,10 +61,10 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
-#define alpha_composite(composite, fg, alpha, bg) { \
- ush temp = ((ush)(fg)*(ush)(alpha) + \
- (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
- (composite) = (uch)((temp + (temp >> 8)) >> 8); \
+#define alpha_composite(composite, fg, alpha, bg) { \
+ ush temp = ((ush)(fg)*(ush)(alpha) + \
+ (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
+ (composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
@@ -78,7 +78,7 @@ LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
-static char *icon_name = PROGNAME; /* GRR: not (yet) used */
+static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename;
static FILE *infile;
@@ -104,15 +104,15 @@ static HWND global_hwnd;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
- char *args[1024]; /* arbitrary limit, but should suffice */
+ char *args[1024]; /* arbitrary limit, but should suffice */
char *p, *q, **argv = args;
int argc = 0;
int rc, alen, flen;
int error = 0;
int have_bg = FALSE;
- double LUT_exponent; /* just the lookup table */
- double CRT_exponent = 2.2; /* just the monitor */
- double default_display_exponent; /* whole display system */
+ double LUT_exponent; /* just the lookup table */
+ double CRT_exponent = 2.2; /* just the monitor */
+ double default_display_exponent; /* whole display system */
MSG msg;
@@ -150,7 +150,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
LUT_exponent = 1.8 / 2.61;
/*
if (some_mac_function_that_returns_gamma(&mac_gamma))
- LUT_exponent = mac_gamma / 2.61;
+ LUT_exponent = mac_gamma / 2.61;
*/
#else
LUT_exponent = 1.0; /* assume no LUT: most PCs */
@@ -371,7 +371,7 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*image_height)))
{
- return 4; /* fail */
+ return 4; /* fail */
}
/*---------------------------------------------------------------------------
@@ -477,7 +477,7 @@ static int rpng_win_display_image()
g = *src++;
b = *src++;
*dest++ = b;
- *dest++ = g; /* note reverse order */
+ *dest++ = g; /* note reverse order */
*dest++ = r;
}
} else /* if (image_channels == 4) */ {
@@ -582,15 +582,15 @@ LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
/* wait for the user to tell us when to quit */
case WM_CHAR:
- switch (wP) { /* only need one, so ignore repeat count */
+ switch (wP) { /* only need one, so ignore repeat count */
case 'q':
case 'Q':
- case 0x1B: /* Esc key */
+ case 0x1B: /* Esc key */
PostQuitMessage(0);
}
return 0;
- case WM_LBUTTONDOWN: /* another way of quitting */
+ case WM_LBUTTONDOWN: /* another way of quitting */
case WM_DESTROY:
PostQuitMessage(0);
return 0;
diff --git a/contrib/gregbook/rpng-x.c b/contrib/gregbook/rpng-x.c
index ee9ebb72b..5f0a8a1fb 100644
--- a/contrib/gregbook/rpng-x.c
+++ b/contrib/gregbook/rpng-x.c
@@ -54,18 +54,18 @@
/* #define DEBUG : this enables the Trace() macros */
-#include "readpng.h" /* typedefs, common macros, readpng prototypes */
+#include "readpng.h" /* typedefs, common macros, readpng prototypes */
/* could just include png.h, but this macro is the only thing we need
- * (name and typedefs changed to local versions); note that side effects
- * only happen with alpha (which could easily be avoided with
+ * (name and typedefs changed to local versions); note that side effects
+ * only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
-#define alpha_composite(composite, fg, alpha, bg) { \
- ush temp = ((ush)(fg)*(ush)(alpha) + \
- (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
- (composite) = (uch)((temp + (temp >> 8)) >> 8); \
+#define alpha_composite(composite, fg, alpha, bg) { \
+ ush temp = ((ush)(fg)*(ush)(alpha) + \
+ (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
+ (composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
@@ -123,9 +123,9 @@ int main(int argc, char **argv)
int rc, alen, flen;
int error = 0;
int have_bg = FALSE;
- double LUT_exponent; /* just the lookup table */
- double CRT_exponent = 2.2; /* just the monitor */
- double default_display_exponent; /* whole display system */
+ double LUT_exponent; /* just the lookup table */
+ double CRT_exponent = 2.2; /* just the monitor */
+ double default_display_exponent; /* whole display system */
XEvent e;
KeySym k;
@@ -222,7 +222,7 @@ int main(int argc, char **argv)
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error;
} else {
- if ((rc = readpng_init(infile, (long *)(&image_width),
+ if ((rc = readpng_init(infile, (long *)(&image_width),
(long *)(&image_height))) != 0) {
switch (rc) {
case 1:
@@ -408,11 +408,11 @@ static int rpng_x_create_window()
}
have_colormap = TRUE;
} else if (depth == 16) {
- RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
+ RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
GPixelShift = 15 - rpng_x_msb(GreenMask);
BPixelShift = 15 - rpng_x_msb(BlueMask);
} else /* if (depth > 16) */ {
- RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
+ RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
GPixelShift = rpng_x_msb(GreenMask) - 7;
BPixelShift = rpng_x_msb(BlueMask) - 7;
}
diff --git a/contrib/gregbook/rpng2-win.c b/contrib/gregbook/rpng2-win.c
index fd32ec4c8..66e682eef 100644
--- a/contrib/gregbook/rpng2-win.c
+++ b/contrib/gregbook/rpng2-win.c
@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------
- rpng2 - progressive-model PNG display program rpng2-win.c
+ rpng2 - progressive-model PNG display program rpng2-win.c
This program decodes and displays PNG files progressively, as if it were
a web browser (though the front end is only set up to read from files).
@@ -57,9 +57,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
+#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <time.h>
-#include <math.h> /* only for PvdM background code */
+#include <math.h> /* only for PvdM background code */
#include <windows.h>
/* all for PvdM background code: */
@@ -80,9 +80,9 @@
#define rgb2_max bg_bsat
#define rgb2_min bg_brot
-/* #define DEBUG */ /* this enables the Trace() macros */
+/* #define DEBUG */ /* this enables the Trace() macros */
-#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
+#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
/* could just include png.h, but this macro is the only thing we need
@@ -90,18 +90,18 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
-#define alpha_composite(composite, fg, alpha, bg) { \
- ush temp = ((ush)(fg)*(ush)(alpha) + \
- (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
- (composite) = (uch)((temp + (temp >> 8)) >> 8); \
+#define alpha_composite(composite, fg, alpha, bg) { \
+ ush temp = ((ush)(fg)*(ush)(alpha) + \
+ (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
+ (composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
-#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
- * block size corresponds roughly to a download
- * speed 10% faster than theoretical 33.6K maximum
- * (assuming 8 data bits, 1 stop bit and no other
- * overhead) */
+#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
+ * block size corresponds roughly to a download
+ * speed 10% faster than theoretical 33.6K maximum
+ * (assuming 8 data bits, 1 stop bit and no other
+ * overhead) */
/* local prototypes */
static void rpng2_win_init(void);
@@ -116,7 +116,7 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
-static char *icon_name = PROGNAME; /* GRR: not (yet) used */
+static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename;
static FILE *infile;
@@ -125,7 +125,7 @@ static mainprog_info rpng2_info;
static uch inbuf[INBUFSIZE];
static int incount;
-static int pat = 6; /* must be less than num_bgpat */
+static int pat = 6; /* must be less than num_bgpat */
static int bg_image = 0;
static int bgscale = 16;
static ulg bg_rowbytes;
@@ -134,22 +134,22 @@ static uch *bg_data;
static struct rgb_color {
uch r, g, b;
} rgb[] = {
- { 0, 0, 0}, /* 0: black */
- {255, 255, 255}, /* 1: white */
- {173, 132, 57}, /* 2: tan */
- { 64, 132, 0}, /* 3: medium green */
- {189, 117, 1}, /* 4: gold */
- {253, 249, 1}, /* 5: yellow */
- { 0, 0, 255}, /* 6: blue */
- { 0, 0, 120}, /* 7: medium blue */
- {255, 0, 255}, /* 8: magenta */
- { 64, 0, 64}, /* 9: dark magenta */
- {255, 0, 0}, /* 10: red */
- { 64, 0, 0}, /* 11: dark red */
- {255, 127, 0}, /* 12: orange */
- {192, 96, 0}, /* 13: darker orange */
- { 24, 60, 0}, /* 14: dark green-yellow */
- { 85, 125, 200} /* 15: ice blue */
+ { 0, 0, 0}, /* 0: black */
+ {255, 255, 255}, /* 1: white */
+ {173, 132, 57}, /* 2: tan */
+ { 64, 132, 0}, /* 3: medium green */
+ {189, 117, 1}, /* 4: gold */
+ {253, 249, 1}, /* 5: yellow */
+ { 0, 0, 255}, /* 6: blue */
+ { 0, 0, 120}, /* 7: medium blue */
+ {255, 0, 255}, /* 8: magenta */
+ { 64, 0, 64}, /* 9: dark magenta */
+ {255, 0, 0}, /* 10: red */
+ { 64, 0, 0}, /* 11: dark red */
+ {255, 127, 0}, /* 12: orange */
+ {192, 96, 0}, /* 13: darker orange */
+ { 24, 60, 0}, /* 14: dark green-yellow */
+ { 85, 125, 200} /* 15: ice blue */
};
/* not used for now, but should be for error-checking:
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
@@ -174,25 +174,25 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
*/
static struct background_pattern {
ush type;
- int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
- int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
+ int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
+ int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
} bg[] = {
- {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
- {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
- {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
- {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
- {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
- {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
- {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
- {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
- {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
- {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
- {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
- {1, 3,0, 0,0}, /* diamonds: medium green vs. black */
- {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
- {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
- {2, 16, 256, 100, 250}, /* radial: very tight spiral */
- {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
+ {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
+ {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
+ {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
+ {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
+ {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
+ {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
+ {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
+ {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
+ {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
+ {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
+ {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
+ {1, 3,0, 0,0}, /* diamonds: medium green vs. black */
+ {2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
+ {2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
+ {2, 16, 256, 100, 250}, /* radial: very tight spiral */
+ {2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
};
static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern);
@@ -212,16 +212,16 @@ static int global_showmode;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
- char *args[1024]; /* arbitrary limit, but should suffice */
+ char *args[1024]; /* arbitrary limit, but should suffice */
char *p, *q, *bgstr = NULL, **argv = args;
int argc = 0;
int rc, alen, flen;
int error = 0;
int timing = FALSE;
int have_bg = FALSE;
- double LUT_exponent; /* just the lookup table */
- double CRT_exponent = 2.2; /* just the monitor */
- double default_display_exponent; /* whole display system */
+ double LUT_exponent; /* just the lookup table */
+ double CRT_exponent = 2.2; /* just the monitor */
+ double default_display_exponent; /* whole display system */
MSG msg;
@@ -267,7 +267,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
LUT_exponent = 1.8 / 2.61;
/*
if (some_mac_function_that_returns_gamma(&mac_gamma))
- LUT_exponent = mac_gamma / 2.61;
+ LUT_exponent = mac_gamma / 2.61;
*/
#else
LUT_exponent = 1.0; /* assume no LUT: most PCs */
@@ -560,7 +560,7 @@ static int rpng2_win_create_window()
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*rpng2_info.height)))
{
- return 4; /* fail */
+ return 4; /* fail */
}
/*---------------------------------------------------------------------------
@@ -655,7 +655,7 @@ static int rpng2_win_create_window()
TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len);
ReleaseDC(global_hwnd, hdc);
- rpng2_win_load_bg_image(); /* resets bg_image if fails */
+ rpng2_win_load_bg_image(); /* resets bg_image if fails */
}
if (!bg_image) {
@@ -753,7 +753,7 @@ static int rpng2_win_load_bg_image()
even_odd = even_odd_vert ^ even_odd_horiz;
invert_column =
(even_odd_horiz && (bg[pat].type & 0x10));
- if (even_odd == 0) { /* gradient #1 */
+ if (even_odd == 0) { /* gradient #1 */
if (invert_column) {
*dest++ = r1_inv;
*dest++ = g1_inv;
@@ -763,7 +763,7 @@ static int rpng2_win_load_bg_image()
*dest++ = g1;
*dest++ = b1;
}
- } else { /* gradient #2 */
+ } else { /* gradient #2 */
if ((invert_column && invert_gradient2) ||
(!invert_column && !invert_gradient2))
{
@@ -786,8 +786,8 @@ static int rpng2_win_load_bg_image()
} else if ((bg[pat].type & 0x07) == 1) {
- hmax = (bgscale-1)/2; /* half the max weight of a color */
- max = 2*hmax; /* the max weight of a color */
+ hmax = (bgscale-1)/2; /* half the max weight of a color */
+ max = 2*hmax; /* the max weight of a color */
r1 = rgb[bg[pat].rgb1_max].r;
g1 = rgb[bg[pat].rgb1_max].g;
@@ -908,7 +908,7 @@ static int rpng2_win_load_bg_image()
g1 = *src++;
b1 = *src++;
*dest++ = b1;
- *dest++ = g1; /* note reverse order */
+ *dest++ = g1; /* note reverse order */
*dest++ = r1;
}
}
@@ -962,7 +962,7 @@ static void rpng2_win_display_row(ulg row)
g = *src++;
b = *src++;
*dest++ = b;
- *dest++ = g; /* note reverse order */
+ *dest++ = g; /* note reverse order */
*dest++ = r;
}
} else /* if (rpng2_info.channels == 4) */ {
@@ -1084,15 +1084,15 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
/* wait for the user to tell us when to quit */
case WM_CHAR:
- switch (wP) { /* only need one, so ignore repeat count */
+ switch (wP) { /* only need one, so ignore repeat count */
case 'q':
case 'Q':
- case 0x1B: /* Esc key */
+ case 0x1B: /* Esc key */
PostQuitMessage(0);
}
return 0;
- case WM_LBUTTONDOWN: /* another way of quitting */
+ case WM_LBUTTONDOWN: /* another way of quitting */
case WM_DESTROY:
PostQuitMessage(0);
return 0;
diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c
index f0ad73038..8e536e7bb 100644
--- a/contrib/gregbook/rpng2-x.c
+++ b/contrib/gregbook/rpng2-x.c
@@ -1,6 +1,6 @@
/*---------------------------------------------------------------------------
- rpng2 - progressive-model PNG display program rpng2-x.c
+ rpng2 - progressive-model PNG display program rpng2-x.c
This program decodes and displays PNG files progressively, as if it were
a web browser (though the front end is only set up to read from files).
@@ -49,13 +49,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
+#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <time.h>
-#include <math.h> /* only for PvdM background code */
+#include <math.h> /* only for PvdM background code */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
-#include <X11/keysym.h> /* defines XK_* macros */
+#include <X11/keysym.h> /* defines XK_* macros */
#ifdef VMS
#include <unistd.h>
@@ -79,9 +79,9 @@
#define rgb2_max bg_bsat
#define rgb2_min bg_brot
-/* #define DEBUG */ /* this enables the Trace() macros */
+/* #define DEBUG */ /* this enables the Trace() macros */
-#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
+#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
/* could just include png.h, but this macro is the only thing we need
@@ -89,18 +89,18 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
-#define alpha_composite(composite, fg, alpha, bg) { \
- ush temp = ((ush)(fg)*(ush)(alpha) + \
- (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
- (composite) = (uch)((temp + (temp >> 8)) >> 8); \
+#define alpha_composite(composite, fg, alpha, bg) { \
+ ush temp = ((ush)(fg)*(ush)(alpha) + \
+ (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
+ (composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
-#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
- * block size corresponds roughly to a download
- * speed 10% faster than theoretical 33.6K maximum
- * (assuming 8 data bits, 1 stop bit and no other
- * overhead) */
+#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
+ * block size corresponds roughly to a download
+ * speed 10% faster than theoretical 33.6K maximum
+ * (assuming 8 data bits, 1 stop bit and no other
+ * overhead) */
/* local prototypes */
static void rpng2_x_init(void);
@@ -123,7 +123,7 @@ static mainprog_info rpng2_info;
static uch inbuf[INBUFSIZE];
static int incount;
-static int pat = 6; /* must be less than num_bgpat */
+static int pat = 6; /* must be less than num_bgpat */
static int bg_image = 0;
static int bgscale = 16;
static ulg bg_rowbytes;
@@ -132,22 +132,22 @@ static uch *bg_data;
static struct rgb_color {
uch r, g, b;
} rgb[] = {
- { 0, 0, 0}, /* 0: black */
- {255, 255, 255}, /* 1: white */
- {173, 132, 57}, /* 2: tan */
- { 64, 132, 0}, /* 3: medium green */
- {189, 117, 1}, /* 4: gold */
- {253, 249, 1}, /* 5: yellow */
- { 0, 0, 255}, /* 6: blue */
- { 0, 0, 120}, /* 7: medium blue */
- {255, 0, 255}, /* 8: magenta */
- { 64, 0, 64}, /* 9: dark magenta */
- {255, 0, 0}, /* 10: red */
- { 64, 0, 0}, /* 11: dark red */
- {255, 127, 0}, /* 12: orange */
- {192, 96, 0}, /* 13: darker orange */
- { 24, 60, 0}, /* 14: dark green-yellow */
- { 85, 125, 200} /* 15: ice blue */
+ { 0, 0, 0}, /* 0: black */
+ {255, 255, 255}, /* 1: white */
+ {173, 132, 57}, /* 2: tan */
+ { 64, 132, 0}, /* 3: medium green */
+ {189, 117, 1}, /* 4: gold */
+ {253, 249, 1}, /* 5: yellow */
+ { 0, 0, 255}, /* 6: blue */
+ { 0, 0, 120}, /* 7: medium blue */
+ {255, 0, 255}, /* 8: magenta */
+ { 64, 0, 64}, /* 9: dark magenta */
+ {255, 0, 0}, /* 10: red */
+ { 64, 0, 0}, /* 11: dark red */
+ {255, 127, 0}, /* 12: orange */
+ {192, 96, 0}, /* 13: darker orange */
+ { 24, 60, 0}, /* 14: dark green-yellow */
+ { 85, 125, 200} /* 15: ice blue */
};
/* not used for now, but should be for error-checking:
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
@@ -172,21 +172,21 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
*/
static struct background_pattern {
ush type;
- int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
- int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
+ int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
+ int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
} bg[] = {
- {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
- {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
- {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
- {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
- {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
- {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
- {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
- {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
- {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
- {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
- {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
- {1, 3,0, 0,0}, /* diamonds: medium green vs. black */
+ {0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
+ {0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
+ {0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
+ {0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
+ {0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
+ {0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
+ {0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
+ {1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
+ {1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
+ {1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
+ {1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
+ {1, 3,0, 0,0}, /* diamonds: medium green vs. black */
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
@@ -580,7 +580,7 @@ static int rpng2_x_create_window()
return 2;
}
have_colormap = TRUE;
- bg_image = FALSE; /* gradient just wastes palette entries */
+ bg_image = FALSE; /* gradient just wastes palette entries */
} else if (depth == 16) {
RPixelShift = 15 - rpng2_x_msb(RedMask); /* these are right-shifts */
GPixelShift = 15 - rpng2_x_msb(GreenMask);
@@ -684,7 +684,7 @@ static int rpng2_x_create_window()
---------------------------------------------------------------------------*/
if (bg_image)
- rpng2_x_load_bg_image(); /* resets bg_image if fails */
+ rpng2_x_load_bg_image(); /* resets bg_image if fails */
if (!bg_image) {
if (depth == 24 || depth == 32) {
@@ -795,7 +795,7 @@ static int rpng2_x_load_bg_image()
even_odd = even_odd_vert ^ even_odd_horiz;
invert_column =
(even_odd_horiz && (bg[pat].type & 0x10));
- if (even_odd == 0) { /* gradient #1 */
+ if (even_odd == 0) { /* gradient #1 */
if (invert_column) {
*dest++ = r1_inv;
*dest++ = g1_inv;
@@ -805,7 +805,7 @@ static int rpng2_x_load_bg_image()
*dest++ = g1;
*dest++ = b1;
}
- } else { /* gradient #2 */
+ } else { /* gradient #2 */
if ((invert_column && invert_gradient2) ||
(!invert_column && !invert_gradient2))
{
@@ -828,8 +828,8 @@ static int rpng2_x_load_bg_image()
} else if ((bg[pat].type & 0x07) == 1) {
- hmax = (bgscale-1)/2; /* half the max weight of a color */
- max = 2*hmax; /* the max weight of a color */
+ hmax = (bgscale-1)/2; /* half the max weight of a color */
+ max = 2*hmax; /* the max weight of a color */
r1 = rgb[bg[pat].rgb1_max].r;
g1 = rgb[bg[pat].rgb1_max].g;
diff --git a/contrib/gregbook/wpng.c b/contrib/gregbook/wpng.c
index 38f16f803..7709b33a0 100644
--- a/contrib/gregbook/wpng.c
+++ b/contrib/gregbook/wpng.c
@@ -57,27 +57,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
+#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
#include <time.h>
#ifdef DOS_OS2_W32
-# include <io.h> /* for isatty(), setmode() prototypes */
-# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
+# include <io.h> /* for isatty(), setmode() prototypes */
+# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
# ifdef __EMX__
# ifndef getch
-# define getch() _read_kbd(0, 1, 0) /* need getche() */
+# define getch() _read_kbd(0, 1, 0) /* need getche() */
# endif
# else /* !__EMX__ */
# ifdef __GO32__
# include <pc.h>
-# define getch() getkey() /* GRR: need getche() */
+# define getch() getkey() /* GRR: need getche() */
# else
-# include <conio.h> /* for getche() console input */
+# include <conio.h> /* for getche() console input */
# endif
# endif /* ?__EMX__ */
# define FGETS(buf,len,stream) dos_kbd_gets(buf,len)
#else
-# include <unistd.h> /* for isatty() prototype */
+# include <unistd.h> /* for isatty() prototype */
# define FGETS fgets
#endif
@@ -87,7 +87,7 @@
text that includes control characters discouraged by the PNG spec; text
that includes an escape character (27) must be re-entered regardless */
-#include "writepng.h" /* typedefs, common macros, writepng prototypes */
+#include "writepng.h" /* typedefs, common macros, writepng prototypes */
@@ -112,7 +112,7 @@ int main(int argc, char **argv)
FILE *keybd;
#endif
#ifdef sgi
- FILE *tmpfile; /* or we could just use keybd, since no overlap */
+ FILE *tmpfile; /* or we could just use keybd, since no overlap */
char tmpline[80];
#endif
char *inname = NULL, outname[256];
@@ -269,7 +269,7 @@ int main(int argc, char **argv)
": unable to reopen stdout in binary mode\n");
fclose(wpng_info.infile);
++error;
- } else
+ } else
wpng_info.filter = TRUE;
}
} else if ((len = strlen(inname)) > 250) {
@@ -419,7 +419,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_TITLE;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_TITLE;
valid = FALSE;
}
@@ -449,7 +449,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_AUTHOR;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_AUTHOR;
valid = FALSE;
}
@@ -489,7 +489,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_DESC;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_DESC;
valid = FALSE;
}
@@ -519,7 +519,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_COPY;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_COPY;
valid = FALSE;
}
@@ -549,7 +549,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_EMAIL;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_EMAIL;
valid = FALSE;
}
@@ -579,7 +579,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_URL;
valid = FALSE;
#else
- if (p[result] == 27) { /* escape character */
+ if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_URL;
valid = FALSE;
}
@@ -743,10 +743,10 @@ static int wpng_isvalid_latin1(uch *p, int len)
for (i = 0; i < len; ++i) {
if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160)
- continue; /* character is completely OK */
+ continue; /* character is completely OK */
if (result < 0 || (p[result] != 27 && p[i] == 27))
- result = i; /* mark location of first questionable one */
- } /* or of first escape character (bad) */
+ result = i; /* mark location of first questionable one */
+ } /* or of first escape character (bad) */
return result;
}
@@ -791,11 +791,11 @@ static char *dos_kbd_gets(char *buf, int len)
buf[count++] = ch = getche();
} while (ch != '\r' && count < len-1);
- buf[count--] = '\0'; /* terminate string */
- if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
+ buf[count--] = '\0'; /* terminate string */
+ if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
buf[count] = '\n';
- fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
+ fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
fflush(stderr);
return buf;
diff --git a/contrib/gregbook/writepng.c b/contrib/gregbook/writepng.c
index 1bfe44783..44b7e9f93 100644
--- a/contrib/gregbook/writepng.c
+++ b/contrib/gregbook/writepng.c
@@ -30,10 +30,10 @@
---------------------------------------------------------------------------*/
-#include <stdlib.h> /* for exit() prototype */
+#include <stdlib.h> /* for exit() prototype */
-#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
-#include "writepng.h" /* typedefs, common macros, public prototypes */
+#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
+#include "writepng.h" /* typedefs, common macros, public prototypes */
/* local prototype */
@@ -48,7 +48,7 @@ void writepng_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
-}
+}
diff --git a/contrib/pngminus/README b/contrib/pngminus/README
index 02486c514..8683a596a 100644
--- a/contrib/pngminus/README
+++ b/contrib/pngminus/README
@@ -1,4 +1,4 @@
-PngMinus
+PngMinus
--------
(copyright Willem van Schaik, 1999)
@@ -19,7 +19,7 @@ Some history
Soon after the creation of PNG in 1995, the need was felt for a set of
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
(Willem van Schaik) started such a project. Luckily we discovered this
-and merged the two together into pnmtopng.tar.gz, which is available
+and merged the two together into pnmtopng.tar.gz, which is available
from a/o ftp://swrinde.nde.swri.edu/pub/png/.
These two utilities have many, many options and make use of most of the
diff --git a/contrib/pngminus/makevms.com b/contrib/pngminus/makevms.com
index 15d4ad478..7a14be55f 100644
--- a/contrib/pngminus/makevms.com
+++ b/contrib/pngminus/makevms.com
@@ -39,14 +39,14 @@ $ write sys$output "Compiling PNG contrib programs ..."
$ write sys$output "Building pnm2png..."
$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" -
pnm2png.c
-$ call make pnm2png.exe -
- "LINK pnm2png,lib.opt/opt" -
+$ call make pnm2png.exe -
+ "LINK pnm2png,lib.opt/opt" -
pnm2png.obj
$ write sys$output "Building png2pnm..."
$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" -
png2pnm.c
-$ call make pnm2png.exe -
- "LINK pnm2png,lib.opt/opt" -
+$ call make pnm2png.exe -
+ "LINK pnm2png,lib.opt/opt" -
pnm2png.obj
$ exit
$!
diff --git a/contrib/pngminus/png2pnm.c b/contrib/pngminus/png2pnm.c
index 85321097b..a900ec243 100644
--- a/contrib/pngminus/png2pnm.c
+++ b/contrib/pngminus/png2pnm.c
@@ -183,7 +183,7 @@ void usage()
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
{
png_struct *png_ptr = NULL;
- png_info *info_ptr = NULL;
+ png_info *info_ptr = NULL;
png_byte buf[8];
png_byte *png_pixels = NULL;
png_byte **row_pointers = NULL;
@@ -217,13 +217,13 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
return FALSE; /* out of memory */
info_ptr = png_create_info_struct (png_ptr);
- if (!info_ptr)
+ if (!info_ptr)
{
png_destroy_read_struct (&png_ptr, NULL, NULL);
return FALSE; /* out of memory */
}
- if (setjmp (png_ptr->jmpbuf))
+ if (setjmp (png_ptr->jmpbuf))
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
@@ -237,7 +237,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
png_read_info (png_ptr, info_ptr);
/* get size and bit-depth of the PNG-image */
- png_get_IHDR (png_ptr, info_ptr,
+ png_get_IHDR (png_ptr, info_ptr,
&width, &height, &bit_depth, &color_type,
NULL, NULL, NULL);
@@ -294,7 +294,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
channels = 4;
else
- channels = 0; /* should never happen */
+ channels = 0; /* should never happen */
alpha_present = (channels - 1) % 2;
/* check if alpha is expected to be present in file */
@@ -313,7 +313,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
return FALSE;
}
- if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
+ if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
free (png_pixels);
diff --git a/contrib/pngminus/pnm2png.c b/contrib/pngminus/pnm2png.c
index 76533512c..67796dddc 100644
--- a/contrib/pngminus/pnm2png.c
+++ b/contrib/pngminus/pnm2png.c
@@ -64,9 +64,9 @@ int main(int argc, char *argv[])
for (argi = 1; argi < argc; argi++)
{
- if (argv[argi][0] == '-')
+ if (argv[argi][0] == '-')
{
- switch (argv[argi][1])
+ switch (argv[argi][1])
{
case 'i':
interlace = TRUE;
@@ -405,7 +405,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* if needed we will allocate memory for an new array of row-pointers */
if (row_pointers == (unsigned char**) NULL)
{
- if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
+ if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
{
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
return FALSE;
@@ -418,13 +418,13 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* write out the entire image data in one call */
png_write_image (png_ptr, row_pointers);
-
+
/* write the additional chuncks to the PNG file (not really needed) */
png_write_end (png_ptr, info_ptr);
-
- /* clean up after the write, and free any memory allocated */
+
+ /* clean up after the write, and free any memory allocated */
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
-
+
if (row_pointers != (unsigned char**) NULL)
free (row_pointers);
if (png_pixels != (unsigned char*) NULL)
diff --git a/example.c b/example.c
index 430450437..50a285fad 100644
--- a/example.c
+++ b/example.c
@@ -595,6 +595,11 @@ void write_png(char *file_name /* , ... other image information ... */)
text_ptr[2].key = "Description";
text_ptr[2].text = "<long text>";
text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;
+#ifdef PNG_iTXt_SUPPORTED
+ text_ptr[0].lang = NULL;
+ text_ptr[1].lang = NULL;
+ text_ptr[2].lang = NULL;
+#endif
png_set_text(png_ptr, info_ptr, text_ptr, 3);
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
@@ -699,8 +704,6 @@ void write_png(char *file_name /* , ... other image information ... */)
/* if you malloced the palette, free it here */
free(info_ptr->palette);
- /* if you allocated any text comments, free them here */
-
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
diff --git a/libpng.3 b/libpng.3
index 019252e91..599dcb04e 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "November 29, 1999"
+.TH LIBPNG 3 "December 10, 1999"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
.SH SYNOPSIS
\fI\fB
@@ -88,6 +88,30 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_free_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fI\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_free_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_free_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_free_spalette (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum_text\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_free_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_free_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum_text\fP\fB);\fP
+
+\fI\fB
+
\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
@@ -104,6 +128,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP
+
+\fI\fB
+
\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
@@ -128,6 +156,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
+
+\fI\fB
+
\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
@@ -140,6 +172,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, int \fI*proflen\fP\fB);\fP
+
+\fI\fB
+
\fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP
\fI\fB
@@ -210,6 +246,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_get_spalettes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fI*splt_ptr\fP\fB, int \fInum\fP\fB);\fP
+
+\fI\fB
+
\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP
\fI\fB
@@ -226,6 +266,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
+
+\fI\fB
+
\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
@@ -346,6 +390,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
\fI\fB
@@ -406,6 +454,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
@@ -418,6 +470,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP
+
+\fI\fB
+
\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
@@ -434,6 +490,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_keep_unknown_chunks (png_structp \fIpng_ptr\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
\fI\fB
@@ -490,6 +550,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
\fI\fB
@@ -498,6 +562,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_set_spalettes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
\fI\fB
@@ -538,6 +606,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fInum\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP
\fI\fB
@@ -629,7 +701,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng
- libpng version 1.0.5d - November 29, 1999
+ libpng version 1.0.5h - December 10, 1999
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -917,6 +989,17 @@ image data. You do this with a call to png_read_info().
png_read_info(png_ptr, info_ptr);
+This will read all chunks up to but not including the image data.
+Both known and unknown chunks will be read. Known chunks will be
+parsed into information in various info_ptr members; unknown chunks
+will be discarded, unless you previously called
+
+ png_set_keep_unknown_chunks();
+
+in which case they will be saved as raw data onto a list of
+png_unknown_chunk structures (and written out if you subsequently
+call png_write_info and friends).
+
Functions are used to get the information from the info_ptr:
png_get_IHDR(png_ptr, info_ptr, &width, &height,
@@ -1020,6 +1103,16 @@ into the info_ptr is returned for any complex types.
implies specific values of gAMA and
cHRM.
+ png_get_iCCP(png_ptr, info_ptr, &name, &compression_type,
+ &profile, &proflen);
+ name - The profile name.
+ compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
+ for PNG 1.0. You may give NULL to this argument
+ to ignore it.
+ profile - International Color Consortium color profile
+ data. May contain NULs.
+ proflen - length of profile data in bytes.
+
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray,
@@ -1051,7 +1144,9 @@ into the info_ptr is returned for any complex types.
num_text = png_get_text(png_ptr, info_ptr, &text_ptr);
text_ptr - array of png_text holding image
comments
+ text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
+ text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
@@ -1059,6 +1154,11 @@ into the info_ptr is returned for any complex types.
or PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments
+ num_spalettes = png_get_spalettes(png_ptr, info_ptr, &palette_ptr);
+ palette_ptr - array of png_spalette structures holding contents
+ of one or more sPLT chunks read.
+ num_spalettes - number of sPLT chunks read.
+
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
&unit_type);
offset_x - positive offset from the left edge
@@ -1076,6 +1176,19 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
+ png_get_sCAL(png_ptr, info_ptr, &unit, &width, &height)
+ unit - physical scale units (a string)
+ width - width of a pixel in physical scale units
+ height - height of a pixel in physical scale units
+
+ num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr,
+ &unknowns)
+ unknowns - array of png_unknown_chunk structures holding
+ unknown chunks
+ unknowns[i].name - name of unknown chunk
+ unknowns[i].data - data of unknown chunk
+ unknowns[i].size - size of unknown chunk
+
The data from the pHYs chunk can be retrieved in several convenient
forms:
@@ -1110,14 +1223,14 @@ There is also no requirement to have text after the keyword.
Keywords should be limited to 79 Latin-1 characters without leading or
trailing spaces, but non-consecutive spaces are allowed within the
keyword. It is possible to have the same keyword any number of times.
-The text_ptr is an array of png_text structures, each holding pointer
-to a keyword and a pointer to a text string. Only the text string may
-be null. The keyword/text pairs are put into the array in the order
-that they are received. However, some or all of the text chunks may be
-after the image, so, to make sure you have read all the text chunks,
-don't mess with these until after you read the stuff after the image.
-This will be mentioned again below in the discussion that goes with
-png_read_end().
+The text_ptr is an array of png_text structures, each holding a
+pointer to a language string, a pointer to a keyword and a pointer to
+a text string. Only the text string may be null. The keyword/text
+pairs are put into the array in the order that they are received.
+However, some or all of the text chunks may be after the image, so, to
+make sure you have read all the text chunks, don't mess with these
+until after you read the stuff after the image. This will be
+mentioned again below in the discussion that goes with png_read_end().
After you've read the header information, you can set up the library
to handle any special transformations of the image data. The various
@@ -1575,6 +1688,30 @@ When you are done, you can free all memory allocated by libpng like this:
png_destroy_read_struct(&png_ptr, &info_ptr,
&end_info);
+It is also possible to individually free the info_ptr members that
+point to allocated storage with the following functions:
+
+ png_free_text(png_ptr, info_ptr, num)
+ num - number of text item to be freed (-1 for all items)
+
+ png_free_iCCP(png_ptr, info_ptr)
+
+ png_free_pCAL(png_ptr, info_ptr)
+
+ png_free_sCAL(png_ptr, info_ptr)
+
+ png_free_spalette(png_ptr, info_ptr, num)
+ num - number of suggested-paletted entry to be freed
+ (-1 for all suggested palettes)
+
+ png_free_unknown_chunk(png_ptr, info_ptr, num)
+ num - number of unknown chunk to be freed
+ (-1 for all suggested palettes)
+
+These functions may be safely called when the relevant storage has
+already been freed, or has not yet been allocated, and will in that
+case do nothing.
+
For a more compact example of reading a PNG image, see the file example.c.
@@ -1968,6 +2105,16 @@ Some of the more important parts of the png_info are:
that are consistent with sRGB to be
written.
+ png_set_iCCP(png_ptr, info_ptr, name, compression_type,
+ profile, proflen);
+ name - The profile name.
+ compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
+ for PNG 1.0. You may give NULL to this argument
+ to ignore it.
+ profile - International Color Consortium color profile
+ data. May contain NULs.
+ proflen - length of profile data in bytes.
+
png_set_sBIT(png_ptr, info_ptr, sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray, red,
@@ -1999,7 +2146,9 @@ Some of the more important parts of the png_info are:
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
text_ptr - array of png_text holding image
comments
+ text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
+ text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
@@ -2007,6 +2156,11 @@ Some of the more important parts of the png_info are:
PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments in text_ptr
+ png_set_spalettes(png_ptr, info_ptr, &palette_ptr, num_spalettes);
+ palette_ptr - array of png_spalette structures to be added to
+ the list of palettes in the info structure.
+ num_spalettes - number of palette structures to be added.
+
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
unit_type);
offset_x - positive offset from the left
@@ -2024,6 +2178,18 @@ Some of the more important parts of the png_info are:
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
+ png_set_sCAL(png_ptr, info_ptr, unit, width, height)
+ unit - physical scale units (a string)
+ width - width of a pixel in physical scale units
+ height - height of a pixel in physical scale units
+
+ png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, num_unknowns)
+ unknowns - array of png_unknown_chunk structures holding
+ unknown chunks
+ unknowns[i].name - name of unknown chunk
+ unknowns[i].data - data of unknown chunk
+ unknowns[i].size - size of unknown chunk
+
In PNG files, the alpha channel in an image is the level of opacity.
If your data is supplied as a level of transparency, you can invert the
alpha channel before you write it, so that 0 is fully transparent and 255
@@ -2042,12 +2208,17 @@ A quick word about text and num_text. text is an array of png_text
structures. num_text is the number of valid structures in the array.
If you want, you can use max_text to hold the size of the array, but
libpng ignores it for writing (it does use it for reading). Each
-png_text structure holds a keyword-text value, and a compression type.
+png_text structure holds a language code, a keyword, a text value, and
+a compression type.
+
The compression types have the same valid numbers as the compression
types of the image data. Currently, the only valid number is zero.
However, you can store text either compressed or uncompressed, unlike
images, which always have to be compressed. So if you don't want the
text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
+Because compressed-text chunks don't have a language field, if you
+specify compression any language code will not be written out.
+
Until text gets around 1000 bytes, it is not worth compressing it.
After the text has been written out to the file, the compression type
is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
@@ -2113,6 +2284,14 @@ by the software. To facilitate the use of RFC 1123 dates, a function
png_convert_to_rfc1123(png_timep) is provided to convert from PNG
time to an RFC 1123 format string.
+You can use the png_set_unknown_chunks function to queue up chunks
+for writing. You give it a chunk name, raw data, and a size; that's
+all there is to it. The chunks will be written by the next following
+png_write_info_before_PLTE, png_write_info, or png_write_end function.
+Any chunks previously read into the info structure's unknown-chunk
+list will also be written out in a sequence that satisfies the PNG
+specification's ordering rules.
+
You are now ready to write all the file information up to the actual
image data. You do this with a call to png_write_info().
@@ -2123,7 +2302,7 @@ the PLTE chunk when PLTE is present, you can write the PNG info in
two steps, and insert code to write your own chunk between them:
png_write_info_before_PLTE(png_ptr, info_ptr);
- write_my_private_chunks();
+ png_set_unknown_chunks(png_ptr, info_ptr, ...);
png_write_info(png_ptr, info_ptr);
After you've written the file information, you can set up the library
@@ -2332,6 +2511,30 @@ When you are done, you can free all memory used by libpng like this:
png_destroy_write_struct(&png_ptr, &info_ptr);
+It is also possible to individually free the info_ptr members that
+point to allocated storage with the following functions:
+
+ png_free_text(png_ptr, info_ptr, num)
+ num - number of text item to be freed (-1 for all items)
+
+ png_free_iCCP(png_ptr, info_ptr)
+
+ png_free_pCAL(png_ptr, info_ptr)
+
+ png_free_sCAL(png_ptr, info_ptr)
+
+ png_free_spalette(png_ptr, info_ptr, num)
+ num - number of suggested-paletted entry to be freed
+ (-1 for all suggested palettes)
+
+ png_free_unknown_chunk(png_ptr, info_ptr, num)
+ num - number of unknown chunk entry to be freed
+ (-1 for all suggested palettes)
+
+These functions may be safely called when the relevant storage has
+already been freed, or has not yet been allocated, and will in that
+case do nothing.
+
You must free any data you allocated for info_ptr, such as comments,
palette, or histogram, before the call to png_destroy_write_struct();
@@ -2601,7 +2804,7 @@ or all four,
along with directives to turn on any of the capabilities that you do
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
the extra transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks [except for sPLT].
+and writing PNG files with all known public chunks
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
produces a library that is incapable of reading or writing ancillary chunks.
If you are not using the progressive reading capability, you can
@@ -2695,13 +2898,13 @@ the old method.
.SH VII. Y2K Compliance in libpng
-November 29, 1999
+December 10, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.5d are Y2K compliant. It is my belief that earlier
+upward through 1.0.5h 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
@@ -2717,7 +2920,7 @@ The strings are
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
@@ -2726,7 +2929,7 @@ There are seven time-related functions:
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
@@ -2780,7 +2983,7 @@ used for changes in backward compatibility, as it is intended.
The PNG_PNGLIB_VER macro, which is not used within libpng but
is available for applications, is an unsigned integer of the form
xyyzz corresponding to the source version x.y.z (leading zeros in y and z).
-
+
.SH "SEE ALSO"
libpngpf(3), png(5)
.LP
@@ -2826,8 +3029,8 @@ with testing, bug fixes, and patience. This wouldn't have been
possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
-
-Libpng version 1.0.5d - November 29, 1999:
+
+Libpng version 1.0.5h - December 10, 1999:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
@@ -2842,7 +3045,7 @@ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
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.5d, November 29, 1999)
+(libpng versions 0.97, January 1998, through 1.0.5h, December 10, 1999)
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
diff --git a/libpng.txt b/libpng.txt
index 3a567f703..43b8f53f5 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
- libpng version 1.0.5d - November 29, 1999
+ libpng version 1.0.5h - December 10, 1999
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -288,6 +288,17 @@ image data. You do this with a call to png_read_info().
png_read_info(png_ptr, info_ptr);
+This will read all chunks up to but not including the image data.
+Both known and unknown chunks will be read. Known chunks will be
+parsed into information in various info_ptr members; unknown chunks
+will be discarded, unless you previously called
+
+ png_set_keep_unknown_chunks();
+
+in which case they will be saved as raw data onto a list of
+png_unknown_chunk structures (and written out if you subsequently
+call png_write_info and friends).
+
Functions are used to get the information from the info_ptr:
png_get_IHDR(png_ptr, info_ptr, &width, &height,
@@ -391,6 +402,16 @@ into the info_ptr is returned for any complex types.
implies specific values of gAMA and
cHRM.
+ png_get_iCCP(png_ptr, info_ptr, &name, &compression_type,
+ &profile, &proflen);
+ name - The profile name.
+ compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
+ for PNG 1.0. You may give NULL to this argument
+ to ignore it.
+ profile - International Color Consortium color profile
+ data. May contain NULs.
+ proflen - length of profile data in bytes.
+
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray,
@@ -422,7 +443,9 @@ into the info_ptr is returned for any complex types.
num_text = png_get_text(png_ptr, info_ptr, &text_ptr);
text_ptr - array of png_text holding image
comments
+ text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
+ text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
@@ -430,6 +453,11 @@ into the info_ptr is returned for any complex types.
or PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments
+ num_spalettes = png_get_spalettes(png_ptr, info_ptr, &palette_ptr);
+ palette_ptr - array of png_spalette structures holding contents
+ of one or more sPLT chunks read.
+ num_spalettes - number of sPLT chunks read.
+
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
&unit_type);
offset_x - positive offset from the left edge
@@ -447,6 +475,19 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
+ png_get_sCAL(png_ptr, info_ptr, &unit, &width, &height)
+ unit - physical scale units (a string)
+ width - width of a pixel in physical scale units
+ height - height of a pixel in physical scale units
+
+ num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr,
+ &unknowns)
+ unknowns - array of png_unknown_chunk structures holding
+ unknown chunks
+ unknowns[i].name - name of unknown chunk
+ unknowns[i].data - data of unknown chunk
+ unknowns[i].size - size of unknown chunk
+
The data from the pHYs chunk can be retrieved in several convenient
forms:
@@ -481,14 +522,14 @@ There is also no requirement to have text after the keyword.
Keywords should be limited to 79 Latin-1 characters without leading or
trailing spaces, but non-consecutive spaces are allowed within the
keyword. It is possible to have the same keyword any number of times.
-The text_ptr is an array of png_text structures, each holding pointer
-to a keyword and a pointer to a text string. Only the text string may
-be null. The keyword/text pairs are put into the array in the order
-that they are received. However, some or all of the text chunks may be
-after the image, so, to make sure you have read all the text chunks,
-don't mess with these until after you read the stuff after the image.
-This will be mentioned again below in the discussion that goes with
-png_read_end().
+The text_ptr is an array of png_text structures, each holding a
+pointer to a language string, a pointer to a keyword and a pointer to
+a text string. Only the text string may be null. The keyword/text
+pairs are put into the array in the order that they are received.
+However, some or all of the text chunks may be after the image, so, to
+make sure you have read all the text chunks, don't mess with these
+until after you read the stuff after the image. This will be
+mentioned again below in the discussion that goes with png_read_end().
After you've read the header information, you can set up the library
to handle any special transformations of the image data. The various
@@ -946,6 +987,30 @@ When you are done, you can free all memory allocated by libpng like this:
png_destroy_read_struct(&png_ptr, &info_ptr,
&end_info);
+It is also possible to individually free the info_ptr members that
+point to allocated storage with the following functions:
+
+ png_free_text(png_ptr, info_ptr, num)
+ num - number of text item to be freed (-1 for all items)
+
+ png_free_iCCP(png_ptr, info_ptr)
+
+ png_free_pCAL(png_ptr, info_ptr)
+
+ png_free_sCAL(png_ptr, info_ptr)
+
+ png_free_spalette(png_ptr, info_ptr, num)
+ num - number of suggested-paletted entry to be freed
+ (-1 for all suggested palettes)
+
+ png_free_unknown_chunk(png_ptr, info_ptr, num)
+ num - number of unknown chunk to be freed
+ (-1 for all suggested palettes)
+
+These functions may be safely called when the relevant storage has
+already been freed, or has not yet been allocated, and will in that
+case do nothing.
+
For a more compact example of reading a PNG image, see the file example.c.
@@ -1339,6 +1404,16 @@ Some of the more important parts of the png_info are:
that are consistent with sRGB to be
written.
+ png_set_iCCP(png_ptr, info_ptr, name, compression_type,
+ profile, proflen);
+ name - The profile name.
+ compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
+ for PNG 1.0. You may give NULL to this argument
+ to ignore it.
+ profile - International Color Consortium color profile
+ data. May contain NULs.
+ proflen - length of profile data in bytes.
+
png_set_sBIT(png_ptr, info_ptr, sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray, red,
@@ -1370,7 +1445,9 @@ Some of the more important parts of the png_info are:
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
text_ptr - array of png_text holding image
comments
+ text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
+ text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
@@ -1378,6 +1455,11 @@ Some of the more important parts of the png_info are:
PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments in text_ptr
+ png_set_spalettes(png_ptr, info_ptr, &palette_ptr, num_spalettes);
+ palette_ptr - array of png_spalette structures to be added to
+ the list of palettes in the info structure.
+ num_spalettes - number of palette structures to be added.
+
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
unit_type);
offset_x - positive offset from the left
@@ -1395,6 +1477,18 @@ Some of the more important parts of the png_info are:
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
+ png_set_sCAL(png_ptr, info_ptr, unit, width, height)
+ unit - physical scale units (a string)
+ width - width of a pixel in physical scale units
+ height - height of a pixel in physical scale units
+
+ png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, num_unknowns)
+ unknowns - array of png_unknown_chunk structures holding
+ unknown chunks
+ unknowns[i].name - name of unknown chunk
+ unknowns[i].data - data of unknown chunk
+ unknowns[i].size - size of unknown chunk
+
In PNG files, the alpha channel in an image is the level of opacity.
If your data is supplied as a level of transparency, you can invert the
alpha channel before you write it, so that 0 is fully transparent and 255
@@ -1413,12 +1507,17 @@ A quick word about text and num_text. text is an array of png_text
structures. num_text is the number of valid structures in the array.
If you want, you can use max_text to hold the size of the array, but
libpng ignores it for writing (it does use it for reading). Each
-png_text structure holds a keyword-text value, and a compression type.
+png_text structure holds a language code, a keyword, a text value, and
+a compression type.
+
The compression types have the same valid numbers as the compression
types of the image data. Currently, the only valid number is zero.
However, you can store text either compressed or uncompressed, unlike
images, which always have to be compressed. So if you don't want the
text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
+Because compressed-text chunks don't have a language field, if you
+specify compression any language code will not be written out.
+
Until text gets around 1000 bytes, it is not worth compressing it.
After the text has been written out to the file, the compression type
is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
@@ -1484,6 +1583,14 @@ by the software. To facilitate the use of RFC 1123 dates, a function
png_convert_to_rfc1123(png_timep) is provided to convert from PNG
time to an RFC 1123 format string.
+You can use the png_set_unknown_chunks function to queue up chunks
+for writing. You give it a chunk name, raw data, and a size; that's
+all there is to it. The chunks will be written by the next following
+png_write_info_before_PLTE, png_write_info, or png_write_end function.
+Any chunks previously read into the info structure's unknown-chunk
+list will also be written out in a sequence that satisfies the PNG
+specification's ordering rules.
+
You are now ready to write all the file information up to the actual
image data. You do this with a call to png_write_info().
@@ -1494,7 +1601,7 @@ the PLTE chunk when PLTE is present, you can write the PNG info in
two steps, and insert code to write your own chunk between them:
png_write_info_before_PLTE(png_ptr, info_ptr);
- write_my_private_chunks();
+ png_set_unknown_chunks(png_ptr, info_ptr, ...);
png_write_info(png_ptr, info_ptr);
After you've written the file information, you can set up the library
@@ -1703,6 +1810,30 @@ When you are done, you can free all memory used by libpng like this:
png_destroy_write_struct(&png_ptr, &info_ptr);
+It is also possible to individually free the info_ptr members that
+point to allocated storage with the following functions:
+
+ png_free_text(png_ptr, info_ptr, num)
+ num - number of text item to be freed (-1 for all items)
+
+ png_free_iCCP(png_ptr, info_ptr)
+
+ png_free_pCAL(png_ptr, info_ptr)
+
+ png_free_sCAL(png_ptr, info_ptr)
+
+ png_free_spalette(png_ptr, info_ptr, num)
+ num - number of suggested-paletted entry to be freed
+ (-1 for all suggested palettes)
+
+ png_free_unknown_chunk(png_ptr, info_ptr, num)
+ num - number of unknown chunk entry to be freed
+ (-1 for all suggested palettes)
+
+These functions may be safely called when the relevant storage has
+already been freed, or has not yet been allocated, and will in that
+case do nothing.
+
You must free any data you allocated for info_ptr, such as comments,
palette, or histogram, before the call to png_destroy_write_struct();
@@ -1972,7 +2103,7 @@ or all four,
along with directives to turn on any of the capabilities that you do
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
the extra transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks [except for sPLT].
+and writing PNG files with all known public chunks
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
produces a library that is incapable of reading or writing ancillary chunks.
If you are not using the progressive reading capability, you can
@@ -2066,13 +2197,13 @@ the old method.
VII. Y2K Compliance in libpng
-November 29, 1999
+December 10, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.5d are Y2K compliant. It is my belief that earlier
+upward through 1.0.5h 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
@@ -2088,7 +2219,7 @@ The strings are
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
@@ -2097,7 +2228,7 @@ There are seven time-related functions:
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
diff --git a/libpngpf.3 b/libpngpf.3
index 55f9e908e..cdea799f4 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 November 29, 1999
+.TH LIBPNGPF 3 December 10, 1999
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5h
(private functions)
.SH SYNOPSIS
\fB#include <png.h>\fP
@@ -211,6 +211,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
@@ -231,6 +239,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB
@@ -399,6 +415,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
@@ -417,11 +437,15 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP
\fI\fB
-\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
+\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP
\fI\fB
@@ -437,6 +461,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext)\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP
\fI\fB
@@ -457,6 +489,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
+
+\fI\fB
+
+\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
@@ -465,6 +505,12 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29
\fI\fB
+\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, \fIpng_spalette_p
+
+\fI\fBpalette\fP\fB);\fP
+
+\fI\fB
+
\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
diff --git a/png.5 b/png.5
index e9e80f9d9..c911a3d31 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "November 29, 1999"
+.TH PNG 5 "December 10, 1999"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
diff --git a/png.c b/png.c
index 4c9050b3b..4e4b13ead 100644
--- a/png.c
+++ b/png.c
@@ -1,11 +1,11 @@
/* png.c - location for general purpose libpng functions
*
- * libpng version 1.0.5d - November 29, 1999
+ * libpng version 1.0.5h - December 10, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
- *
+ *
*/
#define PNG_INTERNAL
@@ -18,12 +18,12 @@
#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.5d";
+char png_libpng_ver[12] = "1.0.5h";
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-
+
/* Invoke global declarations for constant strings for known chunk types */
PNG_IHDR;
PNG_IDAT;
@@ -33,10 +33,14 @@ PNG_bKGD;
PNG_cHRM;
PNG_gAMA;
PNG_hIST;
+PNG_iCCP;
+PNG_iTXt;
PNG_oFFs;
PNG_pCAL;
+PNG_sCAL;
PNG_pHYs;
PNG_sBIT;
+PNG_sPLT;
PNG_sRGB;
PNG_tEXt;
PNG_tIME;
@@ -254,6 +258,134 @@ png_info_init(png_infop info_ptr)
png_memset(info_ptr, 0, sizeof (png_info));
}
+#if defined(PNG_TEXT_SUPPORTED)
+/* free text item num or (if num == -1) all text items */
+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;
+ }
+}
+#endif
+
+#if defined(PNG_sCAL_SUPPORTED)
+/* free any sCAL entry */
+void
+png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
+{
+ if (info_ptr->valid & PNG_INFO_sCAL)
+ {
+ png_free(png_ptr, info_ptr->scal_unit);
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_free(png_ptr, info_ptr->scal_s_width);
+ png_free(png_ptr, info_ptr->scal_s_height);
+#endif
+ info_ptr->valid &= ~PNG_INFO_sCAL;
+ }
+}
+#endif
+
+#if defined(PNG_pCAL_SUPPORTED)
+/* free any pCAL entry */
+void
+png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
+{
+ if (info_ptr->valid & PNG_INFO_pCAL)
+ {
+ png_free(png_ptr, info_ptr->pcal_purpose);
+ png_free(png_ptr, info_ptr->pcal_units);
+ if (info_ptr->pcal_params != NULL)
+ {
+ int i;
+ for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
+ {
+ png_free(png_ptr, info_ptr->pcal_params[i]);
+ }
+ png_free(png_ptr, info_ptr->pcal_params);
+ }
+ info_ptr->valid &= ~PNG_INFO_pCAL;
+ }
+}
+#endif
+
+#if defined(PNG_iCCP_SUPPORTED)
+/* free any pCAL entry */
+void
+png_free_iCCP(png_structp png_ptr, png_infop info_ptr)
+{
+ if (info_ptr->valid & PNG_INFO_iCCP)
+ {
+ png_free(png_ptr, info_ptr->iccp_name);
+ png_free(png_ptr, info_ptr->iccp_profile);
+ info_ptr->valid &= ~PNG_INFO_iCCP;
+ }
+}
+#endif
+
+#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)
+{
+ if (num != -1)
+ {
+ png_free(png_ptr, info_ptr->splt_palettes[num].name);
+ png_free(png_ptr, info_ptr->splt_palettes[num].entries);
+ }
+ else
+ {
+ png_uint_32 i;
+
+ for (i = 0; i < info_ptr->splt_palettes_num; i++)
+ png_free_spalette(png_ptr, info_ptr, num);
+
+ png_free(png_ptr, info_ptr->splt_palettes);
+ info_ptr->splt_palettes_num = 0;
+ }
+}
+#endif
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+void
+png_free_unknown_chunk(png_structp png_ptr, png_infop info_ptr, int num)
+{
+ if (num != -1)
+ {
+ png_free(png_ptr, info_ptr->unknown_chunks[num].data);
+ info_ptr->unknown_chunks[num].data = NULL;
+ }
+ else
+ {
+ png_uint_32 i;
+
+ for (i = 0; i < info_ptr->unknown_chunks_num; i++)
+ png_free_unknown_chunk(png_ptr, info_ptr, num);
+
+ png_free(png_ptr, info_ptr->unknown_chunks);
+ info_ptr->unknown_chunks_num = 0;
+ }
+}
+#endif
+
/* This is an internal routine to free any memory that the info struct is
* pointing to before re-using it or freeing the struct itself. Recall
* that png_free() checks for NULL pointers for us.
@@ -261,39 +393,25 @@ png_info_init(png_infop info_ptr)
void
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
png_debug(1, "in png_info_destroy\n");
- if (info_ptr->text != NULL)
- {
- int i;
- for (i = 0; i < info_ptr->num_text; i++)
- {
- if(info_ptr->text[i].key != NULL)
- {
- png_free(png_ptr, info_ptr->text[i].key);
- info_ptr->text[i].key = NULL;
- }
- }
- png_free(png_ptr, info_ptr->text);
- info_ptr->text = NULL;
- }
+#if defined(PNG_READ_TEXT_SUPPORTED)
+ png_free_text(png_ptr, info_ptr, -1);
+#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+ png_free_sCAL(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
- png_free(png_ptr, info_ptr->pcal_purpose);
- png_free(png_ptr, info_ptr->pcal_units);
- if (info_ptr->pcal_params != NULL)
- {
- int i;
- for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
- {
- png_free(png_ptr, info_ptr->pcal_params[i]);
- info_ptr->pcal_params[i]=NULL;
- }
- png_free(png_ptr, info_ptr->pcal_params);
- info_ptr->pcal_params = NULL;
- }
+ png_free_pCAL(png_ptr, info_ptr);
+#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+ png_free_iCCP(png_ptr, info_ptr);
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ png_free_spalette(png_ptr, info_ptr, -1);
+#endif
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+ png_free_unknown_chunk(png_ptr, info_ptr, -1);
#endif
-
png_info_init(info_ptr);
}
@@ -371,7 +489,7 @@ 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.5d - November 29, 1999\n\
+ return ("\n libpng version 1.0.5h - December 10, 1999\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
@@ -389,8 +507,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.5d");
- return("1.0.5d");
+ return("1.0.5h");
+ return("1.0.5h");
}
png_charp
@@ -414,8 +532,8 @@ 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_5d png_h_is_not_version_1_0_5d)
+ (version_1_0_5h png_h_is_not_version_1_0_5h)
{
- if(png_h_is_not_version_1_0_5d == NULL)
+ if(png_h_is_not_version_1_0_5h == NULL)
return;
}
diff --git a/png.h b/png.h
index 9d1bc58b2..1757add1b 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.0.5d - November 29, 1999
+ * libpng version 1.0.5h - December 10, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -9,34 +9,34 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.0.5d - November 29, 1999: Glenn
+ * libpng versions 0.97, January 1998, through 1.0.5h - December 10, 1999: Glenn
* See also "Contributing Authors", below.
*
* Y2K compliance in libpng:
* =========================
- *
- * November 29, 1999
- *
+ *
+ * December 10, 1999
+ *
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
- *
+ *
* This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.0.5d are Y2K compliant. It is my belief that earlier
+ * upward through 1.0.5h are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
- *
+ *
* Libpng only has three year fields. One is a 2-byte unsigned integer
* that will hold years up to 65535. The other two hold the date in text
* format, and will hold years up to 9999.
- *
+ *
* The integer is
* "png_uint_16 year" in png_time_struct.
- *
+ *
* The strings are
* "png_charp time_buffer" in png_struct and
* "near_time_buffer", which is a local character string in png.c.
- *
+ *
* There are seven time-related functions:
- * png.c: png_convert_to_rfc_1123() in png.c
+ * 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
@@ -44,8 +44,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 handle dates properly in a Y2K environment. The
+ *
+ * All handle dates properly in a Y2K environment. The
* png_convert_from_time_t() function calls gmtime() to convert from system
* clock time, which returns (year - 1900), which we properly convert to
* the full 4-digit year. There is a possibility that applications using
@@ -55,19 +55,19 @@
* but this is not under our control. The libpng documentation has always
* stated that it works with 4-digit years, and the APIs have been
* documented as such.
- *
+ *
* The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
* integer to hold the year, and can hold years as large as 65535.
- *
+ *
* zlib, upon which libpng depends, is also Y2K compliant. It contains
* no date-related code.
- *
+ *
* Glenn Randers-Pehrson
* libpng maintainer
* PNG Development Group
- *
+ *
* Note about libpng version numbers:
- *
+ *
* Due to various miscommunications, unforeseen code incompatibilities
* and occasional factors outside the authors' control, version numbering
* on the library has not always been consistent and straightforward.
@@ -98,7 +98,8 @@
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
* 1.0.5 1.0.5 10005 2.1.0.5
* 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d
- * 1.0.6 1.0.6 10006 2.1.0.6
+ * 1.0.5e-h 1.0.5e-h 10100 2.1.0.5e-h
+ * 1.1.0 1.1.0 10100 3.1.0.0
*
* Henceforth the source version will match the shared-library minor
* and patch numbers; the shared-library major version number will be
@@ -122,7 +123,7 @@
* 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.5d, November 29, 1999)
+ * (libpng versions 0.97, January 1998, through 1.0.5h, December 10, 1999)
*
* For the purposes of this copyright and license, "Contributing Authors"
* is defined as the following set of individuals:
@@ -135,6 +136,7 @@
* Tom Lane
* Dave Martindale
* Glenn Randers-Pehrson
+ * Eric S. Raymond
* Greg Roelofs
* Guy Eric Schalnat
* Paul Schmidt
@@ -175,9 +177,9 @@
/*
* A "png_get_copyright" function is available, for convenient use in "about"
* boxes and the like:
- *
+ *
* printf("%s",png_get_copyright(NULL));
- *
+ *
* Also, the PNG logo (in PNG format, of course) is supplied in the
* file "pngnow.png".
*/
@@ -222,14 +224,14 @@ extern "C" {
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.5d"
+#define PNG_LIBPNG_VER_STRING "1.0.5h"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
-#define PNG_LIBPNG_VER 10006 /* 1.0.6 */
+#define PNG_LIBPNG_VER 10100 /* 1.1.0 */
/* Note to maintainer: update this number in scripts/pngdef.pas as well */
@@ -296,17 +298,48 @@ typedef struct png_color_8_struct
typedef png_color_8 FAR * png_color_8p;
typedef png_color_8 FAR * FAR * png_color_8pp;
-/* png_text holds the text in a PNG file, and whether they are compressed
- in the PNG file or not. The "text" field points to a regular C string. */
+/*
+ * The following two structures are used for the in-core representation
+ * of sPLT chunks.
+ */
+typedef struct png_spalette_entry_struct
+{
+ png_uint_16 red;
+ png_uint_16 green;
+ png_uint_16 blue;
+ png_uint_16 alpha;
+ png_uint_16 frequency;
+} png_spalette_entry;
+typedef png_spalette_entry FAR * png_spalette_entryp;
+typedef png_spalette_entry FAR * FAR * png_spalette_entrypp;
+
+typedef struct png_spalette_struct
+{
+ png_charp name; /* palette name */
+ png_byte depth; /* depth of palette samples */
+ png_spalette_entryp entries; /* palette entries */
+ png_int_32 nentries; /* number of palette entries */
+} png_spalette;
+typedef png_spalette FAR * png_spalette_p;
+typedef png_spalette FAR * FAR * png_spalette_pp;
+
+#ifdef PNG_TEXT_SUPPORTED
+/* png_text holds the contents of a text chunk in a PNG file, and whether
+ * that contents is compressed or not. The "keyword" field points to a
+ * regular C string. */
typedef struct png_text_struct
{
int compression; /* compression value, see PNG_TEXT_COMPRESSION_ */
png_charp key; /* keyword, 1-79 character description of "text" */
+ png_charp lang; /* language code, 1-79 characters */
+ png_charp translated_key; /* translated keyword, 1-79 characters */
png_charp text; /* comment, may be an empty string (ie "") */
- png_size_t text_length; /* length of "text" field */
+ /* text_length is no longer used, and now present for compatibility only */
+ png_size_t text_length; /* length of "text" field (not used any more) */
} png_text;
typedef png_text FAR * png_textp;
typedef png_text FAR * FAR * png_textpp;
+#endif
/* Supported compression types for text in PNG files (tEXt, and zTXt).
* The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
@@ -334,6 +367,27 @@ typedef struct png_time_struct
typedef png_time FAR * png_timep;
typedef png_time FAR * FAR * png_timepp;
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+/* png_unknown_chunk is a structure to hold queued chunks for which there is
+ * no specific support. The idea is that we can use this to queue
+ * up private chunks for output even though the library doesn't actually
+ * know about their semantics.
+ */
+typedef struct png_unknown_chunk_t
+{
+ png_byte name[5];
+ png_byte *data;
+ png_size_t size;
+
+ /* libpng-using applications should NOT modify this byte. Applications
+ that are inserting a new unknown chunk can set it to 0. */
+ png_byte location; /* mode of operation at read time */
+}
+png_unknown_chunk;
+typedef png_unknown_chunk FAR * png_unknown_chunkp;
+typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
+#endif
+
/* png_info is a structure that holds the information in a PNG file so
* that the application can find out the characteristics of the image.
* If you are reading the file, this structure will tell you what is
@@ -354,6 +408,21 @@ typedef png_time FAR * FAR * png_timepp;
* In any case, the order of the parameters in png_info_struct should NOT
* be changed for as long as possible to keep compatibility with applications
* that use the old direct-access method with png_info_struct.
+ *
+ * The following members may have allocated storage attached that should be
+ * cleaned up before the structure is discarded: palette, text, pcal_purpose,
+ * pcal_units, pcal_params, iccp_name, iccp_profile, splt_palettes, and
+ * scal_unit. Of these, the text, pcal_*, iccp_*, splt_*, and scal_unit
+ * members are automatically freed when the info structure is deallocated.
+ * The palette member is not.
+ *
+ * More allocation details: all the chunk-reading functions that change these
+ * members go through the corresponding png_set_* functions. Functions to
+ * clear these members are available: see png_free_*. The png_set_* functions
+ * do not depend on being able to point info structure members to any of the
+ * storage they are passed (they make their own copies), EXCEPT that the
+ * png_set_text function uses the same storage passed to them
+ * in the text_ptr or itxt_ptr structure argument.
*/
typedef struct png_info_struct
{
@@ -383,41 +452,47 @@ typedef struct png_info_struct
* and initialize the appropriate fields below.
*/
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED) || \
- defined(PNG_READ_GAMMA_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
/* The gAMA chunk describes the gamma characteristics of the system
* on which the image was created, normally in the range [1.0, 2.5].
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
*/
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
-#endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_uint_32 int_gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
+#endif
+#endif
-#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
+#if defined(PNG_sRGB_SUPPORTED)
/* GR-P, 0.96a */
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
-#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
-
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
- defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
- /* The tEXt and zTXt chunks contain human-readable textual data in
- * uncompressed and compressed forms, respectively. The data in "text"
- * is an array of pointers to uncompressed, null-terminated C strings.
- * Each chunk has a keyword that describes the textual data contained
- * in that chunk. Keywords are not required to be unique, and the text
- * string may be empty. Any number of text chunks may be in an image.
+#endif
+
+#if defined(PNG_TEXT_SUPPORTED)
+ /* The tEXt, and zTXt chunks contain human-readable textual data in
+ * uncompressed, compressed, and optionally compressed forms, respectively.
+ * The data in "text" is an array of pointers to uncompressed,
+ * null-terminated C strings. Each chunk has a keyword that describes the
+ * textual data contained in that chunk. Keywords are not required to be
+ * unique, and the text string may be empty. Any number of text chunks may
+ * be in an image.
*/
int num_text; /* number of comments read/to write */
int max_text; /* current size of text array */
png_textp text; /* array of comments read/to write */
-#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
-#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
+#endif /* PNG_TEXT_SUPPORTED */
+
+#if defined(PNG_tIME_SUPPORTED)
/* The tIME chunk holds the last time the displayed image data was
* modified. See the png_time struct for the contents of this struct.
*/
png_time mod_time;
-#endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
-#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
+#endif
+
+#if defined(PNG_sBIT_SUPPORTED)
/* The sBIT chunk specifies the number of significant high-order bits
* in the pixel data. Values are in the range [1, bit_depth], and are
* only specified for the channels in the pixel data. The contents of
@@ -425,9 +500,10 @@ typedef struct png_info_struct
* (valid & PNG_INFO_sBIT) is non-zero.
*/
png_color_8 sig_bit; /* significant bits in color channels */
-#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
-#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
- defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+#endif
+
+#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
+defined(PNG_READ_BACKGROUND_SUPPORTED)
/* The tRNS chunk supplies transparency data for paletted images and
* other image types that don't need a full alpha channel. There are
* "num_trans" transparency values for a paletted image, stored in the
@@ -439,9 +515,9 @@ typedef struct png_info_struct
*/
png_bytep trans; /* transparent values for paletted image */
png_color_16 trans_values; /* transparent color for non-palette image */
-#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
-#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED) || \
- defined(PNG_READ_BACKGROUND_SUPPORTED)
+#endif
+
+#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
/* The bKGD chunk gives the suggested image background color if the
* display program does not have its own background color and the image
* is needs to composited onto a background before display. The colors
@@ -449,18 +525,20 @@ typedef struct png_info_struct
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
*/
png_color_16 background;
-#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#endif
+
+#if defined(PNG_oFFs_SUPPORTED)
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
* and downwards from the top-left corner of the display, page, or other
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
*/
- png_uint_32 x_offset; /* x offset on page */
- png_uint_32 y_offset; /* y offset on page */
+ png_int_32 x_offset; /* x offset on page */
+ png_int_32 y_offset; /* y offset on page */
png_byte offset_unit_type; /* offset units type */
-#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#endif
+
+#if defined(PNG_pHYs_SUPPORTED)
/* The pHYs chunk gives the physical pixel density of the image for
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
@@ -468,8 +546,9 @@ typedef struct png_info_struct
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
-#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
-#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
+#endif
+
+#if defined(PNG_hIST_SUPPORTED)
/* The hIST chunk contains the relative frequency or importance of the
* various palette entries, so that a viewer can intelligently select a
* reduced-color palette, if required. Data is an array of "num_palette"
@@ -477,14 +556,16 @@ typedef struct png_info_struct
* is non-zero.
*/
png_uint_16p hist;
-#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
-#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
+#endif
+
+#if defined(PNG_cHRM_SUPPORTED)
/* The cHRM chunk describes the CIE color characteristics of the monitor
* on which the PNG was created. This data allows the viewer to do gamut
* mapping of the input image to ensure that the viewer sees the same
* colors in the image as the creator. Values are in the range
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
*/
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float x_white;
float y_white;
float x_red;
@@ -493,10 +574,22 @@ typedef struct png_info_struct
float y_green;
float x_blue;
float y_blue;
-#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
-#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_uint_32 int_x_white;
+ png_uint_32 int_y_white;
+ png_uint_32 int_x_red;
+ png_uint_32 int_y_red;
+ png_uint_32 int_x_green;
+ png_uint_32 int_y_green;
+ png_uint_32 int_x_blue;
+ png_uint_32 int_y_blue;
+#endif
+#endif
+
+#if defined(PNG_pCAL_SUPPORTED)
/* The pCAL chunk describes a transformation between the stored pixel
- * values and original physcical data values used to create the image.
+ * values and original physical data values used to create the image.
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
* range given by [pcal_X0, pcal_X1], and are further transformed by a
* (possibly non-linear) transformation function given by "pcal_type"
@@ -514,8 +607,46 @@ typedef struct png_info_struct
png_charpp pcal_params; /* ASCII strings containing parameter values */
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
png_byte pcal_nparams; /* number of parameters given in pcal_params */
-#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
+#endif
+
+#if defined(PNG_iCCP_SUPPORTED)
+ /* iCCP chunk data. */
+ png_charp iccp_name; /* profile name */
+ png_charp iccp_profile; /* International Color Consortium profile data */
+ png_uint_32 iccp_proflen; /* ICC profile data length */
+ png_byte iccp_compression; /* Always zero */
+#endif
+
+#if defined(PNG_sPLT_SUPPORTED)
+ /* data on sPLT chunks (there may be more than one). */
+ png_spalette_p splt_palettes;
+ png_uint_32 splt_palettes_num;
+#endif
+
+#if defined(PNG_sCAL_SUPPORTED)
+ /* The sCAL chunk describes the actual physical dimensions of the
+ * subject matter of the graphic. The chunk contains a unit specification
+ * (an ASCII string), and two ASCII strings representing floating-point
+ * values. The values are width and height corresponsing to one pixel
+ * in the image. This external representation is converted to double
+ * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
+ */
+ png_charp scal_unit; /* unit of physical scale */
+ png_charp scal_s_width; /* string containing height */
+ png_charp scal_s_height; /* string containing width */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ double scal_pixel_width; /* width of one pixel */
+ double scal_pixel_height; /* height of one pixel */
+#endif
+#endif
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+ /* storage for unknown chunks that the library doesn't recognize. */
+ png_unknown_chunkp unknown_chunks;
+ png_size_t unknown_chunks_num;
+#endif
} png_info;
+
typedef png_info FAR * png_infop;
typedef png_info FAR * FAR * png_infopp;
@@ -572,6 +703,8 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_sRGB_INTENT_ABSOLUTE 3
#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
+/* This is for text chunks */
+#define PNG_KEYWORD_MAX_LENGTH 79
/* These determine if an ancillary chunk's data has been successfully read
@@ -591,6 +724,9 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_INFO_tIME 0x0200
#define PNG_INFO_pCAL 0x0400
#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
+#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
+#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
+#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@@ -623,18 +759,19 @@ typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
typedef void (*png_flush_ptr) PNGARG((png_structp));
typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int));
typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int));
+
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
png_uint_32, int));
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
typedef void (*png_user_transform_ptr) PNGARG((png_structp,
png_row_infop, png_bytep));
-#endif /* PNG_READ|WRITE_USER_TRANSFORM_SUPPORTED */
+#endif
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
@@ -656,12 +793,15 @@ struct png_struct_def
png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */
png_voidp io_ptr; /* ptr to application struct for I/O functions*/
+
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr read_user_transform_fn; /* user read transform */
#endif
+
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif
+
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp user_transform_ptr; /* user supplied struct for user transform */
@@ -719,25 +859,36 @@ struct png_struct_def
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
-#endif /* PNG_READ_FILLER_SUPPORTED */
+#endif
+
#if defined(PNG_READ_bKGD_SUPPORTED)
png_byte background_gamma_type;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float background_gamma;
+#endif
png_color_16 background; /* background color in screen gamma space */
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- png_color_16 background_1; /* background normalized to gamma 1.0 */
-#endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
+# if defined(PNG_READ_GAMMA_SUPPORTED)
+ png_color_16 background_1; /* background normalized to gamma 1.0 */
+# endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
#endif /* PNG_READ_bKGD_SUPPORTED */
+
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_flush_ptr output_flush_fn;/* Function for flushing output */
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
png_uint_32 flush_rows; /* number of rows written since last flush */
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif
+
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float gamma; /* file gamma value */
float screen_gamma; /* screen gamma value (display_exponent) */
-#endif /* PNG_READ_GAMMA_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_uint_32 int_gamma;
+#endif
+#endif
+
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_bytep gamma_from_1; /* converts from 1.0 to screen */
@@ -745,18 +896,22 @@ struct png_struct_def
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
-#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
+#endif
+
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits in each available channel */
-#endif /* PNG_READ_GAMMA_SUPPORTED || PNG_READ_sBIT_SUPPORTED */
+#endif
+
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
-#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
+#endif
+
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans; /* transparency values for paletted files */
png_color_16 trans_values; /* transparency values for non-paletted files */
-#endif /* PNG_READ|WRITE_tRNS_SUPPORTED||PNG_READ_EXPAND|BACKGROUND_SUPPORTED */
+#endif
+
png_read_status_ptr read_row_fn; /* called after each row is decoded */
png_write_status_ptr write_row_fn; /* called after each row is encoded */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@@ -775,13 +930,16 @@ struct png_struct_def
png_size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
- png_size_t current_text_size; /* current size of text input data */
- png_size_t current_text_left; /* how much text left to read in input */
- png_charp current_text; /* current text chunk buffer */
- png_charp current_text_ptr; /* current location in current_text */
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
+
+# if defined(PNG_READ_TEXT_SUPPORTED)
+ png_size_t current_text_size; /* current size of text input data */
+ png_size_t current_text_left; /* how much text left to read in input */
+ png_charp current_text; /* current text chunk buffer */
+ png_charp current_text_ptr; /* current location in current_text */
+# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_TEXT_SUPPORTED */
+
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* for the Borland special 64K segment handler */
png_bytepp offset_table_ptr;
@@ -789,14 +947,17 @@ struct png_struct_def
png_uint_16 offset_table_number;
png_uint_16 offset_table_count;
png_uint_16 offset_table_count_free;
-#endif /* __TURBOC__&&!_Windows&&!__FLAT__ */
+#endif
+
#if defined(PNG_READ_DITHER_SUPPORTED)
png_bytep palette_lookup; /* lookup table for dithering */
png_bytep dither_index; /* index translation for palette files */
-#endif /* PNG_READ_DITHER_SUPPORTED */
+#endif
+
#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED)
png_uint_16p hist; /* histogram */
#endif
+
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_byte heuristic_method; /* heuristic for row filter selection */
png_byte num_prev_filters; /* number of weights for previous rows */
@@ -805,21 +966,25 @@ struct png_struct_def
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
png_uint_16p filter_costs; /* relative filter calculation cost */
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
-#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
+#endif
+
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_charp time_buffer; /* String to hold RFC 1123 time text */
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif
+
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif
+
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte rgb_to_gray_status;
png_byte rgb_to_gray_red_coeff;
png_byte rgb_to_gray_green_coeff;
png_byte rgb_to_gray_blue_coeff;
#endif
+
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
png_byte empty_plte_permitted;
@@ -827,9 +992,9 @@ struct png_struct_def
};
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.0.5d
+and png.h are both at * version 1.0.5h
*/
-typedef png_structp version_1_0_5d;
+typedef png_structp version_1_0_5h;
typedef png_struct FAR * FAR * png_structpp;
@@ -914,7 +1079,7 @@ extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
#if defined(PNG_TIME_RFC1123_SUPPORTED)
extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
PNGARG((png_structp png_ptr, png_timep ptime));
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif
#if defined(PNG_WRITE_tIME_SUPPORTED)
/* convert from a struct tm to png_time */
@@ -932,48 +1097,49 @@ extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_EXPAND_SUPPORTED */
+#endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* Use blue, green, red order for pixels. */
extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
+#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* Expand the grayscale to 24-bit RGB if necessary. */
extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
+#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
/* Reduce RGB to grayscale. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
int error_action, double red, double green ));
+#endif
extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
png_ptr));
-#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
+#endif
extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
png_colorp palette));
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */
+#endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
+#endif
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED || PNG_WRITE_INVERT_ALPHA_SUPPORTED */
+#endif
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
/* Add a filler byte to 24-bit RGB images. */
extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
png_uint_32 filler, int flags));
-
/* The values of the PNG_FILLER_ defines should NOT be changed */
#define PNG_FILLER_BEFORE 0
#define PNG_FILLER_AFTER 1
@@ -982,78 +1148,81 @@ extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swap bytes in 16-bit depth files. */
extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
+#endif
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
+#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* Swap packing order of pixels in bytes. */
extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPORTED */
+#endif
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
/* Converts files to legal bit depths. */
extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
png_color_8p true_bits));
-#endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
+#endif
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* Have the code handle the interlacing. Returns the number of passes. */
extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_INTERLACING_SUPPORTED || PNG_WRITE_INTERLACING_SUPPORTED */
+#endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
/* Invert monocrome files */
extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_INVERT_SUPPORTED || PNG_WRITE_INVERT_SUPPORTED */
+#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
/* Handle alpha and tRNS by replacing with a background color. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
png_color_16p background_color, int background_gamma_code,
int need_expand, double background_gamma));
+#endif
#define PNG_BACKGROUND_GAMMA_UNKNOWN 0
#define PNG_BACKGROUND_GAMMA_SCREEN 1
#define PNG_BACKGROUND_GAMMA_FILE 2
#define PNG_BACKGROUND_GAMMA_UNIQUE 3
-#endif /* PNG_READ_BACKGROUND_SUPPORTED */
+#endif
#if defined(PNG_READ_16_TO_8_SUPPORTED)
/* strip the second byte of information from a 16-bit depth file. */
extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
-#endif /* PNG_READ_16_TO_8_SUPPORTED */
+#endif
#if defined(PNG_READ_DITHER_SUPPORTED)
/* Turn on dithering, and reduce the palette to the number of colors available. */
extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
png_colorp palette, int num_palette, int maximum_colors,
png_uint_16p histogram, int full_dither));
-#endif /* PNG_READ_DITHER_SUPPORTED */
+#endif
#if defined(PNG_READ_GAMMA_SUPPORTED)
/* Handle gamma correction. Screen_gamma=(display_exponent) */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
double screen_gamma, double default_file_gamma));
-#endif /* PNG_READ_GAMMA_SUPPORTED */
+#endif
+#endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
int empty_plte_permitted));
-#endif /* PNG_READ_EMPTY_PLTE_SUPPORTED */
+#endif
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
/* Set how many lines between output flushes - 0 for no flushing */
extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
-
/* Flush the current PNG output buffer */
extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif
/* optional update palette with requested transformations */
extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
@@ -1204,9 +1373,11 @@ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
* the weights and costs are set to 1.0, this degenerates the WEIGHTED method
* to the UNWEIGHTED method, but with added encoding time/computation.
*/
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
int heuristic_method, int num_weights, png_doublep filter_weights,
png_doublep filter_costs));
+#endif
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
/* Heuristic used for row filter selection. These defines should NOT be
@@ -1292,10 +1463,9 @@ extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
/* Replace the default memory allocation functions with user supplied one(s). */
extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
-
/* Return the user pointer associated with the memory functions */
extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
@@ -1352,7 +1522,7 @@ extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
png_uint_32 size));
extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
png_voidp ptr));
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif
extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
png_voidp s1, png_voidp s2, png_uint_32 size));
@@ -1443,8 +1613,10 @@ extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
png_ptr, png_infop info_ptr));
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
png_ptr, png_infop info_ptr));
+#endif
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp
@@ -1465,45 +1637,74 @@ png_infop info_ptr));
#if defined(PNG_READ_bKGD_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_16p *background));
-#endif /* PNG_READ_bKGD_SUPPORTED */
+#endif
-#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
+#if defined(PNG_bKGD_SUPPORTED)
extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_16p background));
-#endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
+#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
png_infop info_ptr, double *white_x, double *white_y, double *red_x,
double *red_y, double *green_x, double *green_y, double *blue_x,
double *blue_y));
-#endif /* PNG_READ_cHRM_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 *int_white_x, png_uint_32 *int_white_y,
+ png_uint_32 *int_red_x, png_uint_32 *int_red_y, png_uint_32 *int_green_x,
+ png_uint_32 *int_green_y, png_uint_32 *int_blue_x,
+ png_uint_32 *int_blue_y));
+#endif
+#endif
-#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
+#if defined(PNG_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
png_infop info_ptr, double white_x, double white_y, double red_x,
double red_y, double green_x, double green_y, double blue_x, double blue_y));
-#endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 int_white_x, png_uint_32 int_white_y,
+ png_uint_32 int_red_x, png_uint_32 int_red_y, png_uint_32 int_green_x,
+ png_uint_32 int_green_y, png_uint_32 int_blue_x, png_uint_32 int_blue_y));
+#endif
+#endif
#if defined(PNG_READ_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
png_infop info_ptr, double *file_gamma));
-#endif /* PNG_READ_gAMA_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 *int_file_gamma));
+#endif
+#endif
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
png_infop info_ptr, double file_gamma));
-#endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 int_file_gamma));
+#endif
+#endif
#if defined(PNG_READ_hIST_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_16p *hist));
-#endif /* PNG_READ_hIST_SUPPORTED */
+#endif
-#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
+#if defined(PNG_hIST_SUPPORTED)
extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_16p hist));
-#endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
+#endif
extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
@@ -1516,37 +1717,42 @@ extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
#if defined(PNG_READ_oFFs_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y,
+ png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
int *unit_type));
-#endif /* PNG_READ_oFFs_SUPPORTED */
+#endif
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 offset_x, png_uint_32 offset_y,
+ png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
int unit_type));
-#endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
+#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
int *type, int *nparams, png_charp *units, png_charpp *params));
-#endif /* PNG_READ_pCAL_SUPPORTED */
+#endif
-#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
+#if defined(PNG_pCAL_SUPPORTED)
extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
int type, int nparams, png_charp units, png_charpp params));
-#endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
+#endif
+
+#if defined(PNG_pCAL_SUPPORTED)
+extern PNG_EXPORT(void,png_free_pCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
-#endif /* PNG_READ_pHYs_SUPPORTED */
+#endif
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
-#endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
+#endif
extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_colorp *palette, int *num_palette));
@@ -1557,58 +1763,118 @@ extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
#if defined(PNG_READ_sBIT_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_8p *sig_bit));
-#endif /* PNG_READ_sBIT_SUPPORTED */
+#endif
-#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
+#if defined(PNG_sBIT_SUPPORTED)
extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_8p sig_bit));
-#endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
+#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
png_infop info_ptr, int *intent));
-#endif /* PNG_READ_sRGB_SUPPORTED */
+#endif
-#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
+#if defined(PNG_sRGB_SUPPORTED)
extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
png_infop info_ptr, int intent));
extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
png_infop info_ptr, int intent));
-#endif /* PNG_READ_sRGB_SUPPORTED || PNG_WRITE_sRGB_SUPPORTED */
+#endif
+
+#if defined(PNG_READ_iCCP_SUPPORTED)
+extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charpp name, int *compression_type,
+ png_charpp profile, png_int_32 *proflen));
+#endif
+
+#if defined(PNG_iCCP_SUPPORTED)
+extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp name, int compression_type,
+ png_charp profile, int proflen));
+extern PNG_EXPORT(void,png_free_iCCP) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
+
+#if defined(PNG_READ_sPLT_SUPPORTED)
+extern PNG_EXPORT(png_uint_32,png_get_spalettes) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_spalette_pp entries));
+#endif
+
+#if defined(PNG_sPLT_SUPPORTED)
+extern PNG_EXPORT(void,png_set_spalettes) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_spalette_p entries, int nentries));
+extern PNG_EXPORT(void,png_free_spalette) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int num));
+#endif
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
-/* png_get_text also returns the number of text chunks in text_ptr */
+#if defined(PNG_READ_TEXT_SUPPORTED)
+/* png_get_text also returns the number of text chunks in *num_text */
extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp *text_ptr, int *num_text));
-#endif /* PNG_READ_tEXt_SUPPORTED || PNG_READ_zTXt_SUPPORTED */
+#endif
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
- defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+#if defined(PNG_TEXT_SUPPORTED)
extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp text_ptr, int num_text));
-#endif /* PNG_READ_OR_WRITE_tEXt_OR_zTXt_SUPPORTED */
+extern PNG_EXPORT(void,png_free_text) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int num_text));
+#endif
#if defined(PNG_READ_tIME_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_timep *mod_time));
-#endif /* PNG_READ_tIME_SUPPORTED */
+#endif
-#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_timep mod_time));
-#endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
+#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_bytep *trans, int *num_trans,
png_color_16p *trans_values));
-#endif /* PNG_READ_tRNS_SUPPORTED */
+#endif
-#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
+#if defined(PNG_tRNS_SUPPORTED)
extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_bytep trans, int num_trans,
png_color_16p trans_values));
-#endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
+#endif
+
+#if defined(PNG_READ_sCAL_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charpp unit, double *width, double *height));
+#endif
+extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charpp unit, png_charpp swidth, png_charpp sheight));
+#endif /* PNG_READ_sCAL_SUPPORTED */
+
+#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp unit, double width, double height));
+#endif
+extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_charp unit, png_charp swidth, png_charp sheight));
+#endif /* PNG_READ_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
+
+#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
+extern PNG_EXPORT(void,png_free_sCAL) PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif /* PNG_READ_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
+
+#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
+extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp png_ptr));
+extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_unknown_chunkp unknowns, int nunknowns));
+extern PNG_EXPORT(void,png_free_unknown_chunk) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, int num));
+extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_unknown_chunkpp entries));
+#endif
/* Define PNG_DEBUG at compile time for debugging information. Higher
* numbers for PNG_DEBUG mean more debugging information. This has
@@ -1649,7 +1915,7 @@ extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
-#define PNG_HEADER_VERSION_STRING " libpng version 1.0.5d - November 29, 1999 (header)\n"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.0.5h - December 10, 1999 (header)\n"
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on
@@ -1717,16 +1983,6 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
#define PNG_BACKGROUND_IS_GRAY 0x800
-/* push model modes */
-#define PNG_READ_SIG_MODE 0
-#define PNG_READ_CHUNK_MODE 1
-#define PNG_READ_IDAT_MODE 2
-#define PNG_SKIP_MODE 3
-#define PNG_READ_tEXt_MODE 4
-#define PNG_READ_zTXt_MODE 5
-#define PNG_READ_DONE_MODE 6
-#define PNG_ERROR_MODE 7
-
/* flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
#define PNG_INTERLACE 0x0002
@@ -1779,6 +2035,7 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#define PNG_FLAG_FREE_PALETTE 0x1000
#define PNG_FLAG_FREE_TRANS 0x2000
#define PNG_FLAG_FREE_HIST 0x4000
+#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
@@ -1803,6 +2060,7 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#else
#define png_sig png_sig_bytes(NULL)
#endif
+#endif /* PNG_NO_EXTERN */
/* Constant strings for known chunk types. If you need to add a chunk,
* define the name here, and add an invocation of the macro in png.c and
@@ -1816,10 +2074,14 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
+#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
+#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
+#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
+#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
@@ -1835,10 +2097,14 @@ PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
@@ -1846,7 +2112,6 @@ PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
#endif /* PNG_USE_GLOBAL_ARRAYS */
-#endif /* PNG_NO_EXTERN */
/* Inline macros to do direct reads of bytes from the input buffer. These
* require that you are using an architecture that uses PNG byte ordering
@@ -1880,10 +2145,10 @@ extern void png_read_init PNGARG((png_structp png_ptr));
*/
extern void png_write_init PNGARG((png_structp png_ptr));
-/* allocate memory for an internal libpng struct */
+/* Allocate memory for an internal libpng struct */
PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
-/* free memory from internal libpng struct */
+/* Free memory from internal libpng struct */
PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
@@ -1891,17 +2156,17 @@ PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
png_free_ptr free_fn));
-/* free any memory that info_ptr points to and reset struct. */
+/* Free any memory that info_ptr points to and reset struct. */
PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
png_infop info_ptr));
/* Function to allocate memory for zlib. */
PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
-/* function to free memory for zlib */
+/* Function to free memory for zlib */
PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
-/* reset the CRC variable */
+/* Reset the CRC variable */
PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
/* Write the "data" buffer to whatever output you are using. */
@@ -1912,14 +2177,22 @@ PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
png_size_t length));
-/* read bytes into buf, and update png_ptr->crc */
+/* Read bytes into buf, and update png_ptr->crc */
PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
png_size_t length));
-/* read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
+/* Decompress data in a chunk that uses compression */
+#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
+ defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED)
+PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
+ int comp_type, png_charp chunkdata, png_size_t chunklength,
+ png_size_t prefix_size));
+#endif
+
+/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
-/* read the CRC from the file and compare it to the libpng calculated CRC */
+/* Read the CRC from the file and compare it to the libpng calculated CRC */
PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
/* Calculate the CRC over a section of data. Note that we are only
@@ -1971,8 +2244,14 @@ PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
#if defined(PNG_WRITE_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_uint_32
+ file_gamma));
+#endif
+#endif
#if defined(PNG_WRITE_sBIT_SUPPORTED)
PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
@@ -1980,17 +2259,36 @@ PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
#endif
#if defined(PNG_WRITE_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
double white_x, double white_y,
double red_x, double red_y, double green_x, double green_y,
double blue_x, double blue_y));
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
+ png_uint_32 int_white_x, png_uint_32 int_white_y,
+ png_uint_32 int_red_x, png_uint_32 int_red_y, png_uint_32 int_green_x,
+ png_uint_32 int_green_y, png_uint_32 int_blue_x, png_uint_32 int_blue_y));
+#endif
+#endif
#if defined(PNG_WRITE_sRGB_SUPPORTED)
PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
int intent));
#endif
+#if defined(PNG_WRITE_iCCP_SUPPORTED)
+PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
+ png_charp name, int compression_type,
+ png_charp profile, int proflen));
+#endif
+
+#if defined(PNG_WRITE_sPLT_SUPPORTED)
+PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
+ png_spalette_p palette));
+#endif
+
#if defined(PNG_WRITE_tRNS_SUPPORTED)
PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
png_color_16p values, int number, int color_type));
@@ -2006,8 +2304,8 @@ PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
int num_hist));
#endif
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
- defined(PNG_WRITE_pCAL_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
+ defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
png_charp key, png_charpp new_key));
#endif
@@ -2022,6 +2320,12 @@ PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len, int compression));
#endif
+#if defined(PNG_WRITE_iTXt_SUPPORTED)
+PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
+ int compression, png_charp key, png_charp lang, png_charp translated_key,
+ png_charp text));
+#endif
+
#if defined(PNG_WRITE_oFFs_SUPPORTED)
PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
@@ -2044,6 +2348,15 @@ PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
png_timep mod_time));
#endif
+#if defined(PNG_WRITE_sCAL_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
+ png_charp unit, double width, double height));
+#endif
+PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
+ png_charp unit, png_charp width, png_charp height));
+#endif
+
/* Called when finished processing a row of data */
PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
@@ -2235,6 +2548,16 @@ PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 length));
+#endif /* PNG_READ_iCCP_SUPPORTED */
+
+#if defined(PNG_READ_sPLT_SUPPORTED)
+extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 length));
+#endif /* PNG_READ_sPLT_SUPPORTED */
+
#if defined(PNG_READ_tRNS_SUPPORTED)
PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
@@ -2260,6 +2583,11 @@ PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 length));
+#endif
+
#if defined(PNG_READ_pHYs_SUPPORTED)
PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
@@ -2280,6 +2608,11 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 length));
+#endif
+
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
@@ -2334,6 +2667,12 @@ PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
png_infop info_ptr));
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_uint_32 length));
+PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
+ png_infop info_ptr));
+#endif
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
diff --git a/pngasmrd.h b/pngasmrd.h
index 1525c29bd..520dbb329 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1999 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.5d).
+ * (not available in libpng 1.0.5h).
* MMX will be detected at run time and used if present.
*/
#define PNG_HAVE_ASSEMBLER_COMBINE_ROW
diff --git a/pngconf.h b/pngconf.h
index 85cb792f7..bbfd23a38 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -260,6 +260,7 @@ __dont__ include it again
*/
+
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_TRANSFORMS)
#define PNG_READ_TRANSFORMS_SUPPORTED
@@ -418,6 +419,14 @@ __dont__ include it again
#define PNG_ASSEMBLER_CODE_SUPPORTED
#endif
+#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
+#define PNG_FLOATING_POINT_SUPPORTED
+#endif
+
+#ifndef PNG_NO_FIXED_POINT_SUPPORTED
+#define PNG_FIXED_POINT_SUPPORTED
+#endif
+
/* Do not use global arrays (helps with building DLL's)
* They are no longer used in libpng itself, since version 1.0.5c,
* but might be required for some pre-1.0.5c applications.
@@ -466,87 +475,201 @@ __dont__ include it again
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_READ_bKGD
#define PNG_READ_bKGD_SUPPORTED
+#define PNG_bKGD_SUPPORTED
#endif
#ifndef PNG_NO_READ_cHRM
#define PNG_READ_cHRM_SUPPORTED
+#define PNG_cHRM_SUPPORTED
#endif
#ifndef PNG_NO_READ_gAMA
#define PNG_READ_gAMA_SUPPORTED
+#define PNG_gAMA_SUPPORTED
#endif
#ifndef PNG_NO_READ_hIST
#define PNG_READ_hIST_SUPPORTED
+#define PNG_hIST_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_iCCP
+#define PNG_READ_iCCP_SUPPORTED
+#define PNG_iCCP_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_iTXt
+#define PNG_READ_iTXt_SUPPORTED
+#define PNG_iTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_oFFs
#define PNG_READ_oFFs_SUPPORTED
+#define PNG_oFFs_SUPPORTED
#endif
#ifndef PNG_NO_READ_pCAL
#define PNG_READ_pCAL_SUPPORTED
+#define PNG_pCAL_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sCAL
+#define PNG_READ_sCAL_SUPPORTED
+#define PNG_sCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_pHYs
#define PNG_READ_pHYs_SUPPORTED
+#define PNG_pHYs_SUPPORTED
#endif
#ifndef PNG_NO_READ_sBIT
#define PNG_READ_sBIT_SUPPORTED
+#define PNG_sBIT_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_sPLT
+#define PNG_READ_sPLT_SUPPORTED
+#define PNG_sPLT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sRGB
#define PNG_READ_sRGB_SUPPORTED
+#define PNG_sRGB_SUPPORTED
#endif
#ifndef PNG_NO_READ_tEXt
#define PNG_READ_tEXt_SUPPORTED
+#define PNG_tEXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_tIME
#define PNG_READ_tIME_SUPPORTED
+#define PNG_tIME_SUPPORTED
#endif
#ifndef PNG_NO_READ_tRNS
#define PNG_READ_tRNS_SUPPORTED
+#define PNG_tRNS_SUPPORTED
#endif
#ifndef PNG_NO_READ_zTXt
#define PNG_READ_zTXt_SUPPORTED
+#define PNG_zTXt_SUPPORTED
+#endif
+#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
+#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#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 */
+#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
+ defined(PNG_READ_zTXt_SUPPORTED)
+#define PNG_READ_TEXT_SUPPORTED
+#define PNG_TEXT_SUPPORTED
+#endif
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_WRITE_bKGD
#define PNG_WRITE_bKGD_SUPPORTED
+#ifndef PNG_bKGD_SUPPORTED
+# define PNG_bKGD_SUPPORTED
+#endif
#endif
#ifndef PNG_NO_WRITE_cHRM
#define PNG_WRITE_cHRM_SUPPORTED
+#ifndef PNG_cHRM_SUPPORTED
+# define PNG_cHRM_SUPPORTED
+#endif
#endif
#ifndef PNG_NO_WRITE_gAMA
#define PNG_WRITE_gAMA_SUPPORTED
+#ifndef PNG_gAMA_SUPPORTED
+# define PNG_gAMA_SUPPORTED
+#endif
#endif
#ifndef PNG_NO_WRITE_hIST
#define PNG_WRITE_hIST_SUPPORTED
+#ifndef PNG_hIST_SUPPORTED
+# define PNG_hIST_SUPPORTED
+#endif
+#endif
+#ifndef PNG_NO_WRITE_iCCP
+#define PNG_WRITE_iCCP_SUPPORTED
+#ifndef PNG_iCCP_SUPPORTED
+# define PNG_iCCP_SUPPORTED
+#endif
+#endif
+#ifndef PNG_NO_WRITE_iTXt
+#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
#endif
#ifndef PNG_NO_WRITE_pCAL
#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
#endif
#ifndef PNG_NO_WRITE_pHYs
#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
+#endif
+#ifndef PNG_NO_WRITE_sPLT
+#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
#endif
#ifndef PNG_NO_WRITE_tEXt
#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
#endif
#ifndef PNG_NO_WRITE_tRNS
#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
+#endif
+#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
+#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+#ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
+# define PNG_UNKNOWN_CHUNKS_SUPPORTED
+#endif
+#endif
+#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
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
@@ -644,7 +767,9 @@ 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;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * png_doublep;
+#endif
/* Pointers to pointers; i.e. arrays */
typedef png_byte FAR * FAR * png_bytepp;
@@ -654,7 +779,9 @@ 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;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * FAR * png_doublepp;
+#endif
/* Pointers to pointers to pointers; i.e. pointer to array */
typedef char FAR * FAR * FAR * png_charppp;
@@ -703,7 +830,7 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_EXPORT_VAR(type) extern __declspec(dllexport) type
# endif
# ifdef PNG_ATTR_DLLEXP
-# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
+# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
# endif
# ifdef PNG_DECL_DLLIMP
# define PNG_EXPORT_VAR(type) extern __declspec(dllimport) type
@@ -743,7 +870,7 @@ typedef z_stream FAR * png_zstreamp;
#endif
/* End of memory model independent support */
-/* Just a double check that someone hasn't tried to define something
+/* Just a little check that someone hasn't tried to define something
* contradictory.
*/
#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
diff --git a/pngerror.c b/pngerror.c
index 1bf444e58..af0977193 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngget.c b/pngget.c
index 48cf9ea76..9bedfc637 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -104,7 +104,7 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
@@ -120,7 +120,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
@@ -136,7 +136,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
@@ -150,10 +150,11 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
return (0);
}
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
@@ -167,11 +168,12 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
#endif
return ((float)0.0);
}
+#endif
png_uint_32
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
@@ -187,7 +189,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
@@ -203,7 +205,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
@@ -219,7 +221,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_uint_32
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
@@ -232,7 +234,7 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
return (0);
}
-#ifdef PNG_INCH_CONVERSIONS
+#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{
@@ -302,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 */
+#endif /* PNG_INCH_CONVERSIONS $$ PNG_FLOATING_POINT_SUPPORTED */
/* png_get_channels really belongs in here, too, but it's been around longer */
@@ -343,6 +345,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
@@ -372,8 +375,41 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
return (0);
}
#endif
+#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)
+{
+ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
+ {
+ png_debug1(1, "in %s retrieval function\n", "cHRM");
+ if (white_x != NULL)
+ *white_x = info_ptr->int_x_white;
+ if (white_y != NULL)
+ *white_y = info_ptr->int_y_white;
+ if (red_x != NULL)
+ *red_x = info_ptr->int_x_red;
+ if (red_y != NULL)
+ *red_y = info_ptr->int_y_red;
+ if (green_x != NULL)
+ *green_x = info_ptr->int_x_green;
+ if (green_y != NULL)
+ *green_y = info_ptr->int_y_green;
+ if (blue_x != NULL)
+ *blue_x = info_ptr->int_x_blue;
+ if (blue_y != NULL)
+ *blue_y = info_ptr->int_y_blue;
+ return (PNG_INFO_cHRM);
+ }
+ return (0);
+}
+#endif
+#endif
#if defined(PNG_READ_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
{
@@ -387,6 +423,22 @@ 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)
+{
+ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
+ && int_file_gamma != NULL)
+ {
+ png_debug1(1, "in %s retrieval function\n", "gAMA");
+ *int_file_gamma = info_ptr->int_gamma;
+ return (PNG_INFO_gAMA);
+ }
+ return (0);
+}
+#endif
+#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
png_uint_32
@@ -403,6 +455,39 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
}
#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+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)
+{
+ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
+ && name != NULL && profile != NULL && proflen != NULL)
+ {
+ png_debug1(1, "in %s retrieval function\n", "iCCP");
+ *name = info_ptr->iccp_name;
+ *profile = info_ptr->iccp_profile;
+ /* compression_type is a dummy so the API won't have to change
+ if we introduce multiple compression types later. */
+ *proflen = (int)info_ptr->iccp_proflen;
+ *compression_type = (int)info_ptr->iccp_compression;
+ return (PNG_INFO_iCCP);
+ }
+ return (0);
+}
+#endif
+
+#if defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
+png_uint_32
+png_get_spalettes(png_structp png_ptr, png_infop info_ptr,
+ png_spalette_pp spalettes)
+{
+ if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
+ *spalettes = info_ptr->splt_palettes;
+ return ((png_uint_32)info_ptr->splt_palettes_num);
+}
+#endif
+
#if defined(PNG_READ_hIST_SUPPORTED)
png_uint_32
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
@@ -467,7 +552,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_READ_oFFs_SUPPORTED)
png_uint_32
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
+ png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
@@ -506,6 +591,37 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
}
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
+#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)
+{
+ if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
+ {
+ *unit = info_ptr->scal_unit;
+ *width = info_ptr->scal_pixel_width;
+ *height = info_ptr->scal_pixel_height;
+ return (PNG_INFO_sCAL);
+ }
+ return(0);
+}
+#endif
+png_uint_32
+png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
+ png_charpp unit, png_charpp width, png_charpp height)
+{
+ if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
+ {
+ *unit = info_ptr->scal_unit;
+ *width = info_ptr->scal_s_width;
+ *height = info_ptr->scal_s_height;
+ return (PNG_INFO_sCAL);
+ }
+ return(0);
+}
+#endif
+
#if defined(PNG_READ_pHYs_SUPPORTED)
png_uint_32
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
@@ -567,7 +683,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
}
#endif
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
+#if defined(PNG_READ_TEXT_SUPPORTED)
png_uint_32
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text)
@@ -641,6 +757,17 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
}
#endif
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+png_uint_32
+png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
+ png_unknown_chunkpp unknowns)
+{
+ if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
+ *unknowns = info_ptr->unknown_chunks;
+ return ((png_uint_32)info_ptr->unknown_chunks_num);
+}
+#endif
+
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte
png_get_rgb_to_gray_status (png_structp png_ptr)
diff --git a/pngmem.c b/pngmem.c
index 3e731fa2a..f042ae95a 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngpread.c b/pngpread.c
index e5526ef25..9fa4720ef 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -13,6 +13,17 @@
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+/* push model modes */
+#define PNG_READ_SIG_MODE 0
+#define PNG_READ_CHUNK_MODE 1
+#define PNG_READ_IDAT_MODE 2
+#define PNG_SKIP_MODE 3
+#define PNG_READ_tEXt_MODE 4
+#define PNG_READ_zTXt_MODE 5
+#define PNG_READ_DONE_MODE 6
+#define PNG_READ_iTXt_MODE 7
+#define PNG_ERROR_MODE 8
+
void
png_process_data(png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size)
@@ -62,6 +73,13 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
break;
}
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+ case PNG_READ_iTXt_MODE:
+ {
+ png_push_read_iTXt(png_ptr, info_ptr);
+ break;
+ }
+#endif
case PNG_SKIP_MODE:
{
png_push_crc_finish(png_ptr);
@@ -139,6 +157,9 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
#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
@@ -148,6 +169,12 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
#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
#if defined(PNG_READ_tEXt_SUPPORTED)
PNG_tEXt;
#endif
@@ -287,6 +314,30 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
+ {
+ if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+ {
+ png_push_save_buffer(png_ptr);
+ return;
+ }
+
+ png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
+ }
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
+ {
+ if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+ {
+ png_push_save_buffer(png_ptr);
+ return;
+ }
+
+ png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
+ }
+#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
{
@@ -359,6 +410,18 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
+ {
+ if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+ {
+ png_push_save_buffer(png_ptr);
+ return;
+ }
+
+ png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
+ }
+#endif
#if defined(PNG_READ_tIME_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
{
@@ -383,6 +446,12 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
+ {
+ png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
+ }
+#endif
else
{
png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
@@ -817,30 +886,30 @@ png_read_push_finish_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
-
+
/* start of interlace block in the y direction */
const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
-
+
/* offset to next interlace block in the y direction */
const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
-
+
/* Width of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
*/
-
+
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
#endif
-
+
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
return;
@@ -952,6 +1021,7 @@ png_push_read_tEXt(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_NONE;
+ text_ptr->lang = (char *)NULL;
text_ptr->key = key;
text_ptr->text = text;
@@ -1131,6 +1201,101 @@ 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->text = text;
+
+ png_set_text(png_ptr, info_ptr, text_ptr, 1);
+
+ png_free(png_ptr, text_ptr);
+ }
+}
+#endif
+
+#if defined(PNG_READ_iTXt_SUPPORTED)
+void
+png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+{
+ if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
+ {
+ png_error(png_ptr, "Out of place iTXt");
+ /* to quiet some compiler warnings */
+ if(info_ptr == NULL) return;
+ }
+
+#ifdef PNG_MAX_MALLOC_64K
+ png_ptr->skip_length = 0; /* This may not be necessary */
+
+ if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
+ {
+ png_warning(png_ptr, "iTXt chunk too large to fit in memory");
+ png_ptr->skip_length = length - (png_uint_32)65535L;
+ length = (png_uint_32)65535L;
+ }
+#endif
+
+ png_ptr->current_text = (png_charp)png_malloc(png_ptr,
+ (png_uint_32)(length+1));
+ png_ptr->current_text[length] = '\0';
+ png_ptr->current_text_ptr = png_ptr->current_text;
+ png_ptr->current_text_size = (png_size_t)length;
+ png_ptr->current_text_left = (png_size_t)length;
+ png_ptr->process_mode = PNG_READ_iTXt_MODE;
+}
+
+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;
+
+ if (png_ptr->buffer_size < png_ptr->current_text_left)
+ text_size = png_ptr->buffer_size;
+ else
+ text_size = png_ptr->current_text_left;
+ png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
+ png_ptr->current_text_left -= text_size;
+ png_ptr->current_text_ptr += text_size;
+ }
+ if (!(png_ptr->current_text_left))
+ {
+ png_textp text_ptr;
+ png_charp text;
+ png_charp lang;
+ png_charp key;
+
+ if (png_ptr->buffer_size < 4)
+ {
+ png_push_save_buffer(png_ptr);
+ return;
+ }
+
+ png_push_crc_finish(png_ptr);
+
+#if defined(PNG_MAX_MALLOC_64K)
+ if (png_ptr->skip_length)
+ return;
+#endif
+
+ lang = png_ptr->current_text;
+ png_ptr->current_text = 0;
+
+ for (key = lang; *key; key++)
+ /* empty loop */ ;
+
+ if (key != lang + png_ptr->current_text_size)
+ key++;
+
+ for (text = 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->key = key;
text_ptr->text = text;
diff --git a/pngread.c b/pngread.c
index 9b8e324d9..cdfc01873 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -63,7 +63,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef PNG_USER_MEM_SUPPORTED
png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
@@ -196,6 +196,12 @@ png_read_info(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
@@ -208,6 +214,12 @@ 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)
+ PNG_sCAL;
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ PNG_sPLT;
+#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
#endif
@@ -281,6 +293,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
png_handle_pCAL(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
+ png_handle_sCAL(png_ptr, info_ptr, length);
+#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
png_handle_pHYs(png_ptr, info_ptr, length);
@@ -293,6 +309,14 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
png_handle_sRGB(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
+ png_handle_iCCP(png_ptr, info_ptr, length);
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
+ png_handle_sPLT(png_ptr, info_ptr, length);
+#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
png_handle_tEXt(png_ptr, info_ptr, length);
@@ -309,6 +333,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
png_handle_zTXt(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
+ png_handle_iTXt(png_ptr, info_ptr, length);
+#endif
else
png_handle_unknown(png_ptr, info_ptr, length);
}
@@ -579,7 +607,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.5d.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
*/
void
@@ -628,7 +656,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.5d.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5h.
*/
void
png_read_image(png_structp png_ptr, png_bytepp image)
@@ -697,6 +725,12 @@ png_read_end(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
@@ -709,6 +743,12 @@ 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)
+ PNG_sCAL;
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ PNG_sPLT;
+#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
PNG_sRGB;
#endif
@@ -774,6 +814,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
png_handle_pCAL(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
+ png_handle_sCAL(png_ptr, info_ptr, length);
+#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
png_handle_pHYs(png_ptr, info_ptr, length);
@@ -786,6 +830,14 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
png_handle_sRGB(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_iCCP_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
+ png_handle_iCCP(png_ptr, info_ptr, length);
+#endif
+#if defined(PNG_READ_sPLT_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
+ png_handle_sPLT(png_ptr, info_ptr, length);
+#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
png_handle_tEXt(png_ptr, info_ptr, length);
@@ -802,6 +854,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
png_handle_zTXt(png_ptr, info_ptr, length);
#endif
+#if defined(PNG_READ_iTXt_SUPPORTED)
+ else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
+ png_handle_iTXt(png_ptr, info_ptr, length);
+#endif
else
png_handle_unknown(png_ptr, info_ptr, length);
} while (!(png_ptr->mode & PNG_HAVE_IEND));
@@ -816,7 +872,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL;
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif
png_debug(1, "in png_destroy_read_struct\n");
/* save jump buffer and error functions */
@@ -837,7 +893,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (info_ptr != NULL)
{
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
+#if defined(PNG_TEXT_SUPPORTED)
png_free(png_ptr, info_ptr->text);
#endif
@@ -851,7 +907,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (end_info_ptr != NULL)
{
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
+#if defined(PNG_READ_TEXT_SUPPORTED)
png_free(png_ptr, end_info_ptr->text);
#endif
#ifdef PNG_USER_MEM_SUPPORTED
@@ -909,7 +965,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif
if (png_ptr->flags & PNG_FLAG_FREE_PALETTE)
png_zfree(png_ptr, png_ptr->palette);
-#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED) || \
+#if defined(PNG_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_FREE_TRANS)
png_free(png_ptr, png_ptr->trans);
@@ -954,7 +1010,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer);
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif
inflateEnd(&png_ptr->zstream);
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
diff --git a/pngrio.c b/pngrio.c
index cf7ed17fb..b5e9fc4aa 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
/* pngrio.c - functions for data input
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -146,6 +146,6 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_ptr->output_flush_fn = NULL;
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif
}
diff --git a/pngrtran.c b/pngrtran.c
index 8942c2043..894139b73 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -69,7 +69,8 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
}
}
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
+ defined(PNG_FLOATING_POINT_SUPPORTED)
/* handle alpha and tRNS via a background color */
void
png_set_background(png_structp png_ptr,
@@ -504,7 +505,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
}
#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED)
+#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
/* Transform the image from the file_gamma to the screen_gamma. We
* only do transformations on images where the file_gamma and screen_gamma
* are not close reciprocals, otherwise it slows things down slightly, and
@@ -581,7 +582,8 @@ png_set_gray_to_rgb(png_structp png_ptr)
}
#endif
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \
+ defined(PNG_FLOATING_POINT_SUPPORTED)
/* Convert a RGB image to a grayscale of the same width. This allows us,
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
*/
@@ -718,7 +720,7 @@ png_init_read_transformations(png_structp png_ptr)
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_ptr->background_1 = png_ptr->background;
#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED)
+#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY))
{
png_build_gamma_table(png_ptr);
@@ -731,7 +733,6 @@ png_init_read_transformations(png_structp png_ptr)
png_colorp palette = png_ptr->palette;
int num_palette = png_ptr->num_palette;
int i;
-
if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
{
back.red = png_ptr->gamma_table[png_ptr->background.red];
@@ -789,7 +790,6 @@ png_init_read_transformations(png_structp png_ptr)
back_1.blue = (png_byte)(pow(
(double)png_ptr->background.blue/255, g) * 255.0 + .5);
}
-
for (i = 0; i < num_palette; i++)
{
if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff)
@@ -998,8 +998,15 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_GAMMA_SUPPORTED)
if (png_ptr->transformations & PNG_GAMMA)
+ {
+#ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->gamma = png_ptr->gamma;
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ info_ptr->int_gamma = png_ptr->int_gamma;
+#endif
+ }
+#endif
#if defined(PNG_READ_16_TO_8_SUPPORTED)
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
@@ -1290,7 +1297,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
png_ptr->row_info.channels = png_ptr->user_transform_channels;
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
- png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
+ png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
png_ptr->row_info.pixel_depth+7)>>3;
}
#endif
@@ -1988,7 +1995,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-/* reduce RGB files to grayscale, with or without alpha
+/* reduce RGB files to grayscale, with or without alpha
* using the equation given in Poynton's ColorFAQ at
* <http://www.inforamp.net/~poynton/>
* Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
@@ -1996,7 +2003,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
*
* We approximate this with
- *
+ *
* Y = 0.211 * R + 0.715 * G + 0.074 * B
*
* which can be expressed with integers as
@@ -2072,7 +2079,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
}
}
}
-
+
else /* RGB bit_depth == 16 */
{
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
@@ -2097,7 +2104,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_shift][green>>8];
- png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
+ png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
+ bc*blue_1)>>8);
@@ -2105,7 +2112,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][gray16 >> 8];
rgb_error |= 1;
}
-
+
*(dp++) = (png_byte)((w>>8) & 0xff);
*(dp++) = (png_byte)(w & 0xff);
}
@@ -2194,7 +2201,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_shift][green>>8];
- png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
+ png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc * red_1
+ gc * green_1 + bc * blue_1)>>8);
@@ -2202,7 +2209,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][gray16 >> 8];
rgb_error |= 1;
}
-
+
*(dp++) = (png_byte)((w>>8) & 0xff);
*(dp++) = (png_byte)(w & 0xff);
*(dp++) = *(sp++); /* alpha */
@@ -2298,7 +2305,8 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
int num_palette)
{
png_debug(1, "in png_correct_palette\n");
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
+ defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
{
png_color back, back_1;
@@ -3764,6 +3772,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
}
#endif
+#ifdef PNG_FLOATING_POINT_SUPPORTED
#if defined(PNG_READ_GAMMA_SUPPORTED)
static int png_gamma_shift[] =
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
@@ -3814,7 +3823,7 @@ png_build_gamma_table(png_structp png_ptr)
g) * 255.0 + .5);
}
-
+
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
@@ -3983,4 +3992,6 @@ png_build_gamma_table(png_structp png_ptr)
}
}
#endif
+/* To do: install integer version of png_build_gamma_table here */
+#endif
diff --git a/pngrutil.c b/pngrutil.c
index 3a51f2708..3a69a485d 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -136,6 +136,124 @@ png_crc_error(png_structp png_ptr)
return (0);
}
+#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
+ defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED)
+/*
+ * Decompress trailing data in a chunk. The assumption is that chunkdata
+ * points at an allocated area holding the contents of a chunk with a
+ * trailing compressed part. What we get back is an allocated area
+ * holding the original prefix part and an uncompressed version of the
+ * trailing part (the malloc area passed in is freed).
+ */
+png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
+ png_charp chunkdata, png_size_t chunklength,
+ png_size_t prefix_size)
+{
+ static char msg[] = "Error decoding compressed text";
+ png_charp text = NULL;
+ png_size_t text_size = (chunklength - prefix_size);
+
+ if (comp_type == PNG_TEXT_COMPRESSION_zTXt)
+ {
+ png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size);
+ png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size);
+ png_ptr->zstream.next_out = png_ptr->zbuf;
+ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+
+ text_size = 0;
+ text = NULL;
+
+ while (png_ptr->zstream.avail_in)
+ {
+ int ret;
+
+ ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
+ if (ret != Z_OK && ret != Z_STREAM_END)
+ {
+ if (png_ptr->zstream.msg != NULL)
+ png_warning(png_ptr, png_ptr->zstream.msg);
+ else
+ png_warning(png_ptr, msg);
+ inflateReset(&png_ptr->zstream);
+ png_ptr->zstream.avail_in = 0;
+
+ if (text == NULL)
+ {
+ text_size = prefix_size + sizeof(msg) + 1;
+ text = (png_charp)png_malloc(png_ptr, text_size);
+ png_memcpy(text, chunkdata, prefix_size);
+ }
+
+ text[text_size - 1] = 0x00;
+
+ /* Copy what we can of the error message into the text chunk */
+ text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
+ text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
+ png_memcpy(text + prefix_size, msg, text_size + 1);
+ break;
+ }
+ if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
+ {
+ if (text == NULL)
+ {
+ text_size = prefix_size +
+ png_ptr->zbuf_size - png_ptr->zstream.avail_out;
+ text = (png_charp)png_malloc(png_ptr, text_size + 1);
+ png_memcpy(text + prefix_size, png_ptr->zbuf,
+ text_size - prefix_size);
+ png_memcpy(text, chunkdata, prefix_size);
+ *(text + text_size) = 0x00;
+ }
+ else
+ {
+ png_charp tmp;
+
+ tmp = text;
+ text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
+ png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
+ png_memcpy(text, tmp, text_size);
+ png_free(png_ptr, tmp);
+ png_memcpy(text + text_size, png_ptr->zbuf,
+ (png_ptr->zbuf_size - png_ptr->zstream.avail_out));
+ text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
+ *(text + text_size) = 0x00;
+ }
+ if (ret == Z_STREAM_END)
+ break;
+ else
+ {
+ png_ptr->zstream.next_out = png_ptr->zbuf;
+ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+ }
+ }
+ }
+
+ inflateReset(&png_ptr->zstream);
+ png_ptr->zstream.avail_in = 0;
+
+ png_free(png_ptr, chunkdata);
+ chunkdata = text;
+ }
+ else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */
+ {
+#if !defined(PNG_NO_STDIO)
+ char umsg[50];
+
+ sprintf(umsg, "Unknown zTXt compression type %d", comp_type);
+ png_warning(png_ptr, umsg);
+#else
+ png_warning(png_ptr, "Unknown zTXt compression type");
+#endif
+
+ /* Copy what we can of the error message into the text chunk */
+ text_size = (png_size_t)(chunklength - (text - chunkdata));
+ text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
+ png_memcpy(text, msg, text_size);
+ }
+
+ return chunkdata;
+}
+#endif
/* read and check the IDHR chunk */
void
@@ -378,7 +496,9 @@ void
png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_uint_32 igamma;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float file_gamma;
+#endif
png_byte buf[4];
png_debug(1, "in png_handle_gAMA\n");
@@ -424,7 +544,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB)
- if(fabs((float)igamma - 45455.)>500.)
+ if(igamma < 45000L || igamma > 46000L)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
@@ -435,11 +555,16 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#endif /* PNG_READ_sRGB_SUPPORTED */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
file_gamma = (float)igamma / (float)100000.0;
#ifdef PNG_READ_GAMMA_SUPPORTED
png_ptr->gamma = file_gamma;
#endif
png_set_gAMA(png_ptr, info_ptr, file_gamma);
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_set_gAMA_fixed(png_ptr, info_ptr, igamma);
+#endif
}
#endif
@@ -514,8 +639,11 @@ void
png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_byte buf[4];
- png_uint_32 val;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
+#endif
+ png_uint_32 int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
+ int_y_green, int_x_blue, int_y_blue;
png_debug(1, "in png_handle_cHRM\n");
@@ -550,15 +678,13 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- white_x = (float)val / (float)100000.0;
+ int_x_white = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- white_y = (float)val / (float)100000.0;
+ int_y_white = png_get_uint_32(buf);
- if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
- white_x + white_y > 1.0)
+ if (int_x_white > 80000L || int_y_white > 80000L ||
+ int_x_white + int_y_white > 100000L)
{
png_warning(png_ptr, "Invalid cHRM white point");
png_crc_finish(png_ptr, 24);
@@ -566,15 +692,13 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- red_x = (float)val / (float)100000.0;
+ int_x_red = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- red_y = (float)val / (float)100000.0;
+ int_y_red = png_get_uint_32(buf);
- if (red_x < 0 || red_x > 0.8 || red_y < 0 || red_y > 0.8 ||
- red_x + red_y > 1.0)
+ if (int_x_red > 80000L || int_y_red > 80000L ||
+ int_x_red + int_y_red > 100000L)
{
png_warning(png_ptr, "Invalid cHRM red point");
png_crc_finish(png_ptr, 16);
@@ -582,15 +706,13 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- green_x = (float)val / (float)100000.0;
+ int_x_green = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- green_y = (float)val / (float)100000.0;
+ int_y_green = png_get_uint_32(buf);
- if (green_x < 0 || green_x > 0.8 || green_y < 0 || green_y > 0.8 ||
- green_x + green_y > 1.0)
+ if (int_x_green > 80000L || int_y_green > 80000L ||
+ int_x_green + int_y_green > 100000L)
{
png_warning(png_ptr, "Invalid cHRM green point");
png_crc_finish(png_ptr, 8);
@@ -598,20 +720,28 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- blue_x = (float)val / (float)100000.0;
+ int_x_blue = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4);
- val = png_get_uint_32(buf);
- blue_y = (float)val / (float)100000.0;
+ int_y_blue = png_get_uint_32(buf);
- if (blue_x < (float)0 || blue_x > (float)0.8 || blue_y < (float)0 ||
- blue_y > (float)0.8 || blue_x + blue_y > (float)1.0)
+ if (int_x_blue > 80000L || int_y_blue > 80000L ||
+ int_x_blue + int_y_blue > 100000L)
{
png_warning(png_ptr, "Invalid cHRM blue point");
png_crc_finish(png_ptr, 0);
return;
}
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ white_x = (float)int_x_white / (float)100000.0;
+ white_y = (float)int_y_white / (float)100000.0;
+ red_x = (float)int_x_red / (float)100000.0;
+ red_y = (float)int_y_red / (float)100000.0;
+ green_x = (float)int_x_green / (float)100000.0;
+ green_y = (float)int_y_green / (float)100000.0;
+ blue_x = (float)int_x_blue / (float)100000.0;
+ blue_y = (float)int_y_blue / (float)100000.0;
+#endif
if (png_crc_finish(png_ptr, 0))
return;
@@ -619,31 +749,45 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB)
{
- if (fabs(white_x - (float).3127) > (float).001 ||
- fabs(white_y - (float).3290) > (float).001 ||
- fabs( red_x - (float).6400) > (float).001 ||
- fabs( red_y - (float).3300) > (float).001 ||
- fabs(green_x - (float).3000) > (float).001 ||
- fabs(green_y - (float).6000) > (float).001 ||
- fabs( blue_x - (float).1500) > (float).001 ||
- fabs( blue_y - (float).0600) > (float).001)
+ if (abs((int)int_x_white - 31270L) > 1000 ||
+ abs((int)int_y_white - 32900L) > 1000 ||
+ abs((int) int_x_red - 64000L) > 1000 ||
+ abs((int) int_y_red - 33000L) > 1000 ||
+ abs((int)int_x_green - 30000L) > 1000 ||
+ abs((int)int_y_green - 60000L) > 1000 ||
+ abs((int) int_x_blue - 15000L) > 1000 ||
+ abs((int) int_y_blue - 6000L) > 1000)
{
png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
+#ifdef PNG_FLOATING_POINT_SUPPORTED
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
white_x, white_y, red_x, red_y);
fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",
green_x, green_y, blue_x, blue_y);
+#else
+ fprintf(stderr,"wx=%d, wy=%d, rx=%d, ry=%d\n",
+ int_x_white, int_y_white, int_x_red, int_y_red);
+ fprintf(stderr,"gx=%d, gy=%d, bx=%d, by=%d\n",
+ int_x_green, int_y_green, int_x_blue, int_y_blue);
#endif
+#endif /* PNG_NO_CONSOLE_IO */
}
return;
}
#endif /* PNG_READ_sRGB_SUPPORTED */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
png_set_cHRM(png_ptr, info_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_set_cHRM_fixed(png_ptr, info_ptr,
+ int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
+ int_y_green, int_x_blue, int_y_blue);
+#endif
}
#endif
@@ -652,6 +796,7 @@ void
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
int intent;
+ int igamma;
png_byte buf[1];
png_debug(1, "in png_handle_sRGB\n");
@@ -695,27 +840,38 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ igamma=png_ptr->gamma * 100000.;
+#else
+# ifdef PNG_FIXED_POINT_SUPPORTED
+ igamma=(int)png_ptr->int_gamma;
+# endif
+#endif
if ((info_ptr->valid & PNG_INFO_gAMA))
- if(fabs((png_ptr->gamma*(float)100000.+.5)-45455.) > 500.)
+ if(igamma < 45000L || igamma > 46000L)
{
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
+#ifdef PNG_FLOATING_POINT_SUPPORTED
fprintf(stderr,"gamma=%f\n",png_ptr->gamma);
+#else
+ fprintf(stderr,"gamma=%d\n",png_ptr->int_gamma);
+#endif
#endif
}
#endif /* PNG_READ_gAMA_SUPPORTED */
#ifdef PNG_READ_cHRM_SUPPORTED
if (info_ptr->valid & PNG_INFO_cHRM)
- if (fabs(info_ptr->x_white - (float).3127) > (float).001 ||
- fabs(info_ptr->y_white - (float).3290) > (float).001 ||
- fabs( info_ptr->x_red - (float).6400) > (float).001 ||
- fabs( info_ptr->y_red - (float).3300) > (float).001 ||
- fabs(info_ptr->x_green - (float).3000) > (float).001 ||
- fabs(info_ptr->y_green - (float).6000) > (float).001 ||
- fabs( info_ptr->x_blue - (float).1500) > (float).001 ||
- fabs( info_ptr->y_blue - (float).0600) > (float).001)
+ if (abs((int)info_ptr->int_x_white - 31270L) > 1000 ||
+ abs((int)info_ptr->int_y_white - 32900L) > 1000 ||
+ abs((int) info_ptr->int_x_red - 64000L) > 1000 ||
+ abs((int) info_ptr->int_y_red - 33000L) > 1000 ||
+ abs((int)info_ptr->int_x_green - 30000L) > 1000 ||
+ abs((int)info_ptr->int_y_green - 60000L) > 1000 ||
+ abs((int) info_ptr->int_x_blue - 15000L) > 1000 ||
+ abs((int) info_ptr->int_y_blue - 6000L) > 1000)
{
png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present");
@@ -726,6 +882,195 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#endif /* PNG_READ_sRGB_SUPPORTED */
+#if defined(PNG_READ_iCCP_SUPPORTED)
+void
+png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+/* Note: this does not properly handle chunks that are > 64K under DOS */
+{
+ png_charp chunkdata;
+ png_byte compression_type;
+ png_charp profile;
+ png_uint_32 skip = 0;
+ png_size_t slength, prefix_length;
+
+ png_debug(1, "in png_handle_iCCP\n");
+
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ png_error(png_ptr, "Missing IHDR before iCCP");
+ else if (png_ptr->mode & PNG_HAVE_IDAT)
+ {
+ png_warning(png_ptr, "Invalid iCCP after IDAT");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+ else if (png_ptr->mode & PNG_HAVE_PLTE)
+ /* Should be an error, but we can cope with it */
+ png_warning(png_ptr, "Out of place iCCP chunk");
+
+ else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_iCCP)
+ {
+ png_warning(png_ptr, "Duplicate iCCP chunk");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+
+#ifdef PNG_MAX_MALLOC_64K
+ if (length > (png_uint_32)65535L)
+ {
+ png_warning(png_ptr, "iCCP chunk too large to fit in memory");
+ skip = length - (png_uint_32)65535L;
+ length = (png_uint_32)65535L;
+ }
+#endif
+
+ chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
+ slength = (png_size_t)length;
+ png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
+
+ if (png_crc_finish(png_ptr, skip))
+ {
+ png_free(png_ptr, chunkdata);
+ return;
+ }
+
+ chunkdata[slength] = 0x00;
+
+ for (profile = chunkdata; *profile; profile++)
+ /* empty loop to find end of name */ ;
+ ++profile;
+
+ /* there should be at least one NUL (the compression type byte)
+ following the separator, and we should be on it */
+ if (profile >= chunkdata + slength)
+ {
+ png_free(png_ptr, chunkdata);
+ png_error(png_ptr, "malformed iCCP chunk");
+ }
+
+ /* compression should always be zero */
+ compression_type = *profile++;
+
+ prefix_length = profile - chunkdata;
+ chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata,
+ slength, prefix_length);
+
+ png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type,
+ chunkdata + prefix_length, png_strlen(chunkdata + prefix_length));
+ png_free(png_ptr, chunkdata);
+}
+#endif /* PNG_READ_iCCP_SUPPORTED */
+
+#if defined(PNG_READ_sPLT_SUPPORTED)
+void
+png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+/* Note: this does not properly handle chunks that are > 64K under DOS */
+{
+ png_bytep chunkdata;
+ png_bytep entry_start;
+ png_spalette new_palette;
+ int data_length, entry_size, i;
+ png_uint_32 skip = 0;
+ png_size_t slength;
+
+ png_debug(1, "in png_handle_sPLT\n");
+
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ png_error(png_ptr, "Missing IHDR before sPLT");
+ else if (png_ptr->mode & PNG_HAVE_IDAT)
+ {
+ png_warning(png_ptr, "Invalid sPLT after IDAT");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+ else if (png_ptr->mode & PNG_HAVE_PLTE)
+ /* Should be an error, but we can cope with it */
+ png_warning(png_ptr, "Out of place sPLT chunk");
+
+ else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sPLT)
+ {
+ png_warning(png_ptr, "Duplicate sPLT chunk");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+
+#ifdef PNG_MAX_MALLOC_64K
+ if (length > (png_uint_32)65535L)
+ {
+ png_warning(png_ptr, "sPLT chunk too large to fit in memory");
+ skip = length - (png_uint_32)65535L;
+ length = (png_uint_32)65535L;
+ }
+#endif
+
+ chunkdata = (png_bytep)png_malloc(png_ptr, length + 1);
+ slength = (png_size_t)length;
+ png_crc_read(png_ptr, chunkdata, slength);
+
+ if (png_crc_finish(png_ptr, skip))
+ {
+ png_free(png_ptr, chunkdata);
+ return;
+ }
+
+ chunkdata[slength] = 0x00;
+
+ for (entry_start = chunkdata; *entry_start; entry_start++)
+ /* empty loop to find end of name */ ;
+ ++entry_start;
+
+ /* a sample depth should follow the separator, and we should be on it */
+ if (entry_start > chunkdata + slength)
+ {
+ png_free(png_ptr, chunkdata);
+ png_error(png_ptr, "malformed sPLT chunk");
+ }
+
+ new_palette.depth = *entry_start++;
+ entry_size = (new_palette.depth == 8 ? 6 : 10);
+ data_length = (slength - (entry_start - chunkdata));
+
+ /* integrity-check the data length */
+ if (data_length % entry_size)
+ {
+ png_free(png_ptr, chunkdata);
+ png_error(png_ptr, "sPLT chunk has bad length");
+ }
+
+ new_palette.nentries = data_length / entry_size;
+ new_palette.entries = (png_spalette_entryp)png_malloc(
+ png_ptr, new_palette.nentries * sizeof(png_spalette_entry));
+
+ for (i = 0; i < new_palette.nentries; i++)
+ {
+ png_spalette_entryp pp = new_palette.entries + i;
+
+ if (new_palette.depth == 8)
+ {
+ pp->red = *entry_start++;
+ pp->green = *entry_start++;
+ pp->blue = *entry_start++;
+ pp->alpha = *entry_start++;
+ }
+ else
+ {
+ pp->red = png_get_uint_16(entry_start); entry_start += 2;
+ pp->green = png_get_uint_16(entry_start); entry_start += 2;
+ pp->blue = png_get_uint_16(entry_start); entry_start += 2;
+ pp->alpha = png_get_uint_16(entry_start); entry_start += 2;
+ }
+ pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
+ }
+
+ /* discard all chunk data except the name and stash that */
+ new_palette.name = (png_charp)chunkdata;
+
+ png_set_spalettes(png_ptr, info_ptr, &new_palette, 1);
+
+ png_free(png_ptr, chunkdata);
+ png_free(png_ptr, new_palette.entries);
+}
+#endif /* PNG_READ_sPLT_SUPPORTED */
+
#if defined(PNG_READ_tRNS_SUPPORTED)
void
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
@@ -1012,7 +1357,7 @@ void
png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_byte buf[9];
- png_uint_32 offset_x, offset_y;
+ png_int_32 offset_x, offset_y;
int unit_type;
png_debug(1, "in png_handle_oFFs\n");
@@ -1043,8 +1388,8 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_crc_finish(png_ptr, 0))
return;
- offset_x = png_get_uint_32(buf);
- offset_y = png_get_uint_32(buf + 4);
+ offset_x = png_get_int_32(buf);
+ offset_y = png_get_int_32(buf + 4);
unit_type = buf[8];
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);
}
@@ -1167,6 +1512,99 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#endif
+#if defined(PNG_READ_sCAL_SUPPORTED)
+/* read the sCAL chunk */
+void
+png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+{
+ png_charp unit, swidth, sheight, ep;
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ double width=0., height=0.;
+ png_charp vp;
+#endif
+ png_size_t slength;
+
+ png_debug(1, "in png_handle_sCAL\n");
+
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ png_error(png_ptr, "Missing IHDR before sCAL");
+ else if (png_ptr->mode & PNG_HAVE_IDAT)
+ {
+ png_warning(png_ptr, "Invalid sCAL after IDAT");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+ else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sCAL)
+ {
+ png_warning(png_ptr, "Duplicate sCAL chunk");
+ png_crc_finish(png_ptr, length);
+ return;
+ }
+
+ png_debug1(2, "Allocating and reading sCAL chunk data (%d bytes)\n",
+ length + 1);
+ unit = (png_charp)png_malloc(png_ptr, length + 1);
+ slength = (png_size_t)length;
+ png_crc_read(png_ptr, (png_bytep)unit, slength);
+
+ if (png_crc_finish(png_ptr, 0))
+ {
+ png_free(png_ptr, unit);
+ return;
+ }
+
+ unit[slength] = 0x00; /* null terminate the last string */
+
+ png_debug(3, "Finding end of sCAL unit string\n");
+ for (ep = unit; *ep; ep++)
+ /* empty loop */ ;
+ ep++;
+
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ width = strtod(ep, &vp);
+ if (*vp)
+ png_error(png_ptr, "malformed width string in sCAL chunk");
+#endif
+ swidth = (png_charp)png_malloc(png_ptr, strlen(ep) + 1);
+ png_memcpy(swidth, ep, (png_size_t)strlen(ep));
+
+ for (ep = unit; *ep; ep++)
+ /* empty loop */ ;
+ ep++;
+
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ height = strtod(ep, &vp);
+ if (*vp)
+ png_error(png_ptr, "malformed height string in sCAL chunk");
+#endif
+ sheight = (png_charp)png_malloc(png_ptr, strlen(ep) + 1);
+ png_memcpy(sheight, ep, (png_size_t)strlen(ep));
+
+ if (unit + slength < ep
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ || width <= 0. || height <= 0.
+#endif
+ )
+ {
+ png_warning(png_ptr, "Invalid sCAL data");
+ png_free(png_ptr, unit);
+ png_free(png_ptr, swidth);
+ png_free(png_ptr, sheight);
+ return;
+ }
+
+
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ png_set_sCAL(png_ptr, info_ptr, unit, width, height);
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
+#endif
+
+ png_free(png_ptr, unit);
+}
+#endif
+
#if defined(PNG_READ_tIME_SUPPORTED)
void
png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
@@ -1258,6 +1696,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
+ text_ptr->lang = NULL;
text_ptr->key = key;
text_ptr->text = text;
@@ -1273,12 +1712,11 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void
png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
- static char msg[] = "Error decoding zTXt chunk";
png_textp text_ptr;
- png_charp key;
+ png_charp chunkdata;
png_charp text;
int comp_type = PNG_TEXT_COMPRESSION_NONE;
- png_size_t slength;
+ png_size_t slength, prefix_len;
png_debug(1, "in png_handle_zTXt\n");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
@@ -1298,153 +1736,154 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#endif
- key = (png_charp)png_malloc(png_ptr, length + 1);
+ chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)key, slength);
+ png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (png_crc_finish(png_ptr, 0))
{
- png_free(png_ptr, key);
+ png_free(png_ptr, chunkdata);
return;
}
- key[slength] = 0x00;
+ chunkdata[slength] = 0x00;
- for (text = key; *text; text++)
+ for (text = chunkdata; *text; text++)
/* empty loop */ ;
- /* zTXt must have some text after the keyword */
- if (text == key + slength)
+ /* zTXt must have some text after the chunkdataword */
+ if (text == chunkdata + slength)
{
+ comp_type = PNG_TEXT_COMPRESSION_NONE;
png_warning(png_ptr, "Zero length zTXt chunk");
}
- else if ((comp_type = *(++text)) == PNG_TEXT_COMPRESSION_zTXt)
+ else
{
- png_size_t text_size, key_size;
- text++;
+ comp_type = *(++text);
+ text++; /* skip the compression byte */
+ }
+ prefix_len = text - chunkdata;
- png_ptr->zstream.next_in = (png_bytep)text;
- png_ptr->zstream.avail_in = (uInt)(length - (text - key));
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+ chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
+ (png_size_t)length, prefix_len);
- key_size = (png_size_t)(text - key);
- text_size = 0;
- text = NULL;
+ text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+ text_ptr->compression = comp_type;
+ text_ptr->lang = NULL;
+ text_ptr->key = chunkdata;
+ text_ptr->text = chunkdata + prefix_len;
- while (png_ptr->zstream.avail_in)
- {
- int ret;
+ png_set_text(png_ptr, info_ptr, text_ptr, 1);
- ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
- if (ret != Z_OK && ret != Z_STREAM_END)
- {
- if (png_ptr->zstream.msg != NULL)
- png_warning(png_ptr, png_ptr->zstream.msg);
- else
- png_warning(png_ptr, msg);
- inflateReset(&png_ptr->zstream);
- png_ptr->zstream.avail_in = 0;
+ png_free(png_ptr, text_ptr);
+ png_free(png_ptr, chunkdata);
+}
+#endif
- if (text == NULL)
- {
- text_size = key_size + sizeof(msg) + 1;
- text = (png_charp)png_malloc(png_ptr, (png_uint_32)text_size);
- png_memcpy(text, key, key_size);
- }
+#if defined(PNG_READ_iTXt_SUPPORTED)
+/* note: this does not correctly handle chunks that are > 64K under DOS */
+void
+png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
+{
+ png_textp text_ptr;
+ png_charp chunkdata;
+ png_charp lang, text;
+ int comp_type = PNG_TEXT_COMPRESSION_NONE;
+ int comp_flag = 0;
+ png_size_t slength, prefix_len;
- text[text_size - 1] = 0x00;
+ png_debug(1, "in png_handle_iTXt\n");
- /* Copy what we can of the error message into the text chunk */
- text_size = (png_size_t)(slength - (text - key) - 1);
- text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
- png_memcpy(text + key_size, msg, text_size + 1);
- break;
- }
- if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
- {
- if (text == NULL)
- {
- text = (png_charp)png_malloc(png_ptr,
- (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
- + key_size + 1));
- png_memcpy(text + key_size, png_ptr->zbuf,
- png_ptr->zbuf_size - png_ptr->zstream.avail_out);
- png_memcpy(text, key, key_size);
- text_size = key_size + png_ptr->zbuf_size -
- png_ptr->zstream.avail_out;
- *(text + text_size) = 0x00;
- }
- else
- {
- png_charp tmp;
-
- tmp = text;
- text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
- png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
- png_memcpy(text, tmp, text_size);
- png_free(png_ptr, tmp);
- png_memcpy(text + text_size, png_ptr->zbuf,
- (png_ptr->zbuf_size - png_ptr->zstream.avail_out));
- text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
- *(text + text_size) = 0x00;
- }
- if (ret != Z_STREAM_END)
- {
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
- }
- else
- {
- break;
- }
- }
- }
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ png_error(png_ptr, "Missing IHDR before iTXt");
- inflateReset(&png_ptr->zstream);
- png_ptr->zstream.avail_in = 0;
+ if (png_ptr->mode & PNG_HAVE_IDAT)
+ png_ptr->mode |= PNG_AFTER_IDAT;
- png_free(png_ptr, key);
- key = text;
- text += key_size;
+#ifdef PNG_MAX_MALLOC_64K
+ /* We will no doubt have problems with chunks even half this size, but
+ there is no hard and fast rule to tell us where to stop. */
+ if (length > (png_uint_32)65535L)
+ {
+ png_warning(png_ptr,"iTXt chunk too large to fit in memory");
+ png_crc_finish(png_ptr, length);
+ return;
}
- else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */
+#endif
+
+ chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
+ slength = (png_size_t)length;
+ png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
+ if (png_crc_finish(png_ptr, 0))
{
- png_size_t text_size;
-#if !defined(PNG_NO_STDIO)
- char umsg[50];
+ png_free(png_ptr, chunkdata);
+ return;
+ }
- sprintf(umsg, "Unknown zTXt compression type %d", comp_type);
- png_warning(png_ptr, umsg);
-#else
- png_warning(png_ptr, "Unknown zTXt compression type");
-#endif
+ chunkdata[slength] = 0x00;
- /* Copy what we can of the error message into the text chunk */
- text_size = (png_size_t)(slength - (text - key) - 1);
- text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
- png_memcpy(text, msg, text_size + 1);
+ for (lang = chunkdata; *lang; lang++)
+ /* empty loop */ ;
+ lang++; /* skip NUL separator */
+
+ /* iTXt must have a language tag and some text after the keyword */
+ if (lang >= chunkdata + slength)
+ {
+ comp_type = PNG_TEXT_COMPRESSION_NONE;
+ png_warning(png_ptr, "Zero length iTXt chunk");
}
+ else
+ {
+ comp_flag = *lang++;
+ comp_type = *lang++;
+ }
+
+ for (text = lang; *text; text++)
+ /* empty loop */ ;
+ text++; /* skip NUL separator */
+
+ prefix_len = text - chunkdata;
+
+ if (comp_flag)
+ chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata,
+ (size_t)length, prefix_len);
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
- text_ptr->compression = comp_type;
- text_ptr->key = key;
- text_ptr->text = text;
+ text_ptr->compression = (png_byte)comp_type;
+ text_ptr->lang = NULL;
+ text_ptr->key = chunkdata;
+ text_ptr->text = chunkdata + prefix_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr->key);
png_free(png_ptr, text_ptr);
+ png_free(png_ptr, chunkdata);
+}
+#endif
+
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+void
+png_set_keep_unknown_chunks(png_structp png_ptr)
+{
+ png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
}
#endif
/* This function is called when we haven't found a handler for a
chunk. If there isn't a problem with the chunk itself (ie bad
- chunk name, CRC, or a critical chunk), the chunk is silently ignored. */
+ chunk name, CRC, or a critical chunk), the chunk is silently ignored
+ -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
+ case it will be saved away to be written out later. */
void
png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
+ png_uint_32 skip = 0;
+
png_debug(1, "in png_handle_unknown\n");
+ if (png_ptr->mode & PNG_HAVE_IDAT)
+ png_ptr->mode |= PNG_AFTER_IDAT;
+
/* In the future we can have code here that calls user-supplied
* callback functions for unknown chunks before they are ignored or
* cause an error.
@@ -1460,11 +1899,32 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
- if (png_ptr->mode & PNG_HAVE_IDAT)
- png_ptr->mode |= PNG_AFTER_IDAT;
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+ if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
+ {
+ png_unknown_chunk chunk;
- png_crc_finish(png_ptr, length);
+#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(chunk.name, png_ptr->chunk_name);
+ chunk.data = (png_bytep)png_malloc(png_ptr, length);
+ png_crc_read(png_ptr, chunk.data, length);
+ chunk.size = length;
+ png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
+ png_free(png_ptr, chunk.data);
+ }
+ else
+#endif
+ skip = length;
+ png_crc_finish(png_ptr, skip);
}
/* This function is called to verify that a chunk name is valid.
@@ -1715,11 +2175,11 @@ png_do_read_interlace
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
-
+
png_debug(1,"in png_do_read_interlace\n");
if (row != NULL && row_info != NULL)
{
@@ -2060,20 +2520,20 @@ png_read_finish_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
+
/* start of interlace block in the y direction */
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
+
/* offset to next interlace block in the y direction */
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
-
+
png_debug(1, "in png_read_finish_row\n");
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
@@ -2182,20 +2642,20 @@ png_read_start_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
+
/* start of interlace block in the y direction */
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
+
/* offset to next interlace block in the y direction */
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
-
+
int max_pixel_depth;
png_uint_32 row_bytes;
diff --git a/pngset.c b/pngset.c
index d31f44344..6e7420a40 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -16,7 +16,7 @@
#define PNG_INTERNAL
#include "png.h"
-#if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
+#if defined(PNG_bKGD_SUPPORTED)
void
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
{
@@ -29,7 +29,8 @@ png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
}
#endif
-#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
+#if defined(PNG_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
void
png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double white_x, double white_y, double red_x, double red_y,
@@ -50,8 +51,32 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
info_ptr->valid |= PNG_INFO_cHRM;
}
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+void
+png_set_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_debug1(1, "in %s storage function\n", "cHRM");
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
+ info_ptr->int_x_white = white_x;
+ info_ptr->int_y_white = white_y;
+ info_ptr->int_x_red = red_x;
+ info_ptr->int_y_red = red_y;
+ info_ptr->int_x_green = green_x;
+ info_ptr->int_y_green = green_y;
+ info_ptr->int_x_blue = blue_x;
+ info_ptr->int_y_blue = blue_y;
+ info_ptr->valid |= PNG_INFO_cHRM;
+}
+#endif
+#endif
+
+#if defined(PNG_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
void
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{
@@ -60,11 +85,30 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
return;
info_ptr->gamma = (float)file_gamma;
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ info_ptr->int_gamma = (int)(file_gamma*100000.+.5);
+#endif
+ info_ptr->valid |= PNG_INFO_gAMA;
+}
+#endif
+#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+void
+png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_uint_32 int_gamma)
+{
+ png_debug1(1, "in %s storage function\n", "gAMA");
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ info_ptr->gamma = (float)int_gamma/100000.;
+#endif
+ info_ptr->int_gamma = int_gamma;
info_ptr->valid |= PNG_INFO_gAMA;
}
#endif
-#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
+#if defined(PNG_hIST_SUPPORTED)
void
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
{
@@ -117,10 +161,10 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3;
}
-#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
void
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
+ png_int_32 offset_x, png_int_32 offset_y, int unit_type)
{
png_debug1(1, "in %s storage function\n", "oFFs");
if (png_ptr == NULL || info_ptr == NULL)
@@ -133,7 +177,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
}
#endif
-#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
+#if defined(PNG_pCAL_SUPPORTED)
void
png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
@@ -178,7 +222,58 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
}
#endif
-#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+void
+png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
+ png_charp unit, double width, double height)
+{
+ png_uint_32 length;
+
+ png_debug1(1, "in %s storage function\n", "sCAL");
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ length = png_strlen(unit) + 1;
+ png_debug1(3, "allocating unit for info (%d bytes)\n", length);
+ info_ptr->scal_unit = (png_charp)png_malloc(png_ptr, length);
+ png_memcpy(info_ptr->scal_unit, unit, (png_size_t)length);
+ info_ptr->scal_pixel_width = width;
+ info_ptr->scal_pixel_height = height;
+
+ info_ptr->valid |= PNG_INFO_sCAL;
+}
+#endif
+void
+png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
+ png_charp unit, png_charp swidth, png_charp sheight)
+{
+ png_uint_32 length;
+
+ png_debug1(1, "in %s storage function\n", "sCAL");
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ length = png_strlen(unit) + 1;
+ png_debug1(3, "allocating unit for info (%d bytes)\n", length);
+ info_ptr->scal_unit = (png_charp)png_malloc(png_ptr, length);
+ png_memcpy(info_ptr->scal_unit, unit, (png_size_t)length);
+
+ length = png_strlen(swidth) + 1;
+ png_debug1(3, "allocating unit for info (%d bytes)\n", length);
+ info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
+ png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
+
+ length = png_strlen(sheight) + 1;
+ png_debug1(3, "allocating unit for info (%d bytes)\n", length);
+ info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length);
+ png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
+
+ info_ptr->valid |= PNG_INFO_sCAL;
+}
+#endif
+
+#if defined(PNG_pHYs_SUPPORTED)
void
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
@@ -207,7 +302,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
info_ptr->valid |= PNG_INFO_PLTE;
}
-#if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
+#if defined(PNG_sBIT_SUPPORTED)
void
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit)
@@ -221,7 +316,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
}
#endif
-#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
+#if defined(PNG_sRGB_SUPPORTED)
void
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{
@@ -232,28 +327,61 @@ png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
info_ptr->srgb_intent = (png_byte)intent;
info_ptr->valid |= PNG_INFO_sRGB;
}
+
void
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int intent)
{
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float file_gamma;
#endif
-#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_uint_32 int_file_gamma;
+#endif
+#endif
+#if defined(PNG_cHRM_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_uint_32 int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
+ int_green_y, int_blue_x, int_blue_y;
+#endif
+#endif
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
png_set_sRGB(png_ptr, info_ptr, intent);
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
file_gamma = (float).45455;
png_set_gAMA(png_ptr, info_ptr, file_gamma);
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ int_file_gamma = 45455L;
+ png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
+#endif
+#endif
-#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
+#if defined(PNG_cHRM_SUPPORTED)
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ int_white_x = 31270L;
+ int_white_y = 32900L;
+ int_red_x = 64000L;
+ int_red_y = 33000L;
+ int_green_x = 30000L;
+ int_green_y = 60000L;
+ int_blue_x = 15000L;
+ int_blue_y = 6000L;
+
+ png_set_cHRM_fixed(png_ptr, info_ptr,
+ int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
+ int_blue_x, int_blue_y);
+#endif
+#ifdef PNG_FLOATING_POINT_SUPPORTED
white_x = (float).3127;
white_y = (float).3290;
red_x = (float).64;
@@ -265,13 +393,35 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
png_set_cHRM(png_ptr, info_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
-
+#endif
#endif
}
#endif
-#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
- defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+
+#if defined(PNG_iCCP_SUPPORTED)
+void
+png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
+ png_charp name, int compression_type,
+ png_charp profile, int proflen)
+{
+ png_debug1(1, "in %s storage function\n", "iCCP");
+ if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
+ return;
+
+ info_ptr->iccp_name = png_malloc(png_ptr, png_strlen(name)+1);
+ strcpy(info_ptr->iccp_name, name);
+ info_ptr->iccp_profile = png_malloc(png_ptr, proflen);
+ memcpy(info_ptr->iccp_profile, profile, proflen);
+ info_ptr->iccp_proflen = (png_uint_32)proflen;
+ /* Compression is always zero but is here so the API and info structure
+ * does not have to change * if we introduce multiple compression types */
+ info_ptr->iccp_compression = (png_byte)compression_type;
+ info_ptr->valid |= PNG_INFO_iCCP;
+}
+#endif
+
+#if defined(PNG_TEXT_SUPPORTED)
void
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
int num_text)
@@ -320,7 +470,15 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
png_charp key,text;
if (text_ptr[i].key == (png_charp)NULL)
- continue;
+ continue;
+
+#ifdef PNG_iTXt_SUPPORTED
+ textp->lang = text_ptr[i].lang;
+ textp->translated_key = text_ptr[i].translated_key;
+#else
+ textp->lang = NULL;
+ textp->translated_key = NULL;
+#endif
if (text_ptr[i].text[0] == '\0')
{
@@ -346,6 +504,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
png_memcpy(textp->key, text_ptr[i].key,
(png_size_t)(text - key)); /* includes the zero-byte separator */
+
textp->text = textp->key + (text-key);
if(textp->text_length)
{
@@ -362,7 +521,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
}
#endif
-#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
void
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{
@@ -376,7 +535,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
}
#endif
-#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
+#if defined(PNG_tRNS_SUPPORTED)
void
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values)
@@ -402,6 +561,74 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
}
#endif
+#if defined(PNG_sPLT_SUPPORTED)
+void
+png_set_spalettes(png_structp png_ptr,
+ png_infop info_ptr, png_spalette_p entries, int nentries)
+{
+ png_spalette_p np;
+ int i;
+
+ np = (png_spalette_p)png_malloc(png_ptr,
+ (info_ptr->splt_palettes_num + nentries) * sizeof(png_spalette));
+
+ memcpy(np, info_ptr->splt_palettes,
+ info_ptr->splt_palettes_num * sizeof(png_spalette));
+ png_free(png_ptr, info_ptr->splt_palettes);
+
+ for (i = 0; i < nentries; i++)
+ {
+ png_spalette_p to = np + info_ptr->splt_palettes_num + i;
+ png_spalette_p from = entries + i;
+
+ to->name = (png_charp)png_malloc(png_ptr,
+ png_strlen(from->name) + 1);
+ png_strcpy(to->name, from->name);
+ to->entries = (png_spalette_entryp)png_malloc(png_ptr,
+ from->nentries * sizeof(png_spalette));
+ memcpy(to->entries, from->entries,
+ from->nentries * sizeof(png_spalette));
+ }
+
+ info_ptr->splt_palettes = np;
+ info_ptr->splt_palettes_num += nentries;
+}
+#endif /* PNG_sPLT_SUPPORTED */
+
+#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
+void
+png_set_unknown_chunks(png_structp png_ptr,
+ png_infop info_ptr, png_unknown_chunkp unknowns, int nunknowns)
+{
+ png_unknown_chunkp np;
+ int i;
+
+ np = (png_unknown_chunkp)png_malloc(png_ptr,
+ (info_ptr->unknown_chunks_num + nunknowns) * sizeof(png_unknown_chunk));
+
+ memcpy(np, info_ptr->unknown_chunks,
+ info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
+ png_free(png_ptr, info_ptr->unknown_chunks);
+
+ for (i = 0; i < nunknowns; i++)
+ {
+ png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
+ png_unknown_chunkp from = unknowns + i;
+
+ png_strcpy(to->name, from->name);
+ to->data = (png_bytep)png_malloc(png_ptr, from->size);
+ memcpy(to->data, from->data, from->size);
+ to->size = from->size;
+
+ /* note our location in the read or write sequence */
+ to->location = png_ptr->mode;
+ }
+
+ info_ptr->unknown_chunks = np;
+ info_ptr->unknown_chunks_num += nunknowns;
+}
+#endif
+
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED)
void
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
@@ -412,3 +639,10 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
png_ptr->empty_plte_permitted=(png_byte)empty_plte_permitted;
}
#endif
+
+
+
+
+
+
+
diff --git a/pngtest.c b/pngtest.c
index 1dc227616..a1e453133 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -39,6 +39,10 @@
#define PNGTEST_TIMING
*/
+#ifdef PNG_NO_FLOATING_POINT_SUPPORTED
+#undef PNGTEST_TIMING
+#endif
+
#ifdef PNGTEST_TIMING
static float t_start, t_stop, t_decode, t_encode, t_misc;
#include <time.h>
@@ -48,7 +52,7 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
#ifdef PNGTEST_TIMING
static float t_start, t_stop, t_decode, t_encode, t_misc;
-#if !defined(PNG_READ_tIME_SUPPORTED) && !defined(PNG_WRITE_tIME_SUPPORTED)
+#if !defined(PNG_tIME_SUPPORTED)
#include <time.h>
#endif
#endif
@@ -56,7 +60,7 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
#if defined(PNG_TIME_RFC1123_SUPPORTED)
static int tIME_chunk_present=0;
static char tIME_string[30] = "no tIME chunk present in file";
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif
static int verbose = 0;
@@ -512,7 +516,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int bit_depth, color_type;
#ifdef USE_FAR_KEYWORD
jmp_buf jmpbuf;
-#endif
+#endif
char inbuf[256], outbuf[256];
@@ -657,39 +661,45 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
}
}
-#if defined(PNG_READ_bKGD_SUPPORTED) && defined(PNG_WRITE_bKGD_SUPPORTED)
+#if defined(PNG_cHRM_SUPPORTED)
{
- png_color_16p background;
+ png_uint_32 white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
+ blue_y;
- if (png_get_bKGD(read_ptr, read_info_ptr, &background))
+ if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
+ &red_y, &green_x, &green_y, &blue_x, &blue_y))
{
- png_set_bKGD(write_ptr, write_info_ptr, background);
+ png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
+ red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
-#if defined(PNG_READ_cHRM_SUPPORTED) && defined(PNG_WRITE_cHRM_SUPPORTED)
+#if defined(PNG_gAMA_SUPPORTED)
{
- double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
+ png_uint_32 gamma;
- if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
- &red_y, &green_x, &green_y, &blue_x, &blue_y))
+ if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
{
- png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
- red_y, green_x, green_y, blue_x, blue_y);
+ png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
}
}
#endif
-#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_WRITE_gAMA_SUPPORTED)
+#if defined(PNG_iCCP_SUPPORTED)
{
- double gamma;
+ png_charp name;
+ png_charp profile;
+ png_int_32 proflen;
+ int compression_type;
- if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
+ if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
+ &profile, &proflen))
{
- png_set_gAMA(write_ptr, write_info_ptr, gamma);
+ png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
+ profile, proflen);
}
}
#endif
-#if defined(PNG_READ_sRGB_SUPPORTED) && defined(PNG_WRITE_sRGB_SUPPORTED)
+#if defined(PNG_sRGB_SUPPORTED)
{
int intent;
@@ -699,7 +709,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
-#if defined(PNG_READ_hIST_SUPPORTED) && defined(PNG_WRITE_hIST_SUPPORTED)
+ {
+ png_colorp palette;
+ int num_palette;
+
+ if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
+ {
+ png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
+ }
+ }
+#if defined(PNG_bKGD_SUPPORTED)
+ {
+ png_color_16p background;
+
+ if (png_get_bKGD(read_ptr, read_info_ptr, &background))
+ {
+ png_set_bKGD(write_ptr, write_info_ptr, background);
+ }
+ }
+#endif
+#if defined(PNG_hIST_SUPPORTED)
{
png_uint_16p hist;
@@ -709,9 +738,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
-#if defined(PNG_READ_oFFs_SUPPORTED) && defined(PNG_WRITE_oFFs_SUPPORTED)
+#if defined(PNG_oFFs_SUPPORTED)
{
- png_uint_32 offset_x, offset_y;
+ long offset_x, offset_y;
int unit_type;
if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type))
@@ -720,7 +749,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
-#if defined(PNG_READ_pCAL_SUPPORTED) && defined(PNG_WRITE_pCAL_SUPPORTED)
+#if defined(PNG_pCAL_SUPPORTED)
{
png_charp purpose, units;
png_charpp params;
@@ -735,7 +764,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
-#if defined(PNG_READ_pHYs_SUPPORTED) && defined(PNG_WRITE_pHYs_SUPPORTED)
+#if defined(PNG_pHYs_SUPPORTED)
{
png_uint_32 res_x, res_y;
int unit_type;
@@ -746,39 +775,51 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
+#if defined(PNG_sBIT_SUPPORTED)
{
- png_colorp palette;
- int num_palette;
+ png_color_8p sig_bit;
- if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
+ if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
{
- png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
+ png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
}
}
-#if defined(PNG_READ_sBIT_SUPPORTED) && defined(PNG_WRITE_sBIT_SUPPORTED)
+#endif
+#if defined(PNG_sCAL_SUPPORTED)
+#ifdef PNG_FLOATING_POINT_SUPPORTED
{
- png_color_8p sig_bit;
+ png_charp unit;
+ double width, height;
- if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
+ if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &width, &height))
{
- png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
+ png_set_sCAL(write_ptr, write_info_ptr, unit, width, height);
+ }
+ }
+#else
+#endif
+ {
+ png_charp unit, width, height;
+
+ if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &width, &height))
+ {
+ png_set_sCAL_s(write_ptr, write_info_ptr, unit, width, height);
}
}
#endif
-#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) || \
- (defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
+#if defined(PNG_TEXT_SUPPORTED)
{
png_textp text_ptr;
int num_text;
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
{
- png_debug1(0, "Handling %d tEXt/zTXt chunks\n", num_text);
+ png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
}
}
#endif
-#if defined(PNG_READ_tIME_SUPPORTED) && defined(PNG_WRITE_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
{
png_timep mod_time;
@@ -795,7 +836,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
-#if defined(PNG_READ_tRNS_SUPPORTED) && defined(PNG_WRITE_tRNS_SUPPORTED)
+#if defined(PNG_tRNS_SUPPORTED)
{
png_bytep trans;
int num_trans;
@@ -867,20 +908,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_debug(0, "Reading and writing end_info data\n");
png_read_end(read_ptr, end_info_ptr);
-#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) || \
- (defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
+#if defined(PNG_TEXT_SUPPORTED)
{
png_textp text_ptr;
int num_text;
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
{
- png_debug1(0, "Handling %d tEXt/zTXt chunks\n", num_text);
+ png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
}
}
#endif
-#if defined(PNG_READ_tIME_SUPPORTED) && defined(PNG_WRITE_tIME_SUPPORTED)
+#if defined(PNG_tIME_SUPPORTED)
{
png_timep mod_time;
@@ -1223,7 +1263,7 @@ main(int argc, char *argv[])
/* Generate a compiler error if there is an old png.h in the search path. */
void
png_check_pngtest_version
- (version_1_0_5d png_h_is_not_version_1_0_5d)
+ (version_1_0_5h png_h_is_not_version_1_0_5h)
{
- if(png_h_is_not_version_1_0_5d == NULL) return;
+ if(png_h_is_not_version_1_0_5h == NULL) return;
}
diff --git a/pngtrans.c b/pngtrans.c
index f6458d52d..11bb38e36 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngtypes.h b/pngtypes.h
index 8b78f87ab..ab192b6e0 100644
--- a/pngtypes.h
+++ b/pngtypes.h
@@ -1,6 +1,6 @@
/* pngtypes.h - array of chunk-types for libpng
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -19,10 +19,13 @@ PNG_bKGD;
PNG_cHRM;
PNG_gAMA;
PNG_hIST;
+PNG_iCCP;
+PNG_iTXt;
PNG_oFFs;
PNG_pCAL;
PNG_pHYs;
PNG_sBIT;
+PNG_sPLT;
PNG_sRGB;
PNG_tEXt;
PNG_tIME;
diff --git a/pngvcrd.c b/pngvcrd.c
index a20a78382..069f00361 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
*
* For Intel x86 CPU and Microsoft Visual C++ compiler
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998, Intel Corporation
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -1502,8 +1502,8 @@ loop2_pass0:
}
}
- sptr -= (width_mmx*2 - 2); // sign fixed
- dp -= (width_mmx*16 - 2); // sign fixed
+ sptr -= (width_mmx*2 - 2); // sign fixed
+ dp -= (width_mmx*16 - 2); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
@@ -1547,8 +1547,8 @@ loop2_pass2:
}
}
- sptr -= (width_mmx*2 - 2); // sign fixed
- dp -= (width_mmx*8 - 2); // sign fixed
+ sptr -= (width_mmx*2 - 2); // sign fixed
+ dp -= (width_mmx*8 - 2); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
@@ -1587,8 +1587,8 @@ loop2_pass4:
}
}
- sptr -= (width_mmx*2 - 2); // sign fixed
- dp -= (width_mmx*4 - 2); // sign fixed
+ sptr -= (width_mmx*2 - 2); // sign fixed
+ dp -= (width_mmx*4 - 2); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
@@ -1640,8 +1640,8 @@ loop4_pass0:
}
}
- sptr -= (width_mmx*4 - 4); // sign fixed
- dp -= (width_mmx*32 - 4); // sign fixed
+ sptr -= (width_mmx*4 - 4); // sign fixed
+ dp -= (width_mmx*32 - 4); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
@@ -1685,8 +1685,8 @@ loop4_pass2:
}
}
- sptr -= (width_mmx*4 - 4); // sign fixed
- dp -= (width_mmx*16 - 4); // sign fixed
+ sptr -= (width_mmx*4 - 4); // sign fixed
+ dp -= (width_mmx*16 - 4); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
@@ -1728,8 +1728,8 @@ loop4_pass4:
}
}
- sptr -= (width_mmx*4 - 4); // sign fixed
- dp -= (width_mmx*8 - 4); // sign fixed
+ sptr -= (width_mmx*4 - 4); // sign fixed
+ dp -= (width_mmx*8 - 4); // sign fixed
for (i = width; i; i--)
{
png_byte v[8];
diff --git a/pngwio.c b/pngwio.c
index c55fff362..faf2e77c4 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
/* pngwio.c - functions for data output
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwrite.c b/pngwrite.c
index bd7c7c3b3..19773ab96 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -24,6 +24,9 @@
void
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{
+#if defined(PNG_WRITE_sPLT_SUPPORTED)
+ int i;
+#endif
png_debug(1, "in png_write_info_before_PLTE\n");
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
{
@@ -41,23 +44,67 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
flag set, and if it does, writes the chunk. */
#if defined(PNG_WRITE_gAMA_SUPPORTED)
if (info_ptr->valid & PNG_INFO_gAMA)
+ {
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_write_gAMA_fixed(png_ptr, info_ptr->int_gamma);
+#else
+# ifdef PNG_FLOATING_POINT_SUPPORTED
png_write_gAMA(png_ptr, info_ptr->gamma);
+# endif
+#endif
+ }
#endif
#if defined(PNG_WRITE_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB)
png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);
#endif
+#if defined(PNG_WRITE_iCCP_SUPPORTED)
+ if (info_ptr->valid & PNG_INFO_iCCP)
+ png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_TEXT_COMPRESSION_NONE,
+ info_ptr->iccp_profile, (int)info_ptr->iccp_proflen);
+#endif
+#if defined(PNG_WRITE_sPLT_SUPPORTED)
+ if (info_ptr->valid & PNG_INFO_sPLT)
+ for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
+ png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
+#endif
#if defined(PNG_WRITE_sBIT_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sBIT)
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
#endif
#if defined(PNG_WRITE_cHRM_SUPPORTED)
if (info_ptr->valid & PNG_INFO_cHRM)
+ {
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_write_cHRM_fixed(png_ptr,
+ info_ptr->int_x_white, info_ptr->int_y_white,
+ info_ptr->int_x_red, info_ptr->int_y_red,
+ info_ptr->int_x_green, info_ptr->int_y_green,
+ info_ptr->int_x_blue, info_ptr->int_y_blue);
+#else
+# ifdef PNG_FLOATING_POINT_SUPPORTED
png_write_cHRM(png_ptr,
info_ptr->x_white, info_ptr->y_white,
info_ptr->x_red, info_ptr->y_red,
info_ptr->x_green, info_ptr->y_green,
info_ptr->x_blue, info_ptr->y_blue);
+# endif
+#endif
+ }
+#endif
+#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
+ if (info_ptr->unknown_chunks_num)
+ {
+ png_unknown_chunk *up;
+
+ png_debug(5, "writing extra chunks\n");
+
+ for (up = info_ptr->unknown_chunks;
+ up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
+ up++)
+ if (!(up->location & PNG_HAVE_PLTE))
+ png_write_chunk(png_ptr, up->name, up->data, up->size);
+ }
#endif
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
}
@@ -66,7 +113,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
void
png_write_info(png_structp png_ptr, png_infop info_ptr)
{
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
int i;
#endif
@@ -116,6 +163,11 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
info_ptr->pcal_units, info_ptr->pcal_params);
#endif
+#if defined(PNG_WRITE_sCAL_SUPPORTED)
+ if (info_ptr->valid & PNG_INFO_sCAL)
+ png_write_sCAL_s(png_ptr, info_ptr->scal_unit,
+ info_ptr->scal_s_width, info_ptr->scal_s_height);
+#endif
#if defined(PNG_WRITE_pHYs_SUPPORTED)
if (info_ptr->valid & PNG_INFO_pHYs)
png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
@@ -128,14 +180,31 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode |= PNG_WROTE_tIME;
}
#endif
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
/* Check to see if we need to write text chunks */
for (i = 0; i < info_ptr->num_text; i++)
{
png_debug2(2, "Writing header text chunk %d, type %d\n", i,
info_ptr->text[i].compression);
+ /* an internationalized chunk? */
+ if (info_ptr->text[i].lang)
+ {
+#if defined(PNG_WRITE_iTXt_SUPPORTED)
+ /* write international chunk */
+ png_write_iTXt(png_ptr,
+ info_ptr->text[i].compression,
+ info_ptr->text[i].lang,
+ info_ptr->text[i].key,
+ info_ptr->text[i].translated_key,
+ info_ptr->text[i].text);
+#else
+ png_warning(png_ptr, "Unable to write international text\n");
+#endif
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
+ }
/* If we want a compressed text chunk */
- if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
+ else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
{
#if defined(PNG_WRITE_zTXt_SUPPORTED)
/* write compressed chunk */
@@ -153,7 +222,8 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_WRITE_tEXt_SUPPORTED)
/* write uncompressed chunk */
png_write_tEXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, info_ptr->text[i].text_length);
+ info_ptr->text[i].text,
+ info_ptr->text[i].text_length);
#else
png_warning(png_ptr, "Unable to write uncompressed text\n");
#endif
@@ -162,6 +232,20 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
}
}
#endif
+#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
+ if (info_ptr->unknown_chunks_num)
+ {
+ png_unknown_chunk *up;
+
+ png_debug(5, "writing extra chunks\n");
+
+ for (up = info_ptr->unknown_chunks;
+ up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
+ up++)
+ if ((up->location& PNG_HAVE_PLTE) && !(up->location& PNG_HAVE_IDAT))
+ png_write_chunk(png_ptr, up->name, up->data, up->size);
+ }
+#endif
}
/* Writes the end of the PNG file. If you don't want to write comments or
@@ -179,7 +263,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
/* see if user wants us to write information chunks */
if (info_ptr != NULL)
{
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
int i; /* local index variable */
#endif
#if defined(PNG_WRITE_tIME_SUPPORTED)
@@ -188,7 +272,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
!(png_ptr->mode & PNG_WROTE_tIME))
png_write_tIME(png_ptr, &(info_ptr->mod_time));
#endif
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
/* loop through comment chunks */
for (i = 0; i < info_ptr->num_text; i++)
{
@@ -222,6 +306,20 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
}
}
#endif
+#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
+ if (info_ptr->unknown_chunks_num)
+ {
+ png_unknown_chunk *up;
+
+ png_debug(5, "writing extra chunks\n");
+
+ for (up = info_ptr->unknown_chunks;
+ up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
+ up++)
+ if (up->location & PNG_HAVE_IDAT)
+ png_write_chunk(png_ptr, up->name, up->data, up->size);
+ }
+#endif
}
png_ptr->mode |= PNG_AFTER_IDAT;
@@ -643,36 +741,25 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
if (info_ptr != NULL)
{
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
- png_debug(1, "in png_info_destroy\n");
- if (info_ptr->text != NULL)
- {
- int i;
- for (i = 0; i < info_ptr->num_text; i++)
- {
- if(info_ptr->text[i].key != NULL)
- {
- png_free(png_ptr, info_ptr->text[i].key);
- info_ptr->text[i].key = NULL;
- }
- }
- png_free(png_ptr, info_ptr->text);
- info_ptr->text = NULL;
- }
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
+ png_free_text(png_ptr, info_ptr, -1);
#endif
-#if defined(PNG_READ_pCAL_SUPPORTED)
- png_free(png_ptr, info_ptr->pcal_purpose);
- png_free(png_ptr, info_ptr->pcal_units);
- if (info_ptr->pcal_params != NULL)
- {
- int i;
- for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
- {
- png_free(png_ptr, info_ptr->pcal_params[i]);
- }
- png_free(png_ptr, info_ptr->pcal_params);
- }
+#if defined(PNG_WRITE_sCAL_SUPPORTED)
+ png_free_sCAL(png_ptr, info_ptr);
+#endif
+#if defined(PNG_WRITE_pCAL_SUPPORTED)
+ png_free_pCAL(png_ptr, info_ptr);
+#endif
+#if defined(PNG_WRITE_iCCP_SUPPORTED)
+ png_free_iCCP(png_ptr, info_ptr);
#endif
+#if defined(PNG_WRITE_sPLT_SUPPORTED)
+ png_free_spalette(png_ptr, info_ptr, -1);
+#endif
+#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
+ png_free_unknown_chunk(png_ptr, info_ptr, -1);
+#endif
+
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
#else
@@ -718,16 +805,18 @@ png_write_destroy(png_structp png_ptr)
png_free(png_ptr, png_ptr->up_row);
png_free(png_ptr, png_ptr->avg_row);
png_free(png_ptr, png_ptr->paeth_row);
+
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer);
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif
+
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_free(png_ptr, png_ptr->prev_filters);
png_free(png_ptr, png_ptr->filter_weights);
png_free(png_ptr, png_ptr->inv_filter_weights);
png_free(png_ptr, png_ptr->filter_costs);
png_free(png_ptr, png_ptr->inv_filter_costs);
-#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
+#endif
/* reset structure */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
@@ -1000,6 +1089,14 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
else if (window_bits < 8)
png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
+#ifndef WBITS_8_OK
+ /* avoid libpng bug with 256-byte windows */
+ if (window_bits == 8)
+ {
+ png_warning(png_ptr, "Compression window is being reset to 512");
+ window_bits=9;
+ }
+#endif
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;
png_ptr->zlib_window_bits = window_bits;
}
diff --git a/pngwtran.c b/pngwtran.c
index f891471a4..7647c4d94 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -19,6 +19,9 @@ png_do_write_transformations(png_structp png_ptr)
{
png_debug(1, "in png_do_write_transformations\n");
+ if (png_ptr == NULL)
+ return;
+
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
if (png_ptr->transformations & PNG_USER_TRANSFORM)
if(png_ptr->write_user_transform_fn != NULL)
diff --git a/pngwutil.c b/pngwutil.c
index 2b08369ca..2ac333242 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
- * libpng 1.0.5d - November 29, 1999
+ * libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
@@ -133,6 +133,223 @@ png_write_sig(png_structp png_ptr)
(png_size_t)8 - png_ptr->sig_bytes);
}
+#if defined(PNG_WRITE_TEXT_SUPPORTED)
+/*
+ * This pair of functions encapsulates the operation of (a) compressing a
+ * text string, and (b) issuing it later as a series of chunk data writes.
+ * The compression_state structure is shared context for these functions
+ * set up by the caller in order to make the whole mess thread-safe.
+ */
+
+typedef struct
+{
+ char *input; /* the uncompressed input data */
+ int input_len; /* its length */
+ int num_output_ptr; /* number of output pointers used */
+ int max_output_ptr; /* size of output_ptr */
+ png_charpp output_ptr; /* array of pointers to output */
+} compression_state;
+
+/* compress given text into storage in the png_ptr structure */
+static int
+png_text_compress(png_structp png_ptr,
+ png_charp text, png_size_t text_len, int compression,
+ compression_state *comp)
+{
+ int ret;
+
+ comp->num_output_ptr = comp->max_output_ptr = 0;
+ comp->output_ptr = NULL;
+ comp->input = NULL;
+
+ /* we may just want to pass the text right through */
+ if (compression == PNG_TEXT_COMPRESSION_NONE)
+ {
+ comp->input = text;
+ comp->input_len = text_len;
+ return(text_len);
+ }
+
+ if (compression >= PNG_TEXT_COMPRESSION_LAST)
+ {
+#if !defined(PNG_NO_STDIO)
+ char msg[50];
+ sprintf(msg, "Unknown compression type %d", compression);
+ png_warning(png_ptr, msg);
+#else
+ png_warning(png_ptr, "Unknown compression type");
+#endif
+ compression = PNG_TEXT_COMPRESSION_zTXt;
+ }
+
+ /* We can't write the chunk until we find out how much data we have,
+ * which means we need to run the compressor first and save the
+ * output. This shouldn't be a problem, as the vast majority of
+ * comments should be reasonable, but we will set up an array of
+ * malloc'd pointers to be sure.
+ *
+ * If we knew the application was well behaved, we could simplify this
+ * greatly by assuming we can always malloc an output buffer large
+ * enough to hold the compressed text ((1001 * text_len / 1000) + 12)
+ * and malloc this directly. The only time this would be a bad idea is
+ * if we can't malloc more than 64K and we have 64K of random input
+ * data, or if the input string is incredibly large (although this
+ * wouldn't cause a failure, just a slowdown due to swapping).
+ */
+
+ /* set up the compression buffers */
+ png_ptr->zstream.avail_in = (uInt)text_len;
+ png_ptr->zstream.next_in = (Bytef *)text;
+ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+ png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
+
+ /* this is the same compression loop as in png_write_row() */
+ do
+ {
+ /* compress the data */
+ ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);
+ if (ret != Z_OK)
+ {
+ /* error */
+ if (png_ptr->zstream.msg != NULL)
+ png_error(png_ptr, png_ptr->zstream.msg);
+ else
+ png_error(png_ptr, "zlib error");
+ }
+ /* check to see if we need more room */
+ if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in)
+ {
+ /* make sure the output array has room */
+ if (comp->num_output_ptr >= comp->max_output_ptr)
+ {
+ int old_max;
+
+ old_max = comp->max_output_ptr;
+ comp->max_output_ptr = comp->num_output_ptr + 4;
+ if (comp->output_ptr != NULL)
+ {
+ png_charpp old_ptr;
+
+ old_ptr = comp->output_ptr;
+ comp->output_ptr = (png_charpp)png_malloc(png_ptr,
+ (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
+ png_memcpy(comp->output_ptr, old_ptr,
+ old_max * sizeof (png_charp));
+ png_free(png_ptr, old_ptr);
+ }
+ else
+ comp->output_ptr = (png_charpp)png_malloc(png_ptr,
+ (png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
+ }
+
+ /* save the data */
+ comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
+ (png_uint_32)png_ptr->zbuf_size);
+ png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
+ png_ptr->zbuf_size);
+ comp->num_output_ptr++;
+
+ /* and reset the buffer */
+ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+ png_ptr->zstream.next_out = png_ptr->zbuf;
+ }
+ /* continue until we don't have any more to compress */
+ } while (png_ptr->zstream.avail_in);
+
+ /* finish the compression */
+ do
+ {
+ /* tell zlib we are finished */
+ ret = deflate(&png_ptr->zstream, Z_FINISH);
+ if (ret != Z_OK && ret != Z_STREAM_END)
+ {
+ /* we got an error */
+ if (png_ptr->zstream.msg != NULL)
+ png_error(png_ptr, png_ptr->zstream.msg);
+ else
+ png_error(png_ptr, "zlib error");
+ }
+
+ /* check to see if we need more room */
+ if (!(png_ptr->zstream.avail_out) && ret == Z_OK)
+ {
+ /* check to make sure our output array has room */
+ if (comp->num_output_ptr >= comp->max_output_ptr)
+ {
+ int old_max;
+
+ old_max = comp->max_output_ptr;
+ comp->max_output_ptr = comp->num_output_ptr + 4;
+ if (comp->output_ptr != NULL)
+ {
+ png_charpp old_ptr;
+
+ old_ptr = comp->output_ptr;
+ /* This could be optimized to realloc() */
+ comp->output_ptr = (png_charpp)png_malloc(png_ptr,
+ (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
+ png_memcpy(comp->output_ptr, old_ptr,
+ old_max * sizeof (png_charp));
+ png_free(png_ptr, old_ptr);
+ }
+ else
+ comp->output_ptr = (png_charpp)png_malloc(png_ptr,
+ (png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
+ }
+
+ /* save off the data */
+ comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
+ (png_uint_32)png_ptr->zbuf_size);
+ png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
+ png_ptr->zbuf_size);
+ comp->num_output_ptr++;
+
+ /* and reset the buffer pointers */
+ png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
+ png_ptr->zstream.next_out = png_ptr->zbuf;
+ }
+ } while (ret != Z_STREAM_END);
+
+ /* text length is number of buffers plus last buffer */
+ text_len = png_ptr->zbuf_size * comp->num_output_ptr;
+ if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
+ text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;
+
+ return(text_len);
+}
+
+/* ship the compressed text out via chunk writes */
+static void
+png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
+{
+ int i;
+
+ /* handle the no-compression case */
+ if (comp->input)
+ {
+ png_write_chunk_data(png_ptr, (png_bytep)comp->input, comp->input_len);
+ return;
+ }
+
+ /* write saved output buffers, if any */
+ for (i = 0; i < comp->num_output_ptr; i++)
+ {
+ png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],png_ptr->zbuf_size);
+ png_free(png_ptr, comp->output_ptr[i]);
+ }
+ if (comp->max_output_ptr != 0)
+ png_free(png_ptr, comp->output_ptr);
+ /* write anything left in zbuf */
+ if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
+ png_write_chunk_data(png_ptr, png_ptr->zbuf,
+ png_ptr->zbuf_size - png_ptr->zstream.avail_out);
+
+ /* reset zlib for another zTXt/iTXt or the image data */
+ deflateReset(&png_ptr->zstream);
+
+}
+#endif
+
/* Write the IHDR chunk, and update the png_struct with the necessary
* information. Note that the rest of this code depends upon this
* information being correct.
@@ -349,6 +566,7 @@ png_write_IEND(png_structp png_ptr)
#if defined(PNG_WRITE_gAMA_SUPPORTED)
/* write a gAMA chunk */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
void
png_write_gAMA(png_structp png_ptr, double file_gamma)
{
@@ -365,6 +583,22 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
}
#endif
+void
+#ifdef PNG_FIXED_POINT_SUPPORTED
+png_write_gAMA_fixed(png_structp png_ptr, png_uint_32 file_gamma)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_gAMA;
+#endif
+ png_byte buf[4];
+
+ png_debug(1, "in png_write_gAMA\n");
+ /* file_gamma is saved in 1/1000000ths */
+ png_save_uint_32(buf, file_gamma);
+ png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
+}
+#endif
+#endif
#if defined(PNG_WRITE_sRGB_SUPPORTED)
/* write a sRGB chunk */
@@ -385,6 +619,104 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
}
#endif
+#if defined(PNG_WRITE_iCCP_SUPPORTED)
+/* write an iCCP chunk */
+void
+png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
+ png_charp profile, int profile_len)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_iCCP;
+#endif
+ png_size_t name_len;
+ png_charp new_name;
+ compression_state comp;
+
+ png_debug(1, "in png_write_iCCP\n");
+ if (name == NULL || (name_len = png_check_keyword(png_ptr, name,
+ &new_name)) == 0)
+ {
+ png_warning(png_ptr, "Empty keyword in iCCP chunk");
+ return;
+ }
+
+ if (compression_type)
+ /* ignore */ ;
+
+ if (profile == NULL || *profile == '\0')
+ profile_len = 0;
+
+ if (profile_len)
+ profile_len = png_text_compress(png_ptr, profile, profile_len,
+ PNG_TEXT_COMPRESSION_zTXt, &comp);
+
+ /* make sure we include the NULL after the name and the compression type */
+ png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
+ (png_uint_32)name_len+profile_len+2);
+ png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
+
+ if (profile_len)
+ png_write_compressed_data_out(png_ptr, &comp);
+
+ png_write_chunk_end(png_ptr);
+ png_free(png_ptr, new_name);
+}
+#endif
+
+#if defined(PNG_WRITE_sPLT_SUPPORTED)
+/* write a sPLT chunk */
+void
+png_write_sPLT(png_structp png_ptr, png_spalette_p spalette)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_sPLT;
+#endif
+ png_size_t name_len;
+ png_charp new_name;
+ png_byte entrybuf[10];
+ int entry_size = (spalette->depth == 8 ? 6 : 10);
+ int palette_size = entry_size * spalette->nentries;
+ png_spalette_entryp ep;
+
+ png_debug(1, "in png_write_sPLT\n");
+ if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, spalette->name, &new_name))==0)
+ {
+ png_warning(png_ptr, "Empty keyword in sPLT chunk");
+ return;
+ }
+
+ /* make sure we include the NULL after the name */
+ png_write_chunk_start(png_ptr, (png_bytep) png_sPLT,
+ (png_uint_32)(name_len + 1 + palette_size));
+ png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
+
+ /* loop through each palette entry, writing appropriately */
+ for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++)
+ {
+ if (spalette->depth == 8)
+ {
+ entrybuf[0] = (png_byte)ep->red;
+ entrybuf[1] = (png_byte)ep->green;
+ entrybuf[2] = (png_byte)ep->blue;
+ entrybuf[3] = (png_byte)ep->alpha;
+ png_save_uint_16(entrybuf + 4, ep->frequency);
+ }
+ else
+ {
+ png_save_uint_16(entrybuf + 0, ep->red);
+ png_save_uint_16(entrybuf + 2, ep->green);
+ png_save_uint_16(entrybuf + 4, ep->blue);
+ png_save_uint_16(entrybuf + 6, ep->alpha);
+ png_save_uint_16(entrybuf + 8, ep->frequency);
+ }
+ png_write_chunk_data(png_ptr, entrybuf, entry_size);
+ }
+
+ png_write_chunk_end(png_ptr);
+ png_free(png_ptr, new_name);
+}
+#endif
+
#if defined(PNG_WRITE_sBIT_SUPPORTED)
/* write the sBIT chunk */
void
@@ -443,6 +775,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
#if defined(PNG_WRITE_cHRM_SUPPORTED)
/* write the cHRM chunk */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
void
png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
double red_x, double red_y, double green_x, double green_y,
@@ -455,7 +788,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
png_byte buf[32];
png_debug(1, "in png_write_cHRM\n");
- /* each value is saved int 1/1000000ths */
+ /* each value is saved in 1/1000000ths */
if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
white_x + white_y > 1.0)
{
@@ -503,6 +836,57 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
}
#endif
+#ifdef PNG_FIXED_POINT_SUPPORTED
+void
+png_write_cHRM_fixed(png_structp png_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)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_cHRM;
+#endif
+ png_uint_32 itemp;
+ png_byte buf[32];
+
+ png_debug(1, "in png_write_cHRM\n");
+ /* each value is saved int 1/1000000ths */
+ if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
+ {
+ png_warning(png_ptr, "Invalid cHRM white point specified");
+ return;
+ }
+ png_save_uint_32(buf, white_x);
+ png_save_uint_32(buf + 4, white_y);
+
+ if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L)
+ {
+ png_warning(png_ptr, "Invalid cHRM red point specified");
+ return;
+ }
+ png_save_uint_32(buf + 8, red_x);
+ png_save_uint_32(buf + 12, red_y);
+
+ if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L)
+ {
+ png_warning(png_ptr, "Invalid cHRM green point specified");
+ return;
+ }
+ png_save_uint_32(buf + 16, green_x);
+ png_save_uint_32(buf + 20, green_y);
+
+ if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L)
+ {
+ png_warning(png_ptr, "Invalid cHRM blue point specified");
+ return;
+ }
+ png_save_uint_32(buf + 24, blue_x);
+ png_save_uint_32(buf + 28, blue_y);
+
+ png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
+}
+#endif
+#endif
#if defined(PNG_WRITE_tRNS_SUPPORTED)
/* write the tRNS chunk */
@@ -618,8 +1002,8 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
}
#endif
-#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED) || \
- defined(PNG_WRITE_pCAL_SUPPORTED)
+#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
+ defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,
* and if invalid, correct the keyword rather than discarding the entire
* chunk. The PNG 1.0 specification requires keywords 1-79 characters in
@@ -766,6 +1150,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
* We leave it to the application to meet PNG-1.0 requirements on the
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
+ * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
*/
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
if (text_len)
@@ -788,10 +1173,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_size_t key_len;
char buf[1];
png_charp new_key;
- int i, ret;
- png_charpp output_ptr = NULL; /* array of pointers to output */
- int num_output_ptr = 0; /* number of output pointers used */
- int max_output_ptr = 0; /* size of output_ptr */
+ compression_state comp;
png_debug(1, "in png_write_zTXt\n");
@@ -810,178 +1192,101 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_free(png_ptr, new_key);
- if (compression >= PNG_TEXT_COMPRESSION_LAST)
- {
-#if !defined(PNG_NO_STDIO)
- char msg[50];
- sprintf(msg, "Unknown zTXt compression type %d", compression);
- png_warning(png_ptr, msg);
-#else
- png_warning(png_ptr, "Unknown zTXt compression type");
-#endif
- compression = PNG_TEXT_COMPRESSION_zTXt;
- }
-
- /* We can't write the chunk until we find out how much data we have,
- * which means we need to run the compressor first and save the
- * output. This shouldn't be a problem, as the vast majority of
- * comments should be reasonable, but we will set up an array of
- * malloc'd pointers to be sure.
- *
- * If we knew the application was well behaved, we could simplify this
- * greatly by assuming we can always malloc an output buffer large
- * enough to hold the compressed text ((1001 * text_len / 1000) + 12)
- * and malloc this directly. The only time this would be a bad idea is
- * if we can't malloc more than 64K and we have 64K of random input
- * data, or if the input string is incredibly large (although this
- * wouldn't cause a failure, just a slowdown due to swapping).
- */
-
- /* set up the compression buffers */
- png_ptr->zstream.avail_in = (uInt)text_len;
- png_ptr->zstream.next_in = (Bytef *)text;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
- png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
+ /* compute the compressed data; do it now for the length */
+ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
- /* this is the same compression loop as in png_write_row() */
- do
- {
- /* compress the data */
- ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);
- if (ret != Z_OK)
- {
- /* error */
- if (png_ptr->zstream.msg != NULL)
- png_error(png_ptr, png_ptr->zstream.msg);
- else
- png_error(png_ptr, "zlib error");
- }
- /* check to see if we need more room */
- if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in)
- {
- /* make sure the output array has room */
- if (num_output_ptr >= max_output_ptr)
- {
- int old_max;
+ /* write start of chunk */
+ png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
+ (key_len+text_len+2));
+ /* write key */
+ png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1);
+ buf[0] = (png_byte)compression;
+ /* write compression */
+ png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
+ /* write the compressed data */
+ png_write_compressed_data_out(png_ptr, &comp);
- old_max = max_output_ptr;
- max_output_ptr = num_output_ptr + 4;
- if (output_ptr != NULL)
- {
- png_charpp old_ptr;
+ /* close the chunk */
+ png_write_chunk_end(png_ptr);
+}
+#endif
- old_ptr = output_ptr;
- output_ptr = (png_charpp)png_malloc(png_ptr,
- (png_uint_32)(max_output_ptr * sizeof (png_charpp)));
- png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
- png_free(png_ptr, old_ptr);
- }
- else
- output_ptr = (png_charpp)png_malloc(png_ptr,
- (png_uint_32)(max_output_ptr * sizeof (png_charp)));
- }
+#if defined(PNG_WRITE_iTXt_SUPPORTED)
+/* write an iTXt chunk */
+void
+png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
+ png_charp lang, png_charp translated_key, png_charp text)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_iTXt;
+#endif
+ png_size_t lang_len, key_len, translated_key_len, text_len;
+ png_charp new_lang, new_key;
+ png_byte cbuf[2];
+ compression_state comp;
- /* save the data */
- output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
- (png_uint_32)png_ptr->zbuf_size);
- png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
- png_ptr->zbuf_size);
- num_output_ptr++;
+ png_debug(1, "in png_write_iTXt\n");
- /* and reset the buffer */
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
- png_ptr->zstream.next_out = png_ptr->zbuf;
- }
- /* continue until we don't have any more to compress */
- } while (png_ptr->zstream.avail_in);
+ translated_key_len = png_strlen(translated_key);
+ text_len = png_strlen(text);
- /* finish the compression */
- do
+ if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang,
+ &new_lang))==0)
{
- /* tell zlib we are finished */
- ret = deflate(&png_ptr->zstream, Z_FINISH);
- if (ret != Z_OK && ret != Z_STREAM_END)
- {
- /* we got an error */
- if (png_ptr->zstream.msg != NULL)
- png_error(png_ptr, png_ptr->zstream.msg);
- else
- png_error(png_ptr, "zlib error");
- }
-
- /* check to see if we need more room */
- if (!(png_ptr->zstream.avail_out) && ret == Z_OK)
- {
- /* check to make sure our output array has room */
- if (num_output_ptr >= max_output_ptr)
- {
- int old_max;
+ png_warning(png_ptr, "Empty language field in iTXt chunk");
+ return;
+ }
+ if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
+ {
+ png_warning(png_ptr, "Empty keyword in iTXt chunk");
+ return;
+ }
- old_max = max_output_ptr;
- max_output_ptr = num_output_ptr + 4;
- if (output_ptr != NULL)
- {
- png_charpp old_ptr;
+ if (text == NULL || *text == '\0')
+ text_len = 0;
- old_ptr = output_ptr;
- /* This could be optimized to realloc() */
- output_ptr = (png_charpp)png_malloc(png_ptr,
- (png_uint_32)(max_output_ptr * sizeof (png_charpp)));
- png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
- png_free(png_ptr, old_ptr);
- }
- else
- output_ptr = (png_charpp)png_malloc(png_ptr,
- (png_uint_32)(max_output_ptr * sizeof (png_charp)));
- }
+ /* compute the compressed data; do it now for the length */
+ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
- /* save off the data */
- output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
- (png_uint_32)png_ptr->zbuf_size);
- png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
- png_ptr->zbuf_size);
- num_output_ptr++;
+ /* make sure we include the compression flag, the compression byte,
+ * and the NULs after the key, lang, and translated_key parts */
+ png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
+ (png_uint_32)(2 + lang_len+1 + key_len+1 + translated_key_len +
+ text_len));
- /* and reset the buffer pointers */
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
- png_ptr->zstream.next_out = png_ptr->zbuf;
- }
- } while (ret != Z_STREAM_END);
+ /* set the compression bits */
+ if (compression == PNG_TEXT_COMPRESSION_NONE)
+ {
+ cbuf[0] = 0;
+ cbuf[1] = 0;
+ }
+ else /* compression == PNG_TEXT_COMPRESSION_zTXt */
+ {
+ cbuf[0] = 1;
+ cbuf[1] = 0;
+ }
+ png_write_chunk_data(png_ptr, cbuf, 2);
- /* text length is number of buffers plus last buffer */
- text_len = png_ptr->zbuf_size * num_output_ptr;
- if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
- text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;
+ /*
+ * We leave it to the application to meet PNG-1.0 requirements on the
+ * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
+ * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
+ * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
+ */
+ png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
+ png_write_chunk_data(png_ptr, (png_bytep)new_lang, lang_len + 1);
+ png_write_chunk_data(png_ptr, (png_bytep)translated_key,
+ translated_key_len);
+ png_write_chunk_data(png_ptr, '\0', 1);
- /* write start of chunk */
- png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)(key_len+text_len+2));
- /* write key */
- png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1);
- buf[0] = (png_byte)compression;
- /* write compression */
- png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
+ png_write_compressed_data_out(png_ptr, &comp);
- /* write saved output buffers, if any */
- for (i = 0; i < num_output_ptr; i++)
- {
- png_write_chunk_data(png_ptr,(png_bytep)output_ptr[i],png_ptr->zbuf_size);
- png_free(png_ptr, output_ptr[i]);
- }
- if (max_output_ptr != 0)
- png_free(png_ptr, output_ptr);
- /* write anything left in zbuf */
- if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
- png_write_chunk_data(png_ptr, png_ptr->zbuf,
- png_ptr->zbuf_size - png_ptr->zstream.avail_out);
- /* close the chunk */
png_write_chunk_end(png_ptr);
-
- /* reset zlib for another zTXt or the image data */
- deflateReset(&png_ptr->zstream);
+ png_free(png_ptr, new_key);
+ png_free(png_ptr, new_lang);
}
#endif
-
#if defined(PNG_WRITE_oFFs_SUPPORTED)
/* write the oFFs chunk */
void
@@ -1066,6 +1371,59 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
}
#endif
+#if defined(PNG_WRITE_sCAL_SUPPORTED)
+/* write the sCAL chunk */
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+void
+png_write_sCAL(png_structp png_ptr, png_charp unit, double width,double height)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_sCAL;
+#endif
+ png_size_t total_len;
+ char wbuf[32], hbuf[32];
+
+ png_debug(1, "in png_write_sCAL\n");
+
+ sprintf(wbuf, "%12.12e", width);
+ sprintf(hbuf, "%12.12e", height);
+ total_len = png_strlen(unit)+1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
+
+ png_debug1(3, "sCAL total length = %d\n", total_len);
+ png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
+ png_write_chunk_data(png_ptr, (png_bytep)unit, png_strlen(unit)+1);
+ png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
+ png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
+
+ png_write_chunk_end(png_ptr);
+}
+#endif
+void
+png_write_sCAL_s(png_structp png_ptr, png_charp unit, png_charp width,
+ png_charp height)
+{
+#ifdef PNG_USE_LOCAL_ARRAYS
+ PNG_sCAL;
+#endif
+ png_size_t total_len;
+ char wbuf[32], hbuf[32];
+
+ png_debug(1, "in png_write_sCAL\n");
+
+ sprintf(wbuf, "%s", width);
+ sprintf(hbuf, "%s", height);
+ total_len = png_strlen(unit)+1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
+
+ png_debug1(3, "sCAL total length = %d\n", total_len);
+ png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
+ png_write_chunk_data(png_ptr, (png_bytep)unit, png_strlen(unit)+1);
+ png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1);
+ png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf));
+
+ png_write_chunk_end(png_ptr);
+}
+#endif
+
#if defined(PNG_WRITE_pHYs_SUPPORTED)
/* write the pHYs chunk */
void
@@ -1128,20 +1486,20 @@ png_write_start_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
+
/* start of interlace block in the y direction */
int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
+
/* offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
-
+
png_size_t buf_size;
png_debug(1, "in png_write_start_row\n");
@@ -1222,20 +1580,20 @@ png_write_finish_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
+
/* start of interlace block in the y direction */
int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
+
/* offset to next interlace block in the y direction */
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif
-
+
int ret;
png_debug(1, "in png_write_finish_row\n");
@@ -1336,14 +1694,14 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
+
/* start of interlace block */
int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
+
/* offset to next interlace block */
int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
-
+
png_debug(1, "in png_do_write_interlace\n");
/* we don't have to do anything on the last pass (6) */
#if defined(PNG_USELESS_TESTS_SUPPORTED)
@@ -2170,5 +2528,5 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
{
png_write_flush(png_ptr);
}
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif
}
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index b4d035ef1..b764fcc1d 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -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.5d
+PNGMIN = 1.0.5h
PNGVER = $(PNGMAJ).$(PNGMIN)
# where make install puts libpng.a, libpng.so*, and png.h
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 5baafdeac..0e14dfe49 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -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.5d
+PNGMIN = 1.0.5h
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=cc
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index 780bfe5db..1a98fdd3e 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -47,6 +47,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/makefile.knr b/scripts/makefile.knr
index 09cb0a2a0..09a74b6fc 100644
--- a/scripts/makefile.knr
+++ b/scripts/makefile.knr
@@ -58,6 +58,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png ansi2knr
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index c85d01ec2..0ea7d3e27 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -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.5d
+PNGMIN = 1.0.5h
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
@@ -86,6 +86,10 @@ install: libpng.a libpng.so.$(PNGVER)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
diff --git a/scripts/makefile.mips b/scripts/makefile.mips
index 06ca02ff3..8db26277f 100644
--- a/scripts/makefile.mips
+++ b/scripts/makefile.mips
@@ -42,6 +42,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index fc572afe4..176a5364e 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -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.5d
+PNGMIN = 1.0.5h
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
@@ -77,6 +77,10 @@ install: libpng.a libpng.so.$(PNGVER)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index e3739b533..010f5f7c3 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -50,6 +50,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index 054cd55b5..b79690714 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -6,11 +6,16 @@
CC=gcc
-# The commands "CC" and "LD" must NOT refer to /usr/ucb/cc and /usr/ucb/ld.
-# If they do, you need to adjust your PATH environment variable to put
-# /usr/ccs/bin ahead of /usr/ucb. The environment variable LD_LIBRARY_PATH
-# should not be set at all. If it is, things are likely to break because
-# of the libucb dependency that is created.
+case "`type ld`" in *ucb*) echo "
+# WARNING:
+# The commands "CC" and "LD" must NOT refer to /usr/ucb/cc and
+# /usr/ucb/ld. If they do, you need to adjust your PATH environment
+# variable to put /usr/ccs/bin ahead of /usr/ucb. The environment
+# variable LD_LIBRARY_PATH should not be set at all. If it is,
+# things are likely to break because of the libucb dependency that
+# is created.
+" ;;
+esac
# Where make install puts libpng.a, libpng.so*, and png.h
prefix=/usr/local
@@ -37,7 +42,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.5d
+PNGMIN = 1.0.5h
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
@@ -89,6 +94,10 @@ install: libpng.a libpng.so.$(PNGVER)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
diff --git a/scripts/makefile.std b/scripts/makefile.std
index 6afe481e1..824744985 100644
--- a/scripts/makefile.std
+++ b/scripts/makefile.std
@@ -47,6 +47,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/makefile.sunos b/scripts/makefile.sunos
index f2ce329dc..220393153 100644
--- a/scripts/makefile.sunos
+++ b/scripts/makefile.sunos
@@ -51,6 +51,10 @@ install: libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+ chmod a-w *.[ch35] $(DOCS) scripts/*
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 984137d38..81f04068a 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -3,7 +3,7 @@ unit pngdef;
interface
const
- PNG_LIBPNG_VER_STRING = '1.0.5d';
+ PNG_LIBPNG_VER_STRING = '1.0.5h';
PNG_LIBPNG_VER = 10006;
type
@@ -179,10 +179,10 @@ const
PNG_RESOLUTION_METER = 1; // pixels/meter
// These are for the sRGB chunk. These values should NOT be changed.
- PNG_sRGB_INTENT_SATURATION = 0;
- PNG_sRGB_INTENT_PERCEPTUAL = 1;
- PNG_sRGB_INTENT_ABSOLUTE = 2;
- PNG_sRGB_INTENT_RELATIVE = 3;
+ PNG_sRGB_INTENT_PERCEPTUAL = 0;
+ PNG_sRGB_INTENT_RELATIVE = 1;
+ PNG_sRGB_INTENT_SATURATION = 2;
+ PNG_sRGB_INTENT_ABSOLUTE = 3;
// Handle alpha and tRNS by replacing with a background color.
PNG_BACKGROUND_GAMMA_UNKNOWN = 0;
@@ -334,6 +334,10 @@ function png_get_oFFs(png_ptr: png_structp; info_ptr: png_infop;
var offset_x, offset_y: png_uint_32;
var unit_type: int): png_uint_32;
stdcall;
+function png_get_sCAL(png_ptr: png_structp; info_ptr: png_infop;
+ var unit:int; var width: png_uint_32; height: png_uint_32):
+ png_uint_32;
+ stdcall
function png_get_pCAL(png_ptr: png_structp; info_ptr: png_infop;
var purpose: png_charp; var X0, X1: png_int_32;
var typ, nparams: int; var units: png_charp;
@@ -600,6 +604,28 @@ procedure png_write_row(png_ptr: png_structp; row: png_bytep);
procedure png_write_rows(png_ptr: png_structp; row: png_bytepp;
num_rows: png_uint_32);
stdcall;
+procedure png_get_iCCP(png_ptr: png_structp; info_ptr: png_infop;
+ name: png_charpp; compression_type: int *; profile: png_charpp;
+ proflen: png_int_32): png_bytep;
+ stdcall;
+procedure png_get_spalettes(png_ptr: png_structp;
+ info_ptr: png_infop; entries: png_spalette_pp): png_uint_32;
+ stdcall;
+procedure png_free_pCAL(png_ptr: png_structp; info_ptr: png_infop);
+ stdcall;
+procedure png_set_iCCP(png_ptr: png_structp; info_ptr: png_infop;
+ name: png_charp; compression_type: int; profile: png_charp;
+ proflen: int);
+ stdcall;
+procedure png_free_iCCP(png_ptr: png_structp; info_ptr: png_infop);
+ stdcall;
+procedure png_free_text(png_ptr: png_structp; info_ptr: png_infop);
+ stdcall;
+procedure png_set_spalettes(png_ptr: png_structp; info_ptr: png_infop;
+ entries: png_spalette_p; nentries: int);
+ stdcall;
+procedure png_free_sPLT(png_ptr: png_structp; info_ptr: png_infop);
+ stdcall;
implementation
@@ -725,5 +751,13 @@ procedure png_write_info; external pngDLL;
procedure png_write_info_before_PLTE; external pngDLL;
procedure png_write_row; external pngDLL;
procedure png_write_rows; external pngDLL;
+procedure png_get_iCCP; external pngDLL;
+procedure png_get_spalettes; external pngDLL;
+procedure png_free_pCAL; external pngDLL;
+procedure png_set_iCCP; external pngDLL;
+procedure png_free_iCCP; external pngDLL;
+procedure png_free_text; external pngDLL;
+procedure png_set_spalettes; external pngDLL;
+procedure png_free_sPLT; external pngDLL;
end.
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 611918c5f..9edb8bfca 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -279,6 +279,16 @@ EXPORTS
png_pass_dsp_mask
; png_pass_width
; png_pass_height
+ png_get_iCCP
+ png_get_sCAL
+ png_get_spalettes
+ png_free_pCAL
+ png_set_iCCP
+ png_free_iCCP
+ png_free_text
+ png_free_sCAL
+ png_set_spalettes
+ png_free_sPLT
png_IHDR
png_IDAT
@@ -288,10 +298,14 @@ EXPORTS
png_cHRM
png_gAMA
png_hIST
+ png_iCCP
+ png_iTXt
png_oFFs
png_pCAL
png_pHYs
png_sBIT
+ png_sCAL
+ png_sPLT
png_sRGB
png_tEXt
png_tIME