Imported from libpng-1.0.5h.tar

This commit is contained in:
Glenn Randers-Pehrson 1999-12-10 09:43:02 -06:00
parent 074af5e9ca
commit 166c5a397e
62 changed files with 3740 additions and 1045 deletions

View File

@ -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.
@ -34,13 +34,52 @@ version libpng-1.0.5c November 26, 1999
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]
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

39
CHANGES
View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

6
README
View File

@ -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

2
TODO
View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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 */
@ -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);

View File

@ -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;

View File

@ -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;
@ -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;

View File

@ -54,7 +54,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
@ -62,10 +62,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); \
}
@ -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;
@ -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;
}

View File

@ -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;
@ -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;

View File

@ -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;

View File

@ -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];
@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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);

239
libpng.3
View File

@ -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
@ -2827,7 +3030,7 @@ 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:

View File

@ -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

View File

@ -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

2
png.5
View File

@ -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

190
png.c
View File

@ -1,7 +1,7 @@
/* 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
@ -18,7 +18,7 @@
#ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */
char png_libpng_ver[12] = "1.0.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. */
@ -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;
}

661
png.h

File diff suppressed because it is too large Load Diff

View File

@ -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

131
pngconf.h
View File

@ -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;
@ -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)

View File

@ -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

153
pngget.c
View File

@ -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)

View File

@ -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

View File

@ -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)
@ -61,6 +72,13 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
png_push_read_zTXt(png_ptr, 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:
{
@ -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))
{
@ -382,6 +445,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
{
@ -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;

View File

@ -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);
@ -308,6 +332,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_zTXt_SUPPORTED)
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);
@ -801,6 +853,10 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_zTXt_SUPPORTED)
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);
@ -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

View File

@ -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
}

View File

@ -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)
@ -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};
@ -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

File diff suppressed because it is too large Load Diff

276
pngset.c
View File

@ -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,15 +327,27 @@ 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)
@ -248,12 +355,33 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
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

136
pngtest.c
View File

@ -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;
@ -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))
{
png_set_bKGD(write_ptr, write_info_ptr, background);
}
}
#endif
#if defined(PNG_READ_cHRM_SUPPORTED) && defined(PNG_WRITE_cHRM_SUPPORTED)
{
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
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_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
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_gAMA_SUPPORTED) && defined(PNG_WRITE_gAMA_SUPPORTED)
#if defined(PNG_gAMA_SUPPORTED)
{
double gamma;
png_uint_32 gamma;
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
{
png_set_gAMA(write_ptr, write_info_ptr, gamma);
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
}
}
#endif
#if defined(PNG_READ_sRGB_SUPPORTED) && defined(PNG_WRITE_sRGB_SUPPORTED)
#if defined(PNG_iCCP_SUPPORTED)
{
png_charp name;
png_charp profile;
png_int_32 proflen;
int compression_type;
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
&profile, &proflen))
{
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
profile, proflen);
}
}
#endif
#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,16 +775,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#endif
{
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_READ_sBIT_SUPPORTED) && defined(PNG_WRITE_sBIT_SUPPORTED)
#if defined(PNG_sBIT_SUPPORTED)
{
png_color_8p sig_bit;
@ -765,20 +785,41 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
}
#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_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED
{
png_charp unit;
double width, height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &width, &height))
{
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_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;
}

View File

@ -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

View File

@ -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;

View File

@ -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];

View File

@ -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

View File

@ -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++)
{
@ -221,6 +305,20 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
}
#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
}
@ -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;
}

View File

@ -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)

View File

@ -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,177 +1192,100 @@ 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;
/* 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;
old_max = max_output_ptr;
max_output_ptr = num_output_ptr + 4;
if (output_ptr != NULL)
{
png_charpp old_ptr;
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)));
}
/* 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++;
/* 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 (num_output_ptr >= max_output_ptr)
{
int old_max;
old_max = max_output_ptr;
max_output_ptr = num_output_ptr + 4;
if (output_ptr != NULL)
{
png_charpp old_ptr;
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)));
}
/* 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++;
/* 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 * 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;
/* compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
/* write start of chunk */
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)(key_len+text_len+2));
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);
/* 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);
}
#endif
#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;
png_debug(1, "in png_write_iTXt\n");
translated_key_len = png_strlen(translated_key);
text_len = png_strlen(text);
if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang,
&new_lang))==0)
{
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;
}
if (text == NULL || *text == '\0')
text_len = 0;
/* compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
/* 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));
/* 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);
/*
* 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);
png_write_compressed_data_out(png_ptr, &comp);
png_write_chunk_end(png_ptr);
png_free(png_ptr, new_key);
png_free(png_ptr, new_lang);
}
#endif
#if defined(PNG_WRITE_oFFs_SUPPORTED)
/* write the oFFs chunk */
@ -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
@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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