Imported from libpng-1.0.2a.tar

This commit is contained in:
Glenn Randers-Pehrson 1998-12-29 11:47:59 -06:00
parent 345bc27e70
commit 5c6aeb25c1
45 changed files with 1160 additions and 735 deletions

View File

@ -1,67 +1,38 @@
Libpng 1.0.2 - June 14, 1998
Libpng 1.0.2a - December 29, 1998
This is a public release of libpng, intended for use in production codes.
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.
Changes since the previous public release (1.0.1):
Changes since the last public release:
Optimized Paeth calculations by replacing abs() function calls with intrinsics
plus other loop optimizations. Improves avg decoding speed by about 20%.
Commented out i386istic "align" compiler flags in makefile.lnx.
Reduced the default warning level in some makefiles, to make them consistent.
Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
Added grayscale and 16-bit capability to png_do_read_filler().
Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
too large when writing an image with bit_depth < 8 (Bob Dellaca).
Corrected some bugs in the experimental weighted filtering heuristics.
Moved a misplaced pngrutil code block that truncates tRNS if it has more
than num_palette entries -- test was done before num_palette was defined.
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen).
Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
Relocated the png_composite macros from pngrtran.c to png.h (Greg).
Added makefile.sco (contributed by Mike Hopkirk).
Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
Added warnings when people try to use transforms they've defined out.
Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran.
Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg)
Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images.
Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED
out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h
Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED,
for consistency, in pngconf.h
Added individual "ifndef PNG_NO_CAPABILITY" for the capabilities in pngconf.h
to make it easier to remove unwanted capabilities via the compile line
Made some corrections to grammar (which, it's) in documentation (Greg).
Corrected example.c, use of row_pointers in png_write_image().
Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert)
More corrections to example.c, use of row_pointers in png_write_image()
and png_read_rows().
Added pngdll.mak and pngdef.pas to scripts directory, contributed by
Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
Changed several loops from count-down to count-up, for consistency.
Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
added warnings when people try to set png_read_fn and png_write_fn in
the same structure.
Added a test such that png_do_gamma will be done when num_trans==0
for truecolor images that have defined a background. This corrects an
error that was introduced in libpng-0.90 that can cause gamma processing
to be skipped.
Added tests in png.h to include "trans" and "trans_values" in structures
when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined.
Add png_free(png_ptr->time_buffer) in png_destroy_read_struct()
Moved png_convert_to_rfc_1123() from pngwrite.c to png.c
Added capability for user-provided malloc_fn() and free_fn() functions,
and revised pngtest.c to demonstrate their use, replacing the
PNGTEST_DEBUG_MEM feature.
Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
Fixed two bugs in makefile.bor
libpng-1.0.2a:
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
the left-most pixel of each row (Kevin Bracey).
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
in pngtest.c (Duncan Simpson).
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
Fixed a problem in png_read_push_finish_row(), which would not skip some
passes that it should skip, for images that are less than 3 pixels high.
Interchanged the order of calls to png_do_swap() and png_do_shift()
in pngwtran.c (John Cromer).
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
Fixed a documentation error about default filtering with 8-bit indexed-color.
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
(L. Peter Deutsch).
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
Added png_get_copyright() and png_get_header_version() functions.
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
Added information about debugging in libpng.txt and libpng.3 .
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
Removed lines after Dynamic Dependencies" in makefile.aco .
Revised makefile.dec to make a shared library (Jeremie Petit).
Removed trailing blanks from all files.
Send comments/corrections/commendations to
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
Glenn Randers-Pehrson
libpng maintainer
PNG Development Group
Glenn R-P

33
CHANGES
View File

@ -89,7 +89,7 @@ version 0.89 [July, 1996]
so that people are aware that they need to change their code
changed filter selection API to allow selection of multiple filters
since it didn't work in previous versions of libpng anyways
optimized filter selection code
optimized filter selection code
fixed png_set_background() to allow using an arbitrary RGB color for
paletted images
fixed gamma and background correction for paletted images, so
@ -256,7 +256,7 @@ version 0.99g [March 6, 1998, morning]
Minor changes to pngtest.c to suppress compiler warnings.
Removed "beta" language from documentation.
version 0.99h [March 6, 1998, evening]
Minor changes to previous minor changes to pngtest.c
Minor changes to previous minor changes to pngtest.c
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
version 1.00 [March 7, 1998]
@ -334,7 +334,7 @@ version 1.0.1d [May 24, 1998]
Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5
Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.)
Changed several loops from count-down to count-up, for consistency.
version 1.0.2 [June 14, 1998]
version 1.0.1e [June 6, 1998]
Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and
added warnings when people try to set png_read_fn and png_write_fn in
the same structure.
@ -350,4 +350,29 @@ version 1.0.2 [June 14, 1998]
and revised pngtest.c to demonstrate their use, replacing the
PNGTEST_DEBUG_MEM feature.
Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner).
Fixed two bugs in makefile.bor
version 1.0.2 [June 14, 1998]
Fixed two bugs in makefile.bor .
version 1.0.2a [December 29, 1998]
Replaced and extended code that was removed from png_set_filler() in 1.0.1a.
Fixed a bug in png_do_filler() that made it fail to write filler bytes in
the left-most pixel of each row (Kevin Bracey).
Changed "static pngcharp tIME_string" to "static char tIME_string[30]"
in pngtest.c (Duncan Simpson).
Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit.
Fixed a problem in png_read_push_finish_row(), which would not skip some
passes that it should skip, for images that are less than 3 pixels high.
Interchanged the order of calls to png_do_swap() and png_do_shift()
in pngwtran.c (John Cromer).
Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h .
Changed "bad adaptive filter type" from error to warning in pngrutil.c .
Fixed a documentation error about default filtering with 8-bit indexed-color.
Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO
(L. Peter Deutsch).
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
Added png_get_copyright() and png_get_header_version() functions.
Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c
Added information about debugging in libpng.txt and libpng.3 .
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
Removed lines after Dynamic Dependencies" in makefile.aco .
Revised makefile.dec to make a shared library (Jeremie Petit).
Removed trailing blanks from all files.

