提交 166c5a39 编写于 作者: G Glenn Randers-Pehrson

Imported from libpng-1.0.5h.tar

上级 074af5e9
Libpng 1.0.5d - November 29, 1999
Libpng 1.0.5h - December 10, 1999
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
......@@ -33,14 +33,53 @@ version libpng-1.0.5c November 26, 1999
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
Removed some extraneous "-I" from contrib/pngminus/makefile.std
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
version 1.0.5d [November 29, 1999]
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
version libpng-1.0.5d November 29, 1999
Add type cast (png_const_charp) two places in png.c
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
to applications a macro "PNG_USE_LOCAL_ARRAYS".
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
version libpng-1.0.5e November 30, 1999
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
structure; refactored the inflate/deflate support to make adding new chunks
with trailing compressed parts easier in the future, and added new functions
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
NOTE: Applications that write text chunks MUST define png_text->lang. Before
calling png_set_text(). It must be set to NULL if you want to write tEXt or
zTXt chunks. If you want your application to be able to run with older
versions of libpng, use
#ifdef PNG_iTXt_SUPPORTED
png_text[i].lang = NULL;
#endif
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
offsets (Eric S. Raymond).
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
macros, leaving the separate macros also available.
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
version libpng-1.0.5f December 6, 1999
Changed makefile.solaris to issue a warning about potential problems when
the ucb "ld" is in the path ahead of the ccs "ld".
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
Added sCAL chunk support (Eric S. Raymond).
version libpng-1.0.5g December 7, 1999
Fixed "png_free_spallettes" typo in png.h
Added code to handle new chunks in pngpread.c
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
Added "translated_key" to png_text structure and png_write_iTXt().
Added code in pngwrite.c to work around a newly discovered zlib bug.
version 1.0.5h [December 10, 1999]
NOTE: regarding the not for version 1.0.5e, the following must also
be included in your code:
png_text[i].translated_key = NULL;
Unknown chunk handling is now supported.
Option to eliminate all floating point support was added. Some new
fixed-point functions such as png_set_gAMA_fixed() were added.
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
......
......@@ -503,7 +503,7 @@ version 1.0.5c [November 26, 1999]
PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined.
Removed some extraneous "-I" from contrib/pngminus/makefile.std
Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3
version 1.0.5d [November 29, 1999]
Add type cast (png_const_charp) two places in png.c
Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
......@@ -511,3 +511,42 @@ version 1.0.5d [November 29, 1999]
to applications a macro "PNG_USE_LOCAL_ARRAYS".
#ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
Added PNG_EXPORT_VAR macro to accommodate making DLL's.
version 1.0.5e [November 30, 1999]
Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text
structure; refactored the inflate/deflate support to make adding new chunks
with trailing compressed parts easier in the future, and added new functions
png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP,
png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond).
NOTE: Applications that write text chunks MUST define png_text->lang and
before calling png_set_text(). It must be set to NULL if you want to
write tEXt or zTXt chunks. If you want your application to be able to
run with older versions of libpng, use
#ifdef PNG_iTXt_SUPPORTED
png_text[i].lang = NULL;
#endif
Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned
offsets (Eric S. Raymond).
Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into
PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED
macros, leaving the separate macros also available.
Removed comments on #endifs at the end of many short, non-nested #if-blocks.
version 1.0.5f [December 6, 1999]
Changed makefile.solaris to issue a warning about potential problems when
the ucb "ld" is in the path ahead of the ccs "ld".
Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3.
Added sCAL chunk support (Eric S. Raymond).
version 1.0.5g [December 7, 1999]
Fixed "png_free_spallettes" typo in png.h
Added code to handle new chunks in pngpread.c
Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block
Added "translated_key" to png_text structure and png_write_iTXt().
Added code in pngwrite.c to work around a newly discovered zlib bug.
version 1.0.5h [December 10, 1999]
NOTE: regarding the not for version 1.0.5e, the following must also
be included in your code:
png_text[i].translated_key = NULL;
Unknown chunk handling is now supported.
Option to eliminate all floating point support was added. Some new
fixed-point functions such as png_set_gAMA_fixed() were added.
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
......
......@@ -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.
......@@ -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
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
......
......@@ -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.
......
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
......
......@@ -17,7 +17,7 @@
# "c:\windows\command.com /e:4096" as the program command line and set the
# working directory to this directory. Then double-click to open the new
# DOS-prompt window with a bigger environment and retry the commands above.
#
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are in subdirectories at the same level as the current subdirectory
# (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate.
......
......@@ -45,20 +45,20 @@ $ CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" -
$ write sys$output "Building rpng-x..."
$ CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" -
rpng-x.c readpng.h
$ call make rpng-x.exe -
"LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
$ call make rpng-x.exe -
"LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
rpng-x.obj readpng.obj
$ write sys$output "Building rpng2-x..."
$ CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" -
rpng2-x.c readpng2.h
$ call make rpng2-x.exe -
"LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
$ call make rpng2-x.exe -
"LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
rpng2-x.obj readpng2.obj
$ write sys$output "Building wpng..."
$ CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" -
wpng.c writepng.h
$ call make wpng.exe -
"LINK wpng,writepng,lib.opt/opt" -
$ call make wpng.exe -
"LINK wpng,writepng,lib.opt/opt" -
wpng.obj writepng.obj
$ exit
$!
......
......@@ -32,8 +32,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "png.h" /* libpng header; includes zlib.h */
#include "readpng.h" /* typedefs, common macros, public prototypes */
#include "png.h" /* libpng header; includes zlib.h */
#include "readpng.h" /* typedefs, common macros, public prototypes */
static png_structp png_ptr = NULL;
......@@ -50,7 +50,7 @@ void readpng_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
}
}
/* return value = 0 for success, 1 for bad sig, 2 for bad IHDR, 4 for no mem */
......
......@@ -30,10 +30,10 @@
---------------------------------------------------------------------------*/
#include <stdlib.h> /* for exit() prototype */
#include <stdlib.h> /* for exit() prototype */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "readpng2.h" /* typedefs, common macros, public prototypes */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "readpng2.h" /* typedefs, common macros, public prototypes */
/* local prototypes */
......@@ -53,7 +53,7 @@ void readpng2_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
}
}
......@@ -70,7 +70,7 @@ int readpng2_check_sig(uch *sig, int num)
int readpng2_init(mainprog_info *mainprog_ptr)
{
png_structp png_ptr; /* note: temporary variables! */
png_structp png_ptr; /* note: temporary variables! */
png_infop info_ptr;
......@@ -176,7 +176,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
mainprog_ptr = png_get_progressive_ptr(png_ptr);
if (mainprog_ptr == NULL) { /* we be hosed */
if (mainprog_ptr == NULL) { /* we be hosed */
fprintf(stderr,
"readpng2 error: main struct not recoverable in info_callback.\n");
fflush(stderr);
......@@ -408,7 +408,7 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
fflush(stderr);
mainprog_ptr = png_get_error_ptr(png_ptr);
if (mainprog_ptr == NULL) { /* we are completely hosed now */
if (mainprog_ptr == NULL) { /* we are completely hosed now */
fprintf(stderr,
"readpng2 severe error: jmpbuf not recoverable; terminating.\n");
fflush(stderr);
......
......@@ -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;
......
......@@ -53,7 +53,7 @@
/* #define DEBUG : this enables the Trace() macros */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
/* could just include png.h, but this macro is the only thing we need
......@@ -61,10 +61,10 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
......@@ -78,7 +78,7 @@ LRESULT CALLBACK rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename;
static FILE *infile;
......@@ -104,15 +104,15 @@ static HWND global_hwnd;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
char *args[1024]; /* arbitrary limit, but should suffice */
char *args[1024]; /* arbitrary limit, but should suffice */
char *p, *q, **argv = args;
int argc = 0;
int rc, alen, flen;
int error = 0;
int have_bg = FALSE;
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
MSG msg;
......@@ -150,7 +150,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
LUT_exponent = 1.8 / 2.61;
/*
if (some_mac_function_that_returns_gamma(&mac_gamma))
LUT_exponent = mac_gamma / 2.61;
LUT_exponent = mac_gamma / 2.61;
*/
#else
LUT_exponent = 1.0; /* assume no LUT: most PCs */
......@@ -371,7 +371,7 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*image_height)))
{
return 4; /* fail */
return 4; /* fail */
}
/*---------------------------------------------------------------------------
......@@ -477,7 +477,7 @@ static int rpng_win_display_image()
g = *src++;
b = *src++;
*dest++ = b;
*dest++ = g; /* note reverse order */
*dest++ = g; /* note reverse order */
*dest++ = r;
}
} else /* if (image_channels == 4) */ {
......@@ -582,15 +582,15 @@ LRESULT CALLBACK rpng_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
/* wait for the user to tell us when to quit */
case WM_CHAR:
switch (wP) { /* only need one, so ignore repeat count */
switch (wP) { /* only need one, so ignore repeat count */
case 'q':
case 'Q':
case 0x1B: /* Esc key */
case 0x1B: /* Esc key */
PostQuitMessage(0);
}
return 0;
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_DESTROY:
PostQuitMessage(0);
return 0;
......
......@@ -54,18 +54,18 @@
/* #define DEBUG : this enables the Trace() macros */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
#include "readpng.h" /* typedefs, common macros, readpng prototypes */
/* could just include png.h, but this macro is the only thing we need
* (name and typedefs changed to local versions); note that side effects
* only happen with alpha (which could easily be avoided with
* (name and typedefs changed to local versions); note that side effects
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
......@@ -123,9 +123,9 @@ int main(int argc, char **argv)
int rc, alen, flen;
int error = 0;
int have_bg = FALSE;
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
XEvent e;
KeySym k;
......@@ -222,7 +222,7 @@ int main(int argc, char **argv)
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error;
} else {
if ((rc = readpng_init(infile, (long *)(&image_width),
if ((rc = readpng_init(infile, (long *)(&image_width),
(long *)(&image_height))) != 0) {
switch (rc) {
case 1:
......@@ -408,11 +408,11 @@ static int rpng_x_create_window()
}
have_colormap = TRUE;
} else if (depth == 16) {
RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
RPixelShift = 15 - rpng_x_msb(RedMask); /* these are right-shifts */
GPixelShift = 15 - rpng_x_msb(GreenMask);
BPixelShift = 15 - rpng_x_msb(BlueMask);
} else /* if (depth > 16) */ {
RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
RPixelShift = rpng_x_msb(RedMask) - 7; /* these are left-shifts */
GPixelShift = rpng_x_msb(GreenMask) - 7;
BPixelShift = rpng_x_msb(BlueMask) - 7;
}
......
/*---------------------------------------------------------------------------
rpng2 - progressive-model PNG display program rpng2-win.c
rpng2 - progressive-model PNG display program rpng2-win.c
This program decodes and displays PNG files progressively, as if it were
a web browser (though the front end is only set up to read from files).
......@@ -57,9 +57,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <time.h>
#include <math.h> /* only for PvdM background code */
#include <math.h> /* only for PvdM background code */
#include <windows.h>
/* all for PvdM background code: */
......@@ -80,9 +80,9 @@
#define rgb2_max bg_bsat
#define rgb2_min bg_brot
/* #define DEBUG */ /* this enables the Trace() macros */
/* #define DEBUG */ /* this enables the Trace() macros */
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
/* could just include png.h, but this macro is the only thing we need
......@@ -90,18 +90,18 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
* block size corresponds roughly to a download
* speed 10% faster than theoretical 33.6K maximum
* (assuming 8 data bits, 1 stop bit and no other
* overhead) */
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
* block size corresponds roughly to a download
* speed 10% faster than theoretical 33.6K maximum
* (assuming 8 data bits, 1 stop bit and no other
* overhead) */
/* local prototypes */
static void rpng2_win_init(void);
......@@ -116,7 +116,7 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND, UINT, WPARAM, LPARAM);
static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *icon_name = PROGNAME; /* GRR: not (yet) used */
static char *filename;
static FILE *infile;
......@@ -125,7 +125,7 @@ static mainprog_info rpng2_info;
static uch inbuf[INBUFSIZE];
static int incount;
static int pat = 6; /* must be less than num_bgpat */
static int pat = 6; /* must be less than num_bgpat */
static int bg_image = 0;
static int bgscale = 16;
static ulg bg_rowbytes;
......@@ -134,22 +134,22 @@ static uch *bg_data;
static struct rgb_color {
uch r, g, b;
} rgb[] = {
{ 0, 0, 0}, /* 0: black */
{255, 255, 255}, /* 1: white */
{173, 132, 57}, /* 2: tan */
{ 64, 132, 0}, /* 3: medium green */
{189, 117, 1}, /* 4: gold */
{253, 249, 1}, /* 5: yellow */
{ 0, 0, 255}, /* 6: blue */
{ 0, 0, 120}, /* 7: medium blue */
{255, 0, 255}, /* 8: magenta */
{ 64, 0, 64}, /* 9: dark magenta */
{255, 0, 0}, /* 10: red */
{ 64, 0, 0}, /* 11: dark red */
{255, 127, 0}, /* 12: orange */
{192, 96, 0}, /* 13: darker orange */
{ 24, 60, 0}, /* 14: dark green-yellow */
{ 85, 125, 200} /* 15: ice blue */
{ 0, 0, 0}, /* 0: black */
{255, 255, 255}, /* 1: white */
{173, 132, 57}, /* 2: tan */
{ 64, 132, 0}, /* 3: medium green */
{189, 117, 1}, /* 4: gold */
{253, 249, 1}, /* 5: yellow */
{ 0, 0, 255}, /* 6: blue */
{ 0, 0, 120}, /* 7: medium blue */
{255, 0, 255}, /* 8: magenta */
{ 64, 0, 64}, /* 9: dark magenta */
{255, 0, 0}, /* 10: red */
{ 64, 0, 0}, /* 11: dark red */
{255, 127, 0}, /* 12: orange */
{192, 96, 0}, /* 13: darker orange */
{ 24, 60, 0}, /* 14: dark green-yellow */
{ 85, 125, 200} /* 15: ice blue */
};
/* not used for now, but should be for error-checking:
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
......@@ -174,25 +174,25 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
*/
static struct background_pattern {
ush type;
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
} bg[] = {
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
{2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
{2, 10000, 256, 11, 0} /* radial: dipole-moire' (almost fractal) */
};
static int num_bgpat = sizeof(bg) / sizeof(struct background_pattern);
......@@ -212,16 +212,16 @@ static int global_showmode;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
char *args[1024]; /* arbitrary limit, but should suffice */
char *args[1024]; /* arbitrary limit, but should suffice */
char *p, *q, *bgstr = NULL, **argv = args;
int argc = 0;
int rc, alen, flen;
int error = 0;
int timing = FALSE;
int have_bg = FALSE;
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
double LUT_exponent; /* just the lookup table */
double CRT_exponent = 2.2; /* just the monitor */
double default_display_exponent; /* whole display system */
MSG msg;
......@@ -267,7 +267,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
LUT_exponent = 1.8 / 2.61;
/*
if (some_mac_function_that_returns_gamma(&mac_gamma))
LUT_exponent = mac_gamma / 2.61;
LUT_exponent = mac_gamma / 2.61;
*/
#else
LUT_exponent = 1.0; /* assume no LUT: most PCs */
......@@ -560,7 +560,7 @@ static int rpng2_win_create_window()
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
wimage_rowbytes*rpng2_info.height)))
{
return 4; /* fail */
return 4; /* fail */
}
/*---------------------------------------------------------------------------
......@@ -655,7 +655,7 @@ static int rpng2_win_create_window()
TextOut(hdc, ((x < 0)? 0 : x), ((y < 0)? 0 : y), msg, len);
ReleaseDC(global_hwnd, hdc);
rpng2_win_load_bg_image(); /* resets bg_image if fails */
rpng2_win_load_bg_image(); /* resets bg_image if fails */
}
if (!bg_image) {
......@@ -753,7 +753,7 @@ static int rpng2_win_load_bg_image()
even_odd = even_odd_vert ^ even_odd_horiz;
invert_column =
(even_odd_horiz && (bg[pat].type & 0x10));
if (even_odd == 0) { /* gradient #1 */
if (even_odd == 0) { /* gradient #1 */
if (invert_column) {
*dest++ = r1_inv;
*dest++ = g1_inv;
......@@ -763,7 +763,7 @@ static int rpng2_win_load_bg_image()
*dest++ = g1;
*dest++ = b1;
}
} else { /* gradient #2 */
} else { /* gradient #2 */
if ((invert_column && invert_gradient2) ||
(!invert_column && !invert_gradient2))
{
......@@ -786,8 +786,8 @@ static int rpng2_win_load_bg_image()
} else if ((bg[pat].type & 0x07) == 1) {
hmax = (bgscale-1)/2; /* half the max weight of a color */
max = 2*hmax; /* the max weight of a color */
hmax = (bgscale-1)/2; /* half the max weight of a color */
max = 2*hmax; /* the max weight of a color */
r1 = rgb[bg[pat].rgb1_max].r;
g1 = rgb[bg[pat].rgb1_max].g;
......@@ -908,7 +908,7 @@ static int rpng2_win_load_bg_image()
g1 = *src++;
b1 = *src++;
*dest++ = b1;
*dest++ = g1; /* note reverse order */
*dest++ = g1; /* note reverse order */
*dest++ = r1;
}
}
......@@ -962,7 +962,7 @@ static void rpng2_win_display_row(ulg row)
g = *src++;
b = *src++;
*dest++ = b;
*dest++ = g; /* note reverse order */
*dest++ = g; /* note reverse order */
*dest++ = r;
}
} else /* if (rpng2_info.channels == 4) */ {
......@@ -1084,15 +1084,15 @@ LRESULT CALLBACK rpng2_win_wndproc(HWND hwnd, UINT iMsg, WPARAM wP, LPARAM lP)
/* wait for the user to tell us when to quit */
case WM_CHAR:
switch (wP) { /* only need one, so ignore repeat count */
switch (wP) { /* only need one, so ignore repeat count */
case 'q':
case 'Q':
case 0x1B: /* Esc key */
case 0x1B: /* Esc key */
PostQuitMessage(0);
}
return 0;
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_LBUTTONDOWN: /* another way of quitting */
case WM_DESTROY:
PostQuitMessage(0);
return 0;
......
/*---------------------------------------------------------------------------
rpng2 - progressive-model PNG display program rpng2-x.c
rpng2 - progressive-model PNG display program rpng2-x.c
This program decodes and displays PNG files progressively, as if it were
a web browser (though the front end is only set up to read from files).
......@@ -49,13 +49,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <setjmp.h> /* for jmpbuf declaration in readpng2.h */
#include <time.h>
#include <math.h> /* only for PvdM background code */
#include <math.h> /* only for PvdM background code */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/keysym.h> /* defines XK_* macros */
#include <X11/keysym.h> /* defines XK_* macros */
#ifdef VMS
#include <unistd.h>
......@@ -79,9 +79,9 @@
#define rgb2_max bg_bsat
#define rgb2_min bg_brot
/* #define DEBUG */ /* this enables the Trace() macros */
/* #define DEBUG */ /* this enables the Trace() macros */
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
#include "readpng2.h" /* typedefs, common macros, readpng2 prototypes */
/* could just include png.h, but this macro is the only thing we need
......@@ -89,18 +89,18 @@
* only happen with alpha (which could easily be avoided with
* "ush acopy = (alpha);") */
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
#define alpha_composite(composite, fg, alpha, bg) { \
ush temp = ((ush)(fg)*(ush)(alpha) + \
(ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128); \
(composite) = (uch)((temp + (temp >> 8)) >> 8); \
}
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
* block size corresponds roughly to a download
* speed 10% faster than theoretical 33.6K maximum
* (assuming 8 data bits, 1 stop bit and no other
* overhead) */
#define INBUFSIZE 4096 /* with pseudo-timing on (1 sec delay/block), this
* block size corresponds roughly to a download
* speed 10% faster than theoretical 33.6K maximum
* (assuming 8 data bits, 1 stop bit and no other
* overhead) */
/* local prototypes */
static void rpng2_x_init(void);
......@@ -123,7 +123,7 @@ static mainprog_info rpng2_info;
static uch inbuf[INBUFSIZE];
static int incount;
static int pat = 6; /* must be less than num_bgpat */
static int pat = 6; /* must be less than num_bgpat */
static int bg_image = 0;
static int bgscale = 16;
static ulg bg_rowbytes;
......@@ -132,22 +132,22 @@ static uch *bg_data;
static struct rgb_color {
uch r, g, b;
} rgb[] = {
{ 0, 0, 0}, /* 0: black */
{255, 255, 255}, /* 1: white */
{173, 132, 57}, /* 2: tan */
{ 64, 132, 0}, /* 3: medium green */
{189, 117, 1}, /* 4: gold */
{253, 249, 1}, /* 5: yellow */
{ 0, 0, 255}, /* 6: blue */
{ 0, 0, 120}, /* 7: medium blue */
{255, 0, 255}, /* 8: magenta */
{ 64, 0, 64}, /* 9: dark magenta */
{255, 0, 0}, /* 10: red */
{ 64, 0, 0}, /* 11: dark red */
{255, 127, 0}, /* 12: orange */
{192, 96, 0}, /* 13: darker orange */
{ 24, 60, 0}, /* 14: dark green-yellow */
{ 85, 125, 200} /* 15: ice blue */
{ 0, 0, 0}, /* 0: black */
{255, 255, 255}, /* 1: white */
{173, 132, 57}, /* 2: tan */
{ 64, 132, 0}, /* 3: medium green */
{189, 117, 1}, /* 4: gold */
{253, 249, 1}, /* 5: yellow */
{ 0, 0, 255}, /* 6: blue */
{ 0, 0, 120}, /* 7: medium blue */
{255, 0, 255}, /* 8: magenta */
{ 64, 0, 64}, /* 9: dark magenta */
{255, 0, 0}, /* 10: red */
{ 64, 0, 0}, /* 11: dark red */
{255, 127, 0}, /* 12: orange */
{192, 96, 0}, /* 13: darker orange */
{ 24, 60, 0}, /* 14: dark green-yellow */
{ 85, 125, 200} /* 15: ice blue */
};
/* not used for now, but should be for error-checking:
static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
......@@ -172,21 +172,21 @@ static int num_rgb = sizeof(rgb) / sizeof(struct rgb_color);
*/
static struct background_pattern {
ush type;
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
int rgb1_max, rgb1_min; /* or bg_freq, bg_gray */
int rgb2_max, rgb2_min; /* or bg_bsat, bg_brot (both scaled by 10)*/
} bg[] = {
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
{0+8, 2,0, 1,15}, /* checkered: tan/black vs. white/ice blue */
{0+24, 2,0, 1,0}, /* checkered: tan/black vs. white/black */
{0+8, 4,5, 0,2}, /* checkered: gold/yellow vs. black/tan */
{0+8, 4,5, 0,6}, /* checkered: gold/yellow vs. black/blue */
{0, 7,0, 8,9}, /* checkered: deep blue/black vs. magenta */
{0+8, 13,0, 5,14}, /* checkered: orange/black vs. yellow */
{0+8, 12,0, 10,11}, /* checkered: orange/black vs. red */
{1, 7,0, 8,0}, /* diamonds: deep blue/black vs. magenta */
{1, 12,0, 11,0}, /* diamonds: orange vs. dark red */
{1, 10,0, 7,0}, /* diamonds: red vs. medium blue */
{1, 4,0, 5,0}, /* diamonds: gold vs. yellow */
{1, 3,0, 0,0}, /* diamonds: medium green vs. black */
{2, 16, 100, 20, 0}, /* radial: ~hard radial color-beams */
{2, 18, 100, 10, 2}, /* radial: soft, curved radial color-beams */
{2, 16, 256, 100, 250}, /* radial: very tight spiral */
......@@ -580,7 +580,7 @@ static int rpng2_x_create_window()
return 2;
}
have_colormap = TRUE;
bg_image = FALSE; /* gradient just wastes palette entries */
bg_image = FALSE; /* gradient just wastes palette entries */
} else if (depth == 16) {
RPixelShift = 15 - rpng2_x_msb(RedMask); /* these are right-shifts */
GPixelShift = 15 - rpng2_x_msb(GreenMask);
......@@ -684,7 +684,7 @@ static int rpng2_x_create_window()
---------------------------------------------------------------------------*/
if (bg_image)
rpng2_x_load_bg_image(); /* resets bg_image if fails */
rpng2_x_load_bg_image(); /* resets bg_image if fails */
if (!bg_image) {
if (depth == 24 || depth == 32) {
......@@ -795,7 +795,7 @@ static int rpng2_x_load_bg_image()
even_odd = even_odd_vert ^ even_odd_horiz;
invert_column =
(even_odd_horiz && (bg[pat].type & 0x10));
if (even_odd == 0) { /* gradient #1 */
if (even_odd == 0) { /* gradient #1 */
if (invert_column) {
*dest++ = r1_inv;
*dest++ = g1_inv;
......@@ -805,7 +805,7 @@ static int rpng2_x_load_bg_image()
*dest++ = g1;
*dest++ = b1;
}
} else { /* gradient #2 */
} else { /* gradient #2 */
if ((invert_column && invert_gradient2) ||
(!invert_column && !invert_gradient2))
{
......@@ -828,8 +828,8 @@ static int rpng2_x_load_bg_image()
} else if ((bg[pat].type & 0x07) == 1) {
hmax = (bgscale-1)/2; /* half the max weight of a color */
max = 2*hmax; /* the max weight of a color */
hmax = (bgscale-1)/2; /* half the max weight of a color */
max = 2*hmax; /* the max weight of a color */
r1 = rgb[bg[pat].rgb1_max].r;
g1 = rgb[bg[pat].rgb1_max].g;
......
......@@ -57,27 +57,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
#include <setjmp.h> /* for jmpbuf declaration in writepng.h */
#include <time.h>
#ifdef DOS_OS2_W32
# include <io.h> /* for isatty(), setmode() prototypes */
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
# include <io.h> /* for isatty(), setmode() prototypes */
# include <fcntl.h> /* O_BINARY for fdopen() without text translation */
# ifdef __EMX__
# ifndef getch
# define getch() _read_kbd(0, 1, 0) /* need getche() */
# define getch() _read_kbd(0, 1, 0) /* need getche() */
# endif
# else /* !__EMX__ */
# ifdef __GO32__
# include <pc.h>
# define getch() getkey() /* GRR: need getche() */
# define getch() getkey() /* GRR: need getche() */
# else
# include <conio.h> /* for getche() console input */
# include <conio.h> /* for getche() console input */
# endif
# endif /* ?__EMX__ */
# define FGETS(buf,len,stream) dos_kbd_gets(buf,len)
#else
# include <unistd.h> /* for isatty() prototype */
# include <unistd.h> /* for isatty() prototype */
# define FGETS fgets
#endif
......@@ -87,7 +87,7 @@
text that includes control characters discouraged by the PNG spec; text
that includes an escape character (27) must be re-entered regardless */
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
#include "writepng.h" /* typedefs, common macros, writepng prototypes */
......@@ -112,7 +112,7 @@ int main(int argc, char **argv)
FILE *keybd;
#endif
#ifdef sgi
FILE *tmpfile; /* or we could just use keybd, since no overlap */
FILE *tmpfile; /* or we could just use keybd, since no overlap */
char tmpline[80];
#endif
char *inname = NULL, outname[256];
......@@ -269,7 +269,7 @@ int main(int argc, char **argv)
": unable to reopen stdout in binary mode\n");
fclose(wpng_info.infile);
++error;
} else
} else
wpng_info.filter = TRUE;
}
} else if ((len = strlen(inname)) > 250) {
......@@ -419,7 +419,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_TITLE;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_TITLE;
valid = FALSE;
}
......@@ -449,7 +449,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_AUTHOR;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_AUTHOR;
valid = FALSE;
}
......@@ -489,7 +489,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_DESC;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_DESC;
valid = FALSE;
}
......@@ -519,7 +519,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_COPY;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_COPY;
valid = FALSE;
}
......@@ -549,7 +549,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_EMAIL;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_EMAIL;
valid = FALSE;
}
......@@ -579,7 +579,7 @@ int main(int argc, char **argv)
wpng_info.have_text &= ~TEXT_URL;
valid = FALSE;
#else
if (p[result] == 27) { /* escape character */
if (p[result] == 27) { /* escape character */
wpng_info.have_text &= ~TEXT_URL;
valid = FALSE;
}
......@@ -743,10 +743,10 @@ static int wpng_isvalid_latin1(uch *p, int len)
for (i = 0; i < len; ++i) {
if (p[i] == 10 || (p[i] > 31 && p[i] < 127) || p[i] > 160)
continue; /* character is completely OK */
continue; /* character is completely OK */
if (result < 0 || (p[result] != 27 && p[i] == 27))
result = i; /* mark location of first questionable one */
} /* or of first escape character (bad) */
result = i; /* mark location of first questionable one */
} /* or of first escape character (bad) */
return result;
}
......@@ -791,11 +791,11 @@ static char *dos_kbd_gets(char *buf, int len)
buf[count++] = ch = getche();
} while (ch != '\r' && count < len-1);
buf[count--] = '\0'; /* terminate string */
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
buf[count--] = '\0'; /* terminate string */
if (buf[count] == '\r') /* Enter key makes CR, so change to newline */
buf[count] = '\n';
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
fprintf(stderr, "\n"); /* Enter key does *not* cause a newline */
fflush(stderr);
return buf;
......
......@@ -30,10 +30,10 @@
---------------------------------------------------------------------------*/
#include <stdlib.h> /* for exit() prototype */
#include <stdlib.h> /* for exit() prototype */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "writepng.h" /* typedefs, common macros, public prototypes */
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
#include "writepng.h" /* typedefs, common macros, public prototypes */
/* local prototype */
......@@ -48,7 +48,7 @@ void writepng_version_info()
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
}
}
......
PngMinus
PngMinus
--------
(copyright Willem van Schaik, 1999)
......@@ -19,7 +19,7 @@ Some history
Soon after the creation of PNG in 1995, the need was felt for a set of
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
(Willem van Schaik) started such a project. Luckily we discovered this
and merged the two together into pnmtopng.tar.gz, which is available
and merged the two together into pnmtopng.tar.gz, which is available
from a/o ftp://swrinde.nde.swri.edu/pub/png/.
These two utilities have many, many options and make use of most of the
......
......@@ -39,14 +39,14 @@ $ write sys$output "Compiling PNG contrib programs ..."
$ write sys$output "Building pnm2png..."
$ CALL MAKE pnm2png.OBJ "cc ''CCOPT' pnm2png" -
pnm2png.c
$ call make pnm2png.exe -
"LINK pnm2png,lib.opt/opt" -
$ call make pnm2png.exe -
"LINK pnm2png,lib.opt/opt" -
pnm2png.obj
$ write sys$output "Building png2pnm..."
$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" -
png2pnm.c
$ call make pnm2png.exe -
"LINK pnm2png,lib.opt/opt" -
$ call make pnm2png.exe -
"LINK pnm2png,lib.opt/opt" -
pnm2png.obj
$ exit
$!
......
......@@ -183,7 +183,7 @@ void usage()
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
{
png_struct *png_ptr = NULL;
png_info *info_ptr = NULL;
png_info *info_ptr = NULL;
png_byte buf[8];
png_byte *png_pixels = NULL;
png_byte **row_pointers = NULL;
......@@ -217,13 +217,13 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
return FALSE; /* out of memory */
info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr)
if (!info_ptr)
{
png_destroy_read_struct (&png_ptr, NULL, NULL);
return FALSE; /* out of memory */
}
if (setjmp (png_ptr->jmpbuf))
if (setjmp (png_ptr->jmpbuf))
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
......@@ -237,7 +237,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
png_read_info (png_ptr, info_ptr);
/* get size and bit-depth of the PNG-image */
png_get_IHDR (png_ptr, info_ptr,
png_get_IHDR (png_ptr, info_ptr,
&width, &height, &bit_depth, &color_type,
NULL, NULL, NULL);
......@@ -294,7 +294,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
channels = 4;
else
channels = 0; /* should never happen */
channels = 0; /* should never happen */
alpha_present = (channels - 1) % 2;
/* check if alpha is expected to be present in file */
......@@ -313,7 +313,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
return FALSE;
}
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
free (png_pixels);
......
......@@ -64,9 +64,9 @@ int main(int argc, char *argv[])
for (argi = 1; argi < argc; argi++)
{
if (argv[argi][0] == '-')
if (argv[argi][0] == '-')
{
switch (argv[argi][1])
switch (argv[argi][1])
{
case 'i':
interlace = TRUE;
......@@ -405,7 +405,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* if needed we will allocate memory for an new array of row-pointers */
if (row_pointers == (unsigned char**) NULL)
{
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
{
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
return FALSE;
......@@ -418,13 +418,13 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* write out the entire image data in one call */
png_write_image (png_ptr, row_pointers);
/* write the additional chuncks to the PNG file (not really needed) */
png_write_end (png_ptr, info_ptr);
/* clean up after the write, and free any memory allocated */
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
if (row_pointers != (unsigned char**) NULL)
free (row_pointers);
if (png_pixels != (unsigned char*) NULL)
......
......@@ -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);
......
此差异已折叠。
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.5d - November 29, 1999
libpng version 1.0.5h - December 10, 1999
Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu>
Copyright (c) 1998, 1999 Glenn Randers-Pehrson
......@@ -288,6 +288,17 @@ image data. You do this with a call to png_read_info().
png_read_info(png_ptr, info_ptr);
This will read all chunks up to but not including the image data.
Both known and unknown chunks will be read. Known chunks will be
parsed into information in various info_ptr members; unknown chunks
will be discarded, unless you previously called
png_set_keep_unknown_chunks();
in which case they will be saved as raw data onto a list of
png_unknown_chunk structures (and written out if you subsequently
call png_write_info and friends).
Functions are used to get the information from the info_ptr:
png_get_IHDR(png_ptr, info_ptr, &width, &height,
......@@ -391,6 +402,16 @@ into the info_ptr is returned for any complex types.
implies specific values of gAMA and
cHRM.
png_get_iCCP(png_ptr, info_ptr, &name, &compression_type,
&profile, &proflen);
name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
for PNG 1.0. You may give NULL to this argument
to ignore it.
profile - International Color Consortium color profile
data. May contain NULs.
proflen - length of profile data in bytes.
png_get_sBIT(png_ptr, info_ptr, &sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray,
......@@ -422,7 +443,9 @@ into the info_ptr is returned for any complex types.
num_text = png_get_text(png_ptr, info_ptr, &text_ptr);
text_ptr - array of png_text holding image
comments
text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
......@@ -430,6 +453,11 @@ into the info_ptr is returned for any complex types.
or PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments
num_spalettes = png_get_spalettes(png_ptr, info_ptr, &palette_ptr);
palette_ptr - array of png_spalette structures holding contents
of one or more sPLT chunks read.
num_spalettes - number of sPLT chunks read.
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
&unit_type);
offset_x - positive offset from the left edge
......@@ -447,6 +475,19 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
png_get_sCAL(png_ptr, info_ptr, &unit, &width, &height)
unit - physical scale units (a string)
width - width of a pixel in physical scale units
height - height of a pixel in physical scale units
num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr,
&unknowns)
unknowns - array of png_unknown_chunk structures holding
unknown chunks
unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk
The data from the pHYs chunk can be retrieved in several convenient
forms:
......@@ -481,14 +522,14 @@ There is also no requirement to have text after the keyword.
Keywords should be limited to 79 Latin-1 characters without leading or
trailing spaces, but non-consecutive spaces are allowed within the
keyword. It is possible to have the same keyword any number of times.
The text_ptr is an array of png_text structures, each holding pointer
to a keyword and a pointer to a text string. Only the text string may
be null. The keyword/text pairs are put into the array in the order
that they are received. However, some or all of the text chunks may be
after the image, so, to make sure you have read all the text chunks,
don't mess with these until after you read the stuff after the image.
This will be mentioned again below in the discussion that goes with
png_read_end().
The text_ptr is an array of png_text structures, each holding a
pointer to a language string, a pointer to a keyword and a pointer to
a text string. Only the text string may be null. The keyword/text
pairs are put into the array in the order that they are received.
However, some or all of the text chunks may be after the image, so, to
make sure you have read all the text chunks, don't mess with these
until after you read the stuff after the image. This will be
mentioned again below in the discussion that goes with png_read_end().
After you've read the header information, you can set up the library
to handle any special transformations of the image data. The various
......@@ -946,6 +987,30 @@ When you are done, you can free all memory allocated by libpng like this:
png_destroy_read_struct(&png_ptr, &info_ptr,
&end_info);
It is also possible to individually free the info_ptr members that
point to allocated storage with the following functions:
png_free_text(png_ptr, info_ptr, num)
num - number of text item to be freed (-1 for all items)
png_free_iCCP(png_ptr, info_ptr)
png_free_pCAL(png_ptr, info_ptr)
png_free_sCAL(png_ptr, info_ptr)
png_free_spalette(png_ptr, info_ptr, num)
num - number of suggested-paletted entry to be freed
(-1 for all suggested palettes)
png_free_unknown_chunk(png_ptr, info_ptr, num)
num - number of unknown chunk to be freed
(-1 for all suggested palettes)
These functions may be safely called when the relevant storage has
already been freed, or has not yet been allocated, and will in that
case do nothing.
For a more compact example of reading a PNG image, see the file example.c.
......@@ -1339,6 +1404,16 @@ Some of the more important parts of the png_info are:
that are consistent with sRGB to be
written.
png_set_iCCP(png_ptr, info_ptr, name, compression_type,
profile, proflen);
name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE
for PNG 1.0. You may give NULL to this argument
to ignore it.
profile - International Color Consortium color profile
data. May contain NULs.
proflen - length of profile data in bytes.
png_set_sBIT(png_ptr, info_ptr, sig_bit);
sig_bit - the number of significant bits for
(PNG_INFO_sBIT) each of the gray, red,
......@@ -1370,7 +1445,9 @@ Some of the more important parts of the png_info are:
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
text_ptr - array of png_text holding image
comments
text_ptr[i]->lang - language of comment (NULL for unknown).
text_ptr[i]->key - keyword for comment.
text_ptr[i]->translated_keyword - keyword in UTF-8 (NULL for unknown).
text_ptr[i]->text - text comments for current
keyword.
text_ptr[i]->compression - type of compression used
......@@ -1378,6 +1455,11 @@ Some of the more important parts of the png_info are:
PNG_TEXT_COMPRESSION_zTXt
num_text - number of comments in text_ptr
png_set_spalettes(png_ptr, info_ptr, &palette_ptr, num_spalettes);
palette_ptr - array of png_spalette structures to be added to
the list of palettes in the info structure.
num_spalettes - number of palette structures to be added.
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
unit_type);
offset_x - positive offset from the left
......@@ -1395,6 +1477,18 @@ Some of the more important parts of the png_info are:
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
png_set_sCAL(png_ptr, info_ptr, unit, width, height)
unit - physical scale units (a string)
width - width of a pixel in physical scale units
height - height of a pixel in physical scale units
png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, num_unknowns)
unknowns - array of png_unknown_chunk structures holding
unknown chunks
unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk
In PNG files, the alpha channel in an image is the level of opacity.
If your data is supplied as a level of transparency, you can invert the
alpha channel before you write it, so that 0 is fully transparent and 255
......@@ -1413,12 +1507,17 @@ A quick word about text and num_text. text is an array of png_text
structures. num_text is the number of valid structures in the array.
If you want, you can use max_text to hold the size of the array, but
libpng ignores it for writing (it does use it for reading). Each
png_text structure holds a keyword-text value, and a compression type.
png_text structure holds a language code, a keyword, a text value, and
a compression type.
The compression types have the same valid numbers as the compression
types of the image data. Currently, the only valid number is zero.
However, you can store text either compressed or uncompressed, unlike
images, which always have to be compressed. So if you don't want the
text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
Because compressed-text chunks don't have a language field, if you
specify compression any language code will not be written out.
Until text gets around 1000 bytes, it is not worth compressing it.
After the text has been written out to the file, the compression type
is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
......@@ -1484,6 +1583,14 @@ by the software. To facilitate the use of RFC 1123 dates, a function
png_convert_to_rfc1123(png_timep) is provided to convert from PNG
time to an RFC 1123 format string.
You can use the png_set_unknown_chunks function to queue up chunks
for writing. You give it a chunk name, raw data, and a size; that's
all there is to it. The chunks will be written by the next following
png_write_info_before_PLTE, png_write_info, or png_write_end function.
Any chunks previously read into the info structure's unknown-chunk
list will also be written out in a sequence that satisfies the PNG
specification's ordering rules.
You are now ready to write all the file information up to the actual
image data. You do this with a call to png_write_info().
......@@ -1494,7 +1601,7 @@ the PLTE chunk when PLTE is present, you can write the PNG info in
two steps, and insert code to write your own chunk between them:
png_write_info_before_PLTE(png_ptr, info_ptr);
write_my_private_chunks();
png_set_unknown_chunks(png_ptr, info_ptr, ...);
png_write_info(png_ptr, info_ptr);
After you've written the file information, you can set up the library
......@@ -1703,6 +1810,30 @@ When you are done, you can free all memory used by libpng like this:
png_destroy_write_struct(&png_ptr, &info_ptr);
It is also possible to individually free the info_ptr members that
point to allocated storage with the following functions:
png_free_text(png_ptr, info_ptr, num)
num - number of text item to be freed (-1 for all items)
png_free_iCCP(png_ptr, info_ptr)
png_free_pCAL(png_ptr, info_ptr)
png_free_sCAL(png_ptr, info_ptr)
png_free_spalette(png_ptr, info_ptr, num)
num - number of suggested-paletted entry to be freed
(-1 for all suggested palettes)
png_free_unknown_chunk(png_ptr, info_ptr, num)
num - number of unknown chunk entry to be freed
(-1 for all suggested palettes)
These functions may be safely called when the relevant storage has
already been freed, or has not yet been allocated, and will in that
case do nothing.
You must free any data you allocated for info_ptr, such as comments,
palette, or histogram, before the call to png_destroy_write_struct();
......@@ -1972,7 +2103,7 @@ or all four,
along with directives to turn on any of the capabilities that you do
want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
the extra transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks [except for sPLT].
and writing PNG files with all known public chunks
Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
produces a library that is incapable of reading or writing ancillary chunks.
If you are not using the progressive reading capability, you can
......@@ -2066,13 +2197,13 @@ the old method.
VII. Y2K Compliance in libpng
November 29, 1999
December 10, 1999
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.5d are Y2K compliant. It is my belief that earlier
upward through 1.0.5h are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that
......@@ -2088,7 +2219,7 @@ The strings are
There are seven time-related functions:
png_convert_to_rfc_1123() in png.c
png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
png_convert_from_time_t() in pngwrite.c
......@@ -2097,7 +2228,7 @@ There are seven time-related functions:
png_set_tIME() in pngset.c
png_write_tIME() in pngwutil.c, called in pngwrite.c
All appear to handle dates properly in a Y2K environment. The
All appear to handle dates properly in a Y2K environment. The
png_convert_from_time_t() function calls gmtime() to convert from system
clock time, which returns (year - 1900), which we properly convert to
the full 4-digit year. There is a possibility that applications using
......
.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
......
.TH PNG 5 "November 29, 1999"
.TH PNG 5 "December 10, 1999"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
......
/* png.c - location for general purpose libpng functions
*
* libpng version 1.0.5d - November 29, 1999
* libpng version 1.0.5h - December 10, 1999
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999 Glenn Randers-Pehrson
*
*
*/
#define PNG_INTERNAL
......@@ -18,12 +18,12 @@
#ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */
char png_libpng_ver[12] = "1.0.5d";
char png_libpng_ver[12] = "1.0.5h";
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
/* Invoke global declarations for constant strings for known chunk types */
PNG_IHDR;
PNG_IDAT;
......@@ -33,10 +33,14 @@ PNG_bKGD;
PNG_cHRM;
PNG_gAMA;
PNG_hIST;
PNG_iCCP;
PNG_iTXt;
PNG_oFFs;
PNG_pCAL;
PNG_sCAL;
PNG_pHYs;
PNG_sBIT;
PNG_sPLT;
PNG_sRGB;
PNG_tEXt;
PNG_tIME;
......@@ -254,6 +258,134 @@ png_info_init(png_infop info_ptr)
png_memset(info_ptr, 0, sizeof (png_info));
}
#if defined(PNG_TEXT_SUPPORTED)
/* free text item num or (if num == -1) all text items */
void
png_free_text(png_structp png_ptr, png_infop info_ptr, int num)
{
if (num != -1)
{
if (info_ptr->text[num].key)
{
png_free(png_ptr, info_ptr->text[num].key);
info_ptr->text[num].key = NULL;
}
if (info_ptr->text[num].lang)
{
png_free(png_ptr, info_ptr->text[num].lang);
info_ptr->text[num].lang = NULL;
}
}
else if (info_ptr->text != NULL)
{
int i;
for (i = 0; i < info_ptr->num_text; i++)
png_free_text(png_ptr, info_ptr, i);
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
}
}
#endif
#if defined(PNG_sCAL_SUPPORTED)
/* free any sCAL entry */
void
png_free_sCAL(png_structp png_ptr, png_infop info_ptr)
{
if (info_ptr->valid & PNG_INFO_sCAL)
{
png_free(png_ptr, info_ptr->scal_unit);
#ifdef PNG_FIXED_POINT_SUPPORTED
png_free(png_ptr, info_ptr->scal_s_width);
png_free(png_ptr, info_ptr->scal_s_height);
#endif
info_ptr->valid &= ~PNG_INFO_sCAL;
}
}
#endif
#if defined(PNG_pCAL_SUPPORTED)
/* free any pCAL entry */
void
png_free_pCAL(png_structp png_ptr, png_infop info_ptr)
{
if (info_ptr->valid & PNG_INFO_pCAL)
{
png_free(png_ptr, info_ptr->pcal_purpose);
png_free(png_ptr, info_ptr->pcal_units);
if (info_ptr->pcal_params != NULL)
{
int i;
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{
png_free(png_ptr, info_ptr->pcal_params[i]);
}
png_free(png_ptr, info_ptr->pcal_params);
}
info_ptr->valid &= ~PNG_INFO_pCAL;
}
}
#endif
#if defined(PNG_iCCP_SUPPORTED)
/* free any pCAL entry */
void
png_free_iCCP(png_structp png_ptr, png_infop info_ptr)
{
if (info_ptr->valid & PNG_INFO_iCCP)
{
png_free(png_ptr, info_ptr->iccp_name);
png_free(png_ptr, info_ptr->iccp_profile);
info_ptr->valid &= ~PNG_INFO_iCCP;
}
}
#endif
#if defined(PNG_sPLT_SUPPORTED)
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
void
png_free_spalette(png_structp png_ptr, png_infop info_ptr, int num)
{
if (num != -1)
{
png_free(png_ptr, info_ptr->splt_palettes[num].name);
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
}
else
{
png_uint_32 i;
for (i = 0; i < info_ptr->splt_palettes_num; i++)
png_free_spalette(png_ptr, info_ptr, num);
png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes_num = 0;
}
}
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
void
png_free_unknown_chunk(png_structp png_ptr, png_infop info_ptr, int num)
{
if (num != -1)
{
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
info_ptr->unknown_chunks[num].data = NULL;
}
else
{
png_uint_32 i;
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
png_free_unknown_chunk(png_ptr, info_ptr, num);
png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks_num = 0;
}
}
#endif
/* This is an internal routine to free any memory that the info struct is
* pointing to before re-using it or freeing the struct itself. Recall
* that png_free() checks for NULL pointers for us.
......@@ -261,39 +393,25 @@ png_info_init(png_infop info_ptr)
void
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
{
#if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
png_debug(1, "in png_info_destroy\n");
if (info_ptr->text != NULL)
{
int i;
for (i = 0; i < info_ptr->num_text; i++)
{
if(info_ptr->text[i].key != NULL)
{
png_free(png_ptr, info_ptr->text[i].key);
info_ptr->text[i].key = NULL;
}
}
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
}
#if defined(PNG_READ_TEXT_SUPPORTED)
png_free_text(png_ptr, info_ptr, -1);
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
png_free_sCAL(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
png_free(png_ptr, info_ptr->pcal_purpose);
png_free(png_ptr, info_ptr->pcal_units);
if (info_ptr->pcal_params != NULL)
{
int i;
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{
png_free(png_ptr, info_ptr->pcal_params[i]);
info_ptr->pcal_params[i]=NULL;
}
png_free(png_ptr, info_ptr->pcal_params);
info_ptr->pcal_params = NULL;
}
png_free_pCAL(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_iCCP_SUPPORTED)
png_free_iCCP(png_ptr, info_ptr);
#endif
#if defined(PNG_READ_sPLT_SUPPORTED)
png_free_spalette(png_ptr, info_ptr, -1);
#endif
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_free_unknown_chunk(png_ptr, info_ptr, -1);
#endif
png_info_init(info_ptr);
}
......@@ -371,7 +489,7 @@ png_charp
png_get_copyright(png_structp png_ptr)
{
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
return ("\n libpng version 1.0.5d - November 29, 1999\n\
return ("\n libpng version 1.0.5h - December 10, 1999\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
......@@ -389,8 +507,8 @@ png_get_libpng_ver(png_structp png_ptr)
{
/* Version of *.c files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return("1.0.5d");
return("1.0.5d");
return("1.0.5h");
return("1.0.5h");
}
png_charp
......@@ -414,8 +532,8 @@ png_get_header_version(png_structp png_ptr)
/* Generate a compiler error if there is an old png.h in the search path. */
void
png_check_version
(version_1_0_5d png_h_is_not_version_1_0_5d)
(version_1_0_5h png_h_is_not_version_1_0_5h)
{
if(png_h_is_not_version_1_0_5d == NULL)
if(png_h_is_not_version_1_0_5h == NULL)
return;
}
此差异已折叠。
/* 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
......
/* pngconf.h - machine configurable file for libpng
*
* libpng 1.0.5d - November 29, 1999
* libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -260,6 +260,7 @@ __dont__ include it again
*/
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_TRANSFORMS)
#define PNG_READ_TRANSFORMS_SUPPORTED
......@@ -418,6 +419,14 @@ __dont__ include it again
#define PNG_ASSEMBLER_CODE_SUPPORTED
#endif
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
#define PNG_FLOATING_POINT_SUPPORTED
#endif
#ifndef PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#endif
/* Do not use global arrays (helps with building DLL's)
* They are no longer used in libpng itself, since version 1.0.5c,
* but might be required for some pre-1.0.5c applications.
......@@ -466,87 +475,201 @@ __dont__ include it again
#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_READ_bKGD
#define PNG_READ_bKGD_SUPPORTED
#define PNG_bKGD_SUPPORTED
#endif
#ifndef PNG_NO_READ_cHRM
#define PNG_READ_cHRM_SUPPORTED
#define PNG_cHRM_SUPPORTED
#endif
#ifndef PNG_NO_READ_gAMA
#define PNG_READ_gAMA_SUPPORTED
#define PNG_gAMA_SUPPORTED
#endif
#ifndef PNG_NO_READ_hIST
#define PNG_READ_hIST_SUPPORTED
#define PNG_hIST_SUPPORTED
#endif
#ifndef PNG_NO_READ_iCCP
#define PNG_READ_iCCP_SUPPORTED
#define PNG_iCCP_SUPPORTED
#endif
#ifndef PNG_NO_READ_iTXt
#define PNG_READ_iTXt_SUPPORTED
#define PNG_iTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_oFFs
#define PNG_READ_oFFs_SUPPORTED
#define PNG_oFFs_SUPPORTED
#endif
#ifndef PNG_NO_READ_pCAL
#define PNG_READ_pCAL_SUPPORTED
#define PNG_pCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_sCAL
#define PNG_READ_sCAL_SUPPORTED
#define PNG_sCAL_SUPPORTED
#endif
#ifndef PNG_NO_READ_pHYs
#define PNG_READ_pHYs_SUPPORTED
#define PNG_pHYs_SUPPORTED
#endif
#ifndef PNG_NO_READ_sBIT
#define PNG_READ_sBIT_SUPPORTED
#define PNG_sBIT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sPLT
#define PNG_READ_sPLT_SUPPORTED
#define PNG_sPLT_SUPPORTED
#endif
#ifndef PNG_NO_READ_sRGB
#define PNG_READ_sRGB_SUPPORTED
#define PNG_sRGB_SUPPORTED
#endif
#ifndef PNG_NO_READ_tEXt
#define PNG_READ_tEXt_SUPPORTED
#define PNG_tEXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_tIME
#define PNG_READ_tIME_SUPPORTED
#define PNG_tIME_SUPPORTED
#endif
#ifndef PNG_NO_READ_tRNS
#define PNG_READ_tRNS_SUPPORTED
#define PNG_tRNS_SUPPORTED
#endif
#ifndef PNG_NO_READ_zTXt
#define PNG_READ_zTXt_SUPPORTED
#define PNG_zTXt_SUPPORTED
#endif
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#endif
#ifndef PNG_NO_READ_OPT_PLTE
#define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the optional */
#endif /* PLTE chunk in RGB and RGBA images */
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
defined(PNG_READ_zTXt_SUPPORTED)
#define PNG_READ_TEXT_SUPPORTED
#define PNG_TEXT_SUPPORTED
#endif
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#ifndef PNG_NO_WRITE_bKGD
#define PNG_WRITE_bKGD_SUPPORTED
#ifndef PNG_bKGD_SUPPORTED
# define PNG_bKGD_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_cHRM
#define PNG_WRITE_cHRM_SUPPORTED
#ifndef PNG_cHRM_SUPPORTED
# define PNG_cHRM_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_gAMA
#define PNG_WRITE_gAMA_SUPPORTED
#ifndef PNG_gAMA_SUPPORTED
# define PNG_gAMA_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_hIST
#define PNG_WRITE_hIST_SUPPORTED
#ifndef PNG_hIST_SUPPORTED
# define PNG_hIST_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_iCCP
#define PNG_WRITE_iCCP_SUPPORTED
#ifndef PNG_iCCP_SUPPORTED
# define PNG_iCCP_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_iTXt
#define PNG_WRITE_iTXt_SUPPORTED
#ifndef PNG_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_oFFs
#define PNG_WRITE_oFFs_SUPPORTED
#ifndef PNG_oFFs_SUPPORTED
# define PNG_oFFs_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_pCAL
#define PNG_WRITE_pCAL_SUPPORTED
#ifndef PNG_pCAL_SUPPORTED
# define PNG_pCAL_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_sCAL
#define PNG_WRITE_sCAL_SUPPORTED
#ifndef PNG_sCAL_SUPPORTED
# define PNG_sCAL_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_pHYs
#define PNG_WRITE_pHYs_SUPPORTED
#ifndef PNG_pHYs_SUPPORTED
# define PNG_pHYs_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_sBIT
#define PNG_WRITE_sBIT_SUPPORTED
#ifndef PNG_sBIT_SUPPORTED
# define PNG_sBIT_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_sPLT
#define PNG_WRITE_sPLT_SUPPORTED
#ifndef PNG_sPLT_SUPPORTED
# define PNG_sPLT_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_sRGB
#define PNG_WRITE_sRGB_SUPPORTED
#ifndef PNG_sRGB_SUPPORTED
# define PNG_sRGB_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_tEXt
#define PNG_WRITE_tEXt_SUPPORTED
#ifndef PNG_tEXt_SUPPORTED
# define PNG_tEXt_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_tIME
#define PNG_WRITE_tIME_SUPPORTED
#ifndef PNG_tIME_SUPPORTED
# define PNG_tIME_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_tRNS
#define PNG_WRITE_tRNS_SUPPORTED
#ifndef PNG_tRNS_SUPPORTED
# define PNG_tRNS_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_zTXt
#define PNG_WRITE_zTXt_SUPPORTED
#ifndef PNG_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED
#endif
#endif
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
#endif
#endif
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
defined(PNG_WRITE_zTXt_SUPPORTED)
#define PNG_WRITE_TEXT_SUPPORTED
#ifndef PNG_TEXT_SUPPORTED
# define PNG_TEXT_SUPPORTED
#endif
#endif
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
......@@ -644,7 +767,9 @@ typedef png_uint_16 FAR * png_uint_16p;
typedef png_int_16 FAR * png_int_16p;
typedef PNG_CONST char FAR * png_const_charp;
typedef char FAR * png_charp;
#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * png_doublep;
#endif
/* Pointers to pointers; i.e. arrays */
typedef png_byte FAR * FAR * png_bytepp;
......@@ -654,7 +779,9 @@ typedef png_uint_16 FAR * FAR * png_uint_16pp;
typedef png_int_16 FAR * FAR * png_int_16pp;
typedef PNG_CONST char FAR * FAR * png_const_charpp;
typedef char FAR * FAR * png_charpp;
#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * FAR * png_doublepp;
#endif
/* Pointers to pointers to pointers; i.e. pointer to array */
typedef char FAR * FAR * FAR * png_charppp;
......@@ -703,7 +830,7 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_EXPORT_VAR(type) extern __declspec(dllexport) type
# endif
# ifdef PNG_ATTR_DLLEXP
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
# endif
# ifdef PNG_DECL_DLLIMP
# define PNG_EXPORT_VAR(type) extern __declspec(dllimport) type
......@@ -743,7 +870,7 @@ typedef z_stream FAR * png_zstreamp;
#endif
/* End of memory model independent support */
/* Just a double check that someone hasn't tried to define something
/* Just a little check that someone hasn't tried to define something
* contradictory.
*/
#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
......
/* 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
......
/* 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)
......
/* 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
......
/* 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
{
......@@ -817,30 +886,30 @@ png_read_push_finish_row(png_structp png_ptr)
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */
const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */
const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */
const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Width of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
*/
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
const int png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
#endif
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
return;
......@@ -952,6 +1021,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->lang = (char *)NULL;
text_ptr->key = key;
text_ptr->text = text;
......@@ -1131,6 +1201,101 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->lang = (char *)NULL;
text_ptr->key = key;
text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
}
}
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
void
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
{
png_error(png_ptr, "Out of place iTXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
}
#ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */
if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */
{
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
png_ptr->skip_length = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_iTXt_MODE;
}
void
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->buffer_size && png_ptr->current_text_left)
{
png_size_t text_size;
if (png_ptr->buffer_size < png_ptr->current_text_left)
text_size = png_ptr->buffer_size;
else
text_size = png_ptr->current_text_left;
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += text_size;
}
if (!(png_ptr->current_text_left))
{
png_textp text_ptr;
png_charp text;
png_charp lang;
png_charp key;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_crc_finish(png_ptr);
#if defined(PNG_MAX_MALLOC_64K)
if (png_ptr->skip_length)
return;
#endif
lang = png_ptr->current_text;
png_ptr->current_text = 0;
for (key = lang; *key; key++)
/* empty loop */ ;
if (key != lang + png_ptr->current_text_size)
key++;
for (text = key; *text; text++)
/* empty loop */ ;
if (text != key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->lang = lang;
text_ptr->key = key;
text_ptr->text = text;
......
/* 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
......
/* 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
}
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 1.0.5d - November 29, 1999
* libpng 1.0.5h - December 10, 1999
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
......@@ -69,7 +69,8 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
}
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
defined(PNG_FLOATING_POINT_SUPPORTED)
/* handle alpha and tRNS via a background color */
void
png_set_background(png_structp png_ptr,
......@@ -504,7 +505,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
}
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED)
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
/* Transform the image from the file_gamma to the screen_gamma. We
* only do transformations on images where the file_gamma and screen_gamma
* are not close reciprocals, otherwise it slows things down slightly, and
......@@ -581,7 +582,8 @@ png_set_gray_to_rgb(png_structp png_ptr)
}
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) && \
defined(PNG_FLOATING_POINT_SUPPORTED)
/* Convert a RGB image to a grayscale of the same width. This allows us,
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
*/
......@@ -718,7 +720,7 @@ png_init_read_transformations(png_structp png_ptr)
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
png_ptr->background_1 = png_ptr->background;
#endif
#if defined(PNG_READ_GAMMA_SUPPORTED)
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY))
{
png_build_gamma_table(png_ptr);
......@@ -731,7 +733,6 @@ png_init_read_transformations(png_structp png_ptr)
png_colorp palette = png_ptr->palette;
int num_palette = png_ptr->num_palette;
int i;
if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
{
back.red = png_ptr->gamma_table[png_ptr->background.red];
......@@ -789,7 +790,6 @@ png_init_read_transformations(png_structp png_ptr)
back_1.blue = (png_byte)(pow(
(double)png_ptr->background.blue/255, g) * 255.0 + .5);
}
for (i = 0; i < num_palette; i++)
{
if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff)
......@@ -998,8 +998,15 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_GAMMA_SUPPORTED)
if (png_ptr->transformations & PNG_GAMMA)
{
#ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->gamma = png_ptr->gamma;
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
info_ptr->int_gamma = png_ptr->int_gamma;
#endif
}
#endif
#if defined(PNG_READ_16_TO_8_SUPPORTED)
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
......@@ -1290,7 +1297,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
png_ptr->row_info.channels = png_ptr->user_transform_channels;
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
png_ptr->row_info.pixel_depth+7)>>3;
}
#endif
......@@ -1988,7 +1995,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
/* reduce RGB files to grayscale, with or without alpha
/* reduce RGB files to grayscale, with or without alpha
* using the equation given in Poynton's ColorFAQ at
* <http://www.inforamp.net/~poynton/>
* Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
......@@ -1996,7 +2003,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
*
* We approximate this with
*
*
* Y = 0.211 * R + 0.715 * G + 0.074 * B
*
* which can be expressed with integers as
......@@ -2072,7 +2079,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
}
}
}
else /* RGB bit_depth == 16 */
{
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
......@@ -2097,7 +2104,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_shift][green>>8];
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
+ bc*blue_1)>>8);
......@@ -2105,7 +2112,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][gray16 >> 8];
rgb_error |= 1;
}
*(dp++) = (png_byte)((w>>8) & 0xff);
*(dp++) = (png_byte)(w & 0xff);
}
......@@ -2194,7 +2201,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_shift][green>>8];
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc * red_1
+ gc * green_1 + bc * blue_1)>>8);
......@@ -2202,7 +2209,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_ptr->gamma_shift][gray16 >> 8];
rgb_error |= 1;
}
*(dp++) = (png_byte)((w>>8) & 0xff);
*(dp++) = (png_byte)(w & 0xff);
*(dp++) = *(sp++); /* alpha */
......@@ -2298,7 +2305,8 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
int num_palette)
{
png_debug(1, "in png_correct_palette\n");
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
{
png_color back, back_1;
......@@ -3764,6 +3772,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
}
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
#if defined(PNG_READ_GAMMA_SUPPORTED)
static int png_gamma_shift[] =
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
......@@ -3814,7 +3823,7 @@ png_build_gamma_table(png_structp png_ptr)
g) * 255.0 + .5);
}
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
......@@ -3983,4 +3992,6 @@ png_build_gamma_table(png_structp png_ptr)
}
}
#endif
/* To do: install integer version of png_build_gamma_table here */
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
/* 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
......
/* 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;
......
此差异已折叠。
/* 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
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -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
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册