View File

@ -1,17 +1,17 @@
Installing libpng version 1.0.2 - June 14, 1998
Installing libpng version 1.0.2a - December 29, 1998
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be
placed in another directory, at the same level as libpng.
Note that your system might already have a preinstalled
zlib, but you will still need to have access to the
zlib, but you will still need to have access to the
zlib.h and zconf.h include files that correspond to the
version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.0.2" or "lpng102" and "zlib-1.1.2"
or "zlib112") so that you have directories called "zlib" and "libpng".
might be called "libpng-1.0.2a" 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:

View File

@ -7,13 +7,80 @@ Known bugs and suggested enhancements in libpng-1.0.2
Loops need to be optimized everywhere
Make them count down instead of up -- Kevin Bracey
Optimizing compilers don't need this, and making
the change would be error prone -- Tom Lane, Glenn R-P
Question whether i-- or --i is better.
STATUS: Under investigation, postponed until after
libpng-1.0.2. About 160 loops turned around
in libpng-1.0.2a, for testing.
libpng-1.0.2. About 160 loops will be turned around
in libpng-1.0.Nn, for testing.
2. June 15, 1998 -- BUG -- Evan Light
Under some conditions, 16-bit grayscale images aren't properly
expanded to rgb, because png_read_start_row() returns too small a
value of max_pixel_depth when png_set_filler() has also been called.
STATUS: Fixed in libpng-1.0.2a
3. June 16, 1998 -- BUG -- Matt McConnell
When reading interlaced images with a progressive reader, in some
cases (interlaced images less than 3 pixels high) some passes are
not skipped that should be.
STATUS: Fixed in libpng-1.0.2a
4. July 3, 1998 -- ENHANCEMENT -- Glenn R-P
Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions.
STATUS: Done in libpng-1.0.2a, awaiting comment on resulting test
images.
5. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
libpng-1.0.2 and earlier transform colors to gamma=1.0 space for
merging with background, and then back to the image's gamma. The
bit_depth of the intermediate (gamma=1.0) representation is probably
not sufficient. In the typical gamma=1/2.2 situation, the linear
pixels need about 4 more bits than the gamma-encoded ones, to avoid
loss of precision. A similar situation exists with the rgb_to_gray
operation.
STATUS: under development.
6. August 20, 1998 -- BUG -- Kevin Bracey
When using the filler transformation, the filler isn't written
into the leftmost pixel of each row.
Also, the filler operation isn't being done right when writing
files. Some code that was removed from png_set_filler() in
libpng 1.0.1a shouldn't have been removed.
STATUS: Fixed in libpng-1.0.2a
7. August 23, 1998 -- BUG -- Duncan Simpson
"static pngcharp tIME_string" should be changed to
"static char tIME_string[30]" in pngtest.c
STATUS: Fixed in libpng-1.0.2a
8. August 24, 1998 -- BUG -- John Cromer
Order of byte-swap and shift operations seems to be incorrect in
png_do_write_transformations()
STATUS: Under investigation.
9. September 11, 1998 -- ENHANCEMENT -- L. Peter Deutsch
The PNG_NO_STDIO macro should be split into PNG_NO_STDIO
and PNG_NO_CONSOLE_STDIO.
STATUS: Done in libpng-1.0.2a

2
README
View File

@ -1,4 +1,4 @@
README for libpng 1.0.2 - June 14, 1998 (shared library 2.1)
README for libpng 1.0.2a - December 29, 1998 (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.

45
TODO
View File

@ -1,23 +1,24 @@
TODO - list of things to do for libpng
TODO - list of things to do for libpng:
fix problem with C++ and EXTERN "C"
add "grayscale->palette" transformation and "palette->grayscale" detection
color to gray transformation
improved dithering
multi-lingual error and warning message support
sPLT chunk handling
cHRM transformation
complete sRGB transformation (presently it simply uses gamma=0.45)
man pages for function calls
high-level API for reading images
final bug fixes
better documentation
better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?)
optional palette creation
histogram creation
support for application-defined chunk handlers
keep up with public chunks
better C++ wrapper/full C++ implementation?
text conversion between different code pages (Latin-1 -> Mac and DOS)
improve API by hiding the info_ptr
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.
High-level API for reading images.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Color to gray transformation.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
Optional palette (sPLT) creation.
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr.

View File

@ -220,11 +220,14 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_sRGB(png_ptr, intent, 0);
else
else
{
double image_gamma;
if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.50);
png_set_gamma(png_ptr, screen_gamma, 0.45455);
}
/* Dither RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
@ -324,13 +327,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows);
png_read_rows(png_ptr, NULL, row_pointers[y], number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows);
#endif no_sparkle /* use only one of these two methods */
}
/* if you want to display the image after every pass, do
so here */
#endif no_single /* use only one of these two methods */
@ -384,8 +387,11 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
return ERROR;
}
/* this one's new. You will need to provide all three
/* This one's new. You will need to provide all three
* function callbacks, even if you aren't using them all.
* If you aren't using all functions, you can specify NULL
* parameters. Even when all three functions are NULL,
* you need to call png_set_progressive_read_fn().
* These functions shouldn't be dependent on global or
* static variables if you are decoding several images
* simultaneously. You should store stream specific data
@ -565,7 +571,7 @@ void write_png(char *file_name /* , ... other image information ... */)
sig_bit.alpha = true_alpha_bit_depth;
png_set_sBIT(png_ptr, info_ptr, sig_bit);
/* Optional gamma chunk is strongly suggested if you have any guess
* as to the correct gamma of the image.
*/

197
libpng.3
View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "June 14, 1998"
.TH LIBPNG 3 "December 29, 1998"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.2 - June 14, 1998
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.2a - December 29, 1998
.SH SYNOPSIS
#include <png.h>
@ -27,7 +27,7 @@ png_structp png_create_read_struct (png_const_charp
user_png_ver, voidp error_ptr, png_error_ptr error_fn,
png_error_ptr warn_fn);
png_create_read_struct_2(png_const_charp user_png_ver,
png_structp png_create_read_struct_2(png_const_charp user_png_ver,
png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr
warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,
png_free_ptr free_fn)
@ -41,8 +41,11 @@ user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
png_voidp png_debug_malloc (png_structp png_ptr, png_uint_32
size);
int png_debug(int level, png_const_charp message)
int png_debug1(int level, png_const_charp message, p1)
int png_debug2(int level, png_const_charp message, p1, p2)
void png_destroy_info_struct (png_structp png_ptr, png_infopp
info_ptr_ptr);
@ -79,6 +82,8 @@ info_ptr);
png_byte png_get_compression_type (png_structp png_ptr,
png_infop info_ptr);
png_byte png_get_copyright (png_structp png_ptr);
png_voidp png_get_error_ptr (png_structp png_ptr);
png_byte png_get_filter_type (png_structp png_ptr, png_infop
@ -87,6 +92,8 @@ info_ptr);
png_uint_32 png_get_gAMA (png_structp png_ptr, png_infop
info_ptr, double *file_gamma);
png_byte png_get_header_version (png_structp png_ptr);
png_uint_32 png_get_hIST (png_structp png_ptr, png_infop
info_ptr, png_uint_16p *hist);
@ -131,6 +138,8 @@ png_voidp png_get_progressive_ptr (png_structp png_ptr);
png_uint_32 png_get_PLTE (png_structp png_ptr, png_infop
info_ptr, png_colorp *palette, int *num_palette);
png_byte png_get_rgb_to_gray_status (png_structp png_ptr)
png_uint_32 png_get_rowbytes (png_structp png_ptr, png_infop
info_ptr);
@ -325,7 +334,7 @@ read_row_fn);
void png_set_read_user_transform_fn (png_structp png_ptr,
png_user_transform_ptr read_user_transform_fn);
void png_set_rgb_to_gray (png_structp png_ptr);
void png_set_rgb_to_gray (png_structp png_ptr, int error_action);
void png_set_sBIT (png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit);
@ -414,7 +423,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.2 - June 14, 1998
libpng version 1.0.2a - December 29, 1998
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
@ -424,7 +433,7 @@ libpng.txt - A description on how to use and modify libpng
based on:
libpng 1.0 beta 6 version 0.96 May 28, 1997
Updated and distributed by Andreas Dilger
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
libpng 1.0 beta 2 - version 0.88 January 26, 1996
@ -454,7 +463,8 @@ as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
additional chunks are described in the special-purpose public chunks
documents at <ftp://ftp.uu.net/graphics/png/documents/>. Other information
about PNG can be found at the PNG home page, <http://www.cdrom.com/pub/png/>.
about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.cdrom.com/pub/png/>.
Most users will not have to modify the library significantly; advanced
users may want to modify it more. All attempts were made to make it as
@ -471,6 +481,8 @@ work to be done (see the TODO file), libpng should cover the
majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@ -593,8 +605,8 @@ are only necessary if you are not using the libpng supplied error
handling and memory alloc/free functions.
When libpng encounters an error, it expects to longjmp back
to your routine. Therefore, you will need to call setjmp and pass the
jmpbuf field of your png_struct. If you read the file from different
to your routine. Therefore, you will need to call setjmp and pass
your png_ptr->jmpbuf. If you read the file from different
routines, you will need to update the jmpbuf field every time you enter
a new routine that will call a png_ function.
@ -667,7 +679,7 @@ with
You must supply the function
void read_transform_fn(png_ptr ptr, row_info_ptr
row_info, png_bytep data)
row_info, png_bytep data)
See pngtest.c for a working example. Your function will be called
after all of the other transformations have been processed.
@ -696,7 +708,7 @@ Functions are used to get the information from the info_ptr:
are present.
PNG_COLOR_TYPE_GRAY
(bit depths 1, 2, 4, 8, 16)
PNG_COLOR_TYPE_GRAY_ALPHA
PNG_COLOR_TYPE_GRAY_ALPHA
(bit depths 8, 16)
PNG_COLOR_TYPE_PALETTE
(bit depths 1, 2, 4, 8)
@ -1002,6 +1014,63 @@ RGB. This code will do that conversion:
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
with alpha. This is intended for conversion of images that really are
gray (red == green == blue), so the function simply strips out the red
and blue channels, leaving the green channel in the gray position.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
float red_weight, float green_weight);
error_action = 1: silently do the conversion
error_action = 2: issue a warning if the original
image has any pixel where
red != green or red != blue
error_action = 3: issue an error and abort the
conversion if the original
image has any pixel where
red != green or red != blue
red_weight: weight of red component
(NULL -> default 54/256)
green_weight: weight of green component
(NULL -> default 183/256)
If you have set error_action = 1 or 2, you can
later check whether the image really was gray, after processing
the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
It will return a png_byte that is zero if the image was gray or
1 if there were any non-gray pixels. bKGD and sBIT data
will be silently converted to grayscale, using the green channel
data, regardless of the error_action setting.
With 0.0<=red_weight+green_weight<=1.0,
the normalized graylevel is computed:
int rw = red_weight * 256;
int gw = green_weight * 256;
int bw = 256 - (rw + gw);
gray = (rw*red + gw*green + bw*blue)/256;
The default values approximate those recommended in the Charles
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng approximates this with
Y = 0.211 * R + 0.715 * G + 0.074 * B
which can be expressed with integers as
Y = (54 * R + 183 * G + 19 * B)/256
The calculation is done in a linear colorspace, if the image gamma
is known.
If you have a grayscale and you are using png_set_expand() to change to
a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the
@ -1061,7 +1130,7 @@ compensation other than the display_gamma is needed (viewing_gamma=1.0).
The png_set_gamma() function handles gamma transformations of the data.
Pass both the file gamma and the current screen_gamma. If the file does
not have a gamma value, you can pass one anyway if you have an idea what
it is (usually 0.50 is a good guess for GIF images on PCs). Note
it is (usually 0.45455 is a good guess for GIF images on PCs). Note
that file gammas are inverted from screen gammas. See the discussions
on gamma in the PNG specification for an excellent description of what
gamma is, and why all applications should support it. It is strongly
@ -1070,7 +1139,7 @@ recommended that PNG viewers support gamma correction.
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
png_set_gamma(png_ptr, screen_gamma, gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.50);
png_set_gamma(png_ptr, screen_gamma, 0.45455);
If you need to reduce an RGB file to a paletted file, or if a paletted
file has more entries then will fit on your screen, png_set_dither()
@ -1321,7 +1390,9 @@ png_infop info_ptr;
to be called when the header info is valid,
when each row is completed, and when the image
is finished. If you aren't using all functions,
you can specify a NULL parameter. You can use
you can specify NULL parameters. Even when all
three functions are NULL, you need to call
png_set_progressive_read_fn(). You can use
any struct as the user_ptr (cast to a void pointer
for the function call), and retrieve the pointer
from inside the callbacks using the function
@ -1353,21 +1424,21 @@ png_infop info_ptr;
of data from the file stream (in order, of
course). On machines with segmented memory
models machines, don't give it any more than
64K. The library seems to run fine with sizes
64K. The library seems to run fine with sizes
of 4K. Although you can give it much less if
necessary (I assume you can give it chunks of
1 byte, I haven't tried less then 256 bytes
yet). When this function returns, you may
want to display any rows that were generated
in the row callback if you don't already do
so there.
so there.
*/
png_process_data(png_ptr, info_ptr, buffer, length);
return 0;
}
/* This function is called (as set by
png_set_progressive_fn() above) when enough data
png_set_progressive_read_fn() above) when enough data
has been supplied so all of the header has been
read.
*/
@ -1424,7 +1495,7 @@ png_infop info_ptr;
for interlaced images), you will have to pass
the current row, and the function will combine
the old row and the new row.
*/
*/
}
void
@ -1454,7 +1525,7 @@ You will want to do the I/O initialization before you get into libpng,
so if it doesn't work, you don't have anything to undo. If you are not
using the standard I/O functions, you will need to replace them with
custom writing functions. See the discussion under Customizing libpng.
FILE *fp = fopen(file_name, "wb");
if (!fp)
{
@ -1495,20 +1566,22 @@ png_create_write_struct_2() instead of png_create_read_struct():
After you have these structures, you will need to set up the
error handling. When libpng encounters an error, it expects to
longjmp() back to your routine. Therefore, you will need to call
setjmp and pass the jmpbuf field of your png_struct. If you
setjmp() and pass the png_ptr->jmpbuf. If you
write the file from different routines, you will need to update
the jmpbuf field every time you enter a new routine that will
call a png_ function. See your documentation of setjmp/longjmp
for your compiler for more information on setjmp/longjmp. See
the discussion on libpng error handling in the Customizing Libpng
section below for more information on the libpng error handling.
if (setjmp(png_ptr->jmpbuf))
{
{
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
return;
}
...
return;
Now you need to set up the output code. The default for libpng is to
use the C function fwrite(). If you use this, you will need to pass a
@ -1549,7 +1622,7 @@ flag that indicates which filter type(s) are to be tested for each
scanline. See the Compression Library for details on the specific filter
types.
/* turn on or off filtering, and/or choose
specific filters */
png_set_filter(png_ptr, 0,
@ -1648,7 +1721,7 @@ Some of the more important parts of the png_info are:
PNG_SRGB_INTENT_PERCEPTUAL,
PNG_SRGB_INTENT_ABSOLUTE, or
PNG_SRGB_INTENT_RELATIVE.
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
srgb_intent);
@ -1739,7 +1812,7 @@ png_text structure holds a keyword-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
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.
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
@ -1799,7 +1872,7 @@ depending on whether you mean the PNG file, the time the image was
created in a non-PNG format, a still photo from which the image was
scanned, or possibly the subject matter itself. In order to facilitate
machine-readable dates, it is recommended that the "Creation Time"
tEXt chunk use RFC 1123 format dates (e.g. 22 May 1997 18:07:10 GMT"),
tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function
@ -1841,7 +1914,7 @@ correctly pack the pixels into a single byte:
PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
data is of another bit depth, you can write an sBIT chunk into the
file so that decoders can get the original data if desired.
/* Set the true bit depth of the image data */
if (color_type & PNG_COLOR_MASK_COLOR)
{
@ -1902,7 +1975,7 @@ with
You must supply the function
void write_transform_fn(png_ptr ptr, row_info_ptr
row_info, png_bytep data)
row_info, png_bytep data)
See pngtest.c for a working example. Your function will be called
before any of the other transformations have been processed.
@ -2017,7 +2090,7 @@ The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works.
All of the memory allocation, input/output, and error handling in libpng
goes through callbacks which are user settable. The default routines are
goes through callbacks that are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
these functions, call the appropriate png_set_???_fn() function.
@ -2059,7 +2132,7 @@ The replacement I/O functions should have prototypes as follows:
Supplying NULL for the read, write, or flush functions sets them back
to using the default C stream functions. It is an error to read from
a write stream, and vice versa.
a write stream, and vice versa.
Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error()
@ -2126,7 +2199,7 @@ won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Configuring for DOS:
For DOS users which only have access to the lower 640K, you will
For DOS users who only have access to the lower 640K, you will
have to limit zlib's memory usage via a png_set_compression_mem_level()
call. See zlib.h or zconf.h in the zlib library for more information.
@ -2138,7 +2211,7 @@ defined, and FAR gets defined to far in pngconf.h, and you should be
all set. Everything in the library (except for zlib's structure) is
expecting far data. You must use the typedefs with the p or pp on
the end for pointers (or at least look at them and be careful). Make
note that the row's of data are defined as png_bytepp which is a
note that the row's of data are defined as png_bytepp, which is an
unsigned char far * far *.
Configuring for gui/windowing platforms:
@ -2198,8 +2271,8 @@ can call one of these functions. The selection and configuration
of row filters can have a significant impact on the size and
encoding speed and a somewhat lesser impact on the decoding speed
of an image. Filtering is enabled by default for RGB and grayscale
images (with and without alpha), and for 8-bit paletted images, but
not for paletted images with bit depths less than 8 bits/pixel.
images (with and without alpha), but not for paletted images nor
for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.0 specification. The 'filters'
@ -2234,10 +2307,10 @@ by telling it the relative computational costs of the filters.
PNG_FILTER_SELECTION_WEIGHTED, 3,
weights, costs);
The weights are multiplying factors which indicate to libpng that row
should be the same for successive rows unless another row filter is that
many times better than the previous filter. In the above example, if
the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
The weights are multiplying factors that indicate to libpng that the
row filter should be the same for successive rows unless another row filter
is that many times better than the previous filter. In the above example,
if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
"sum of absolute differences" 1.5 x 1.3 times higher than other filters
and still be chosen, while the NONE filter could have a sum 1.1 times
higher than other filters and still be chosen. Unspecified weights are
@ -2292,10 +2365,46 @@ or DLL file), you should not remove or disable any parts of the library,
as this will cause applications linked with different versions of the
library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections which are actually used will be loaded into memory.
those sections that are actually used will be loaded into memory.
Requesting debug printout:
Changes to Libpng from version 0.88
The macro definition PNG_DEBUG can be used to request debugging
printout. Set it to an integer value in the range 0 to 3. Higher
numbers result in increasing amounts of debugging information. The
information is printed to the "stderr" file, unless another file
name is specified in the PNG_DEBUG_FILE macro definition.
When PNG_DEBUG > 0, the following functions (macros) become available:
png_debug(level, message)
png_debug1(level, message, p1)
png_debug2(level, message, p1, p2)
in which "level" is compared to PNG_DEBUG to decide whether to print
the message, "message" is the formatted string to be printed,
and p1 and p2 are parameters that are to be embedded in the string
according to printf-style formatting directives. For example,
png_debug1(2, "foo=%d\n", foo);
is expanded to
if(PNG_DEBUG > 2)
fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
can still use PNG_DEBUG to control your own debugging:
#ifdef PNG_DEBUG
fprintf(stderr, ...
#endif
When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
.SH VI. Changes to Libpng from version 0.88
It should be noted that versions of libpng later than 0.96 are not
distributed by the original libpng author, Guy Schalnat, nor by
@ -2321,7 +2430,7 @@ allocating and freeing the png_struct for each image read.
Setting the error callbacks via png_set_message_fn() before
png_read_init() as was suggested in libpng-0.88 is no longer supported
because this caused applications which do not use custom error functions
because this caused applications that do not use custom error functions
to fail if the png_ptr was not initialized to zero. It is still possible
to set the error callbacks AFTER png_read_init(), or to change them with
png_set_error_fn(), which is essentially the same function, but with a
@ -2413,7 +2522,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.0.2 - June 14, 1998:
Libpng version 1.0.2a - December 29, 1998:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).

View File

@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.0.2 - June 14, 1998
libpng version 1.0.2a - December 29, 1998
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
@ -10,7 +10,7 @@ libpng.txt - A description on how to use and modify libpng
based on:
libpng 1.0 beta 6 version 0.96 May 28, 1997
Updated and distributed by Andreas Dilger
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
libpng 1.0 beta 2 - version 0.88 January 26, 1996
@ -40,7 +40,8 @@ as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
additional chunks are described in the special-purpose public chunks
documents at <ftp://ftp.uu.net/graphics/png/documents/>. Other information
about PNG can be found at the PNG home page, <http://www.cdrom.com/pub/png/>.
about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.cdrom.com/pub/png/>.
Most users will not have to modify the library significantly; advanced
users may want to modify it more. All attempts were made to make it as
@ -57,6 +58,8 @@ work to be done (see the TODO file), libpng should cover the
majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details.
@ -179,8 +182,8 @@ are only necessary if you are not using the libpng supplied error
handling and memory alloc/free functions.
When libpng encounters an error, it expects to longjmp back
to your routine. Therefore, you will need to call setjmp and pass the
jmpbuf field of your png_struct. If you read the file from different
to your routine. Therefore, you will need to call setjmp and pass
your png_ptr->jmpbuf. If you read the file from different
routines, you will need to update the jmpbuf field every time you enter
a new routine that will call a png_ function.
@ -253,7 +256,7 @@ with
You must supply the function
void read_transform_fn(png_ptr ptr, row_info_ptr
row_info, png_bytep data)
row_info, png_bytep data)
See pngtest.c for a working example. Your function will be called
after all of the other transformations have been processed.
@ -282,7 +285,7 @@ Functions are used to get the information from the info_ptr:
are present.
PNG_COLOR_TYPE_GRAY
(bit depths 1, 2, 4, 8, 16)
PNG_COLOR_TYPE_GRAY_ALPHA
PNG_COLOR_TYPE_GRAY_ALPHA
(bit depths 8, 16)
PNG_COLOR_TYPE_PALETTE
(bit depths 1, 2, 4, 8)
@ -588,6 +591,63 @@ RGB. This code will do that conversion:
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
with alpha. This is intended for conversion of images that really are
gray (red == green == blue), so the function simply strips out the red
and blue channels, leaving the green channel in the gray position.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
float red_weight, float green_weight);
error_action = 1: silently do the conversion
error_action = 2: issue a warning if the original
image has any pixel where
red != green or red != blue
error_action = 3: issue an error and abort the
conversion if the original
image has any pixel where
red != green or red != blue
red_weight: weight of red component
(NULL -> default 54/256)
green_weight: weight of green component
(NULL -> default 183/256)
If you have set error_action = 1 or 2, you can
later check whether the image really was gray, after processing
the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
It will return a png_byte that is zero if the image was gray or
1 if there were any non-gray pixels. bKGD and sBIT data
will be silently converted to grayscale, using the green channel
data, regardless of the error_action setting.
With 0.0<=red_weight+green_weight<=1.0,
the normalized graylevel is computed:
int rw = red_weight * 256;
int gw = green_weight * 256;
int bw = 256 - (rw + gw);
gray = (rw*red + gw*green + bw*blue)/256;
The default values approximate those recommended in the Charles
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng approximates this with
Y = 0.211 * R + 0.715 * G + 0.074 * B
which can be expressed with integers as
Y = (54 * R + 183 * G + 19 * B)/256
The calculation is done in a linear colorspace, if the image gamma
is known.
If you have a grayscale and you are using png_set_expand() to change to
a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the
@ -647,7 +707,7 @@ compensation other than the display_gamma is needed (viewing_gamma=1.0).
The png_set_gamma() function handles gamma transformations of the data.
Pass both the file gamma and the current screen_gamma. If the file does
not have a gamma value, you can pass one anyway if you have an idea what
it is (usually 0.50 is a good guess for GIF images on PCs). Note
it is (usually 0.45455 is a good guess for GIF images on PCs). Note
that file gammas are inverted from screen gammas. See the discussions
on gamma in the PNG specification for an excellent description of what
gamma is, and why all applications should support it. It is strongly
@ -656,7 +716,7 @@ recommended that PNG viewers support gamma correction.
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
png_set_gamma(png_ptr, screen_gamma, gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.50);
png_set_gamma(png_ptr, screen_gamma, 0.45455);
If you need to reduce an RGB file to a paletted file, or if a paletted
file has more entries then will fit on your screen, png_set_dither()
@ -907,7 +967,9 @@ png_infop info_ptr;
to be called when the header info is valid,
when each row is completed, and when the image
is finished. If you aren't using all functions,
you can specify a NULL parameter. You can use
you can specify NULL parameters. Even when all
three functions are NULL, you need to call
png_set_progressive_read_fn(). You can use
any struct as the user_ptr (cast to a void pointer
for the function call), and retrieve the pointer
from inside the callbacks using the function
@ -939,21 +1001,21 @@ png_infop info_ptr;
of data from the file stream (in order, of
course). On machines with segmented memory
models machines, don't give it any more than
64K. The library seems to run fine with sizes
64K. The library seems to run fine with sizes
of 4K. Although you can give it much less if
necessary (I assume you can give it chunks of
1 byte, I haven't tried less then 256 bytes
yet). When this function returns, you may
want to display any rows that were generated
in the row callback if you don't already do
so there.
so there.
*/
png_process_data(png_ptr, info_ptr, buffer, length);
return 0;
}
/* This function is called (as set by
png_set_progressive_fn() above) when enough data
png_set_progressive_read_fn() above) when enough data
has been supplied so all of the header has been
read.
*/
@ -1010,7 +1072,7 @@ png_infop info_ptr;
for interlaced images), you will have to pass
the current row, and the function will combine
the old row and the new row.
*/
*/
}
void
@ -1040,7 +1102,7 @@ You will want to do the I/O initialization before you get into libpng,
so if it doesn't work, you don't have anything to undo. If you are not
using the standard I/O functions, you will need to replace them with
custom writing functions. See the discussion under Customizing libpng.
FILE *fp = fopen(file_name, "wb");
if (!fp)
{
@ -1081,20 +1143,22 @@ png_create_write_struct_2() instead of png_create_read_struct():
After you have these structures, you will need to set up the
error handling. When libpng encounters an error, it expects to
longjmp() back to your routine. Therefore, you will need to call
setjmp and pass the jmpbuf field of your png_struct. If you
setjmp() and pass the png_ptr->jmpbuf. If you
write the file from different routines, you will need to update
the jmpbuf field every time you enter a new routine that will
call a png_ function. See your documentation of setjmp/longjmp
for your compiler for more information on setjmp/longjmp. See
the discussion on libpng error handling in the Customizing Libpng
section below for more information on the libpng error handling.
if (setjmp(png_ptr->jmpbuf))
{
{
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
return;
}
...
return;
Now you need to set up the output code. The default for libpng is to
use the C function fwrite(). If you use this, you will need to pass a
@ -1135,7 +1199,7 @@ flag that indicates which filter type(s) are to be tested for each
scanline. See the Compression Library for details on the specific filter
types.
/* turn on or off filtering, and/or choose
specific filters */
png_set_filter(png_ptr, 0,
@ -1234,7 +1298,7 @@ Some of the more important parts of the png_info are:
PNG_SRGB_INTENT_PERCEPTUAL,
PNG_SRGB_INTENT_ABSOLUTE, or
PNG_SRGB_INTENT_RELATIVE.
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
srgb_intent);
@ -1325,7 +1389,7 @@ png_text structure holds a keyword-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
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.
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
@ -1385,7 +1449,7 @@ depending on whether you mean the PNG file, the time the image was
created in a non-PNG format, a still photo from which the image was
scanned, or possibly the subject matter itself. In order to facilitate
machine-readable dates, it is recommended that the "Creation Time"
tEXt chunk use RFC 1123 format dates (e.g. 22 May 1997 18:07:10 GMT"),
tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function
@ -1427,7 +1491,7 @@ correctly pack the pixels into a single byte:
PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
data is of another bit depth, you can write an sBIT chunk into the
file so that decoders can get the original data if desired.
/* Set the true bit depth of the image data */
if (color_type & PNG_COLOR_MASK_COLOR)
{
@ -1488,7 +1552,7 @@ with
You must supply the function
void write_transform_fn(png_ptr ptr, row_info_ptr
row_info, png_bytep data)
row_info, png_bytep data)
See pngtest.c for a working example. Your function will be called
before any of the other transformations have been processed.
@ -1603,7 +1667,7 @@ The second deals with more complicated things like adding new chunks,
adding new transformations, and generally changing how libpng works.
All of the memory allocation, input/output, and error handling in libpng
goes through callbacks which are user settable. The default routines are
goes through callbacks that are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
these functions, call the appropriate png_set_???_fn() function.
@ -1645,7 +1709,7 @@ The replacement I/O functions should have prototypes as follows:
Supplying NULL for the read, write, or flush functions sets them back
to using the default C stream functions. It is an error to read from
a write stream, and vice versa.
a write stream, and vice versa.
Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error()
@ -1712,7 +1776,7 @@ won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Configuring for DOS:
For DOS users which only have access to the lower 640K, you will
For DOS users who only have access to the lower 640K, you will
have to limit zlib's memory usage via a png_set_compression_mem_level()
call. See zlib.h or zconf.h in the zlib library for more information.
@ -1724,7 +1788,7 @@ defined, and FAR gets defined to far in pngconf.h, and you should be
all set. Everything in the library (except for zlib's structure) is
expecting far data. You must use the typedefs with the p or pp on
the end for pointers (or at least look at them and be careful). Make
note that the row's of data are defined as png_bytepp which is a
note that the row's of data are defined as png_bytepp, which is an
unsigned char far * far *.
Configuring for gui/windowing platforms:
@ -1784,8 +1848,8 @@ can call one of these functions. The selection and configuration
of row filters can have a significant impact on the size and
encoding speed and a somewhat lesser impact on the decoding speed
of an image. Filtering is enabled by default for RGB and grayscale
images (with and without alpha), and for 8-bit paletted images, but
not for paletted images with bit depths less than 8 bits/pixel.
images (with and without alpha), but not for paletted images nor
for any images with bit depths less than 8 bits/pixel.
The 'method' parameter sets the main filtering method, which is
currently only '0' in the PNG 1.0 specification. The 'filters'
@ -1820,10 +1884,10 @@ by telling it the relative computational costs of the filters.
PNG_FILTER_SELECTION_WEIGHTED, 3,
weights, costs);
The weights are multiplying factors which indicate to libpng that row
should be the same for successive rows unless another row filter is that
many times better than the previous filter. In the above example, if
the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
The weights are multiplying factors that indicate to libpng that the
row filter should be the same for successive rows unless another row filter
is that many times better than the previous filter. In the above example,
if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
"sum of absolute differences" 1.5 x 1.3 times higher than other filters
and still be chosen, while the NONE filter could have a sum 1.1 times
higher than other filters and still be chosen. Unspecified weights are
@ -1878,10 +1942,46 @@ or DLL file), you should not remove or disable any parts of the library,
as this will cause applications linked with different versions of the
library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections which are actually used will be loaded into memory.
those sections that are actually used will be loaded into memory.
Requesting debug printout:
Changes to Libpng from version 0.88
The macro definition PNG_DEBUG can be used to request debugging
printout. Set it to an integer value in the range 0 to 3. Higher
numbers result in increasing amounts of debugging information. The
information is printed to the "stderr" file, unless another file
name is specified in the PNG_DEBUG_FILE macro definition.
When PNG_DEBUG > 0, the following functions (macros) become available:
png_debug(level, message)
png_debug1(level, message, p1)
png_debug2(level, message, p1, p2)
in which "level" is compared to PNG_DEBUG to decide whether to print
the message, "message" is the formatted string to be printed,
and p1 and p2 are parameters that are to be embedded in the string
according to printf-style formatting directives. For example,
png_debug1(2, "foo=%d\n", foo);
is expanded to
if(PNG_DEBUG > 2)
fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
can still use PNG_DEBUG to control your own debugging:
#ifdef PNG_DEBUG
fprintf(stderr, ...
#endif
When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
VI. Changes to Libpng from version 0.88
It should be noted that versions of libpng later than 0.96 are not
distributed by the original libpng author, Guy Schalnat, nor by
@ -1907,7 +2007,7 @@ allocating and freeing the png_struct for each image read.
Setting the error callbacks via png_set_message_fn() before
png_read_init() as was suggested in libpng-0.88 is no longer supported
because this caused applications which do not use custom error functions
because this caused applications that do not use custom error functions
to fail if the png_ptr was not initialized to zero. It is still possible
to set the error callbacks AFTER png_read_init(), or to change them with
png_set_error_fn(), which is essentially the same function, but with a

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "June 14, 1998"
.TH LIBPNGPF 3 "December 29, 1998"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.2 - June 14, 1998
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.2a - December 29, 1998
(private functions)
.SH SYNOPSIS
#include <png.h>
@ -88,7 +88,7 @@ row);
void png_do_read_transformations (png_structp png_ptr);
void png_do_rgb_to_gray (png_row_infop row_info, png_bytep
int png_do_rgb_to_gray (png_row_infop row_info, png_bytep
row);
void png_do_shift (png_row_infop row_info, png_bytep row,

6
png.5
View File

@ -1,4 +1,4 @@
.TH PNG 5 "June 14, 1998"
.TH PNG 5 "December 29, 1998"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
@ -7,7 +7,7 @@ lossless, portable, well-compressed storage of raster images. PNG provides
a patent-free replacement for GIF and can also replace many
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
supported, plus an optional alpha channel. Sample depths range from
1 to 16 bits.
1 to 16 bits.
.br
PNG is designed to work well in online viewing applications, such as the
@ -15,7 +15,7 @@ World Wide Web, so it is fully streamable with a progressive display
option. PNG is robust, providing both full file integrity checking and
fast, simple detection of common transmission errors. Also, PNG can store
gamma and chromaticity data for improved color matching on heterogeneous
platforms.
platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)

21
png.c
View File

@ -1,11 +1,11 @@
/* png.c - location for general purpose libpng functions
*
* libpng 1.0.2 - June 14, 1998
* For conditions of distribution and use, see copyright notice in png.h
* libpng version 1.0.2a - December 29, 1998
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
*
*/
#define PNG_INTERNAL
@ -15,7 +15,8 @@
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
char png_libpng_ver[12] = "1.0.2";
char png_libpng_ver[12] = "1.0.2a";
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@ -317,8 +318,8 @@ png_charp
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
{
static PNG_CONST char short_months[12][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
if (png_ptr->time_buffer == NULL)
{
@ -345,3 +346,13 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
return ((png_charp)png_ptr->time_buffer);
}
#endif /* PNG_TIME_RFC1123_SUPPORTED */
png_charp
png_get_copyright(png_structp png_ptr)
{
return("\n libpng version 1.0.2a - December 29, 1998\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, Glenn Randers-Pehrson\n");
}

117
png.h
View File

@ -1,11 +1,10 @@
/* png.h - header file for PNG reference library
*
* libpng 1.0.2 - June 14, 1998
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
* libpng version 1.0.2a - December 29, 1998
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998 Glenn Randers-Pehrson
* Copyright (c) 1998, Glenn Randers-Pehrson
*
* Note about libpng version numbers:
*
@ -31,6 +30,9 @@
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
* 1.0.1 1.0.1 10001 2.1.0
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e
* 1.0.2 1.0.2 10002 2.1.0.2
* 1.0.2a 1.0.2a 10003 2.1.0.2a
* 1.0.3 1.0.3 10003 2.1.0.3
*
* Henceforth the source version will match the shared-library minor
* and patch numbers; the shared-library major version number will be
@ -117,14 +119,14 @@ extern "C" {
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.2"
#define PNG_LIBPNG_VER_STRING "1.0.2a"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
#define PNG_LIBPNG_VER 10002 /* 1.0.2 */
#define PNG_LIBPNG_VER 10003 /* 1.0.3 */
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */