Imported from libpng-0.99e.tar

This commit is contained in:
Glenn Randers-Pehrson 1998-02-28 07:00:24 -06:00
parent a357b99113
commit cbe52d8720
28 changed files with 843 additions and 694 deletions

17
CHANGES
View File

@ -224,12 +224,23 @@ version 0.99c [February 7, 1998]
More type casting. Removed erroneous overflow test in pngmem.c.
Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5.
version 0.99d [February 8, 1998]
version 0.99d [February 11, 1998]
Renamed "far_to_near()" "png_far_to_near()"
Revised libpng.3
Version 99c "buffered" operations didn't work as intended. Replaced them
with png_memcpy_check() and png_memset_check().
version 0.99e [February 9, 1998]
Fixed a bug with background compositing of paletted images in pngrtran.c
Added many "if (png_ptr == NULL) return" to quell compiler warnings about
unused png_ptr, mostly in pngget.c and pngset.c.
Check for overlength tRNS chunk present when indexed-color PLTE is read.
Cleaned up spelling errors in libpng.3/libpng.txt
Corrected a problem with png_get_tRNS() which returned undefined trans array
version 0.99e [February 28, 1998]
Corrected png_get_tRNS() again.
Add parentheses for easier reading of pngget.c, fixed "||" should be "&&".
Touched up example.c to make more of it compileable, although the entire
file still can't be compiled (Willem van Schaik)
Fixed a bug in png_do_shift() (Bryan Tsai)
Added a space in png.h prototype for png_write_chunk_start()
Replaced pngtest.png with one created with zlib 1.1.1
Changed pngtest to report PASS even when file size is different (Jean-loup G.)
Corrected some logic errors in png_do_invert_alpha() (Chris Patterson)

12
README
View File

@ -1,4 +1,4 @@
[NOTE: this is still beta version 0.99d; the text below has already
[NOTE: this is still beta version 0.99e; the text below has already
been updated in anticipation of the imminent 1.0 release.]
@ -127,19 +127,22 @@ Files in this distribution:
CHANGES => Description of changes between libpng versions
README => This file
TODO => Things not implemented in the current library
ansi2knr.1 => Manual page for ansi2knr
ansi2knr.c => Converts files to K&R style function declarations
build.bat => MS-DOS batch file for Borland compiler
descrip.mms => VMS project file
example.c => Example code for using libpng functions
libpng.3 => manual page for libpng
libpng.txt => Description of libpng and its functions
libpngpf.3 => manual page for libpng's private functions
makefile.aco => ACORN makefile
makefile.ama => Amiga makefile
makefile.atr => Atari makefile
makefile.bor => Borland makefile
makefile.dec => DEC makefile
makefile.dj2 => DJGPP 2 makefile
makefile.elf => Unix ELF makefile
makefile.knr => Makefile which calls ansi2knr to convert files
makefile.lnx => Unix Linux/ELF makefile
makefile.mip => MIPS makefile
makefile.msc => Microsoft C makefile
makefile.sgi => Silicon Graphics Irix makefile
@ -147,10 +150,12 @@ Files in this distribution:
makefile.sun => SUN makefile
makefile.tc3 => Turbo C 3.0 makefile
makevms.com => VMS make program
png.5 => manual page for the PNG format
png.c => Basic interface functions common to library
png.h => Library function and interface declarations
pngconf.h => System specific library configuration
pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
pngpread.c => Progressive reading functions
pngread.c => Read data/helper high-level functions
@ -178,5 +183,4 @@ Good luck, and happy coding.
-Guy Eric Schalnat
(formerly of Group 42, Inc)
Web: http://www.group42.com/
Internet: gschal@infinet.com

36
ansi2knr.1 Normal file
View File

@ -0,0 +1,36 @@
.TH ANSI2KNR 1 "19 Jan 1996"
.SH NAME
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
.SH SYNOPSIS
.I ansi2knr
[--varargs] input_file [output_file]
.SH DESCRIPTION
If no output_file is supplied, output goes to stdout.
.br
There are no error messages.
.sp
.I ansi2knr
recognizes function definitions by seeing a non-keyword identifier at the left
margin, followed by a left parenthesis, with a right parenthesis as the last
character on the line, and with a left brace as the first token on the
following line (ignoring possible intervening comments). It will recognize a
multi-line header provided that no intervening line ends with a left or right
brace or a semicolon. These algorithms ignore whitespace and comments, except
that the function name must be the first thing on the line.
.sp
The following constructs will confuse it:
.br
- Any other construct that starts at the left margin and follows the
above syntax (such as a macro or function call).
.br
- Some macros that tinker with the syntax of the function header.
.sp
The --varargs switch is obsolete, and is recognized only for
backwards compatibility. The present version of
.I ansi2knr
will always attempt to convert a ... argument to va_alist and va_dcl.
.SH AUTHOR
L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
continues to maintain the current version; most of the code in the current
version is his work. ansi2knr also includes contributions by Francois
Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.

View File

@ -12,7 +12,7 @@
* working PNG reader/writer, see pngtest.c, included in this distribution.
*/
#include <png.h>
#include "png.h"
/* Check to see if a file is a PNG file using png_check_sig(). Returns
* non-zero if the image is a PNG, and 0 if it isn't a PNG.
@ -54,7 +54,7 @@ int check_if_png(char *file_name, FILE **fp)
* file, and the other where we are given an open file (possibly with
* some or all of the magic bytes read - see comments above).
*/
**** prototype 1 ****
#ifdef open_file /* prototype 1 */
void read_png(char *file_name) /* We need to open the file */
{
png_structp png_ptr;
@ -66,14 +66,14 @@ void read_png(char *file_name) /* We need to open the file */
if ((fp = fopen(file_name, "rb")) == NULL)
return;
**** prototype 2 ****
#else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
**** only use one prototype! ****
#endif no_open_file /* only use one prototype! */
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
@ -113,17 +113,17 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
}
/* One of the following I/O initialization methods is REQUIRED */
**** PNG file I/O method 1 ****
#ifdef streams /* PNG file I/O method 1 */
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
**** PNG file I/O method 2 ****
#else no_streams /* PNG file I/O method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call:
*/
png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);
/* where user_io_ptr is a structure you want available to the callbacks */
**** Use only one I/O method! ****
#endif no_streams /* Use only one I/O method! */
/* If we have already read some of the signature */
png_set_sig_bytes_read(png_ptr, sig_read);
@ -180,10 +180,10 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
* use it - you should use the (solid) application background if it has one.
*/
png_color_16 my_background, *image_background);
png_color_16 my_background, *image_background;
if (png_get_bKGD(png_ptr, info_ptr, &image_background);
png_set_background(png_ptr, image_background),
if (png_get_bKGD(png_ptr, info_ptr, &image_background))
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
png_set_background(png_ptr, &my_background,
@ -191,7 +191,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* Some suggestions as to how to get a screen gamma value */
/* Note that screen gamma is (display_gamma/viewing_gamma)
/* Note that screen gamma is (display_gamma/viewing_gamma) */
if (/* We have a user-defined screen gamma value */)
{
screen_gamma = user-defined screen_gamma;
@ -217,10 +217,10 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
int intent;
if (png_get_sRGB(png_ptr, info_ptr, &intent)
if (png_get_sRGB(png_ptr, info_ptr, &intent))
png_set_sRGB(png_ptr, intent, 0);
else
if (png_get_gAMA(png_ptr, info_ptr, &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);
@ -234,7 +234,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_colorp palette;
/* This reduces the image to the application supplied palette */
if (we have our own palette)
if (/* we have our own palette */)
{
/* An array of colors to which the image should be dithered */
png_color std_color_cube[MAX_SCREEN_COLORS];
@ -243,7 +243,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
MAX_SCREEN_COLORS, NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)))
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
{
png_color16p histogram;
@ -304,37 +304,37 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
}
/* Now it's time to read the image. One of these methods is REQUIRED */
**** Read the entire image in one go ****
#ifdef entire /* Read the entire image in one go */
png_read_image(png_ptr, row_pointers);
**** Read the image one or more scanlines at a time ****
#else no_entire /* Read the image one or more scanlines at a time */
/* The other way to read images - deal with interlacing: */
for (pass = 0; pass < number_passes; pass++)
{
[[[[[[[ Read the image a single row at a time ]]]]]]]
#ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++)
{
png_bytep row_pointers = row[y];
png_read_rows(png_ptr, &row_pointers, NULL, 1);
}
[[[[[[[ Read the image several rows at a time ]]]]]]]
#else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows)
{
<<<<<<<<<< Read the image using the "sparkle" effect. >>>>>>>>>>
#ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, row_pointers, NULL, number_of_rows);
<<<<<<<<<< Read the image using the "rectangle" effect >>>>>>>>>>
#else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, row_pointers, number_of_rows);
<<<<<<<<<< use only one of these two methods >>>>>>>>>>
#endif no_sparkle /* use only one of these two methods */
}
/* if you want to display the image after every pass, do
so here */
[[[[[[[ use only one of these two methods ]]]]]]]
#endif no_single /* use only one of these two methods */
}
**** use only one of these two methods ****
#endif no_entire /* use only one of these two methods */
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr);
@ -479,7 +479,7 @@ end_callback(png_structp png_ptr, png_infop info)
}
/* write a png file */
void write_png(char *file_name, ... other image information ...)
void write_png(char *file_name /* , ... other image information ... */)
{
FILE *fp;
png_structp png_ptr;
@ -526,16 +526,16 @@ void write_png(char *file_name, ... other image information ...)
}
/* One of the following I/O initialization functions is REQUIRED */
**** I/O initialization method 1 ****
#ifdef streams /* I/O initialization method 1 */
/* set up the output control if you are using standard C streams */
png_init_io(png_ptr, fp);
**** I/O initialization method 2 ****
#else no_streams /* I/O initialization method 2 */
/* If you are using replacement read functions, instead of calling
* png_init_io() here you would call */
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
user_IO_flush_function);
/* where user_io_ptr is a structure you want available to the callbacks */
**** only use 1 initialization method ****
#endif no_streams /* only use one initialization method */
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
@ -550,7 +550,7 @@ void write_png(char *file_name, ... other image information ...)
/* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, 256 * sizeof (png_color));
... set palette colors ...
/* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, 256);
/* optional significant bit chunk */
@ -640,12 +640,12 @@ void write_png(char *file_name, ... other image information ...)
png_byte row_pointers[height][width];
/* One of the following output methods is REQUIRED */
**** write out the entire image data in one call ***
#ifdef entire /* write out the entire image data in one call */
png_write_image(png_ptr, row_pointers);
/* the other way to write the image - deal with interlacing */
**** write out the image data by one or more scanlines ****
#else no_entire /* write out the image data by one or more scanlines */
/* The number of passes is either 1 for non-interlaced images,
* or 7 for interlaced images.
*/
@ -661,7 +661,7 @@ void write_png(char *file_name, ... other image information ...)
png_write_rows(png_ptr, &row_pointers, 1);
}
}
**** use only one output method ****
#endif no_entire /* use only one output method */
/* You can write optional chunks like tEXt, zTXt, and tIME at the end
* as well.

442
libpng.3
View File

@ -1,25 +1,10 @@
.TH PNG 5 "February 8, 1998"
.TH LIBPNG 3 "February 28, 1998"
.SH NAME
libpng \- Portable Network Graphics (PNG) format
libpng \- Portable Network Graphics (PNG) Reference Library
.SH SYNOPSIS
#include <png.h>
void png_build_gamma_table (png_structp png_ptr);
void png_build_grayscale_palette (int bit_depth, png_colorp
palette);
void png_calculate_crc (png_structp png_ptr, png_bytep ptr,
png_size_t length);
void png_check_chunk_name (png_structp png_ptr, png_bytep
chunk_name);
png_size_t png_check_keyword (png_structp png_ptr, png_charp
key, png_charpp new_key);
int png_check_sig (png_bytep sig, int num);
void png_chunk_error (png_structp png_ptr, png_const_charp
@ -28,9 +13,6 @@ error);
void png_chunk_warning (png_structp png_ptr, png_const_charp
message);
void png_combine_row (png_structp png_ptr, png_bytep row, int
mask);
void png_convert_from_struct_tm (png_timep ptime, struct tm FAR
* ttime);
@ -39,24 +21,12 @@ void png_convert_from_time_t (png_timep ptime, time_t ttime);
png_charp png_convert_to_rfc1123 (png_structp png_ptr,
png_timep ptime);
void png_correct_palette (png_structp png_ptr, png_colorp
palette, int num_palette);
int png_crc_error (png_structp png_ptr);
int png_crc_finish (png_structp png_ptr, png_uint_32 skip);
void png_crc_read (png_structp png_ptr, png_bytep buf,
png_size_t length);
png_infop png_create_info_struct (png_structp png_ptr);
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_voidp png_create_struct (int type);
png_structp png_create_write_struct (png_const_charp
user_png_ver, voidp error_ptr, png_error_ptr error_fn,
png_error_ptr warn_fn);
@ -72,93 +42,11 @@ info_ptr_ptr);
void png_destroy_read_struct (png_structpp png_ptr_ptr,
png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr);
void png_destroy_struct (png_voidp struct_ptr);
void png_destroy_write_struct (png_structpp png_ptr_ptr,
png_infopp info_ptr_ptr);
void png_do_background (png_row_infop row_info, png_bytep row,
png_color_16p trans_values, png_color_16p background,
png_color_16p background_1, png_bytep gamma_table, png_bytep
gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16,
png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int
gamma_shift);
void png_do_bgr (png_row_infop row_info, png_bytep row);
void png_do_chop (png_row_infop row_info, png_bytep row);
void png_do_dither (png_row_infop row_info, png_bytep row,
png_bytep palette_lookup, png_bytep dither_lookup);
void png_do_expand (png_row_infop row_info, png_bytep row,
png_color_16p trans_value);
void png_do_expand_palette (png_row_infop row_info, png_bytep
row, png_colorp palette, png_bytep trans, int num_trans);
void png_do_gamma (png_row_infop row_info, png_bytep row,
png_bytep gamma_table, png_uint_16pp gamma_16_table, int
gamma_shift);
void png_do_gray_to_rgb (png_row_infop row_info, png_bytep
row);
void png_do_invert (png_row_infop row_info, png_bytep row);
void png_do_pack (png_row_infop row_info, png_bytep row,
png_uint_32 bit_depth);
void png_do_packswap (png_row_infop row_info, png_bytep row);
void png_do_read_filler (png_row_infop row_info, png_bytep row,
png_uint_32 filler, png_uint_32 flags);
void png_do_read_interlace (png_row_infop row_info, png_bytep
row, int pass, png_uint_32 transformations);
void png_do_read_invert_alpha (png_row_infop row_info,
png_bytep row);
void png_do_read_swap_alpha (png_row_infop row_info, png_bytep
row);
void png_do_read_transformations (png_structp png_ptr);
void 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,
png_color_8p bit_depth);
void png_do_strip_filler (png_row_infop row_info, png_bytep
row, png_uint_32 flags);
void png_do_swap (png_row_infop row_info, png_bytep row);
void png_do_unpack (png_row_infop row_info, png_bytep row);
void png_do_unshift (png_row_infop row_info, png_bytep row,
png_color_8p sig_bits);
void png_do_write_interlace (png_row_infop row_info, png_bytep
row, int pass);
void png_do_write_invert_alpha (png_row_infop row_info,
png_bytep row);
void png_do_write_swap_alpha (png_row_infop row_info, png_bytep
row);
void png_do_write_transformations (png_structp png_ptr);
void png_error (png_structp png_ptr, png_const_charp error);
void *png_far_to_near (png_structp png_ptr,png_voidp ptr,
int check);
void png_flush (png_structp png_ptr);
void png_free (png_structp png_ptr, png_voidp ptr);
png_byte png_get_bit_depth (png_structp png_ptr, png_infop
@ -198,8 +86,6 @@ png_infop info_ptr);
png_uint_32 png_get_image_width (png_structp png_ptr, png_infop
info_ptr);
png_int_32 png_get_int_32 (png_bytep buf);
png_byte png_get_interlace_type (png_structp png_ptr, png_infop
info_ptr);
@ -255,10 +141,6 @@ png_uint_32 png_get_tRNS (png_structp png_ptr, png_infop
info_ptr, png_bytep *trans, int *num_trans, png_color_16p
*trans_values);
png_uint_16 png_get_uint_16 (png_bytep buf);
png_uint_32 png_get_uint_32 (png_bytep buf);
png_uint_32 png_get_valid (png_structp png_ptr, png_infop
info_ptr, png_uint_32 flag);
@ -268,72 +150,22 @@ png_infop info_ptr);
png_uint_32 png_get_x_offset_pixels (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);
png_uint_32 png_get_y_offset_microns (png_structp png_ptr,
png_infop info_ptr);
png_uint_32 png_get_y_offset_pixels (png_structp png_ptr,
png_infop info_ptr);
void png_handle_bKGD (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_cHRM (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_gAMA (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_hIST (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_IEND (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_IHDR (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_oFFs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_pCAL (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_pHYs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_PLTE (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_sBIT (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_sRGB (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tEXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tIME (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tRNS (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_handle_zTXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_info_destroy (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);
void png_info_init (png_infop info_ptr);
void png_init_io (png_structp png_ptr, FILE *fp);
void png_init_read_transformations (png_structp png_ptr);
png_voidp png_malloc (png_structp png_ptr, png_uint_32 size);
voidp png_memcpy (png_voidp s1, png_voidp s2, png_size_t size);
@ -349,109 +181,27 @@ s1, int value, png_uint_32 size);
void png_process_data (png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size);
void png_process_IDAT_data (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
void png_process_some_data (png_structp png_ptr, png_infop
info_ptr);
void png_progressive_combine_row (png_structp png_ptr,
png_bytep old_row, png_bytep new_row);
void png_push_check_crc (png_structp png_ptr);
void png_push_crc_finish (png_structp png_ptr);
void png_push_crc_skip (png_structp png_ptr, png_uint_32
length);
void png_push_fill_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t length);
void png_push_handle_tEXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_handle_zTXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_have_end (png_structp png_ptr, png_infop
info_ptr);
void png_push_have_info (png_structp png_ptr, png_infop
info_ptr);
void png_push_have_row (png_structp png_ptr, png_bytep row);
void png_push_process_row (png_structp png_ptr);
void png_push_read_chunk (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_end (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_IDAT (png_structp png_ptr);
void png_push_read_sig (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_tEXt (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_zTXt (png_structp png_ptr, png_infop
info_ptr);
void png_push_restore_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
void png_push_save_buffer (png_structp png_ptr);
void png_read_data (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_read_destroy (png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr);
void png_read_end (png_structp png_ptr, png_infop info_ptr);
void png_read_filter_row (png_structp png_ptr, png_row_infop
row_info, png_bytep row, png_bytep prev_row, int filter);
void png_read_finish_row (png_structp png_ptr);
void png_read_image (png_structp png_ptr, png_bytepp image);
void png_read_info (png_structp png_ptr, png_infop info_ptr);
void png_read_init (png_structp png_ptr);
void png_read_push_finish_row (png_structp png_ptr);
void png_read_row (png_structp png_ptr, png_bytep row,
png_bytep display_row);
void png_read_rows (png_structp png_ptr, png_bytepp row,
png_bytepp display_row, png_uint_32 num_rows);
void png_read_start_row (png_structp png_ptr);
void png_read_transform_info (png_structp png_ptr, png_infop
info_ptr);
void png_read_update_info (png_structp png_ptr, png_infop
info_ptr);
void png_reset_crc (png_structp png_ptr);
void png_save_int_32 (png_bytep buf, png_int_32 i);
void png_save_uint_16 (png_bytep buf, unsigned int i);
void png_save_uint_32 (png_bytep buf, png_uint_32 i);
void png_set_background (png_structp png_ptr, png_color_16p
background_color, int background_gamma_code, int need_expand,
double background_gamma);
@ -595,9 +345,6 @@ void png_start_read_image (png_structp png_ptr);
void png_warning (png_structp png_ptr, png_const_charp
message);
void png_write_bKGD (png_structp png_ptr, png_color_16p values,
int color_type);
void png_write_chunk (png_structp png_ptr, png_bytep
chunk_name, png_bytep data, png_size_t length);
@ -609,92 +356,23 @@ void png_write_chunk_end (png_structp png_ptr);
void png_write_chunk_start (png_structp png_ptr, png_bytep
chunk_name, png_uint_32 length);
void png_write_cHRM (png_structp png_ptr, double white_x,
double white_y, double red_x, double red_y, double green_x,
double green_y, double blue_x, double blue_y);
void png_write_data (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_write_destroy (png_structp png_ptr);
void png_write_destroy_info (png_infop info_ptr);
void png_write_end (png_structp png_ptr, png_infop info_ptr);
void png_write_filtered_row (png_structp png_ptr, png_bytep
filtered_row);
void png_write_find_filter (png_structp png_ptr, png_row_infop
row_info);
void png_write_finish_row (png_structp png_ptr);
void png_write_flush (png_structp png_ptr);
void png_write_gAMA (png_structp png_ptr, double file_gamma);
void png_write_hIST (png_structp png_ptr, png_uint_16p hist,
int num_hist);
void png_write_image (png_structp png_ptr, png_bytepp image);
void png_write_info (png_structp png_ptr, png_infop info_ptr);
void png_write_init (png_structp png_ptr);
void png_write_IDAT (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_write_IEND (png_structp png_ptr);
void png_write_IHDR (png_structp png_ptr, png_uint_32 width,
png_uint_32 height, int bit_depth, int color_type, int
compression_type, int filter_type, int interlace_type);
void png_write_oFFs (png_structp png_ptr, png_uint_32 x_offset,
png_uint_32 y_offset, int unit_type);
void png_write_pCAL (png_structp png_ptr, png_charp purpose,
png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp
units, png_charpp params);
void png_write_pHYs (png_structp png_ptr, png_uint_32
x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int
unit_type);
void png_write_PLTE (png_structp png_ptr, png_colorp palette,
png_uint_32 num_pal);
void png_write_row (png_structp png_ptr, png_bytep row);
void png_write_rows (png_structp png_ptr, png_bytepp row,
png_uint_32 num_rows);
void png_write_sBIT (png_structp png_ptr, png_color_8p sbit,
int color_type);
void png_write_sig (png_structp png_ptr);
void png_write_sRGB (png_structp png_ptr, int intent);
void png_write_start_row (png_structp png_ptr);
void png_write_tEXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len);
void png_write_tIME (png_structp png_ptr, png_timep mod_time);
void png_write_tRNS (png_structp png_ptr, png_bytep trans,
png_color_16p values, int number, int color_type);
void png_write_zTXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len, int compression);
voidpf png_zalloc (voidpf png_ptr, uInt items, uInt size);
void png_zfree (voidpf png_ptr, voidpf ptr);
.SH DESCRIPTION
The
.I libpng
@ -706,11 +384,11 @@ 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 0.99d
libpng version 0.99e
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
February 8, 1998
February 28, 1998
based on:
@ -780,9 +458,7 @@ same instance of a structure.
There are two main structures that are important to libpng, png_struct
and png_info. The first, png_struct, is an internal structure that
will not, for the most part, be used by a user except as the first
variable passed to every libpng function call. It is not actually
used in many of the functions; do not be alarmed about compiler
warnings that say something to the effect that "png_ptr is not used."
variable passed to every libpng function call.
The png_info structure is designed to provide information about the
PNG file. At one time, the fields of png_info were intended to be
@ -964,8 +640,8 @@ Functions are used to get the information from the info_ptr:
for PNG 1.0)
compression_type - (must be PNG_COMPRESSION_TYPE_BASE
for PNG 1.0)
interlace_type - (PNG_INTERLACE_TYPE_NONE or
PNG_INTERLACE_TYPE_ADAM7)
interlace_type - (PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7)
Any or all of interlace_type, compression_type, of
filter_type can be
NULL if you are not interested in their values.
@ -982,7 +658,7 @@ Functions are used to get the information from the info_ptr:
signature - holds the signature read from the
file (if any). The data is kept in
the same offset it would be if the
whole signature were read (ie if an
whole signature were read (i.e. if an
application had already read in 4
bytes of signature before starting
libpng, the remaining 4 bytes would
@ -1084,12 +760,16 @@ into the info_ptr is returned for any complex types.
x direction
res_y - pixels/unit physical resolution in
x direction
unit_type - PNG_RESOLUTION_UNKOWN,
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
The data from the pHYs chunk can be retrieved in several convenient
forms:
res_x = png_get_x_pixels_per_meter(png_ptr,
info_ptr)
res_y = png_get_y_pixels_per_meter(png_ptr,
info_ptr)
res_x_and_y = png_get_pixels_per_meter(png_ptr,
info_ptr)
aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
@ -1132,7 +812,7 @@ ways to transform the data will be described in the order that they
should occur. This is important, as some of these change the color
type and/or bit depth of the data, and some others only work on
certain color types and bit depths. Even though each transformation
checks to see if it has data that it can do somthing with, you should
checks to see if it has data that it can do something with, you should
make sure to only enable a transformation if it will be valid for the
data. For example, don't swap red and blue on grayscale data.
@ -1204,7 +884,7 @@ values of the pixels:
PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
stored in a PNG image have been "scaled" or "shifted" up to the next
higher possible bit depth (eg from 5 bits/sample in the range [0,31] to
higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
8 bits/sample in the range [0, 255]). However, it is also possible to
convert the PNG pixel data back to the original bit depth of the image.
This call reduces the pixels back down to the original bit depth:
@ -1278,8 +958,8 @@ the overall gamma correction required to produce pleasing results,
which depends on the lighting conditions in the surrounding environment.
Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
the amount of additional gamma correction needed to compensate for
a dim (viewing_gamma=1.125) or dark (viewing_gamma=1.25) environment.
In a brightly lit room, no compensation other than the display_gamma
a dark (viewing_gamma=1.25) environment.
In a dim or brightly lit room, no compensation other than the display_gamma
is needed (viewing_gamma=1.0).
if (/* We have a user-defined screen
@ -1297,10 +977,8 @@ is needed (viewing_gamma=1.0).
/* If we don't have another value */
else
{
screen_gamma = 2.5; /* A good guess for a
PC monitor in a bright office */
screen_gamma = 2.2; /* A good guess for a
PC monitor in a dim room */
PC monitor in a bright office or a dim room */
screen_gamma = 2.0; /* A good guess for a
PC monitor in a dark room */
screen_gamma = 1.7 or 1.0; /* A good
@ -1363,8 +1041,8 @@ zero):
png_set_invert_mono(png_ptr);
PNG files store 16 bit pixels in network byte order (big-endian,
ie. most significant bits first). This code chages the storage to the
other way (little-endian, ie. least significant bits first, eg. the
ie. most significant bits first). This code changes the storage to the
other way (little-endian, i.e. least significant bits first, the
way PCs store them):
if (bit_depth == 16)
@ -1420,7 +1098,7 @@ You can point to void or char or whatever you use for pixels.
If you don't want to read in the whole image at once, you can
use png_read_rows() instead. If there is no interlacing (check
interlace_type == PNG_INTERLACE_TYPE_NONE), this is simple:
interlace_type == PNG_INTERLACE_NONE), this is simple:
png_read_rows(png_ptr, row_pointers, NULL,
number_of_rows);
@ -1435,7 +1113,7 @@ row_pointers:
If the file is interlaced (info_ptr->interlace_type != 0), things get
somewhat harder. The only current (PNG Specification version 1.0)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
is a somewhat complicated 2D interlace scheme, known as Adam7, that
breaks down an image into seven smaller images of varying size, based
on an 8x8 grid.
@ -1474,7 +1152,7 @@ numbered scanlines. Phew!
If you want libpng to expand the images, call this before calling
png_start_read_image() or png_read_update_info():
if (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
if (interlace_type == PNG_INTERLACE_ADAM7)
number_of_passes
= png_set_interlace_handling(png_ptr);
@ -1692,7 +1370,7 @@ png_infop info_ptr;
IV. Writing
.SH IV. Writing
Much of this is very similar to reading. However, everything of
importance is repeated here, so you won't have to constantly look
@ -1764,7 +1442,8 @@ have no special needs in this area, let the library do what it wants by
not calling this function at all, as it has been tuned to deliver a good
speed/compression ratio. The second parameter to png_set_filter() is
the filter method, for which the only valid value is '0' (as of the
06/96 PNG specification. The third parameter is a flag that indicates
October 1996 PNG specification, version 1.0). The third parameter is a
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.
@ -1835,8 +1514,8 @@ Some of the more important parts of the png_info are:
PNG_COLOR_MASK_COLOR
PNG_COLOR_MASK_ALPHA
interlace_type - PNG_INTERLACE_TYPE_NONE or
PNG_INTERLACE_TYPE_ADAM7
interlace_type - PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7
compression_type - (must be
PNG_COMPRESSION_TYPE_DEFAULT)
filter_type - (must be PNG_FILTER_TYPE_DEFAULT)
@ -1933,7 +1612,7 @@ Some of the more important parts of the png_info are:
in x direction
res_y - pixels/unit physical resolution
in y direction
unit_type - PNG_RESOLUTION_UNKOWN,
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
In PNG files, the alpha channel in an image is the level of opacity.
@ -1984,7 +1663,7 @@ The keywords that are given in the PNG Specification are:
The keyword-text pairs work like this. Keywords should be short
simple descriptions of what the comment is about. Some typical
keywords are found in the PNG specification, as is some recomendations
keywords are found in the PNG specification, as is some recommendations
on keywords. You can repeat keywords in a file. You can even write
some text before the image and some after. For example, you may want
to put a description of the image before the image, but leave the
@ -2008,7 +1687,7 @@ time_t routine uses gmtime(). You don't have to use either of
these, but if you wish to fill in the png_time structure directly,
you should provide the time in universal time (GMT) if possible
instead of your local time. Note that the year number is the full
year (ie 1996, rather than 96 - PNG is year 2000 compliant!), and
year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
that months start with 1.
If you want to store the time of the original image creation, you should
@ -2018,7 +1697,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 (eg 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
@ -2036,7 +1715,7 @@ ways to transform the data will be described in the order that they
should occur. This is important, as some of these change the color
type and/or bit depth of the data, and some others only work on
certain color types and bit depths. Even though each transformation
checks to see if it has data that it can do somthing with, you should
checks to see if it has data that it can do something with, you should
make sure to only enable a transformation if it will be valid for the
data. For example, don't swap red and blue on grayscale data.
@ -2079,7 +1758,7 @@ file so that decoders can get the original data if desired.
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
If the data is stored in the row buffer in a bit depth other than
one supported by PNG (ie 3 bit data in the range 0-7 for a 4-bit PNG),
one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
this will scale the values to appear to be the correct bit depth as
is required by PNG.
@ -2087,8 +1766,8 @@ is required by PNG.
PNG files store 16 bit pixels in network byte order (big-endian,
ie. most significant bits first). This code would be used if they are
supplied the other way (little-endian, ie. least significant bits
first, eg. the way PCs store them):
supplied the other way (little-endian, i.e. least significant bits
first, the way PCs store them):
if (bit_depth > 8)
png_set_swap(png_ptr);
@ -2125,9 +1804,9 @@ Note that the distance between rows is from the last time png_write_flush()
was called, or the first row of the image if it has never been called.
So if you write 50 lines, and then png_set_flush 25, it will flush the
output on the next scanline, and every 25 lines thereafter, unless
png_write_flush()ls is called before 25 more lines have been written.
png_write_flush() is called before 25 more lines have been written.
If nrows is too small (less than about 10 lines for a 640 pixel wide
RGB image) the image compression may decrease noticably (although this
RGB image) the image compression may decrease noticeably (although this
may be acceptable for real-time applications). Infrequent flushing will
only degrade the compression performance by a few percent over images
that do not use flushing.
@ -2165,9 +1844,9 @@ row_pointers:
png_write_row(png_ptr, &row_pointer);
When the file is interlaced, things can get a good deal more
complicated. The only currently (as of 6/96 -- PNG Specification
version 1.0) defined interlacing scheme for PNG files is a
compilcated interlace scheme, known as Adam7, that breaks down an
complicated. The only currently (as of February 1998 -- PNG Specification
version 1.0, dated October 1996) defined interlacing scheme for PNG files
is the "Adam7" interlace scheme, that breaks down an
image into seven smaller images of varying size. libpng will build
these images for you, or you can do them yourself. If you want to
build them yourself, see the PNG specification for details of which
@ -2212,7 +1891,7 @@ palette, or histogram, before the call to png_destroy_write_struct();
For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng:
.SH V. Modifying/Customizing libpng:
There are two issues here. The first is changing how libpng does
standard things like memory allocation, input/output, and error handling.
@ -2220,9 +1899,9 @@ 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 setable. The default routines are
goes through callbacks which are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
these functions, call the approprate png_set_???_fn() function.
these functions, call the appropriate png_set_???_fn() function.
Memory allocation is done through the functions png_large_malloc(),
png_malloc(), png_realloc(), png_large_free(), and png_free(). These
@ -2320,11 +1999,11 @@ can be found in the comments inside the code itself.
Configuring for 16 bit platforms:
You may need to change the png_large_malloc() and png_large_free()
routines in pngmem.c, as these are requred to allocate 64K, although
routines in pngmem.c, as these are required to allocate 64K, although
there is already support for many of the common DOS compilers. Also,
you will want to look into zconf.h to tell zlib (and thus libpng) that
it cannot allocate more then 64K at a time. Even if you can, the memory
won't be accessable. So limit zlib and libpng to 64K by defining MAXSEG_64K.
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Configuring for DOS:
@ -2349,7 +2028,7 @@ You will need to write new error and warning functions that use the GUI
interface, as described previously, and set them to be the error and
warning functions at the time that png_create_???_struct() is called,
in order to have them available during the structure initialization.
They can be changed later via png_set_error_fn(). On some compliers,
They can be changed later via png_set_error_fn(). On some compilers,
you may also have to change the memory allocators (png_malloc, etc.).
Configuring for compiler xxx:
@ -2451,7 +2130,7 @@ to be considered when selecting row filters. This means that filters
with higher costs are less likely to be chosen over filters with lower
costs, unless their "sum of absolute differences" is that much smaller.
The costs do not necessarily reflect the exact computational speeds of
the various filters, since this would unduely influence the final image
the various filters, since this would unduly influence the final image
size.
Note that the numbers above were invented purely for this example and
@ -2550,7 +2229,7 @@ the first widely used release:
0.99 0.99 2.0.99
0.99a 0.99 2.0.99
0.99b 0.99 2.0.99
0.99d 0.99 2.0.99
0.99e 0.99 2.0.99
1.0 1.00 2.1.0
Henceforth the source version will match the shared-library minor
@ -2558,11 +2237,14 @@ and patch numbers; the shared-library major version number will be
used for changes in backward compatibility, as it is intended.
.SH "SEE ALSO"
libpngpf(3), png(5)
.LP
.IR libpng :
.IP
ftp://ftp.uu.net/graphics/png
http://www.cdrom.com/pub/png
.LP
.IR zlib :
.IP
(generally) at the same location as
@ -2573,8 +2255,8 @@ ftp://ftp.uu.net/pub/archiving/zip/zlib
.br
http://www.cdrom.com/pub/infozip/zlib
PNG specification:
RFC 2083
.LP
.IR PNG specification: RFC 2083
.IP
(generally) at the same location as
.I libpng
@ -2586,6 +2268,7 @@ or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
.LP
In the case of any inconsistency between the PNG specification
and this library, the specification takes precedence.
@ -2595,7 +2278,8 @@ This man page: Glenn Randers-Pehrson
Contributing Authors: John Bowler, Kevin Bracey, Sam Bushell, Andreas Dilger,
Magnus Holmgren, Tom Lane, Dave Martindale, Glenn Randers-Pehrson,
Greg Roelofs, Guy Eric Schalnat, Paul Schmidt, Tom Tanner, Tim Wegner.
Greg Roelofs, Guy Eric Schalnat, Paul Schmidt, Tom Tanner, Willem van
Schaik, Tim Wegner.
<png-implement@dworkin.wustl.edu>
The contributing authors would like to thank all those who helped
@ -2604,7 +2288,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 0.99d (February 8, 1998):
Libpng version 0.99e (February 28, 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,27 +1,28 @@
libpng.txt - A description on how to use and modify libpng
libpng version 0.99d
Updated and distributed by Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
February 8, 1998
libpng version 0.99e
Updated and distributed by Glenn Randers-Pehrson
<randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
February 28, 1998
based on:
based on:
libpng 1.0 beta 6 version 0.96
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
May 28, 1997
libpng 1.0 beta 6 version 0.96
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
May 28, 1997
libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright notice in png.h
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
January 26, 1996
libpng 1.0 beta 2 - version 0.88
For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Schalnat, Group 42, Inc. January 26, 1996
Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995 Frank J. T. Wojcik
December 18, 1995 && January 20, 1996
Updated/rewritten per request in the libpng FAQ
Copyright (c) 1995 Frank J. T. Wojcik
December 18, 1995 && January 20, 1996
I. Introduction
Introduction
This file describes how to use and modify the PNG reference library
(known as libpng) for your own use. There are five sections to this
@ -73,9 +74,7 @@ II. Structures
There are two main structures that are important to libpng, png_struct
and png_info. The first, png_struct, is an internal structure that
will not, for the most part, be used by a user except as the first
variable passed to every libpng function call. It is not actually
used in many of the functions; do not be alarmed about compiler
warnings that say something to the effect that "png_ptr is not used."
variable passed to every libpng function call.
The png_info structure is designed to provide information about the
PNG file. At one time, the fields of png_info were intended to be
@ -257,8 +256,8 @@ Functions are used to get the information from the info_ptr:
for PNG 1.0)
compression_type - (must be PNG_COMPRESSION_TYPE_BASE
for PNG 1.0)
interlace_type - (PNG_INTERLACE_TYPE_NONE or
PNG_INTERLACE_TYPE_ADAM7)
interlace_type - (PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7)
Any or all of interlace_type, compression_type, of
filter_type can be
NULL if you are not interested in their values.
@ -275,7 +274,7 @@ Functions are used to get the information from the info_ptr:
signature - holds the signature read from the
file (if any). The data is kept in
the same offset it would be if the
whole signature were read (ie if an
whole signature were read (i.e. if an
application had already read in 4
bytes of signature before starting
libpng, the remaining 4 bytes would
@ -377,12 +376,16 @@ into the info_ptr is returned for any complex types.
x direction
res_y - pixels/unit physical resolution in
x direction
unit_type - PNG_RESOLUTION_UNKOWN,
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
The data from the pHYs chunk can be retrieved in several convenient
forms:
res_x = png_get_x_pixels_per_meter(png_ptr,
info_ptr)
res_y = png_get_y_pixels_per_meter(png_ptr,
info_ptr)
res_x_and_y = png_get_pixels_per_meter(png_ptr,
info_ptr)
aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
@ -425,7 +428,7 @@ ways to transform the data will be described in the order that they
should occur. This is important, as some of these change the color
type and/or bit depth of the data, and some others only work on
certain color types and bit depths. Even though each transformation
checks to see if it has data that it can do somthing with, you should
checks to see if it has data that it can do something with, you should
make sure to only enable a transformation if it will be valid for the
data. For example, don't swap red and blue on grayscale data.
@ -497,7 +500,7 @@ values of the pixels:
PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
stored in a PNG image have been "scaled" or "shifted" up to the next
higher possible bit depth (eg from 5 bits/sample in the range [0,31] to
higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
8 bits/sample in the range [0, 255]). However, it is also possible to
convert the PNG pixel data back to the original bit depth of the image.
This call reduces the pixels back down to the original bit depth:
@ -571,9 +574,8 @@ the overall gamma correction required to produce pleasing results,
which depends on the lighting conditions in the surrounding environment.
Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
the amount of additional gamma correction needed to compensate for
a dim (viewing_gamma=1.125) or dark (viewing_gamma=1.25) environment.
In a brightly lit room, no compensation other than the display_gamma
is needed (viewing_gamma=1.0).
a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
compensation other than the display_gamma is needed (viewing_gamma=1.0).
if (/* We have a user-defined screen
gamma value */)
@ -590,10 +592,8 @@ is needed (viewing_gamma=1.0).
/* If we don't have another value */
else
{
screen_gamma = 2.5; /* A good guess for a
PC monitor in a bright office */
screen_gamma = 2.2; /* A good guess for a
PC monitor in a dim room */
PC monitor in a bright office or a dim room */
screen_gamma = 2.0; /* A good guess for a
PC monitor in a dark room */
screen_gamma = 1.7 or 1.0; /* A good
@ -656,8 +656,8 @@ zero):
png_set_invert_mono(png_ptr);
PNG files store 16 bit pixels in network byte order (big-endian,
ie. most significant bits first). This code chages the storage to the
other way (little-endian, ie. least significant bits first, eg. the
ie. most significant bits first). This code changes the storage to the
other way (little-endian, i.e. least significant bits first, the
way PCs store them):
if (bit_depth == 16)
@ -713,7 +713,7 @@ You can point to void or char or whatever you use for pixels.
If you don't want to read in the whole image at once, you can
use png_read_rows() instead. If there is no interlacing (check
interlace_type == PNG_INTERLACE_TYPE_NONE), this is simple:
interlace_type == PNG_INTERLACE_NONE), this is simple:
png_read_rows(png_ptr, row_pointers, NULL,
number_of_rows);
@ -728,7 +728,7 @@ row_pointers:
If the file is interlaced (info_ptr->interlace_type != 0), things get
somewhat harder. The only current (PNG Specification version 1.0)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
is a somewhat complicated 2D interlace scheme, known as Adam7, that
breaks down an image into seven smaller images of varying size, based
on an 8x8 grid.
@ -767,7 +767,7 @@ numbered scanlines. Phew!
If you want libpng to expand the images, call this before calling
png_start_read_image() or png_read_update_info():
if (interlace_type == PNG_INTERLACE_TYPE_ADAM7)
if (interlace_type == PNG_INTERLACE_ADAM7)
number_of_passes
= png_set_interlace_handling(png_ptr);
@ -1057,7 +1057,8 @@ have no special needs in this area, let the library do what it wants by
not calling this function at all, as it has been tuned to deliver a good
speed/compression ratio. The second parameter to png_set_filter() is
the filter method, for which the only valid value is '0' (as of the
06/96 PNG specification. The third parameter is a flag that indicates
October 1996 PNG specification, version 1.0). The third parameter is a
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.
@ -1128,8 +1129,8 @@ Some of the more important parts of the png_info are:
PNG_COLOR_MASK_COLOR
PNG_COLOR_MASK_ALPHA
interlace_type - PNG_INTERLACE_TYPE_NONE or
PNG_INTERLACE_TYPE_ADAM7
interlace_type - PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7
compression_type - (must be
PNG_COMPRESSION_TYPE_DEFAULT)
filter_type - (must be PNG_FILTER_TYPE_DEFAULT)
@ -1226,7 +1227,7 @@ Some of the more important parts of the png_info are:
in x direction
res_y - pixels/unit physical resolution
in y direction
unit_type - PNG_RESOLUTION_UNKOWN,
unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER
In PNG files, the alpha channel in an image is the level of opacity.
@ -1277,7 +1278,7 @@ The keywords that are given in the PNG Specification are:
The keyword-text pairs work like this. Keywords should be short
simple descriptions of what the comment is about. Some typical
keywords are found in the PNG specification, as is some recomendations
keywords are found in the PNG specification, as is some recommendations
on keywords. You can repeat keywords in a file. You can even write
some text before the image and some after. For example, you may want
to put a description of the image before the image, but leave the
@ -1301,7 +1302,7 @@ time_t routine uses gmtime(). You don't have to use either of
these, but if you wish to fill in the png_time structure directly,
you should provide the time in universal time (GMT) if possible
instead of your local time. Note that the year number is the full
year (ie 1996, rather than 96 - PNG is year 2000 compliant!), and
year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
that months start with 1.
If you want to store the time of the original image creation, you should
@ -1311,7 +1312,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 (eg 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
@ -1329,7 +1330,7 @@ ways to transform the data will be described in the order that they
should occur. This is important, as some of these change the color
type and/or bit depth of the data, and some others only work on
certain color types and bit depths. Even though each transformation
checks to see if it has data that it can do somthing with, you should
checks to see if it has data that it can do something with, you should
make sure to only enable a transformation if it will be valid for the
data. For example, don't swap red and blue on grayscale data.
@ -1372,7 +1373,7 @@ file so that decoders can get the original data if desired.
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
If the data is stored in the row buffer in a bit depth other than
one supported by PNG (ie 3 bit data in the range 0-7 for a 4-bit PNG),
one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
this will scale the values to appear to be the correct bit depth as
is required by PNG.
@ -1380,8 +1381,8 @@ is required by PNG.
PNG files store 16 bit pixels in network byte order (big-endian,
ie. most significant bits first). This code would be used if they are
supplied the other way (little-endian, ie. least significant bits
first, eg. the way PCs store them):
supplied the other way (little-endian, i.e. least significant bits
first, the way PCs store them):
if (bit_depth > 8)
png_set_swap(png_ptr);
@ -1418,9 +1419,9 @@ Note that the distance between rows is from the last time png_write_flush()
was called, or the first row of the image if it has never been called.
So if you write 50 lines, and then png_set_flush 25, it will flush the
output on the next scanline, and every 25 lines thereafter, unless
png_write_flush()ls is called before 25 more lines have been written.
png_write_flush() is called before 25 more lines have been written.
If nrows is too small (less than about 10 lines for a 640 pixel wide
RGB image) the image compression may decrease noticably (although this
RGB image) the image compression may decrease noticeably (although this
may be acceptable for real-time applications). Infrequent flushing will
only degrade the compression performance by a few percent over images
that do not use flushing.
@ -1458,9 +1459,9 @@ row_pointers:
png_write_row(png_ptr, &row_pointer);
When the file is interlaced, things can get a good deal more
complicated. The only currently (as of 6/96 -- PNG Specification
version 1.0) defined interlacing scheme for PNG files is a
compilcated interlace scheme, known as Adam7, that breaks down an
complicated. The only currently (as of February 1998 -- PNG Specification
version 1.0, dated October 1996) defined interlacing scheme for PNG files
is the "Adam7" interlace scheme, that breaks down an
image into seven smaller images of varying size. libpng will build
these images for you, or you can do them yourself. If you want to
build them yourself, see the PNG specification for details of which
@ -1513,9 +1514,9 @@ 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 setable. The default routines are
goes through callbacks which are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
these functions, call the approprate png_set_???_fn() function.
these functions, call the appropriate png_set_???_fn() function.
Memory allocation is done through the functions png_large_malloc(),
png_malloc(), png_realloc(), png_large_free(), and png_free(). These
@ -1613,11 +1614,11 @@ can be found in the comments inside the code itself.
Configuring for 16 bit platforms:
You may need to change the png_large_malloc() and png_large_free()
routines in pngmem.c, as these are requred to allocate 64K, although
routines in pngmem.c, as these are required to allocate 64K, although
there is already support for many of the common DOS compilers. Also,
you will want to look into zconf.h to tell zlib (and thus libpng) that
it cannot allocate more then 64K at a time. Even if you can, the memory
won't be accessable. So limit zlib and libpng to 64K by defining MAXSEG_64K.
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Configuring for DOS:
@ -1642,7 +1643,7 @@ You will need to write new error and warning functions that use the GUI
interface, as described previously, and set them to be the error and
warning functions at the time that png_create_???_struct() is called,
in order to have them available during the structure initialization.
They can be changed later via png_set_error_fn(). On some compliers,
They can be changed later via png_set_error_fn(). On some compilers,
you may also have to change the memory allocators (png_malloc, etc.).
Configuring for compiler xxx:
@ -1744,7 +1745,7 @@ to be considered when selecting row filters. This means that filters
with higher costs are less likely to be chosen over filters with lower
costs, unless their "sum of absolute differences" is that much smaller.
The costs do not necessarily reflect the exact computational speeds of
the various filters, since this would unduely influence the final image
the various filters, since this would unduly influence the final image
size.
Note that the numbers above were invented purely for this example and
@ -1815,16 +1816,4 @@ 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
new name to force compilation errors with applications that try to use
the old method.
.SH AUTHORS
This man page: Glenn Randers-Pehrson
Libpng version 0.99d (February 8, 1998):
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
Supported by the PNG development group
.br
(png-implement@dworkin.wustl.edu).
.\" end of man page

342
libpngpf.3 Normal file
View File

@ -0,0 +1,342 @@
.TH LIBPNGPF 3 "February 28, 1998"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library
(private functions)
.SH SYNOPSIS
#include <png.h>
void png_build_gamma_table (png_structp png_ptr);
void png_build_grayscale_palette (int bit_depth, png_colorp
palette);
void png_calculate_crc (png_structp png_ptr, png_bytep ptr,
png_size_t length);
void png_check_chunk_name (png_structp png_ptr, png_bytep
chunk_name);
png_size_t png_check_keyword (png_structp png_ptr, png_charp
key, png_charpp new_key);
void png_combine_row (png_structp png_ptr, png_bytep row, int
mask);
void png_correct_palette (png_structp png_ptr, png_colorp
palette, int num_palette);
int png_crc_error (png_structp png_ptr);
int png_crc_finish (png_structp png_ptr, png_uint_32 skip);
void png_crc_read (png_structp png_ptr, png_bytep buf,
png_size_t length);
png_voidp png_create_struct (int type);
void png_destroy_struct (png_voidp struct_ptr);
void png_do_background (png_row_infop row_info, png_bytep row,
png_color_16p trans_values, png_color_16p background,
png_color_16p background_1, png_bytep gamma_table, png_bytep
gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16,
png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int
gamma_shift);
void png_do_bgr (png_row_infop row_info, png_bytep row);
void png_do_chop (png_row_infop row_info, png_bytep row);
void png_do_dither (png_row_infop row_info, png_bytep row,
png_bytep palette_lookup, png_bytep dither_lookup);
void png_do_expand (png_row_infop row_info, png_bytep row,
png_color_16p trans_value);
void png_do_expand_palette (png_row_infop row_info, png_bytep
row, png_colorp palette, png_bytep trans, int num_trans);
void png_do_gamma (png_row_infop row_info, png_bytep row,
png_bytep gamma_table, png_uint_16pp gamma_16_table, int
gamma_shift);
void png_do_gray_to_rgb (png_row_infop row_info, png_bytep
row);
void png_do_invert (png_row_infop row_info, png_bytep row);
void png_do_pack (png_row_infop row_info, png_bytep row,
png_uint_32 bit_depth);
void png_do_packswap (png_row_infop row_info, png_bytep row);
void png_do_read_filler (png_row_infop row_info, png_bytep row,
png_uint_32 filler, png_uint_32 flags);
void png_do_read_interlace (png_row_infop row_info, png_bytep
row, int pass, png_uint_32 transformations);
void png_do_read_invert_alpha (png_row_infop row_info,
png_bytep row);
void png_do_read_swap_alpha (png_row_infop row_info, png_bytep
row);
void png_do_read_transformations (png_structp png_ptr);
void 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,
png_color_8p bit_depth);
void png_do_strip_filler (png_row_infop row_info, png_bytep
row, png_uint_32 flags);
void png_do_swap (png_row_infop row_info, png_bytep row);
void png_do_unpack (png_row_infop row_info, png_bytep row);
void png_do_unshift (png_row_infop row_info, png_bytep row,
png_color_8p sig_bits);
void png_do_write_interlace (png_row_infop row_info, png_bytep
row, int pass);
void png_do_write_invert_alpha (png_row_infop row_info,
png_bytep row);
void png_do_write_swap_alpha (png_row_infop row_info, png_bytep
row);
void png_do_write_transformations (png_structp png_ptr);
void *png_far_to_near (png_structp png_ptr,png_voidp ptr,
int check);
void png_flush (png_structp png_ptr);
png_int_32 png_get_int_32 (png_bytep buf);
png_uint_16 png_get_uint_16 (png_bytep buf);
png_uint_32 png_get_uint_32 (png_bytep buf);
void png_handle_bKGD (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_cHRM (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_gAMA (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_hIST (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_IEND (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_IHDR (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_oFFs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_pCAL (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_pHYs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_PLTE (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_sBIT (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_sRGB (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tEXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tIME (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_tRNS (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_handle_zTXt (png_structp png_ptr, png_infop info_ptr,
png_uint_32 length);
void png_info_destroy (png_structp png_ptr, png_infop
info_ptr);
void png_init_read_transformations (png_structp png_ptr);
void png_process_IDAT_data (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
void png_process_some_data (png_structp png_ptr, png_infop
info_ptr);
void png_push_check_crc (png_structp png_ptr);
void png_push_crc_finish (png_structp png_ptr);
void png_push_crc_skip (png_structp png_ptr, png_uint_32
length);
void png_push_fill_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t length);
void png_push_handle_tEXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_handle_unknown (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_handle_zTXt (png_structp png_ptr, png_infop
info_ptr, png_uint_32 length);
void png_push_have_end (png_structp png_ptr, png_infop
info_ptr);
void png_push_have_info (png_structp png_ptr, png_infop
info_ptr);
void png_push_have_row (png_structp png_ptr, png_bytep row);
void png_push_process_row (png_structp png_ptr);
void png_push_read_chunk (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_end (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_IDAT (png_structp png_ptr);
void png_push_read_sig (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_tEXt (png_structp png_ptr, png_infop
info_ptr);
void png_push_read_zTXt (png_structp png_ptr, png_infop
info_ptr);
void png_push_restore_buffer (png_structp png_ptr, png_bytep
buffer, png_size_t buffer_length);
void png_push_save_buffer (png_structp png_ptr);
void png_read_data (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_read_filter_row (png_structp png_ptr, png_row_infop
row_info, png_bytep row, png_bytep prev_row, int filter);
void png_read_finish_row (png_structp png_ptr);
void png_read_init (png_structp png_ptr);
void png_read_push_finish_row (png_structp png_ptr);
void png_read_start_row (png_structp png_ptr);
void png_read_transform_info (png_structp png_ptr, png_infop
info_ptr);
void png_reset_crc (png_structp png_ptr);
void png_save_int_32 (png_bytep buf, png_int_32 i);
void png_save_uint_16 (png_bytep buf, unsigned int i);
void png_save_uint_32 (png_bytep buf, png_uint_32 i);
void png_write_bKGD (png_structp png_ptr, png_color_16p values,
int color_type);
void png_write_cHRM (png_structp png_ptr, double white_x,
double white_y, double red_x, double red_y, double green_x,
double green_y, double blue_x, double blue_y);
void png_write_data (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_write_filtered_row (png_structp png_ptr, png_bytep
filtered_row);
void png_write_find_filter (png_structp png_ptr, png_row_infop
row_info);
void png_write_finish_row (png_structp png_ptr);
void png_write_gAMA (png_structp png_ptr, double file_gamma);
void png_write_hIST (png_structp png_ptr, png_uint_16p hist,
int num_hist);
void png_write_init (png_structp png_ptr);
void png_write_IDAT (png_structp png_ptr, png_bytep data,
png_size_t length);
void png_write_IEND (png_structp png_ptr);
void png_write_IHDR (png_structp png_ptr, png_uint_32 width,
png_uint_32 height, int bit_depth, int color_type, int
compression_type, int filter_type, int interlace_type);
void png_write_oFFs (png_structp png_ptr, png_uint_32 x_offset,
png_uint_32 y_offset, int unit_type);
void png_write_pCAL (png_structp png_ptr, png_charp purpose,
png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp
units, png_charpp params);
void png_write_pHYs (png_structp png_ptr, png_uint_32
x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int
unit_type);
void png_write_PLTE (png_structp png_ptr, png_colorp palette,
png_uint_32 num_pal);
void png_write_sBIT (png_structp png_ptr, png_color_8p sbit,
int color_type);
void png_write_sig (png_structp png_ptr);
void png_write_sRGB (png_structp png_ptr, int intent);
void png_write_start_row (png_structp png_ptr);
void png_write_tEXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len);
void png_write_tIME (png_structp png_ptr, png_timep mod_time);
void png_write_tRNS (png_structp png_ptr, png_bytep trans,
png_color_16p values, int number, int color_type);
void png_write_zTXt (png_structp png_ptr, png_charp key,
png_charp text, png_size_t text_len, int compression);
voidpf png_zalloc (voidpf png_ptr, uInt items, uInt size);
void png_zfree (voidpf png_ptr, voidpf ptr);
.SH DESCRIPTION
The functions listed above are used privately by libpng
and are not recommended for use by applications. They
are listed alphabetically here as an aid to libpng maintainers.
See png.h for more information on these functions.
.SH SEE ALSO
libpng(3), png(5)
.SH AUTHOR
Glenn Randers-Pehrson

View File

@ -1,80 +0,0 @@
# makefile for libpng
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
CC=cc
# CFLAGS=-I$(ZLIBINC) -O -fullwarn \
# -DPNG_NO_EASY_ACCESS
CFLAGS=-I$(ZLIBINC) -O -fullwarn \
-DPNG_READ_NOT_FULLY_SUPPORTED -DPNG_WRITE_NOT_FULLY_SUPPORTED
#CFLAGS=-I$(ZLIBINC) -O -fullwarn -DPNGTEST_MEMORY_DEBUG \
# -DPNG_READ_NOT_FULLY_SUPPORTED -DPNG_WRITE_NOT_FULLY_SUPPORTED \
# -DPNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED \
# -DPNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED \
# -DPNG_NO_STDIO
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=echo
#RANLIB=ranlib
# where make install puts libpng.a and png.h
prefix=/usr/local
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install: libpng.a
-@mkdir $(prefix)/include
-@mkdir $(prefix)/lib
cp png.h $(prefix)/include
cp pngconf.h $(prefix)/include
chmod 644 $(prefix)/include/png.h
chmod 644 $(prefix)/include/pngconf.h
cp libpng.a $(prefix)/lib
chmod 644 $(prefix)/lib/libpng.a
clean:
rm -f *.o libpng.a pngtest pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o: png.h pngconf.h
pngerror.o: png.h pngconf.h
pngrio.o: png.h pngconf.h
pngwio.o: png.h pngconf.h
pngmem.o: png.h pngconf.h
pngset.o: png.h pngconf.h
pngget.o: png.h pngconf.h
pngread.o: png.h pngconf.h
pngrtran.o: png.h pngconf.h
pngrutil.o: png.h pngconf.h
pngtest.o: png.h pngconf.h
pngtrans.o: png.h pngconf.h
pngwrite.o: png.h pngconf.h
pngwtran.o: png.h pngconf.h
pngwutil.o: png.h pngconf.h
pngpread.o: png.h pngconf.h

2
png.5
View File

@ -1,4 +1,4 @@
.TH PNG 5 "February 8, 1998"
.TH PNG 5 "February 28, 1998"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION

4
png.c
View File

@ -1,12 +1,12 @@
/* png.c - location for general purpose libpng functions
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL

41
png.h
View File

@ -1,12 +1,12 @@
/* png.h - header file for PNG reference library
*
* libpng 0.99d beta
* libpng 0.99e beta
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998 Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* Note about libpng version numbers:
*
@ -30,7 +30,7 @@
* 0.99a 0.99 2.0.99
* 0.99b 0.99 2.0.99
* 0.99c 0.99 2.0.99
* 0.99d 0.99 2.0.99
* 0.99e 0.99 2.0.99
* 1.0 1.00 2.1.0
*
* Henceforth the source version will match the shared-library minor
@ -65,6 +65,7 @@
* Guy Eric Schalnat
* Paul Schmidt
* Tom Tanner
* Willem van Schaik
* Tim Wegner
*
* The contributing authors would like to thank all those who helped
@ -708,6 +709,21 @@ extern PNG_EXPORT(png_structp,png_create_write_struct)
PNGARG((png_const_charp user_png_ver, voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn));
/* Write a PNG chunk - size, type, (optional) data, CRC. */
extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
png_bytep chunk_name, png_bytep data, png_size_t length));
/* Write the start of a PNG chunk - length and chunk name. */
extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
png_bytep chunk_name, png_uint_32 length));
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
/* Allocate and initialize the info structure */
extern PNG_EXPORT(png_infop,png_create_info_struct)
PNGARG((png_structp png_ptr));
@ -1200,6 +1216,10 @@ png_ptr, png_infop info_ptr));
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
png_ptr, png_infop info_ptr));
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
@ -1620,21 +1640,6 @@ PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
*/
PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
/* Write a PNG chunk - size, type, (optional) data, CRC. */
PNG_EXTERN void png_write_chunk PNGARG((png_structp png_ptr,
png_bytep chunk_name, png_bytep data, png_size_t length));
/* Write the start of a PNG chunk - length and chunk name. */
PNG_EXTERN void png_write_chunk_start PNGARG((png_structp png_ptr,
png_bytep chunk_name, png_uint_32 length));
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
PNG_EXTERN void png_write_chunk_data PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
PNG_EXTERN void png_write_chunk_end PNGARG((png_structp png_ptr));
/* simple function to write the signature */
PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));

View File

@ -1,12 +1,12 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
/* Any machine specific code is near the front of this file, so if you
@ -318,7 +318,7 @@ __dont__ include it again
/* very little testing */
/*
#define PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
*/
/* This is only for PowerPC big-endian and 680x0 systems */

View File

@ -1,12 +1,12 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file provides a location for all error handling. Users which
* need special error handling are expected to write replacement functions

185
pngget.c
View File

@ -1,12 +1,12 @@
/* pngget.c - retrieval of values from info struct
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL
@ -102,14 +102,47 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
return (0);
}
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 (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");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0);
else return (info_ptr->x_pixels_per_unit);
}
else
#endif
return (0);
}
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 (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");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0);
else return (info_ptr->y_pixels_per_unit);
}
else
#endif
return (0);
}
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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
return (0);
else return (info_ptr->x_pixels_per_unit);
}
@ -122,7 +155,7 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0)
@ -140,7 +173,7 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
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");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
@ -156,7 +189,7 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
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");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
@ -172,7 +205,7 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
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");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
@ -188,7 +221,7 @@ 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 (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs)
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");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
@ -200,9 +233,82 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
return (0);
}
/* png_get_channels really belongs in here, too, but it's been around longer */
#ifdef PNG_INCH_CONVERSIONS
png_uint_32
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
*.03937 +.5)
}
png_uint_32
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
*.03937 +.5)
}
png_uint_32
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
*.03937 +.5)
}
float
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
{
return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
*.03937/1000000. +.5)
}
float
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
{
return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
*.03937/1000000. +.5)
}
#if defined(PNG_READ_pHYs_SUPPORTED)
png_uint_32
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
retval |= PNG_INFO_pHYs;
}
if (res_y != NULL)
{
*res_y = info_ptr->y_pixels_per_unit;
retval |= PNG_INFO_pHYs;
}
if (unit_type != NULL)
{
*unit_type = (int)info_ptr->phys_unit_type;
retval |= PNG_INFO_pHYs;
if(unit_type == 1)
{
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * 39.37 + .50);
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * 39.37 + .50);
}
}
}
return (retval);
}
#endif
#endif /* PNG_INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
#endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte
png_get_channels(png_structp png_ptr, png_infop info_ptr)
{
@ -226,8 +332,8 @@ png_uint_32
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_color_16p *background)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_bKGD &&
background != NULL)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
&& background != NULL)
{
png_debug1(1, "in %s retrieval function\n", "bKGD");
*background = &(info_ptr->background);
@ -243,7 +349,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_cHRM)
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)
@ -272,8 +378,8 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
png_uint_32
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA &&
file_gamma != NULL)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& file_gamma != NULL)
{
png_debug1(1, "in %s retrieval function\n", "gAMA");
*file_gamma = (double)info_ptr->gamma;
@ -287,8 +393,8 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_uint_32
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB &&
file_srgb_intent != NULL)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
&& file_srgb_intent != NULL)
{
png_debug1(1, "in %s retrieval function\n", "sRGB");
*file_srgb_intent = (int)info_ptr->srgb_intent;
@ -302,8 +408,8 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_uint_32
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_hIST &&
hist != NULL)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
&& hist != NULL)
{
png_debug1(1, "in %s retrieval function\n", "hIST");
*hist = info_ptr->hist;
@ -364,8 +470,8 @@ 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)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs &&
offset_x != NULL && offset_y != NULL && unit_type != NULL)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
{
png_debug1(1, "in %s retrieval function\n", "oFFs");
*offset_x = info_ptr->x_offset;
@ -411,9 +517,13 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pHYs)
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL && res_y != NULL)
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
retval |= PNG_INFO_pHYs;
}
if (res_y != NULL)
{
*res_y = info_ptr->y_pixels_per_unit;
retval |= PNG_INFO_pHYs;
}
@ -422,9 +532,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
*unit_type = (int)info_ptr->phys_unit_type;
retval |= PNG_INFO_pHYs;
}
return (retval);
}
return (0);
return (retval);
}
#endif
@ -464,7 +573,7 @@ png_uint_32
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text)
{
if (png_ptr != NULL && info_ptr != NULL || info_ptr->num_text > 0)
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
png_debug1(1, "in %s retrieval function\n",
(png_ptr->chunk_name[0] == '\0' ? "text"
@ -499,25 +608,37 @@ png_uint_32
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep *trans, int *num_trans, png_color_16p *trans_values)
{
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{
png_debug1(1, "in %s retrieval function\n", "tRNS");
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE && trans != NULL)
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (trans != NULL)
{
*trans = info_ptr->trans;
retval |= PNG_INFO_tRNS;
}
else if (trans_values != NULL)
{
if (trans_values != NULL)
*trans_values = &(info_ptr->trans_values);
}
else
else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
{
return (0);
if (trans_values != NULL)
{
*trans_values = &(info_ptr->trans_values);
retval |= PNG_INFO_tRNS;
}
if(trans != NULL)
*trans = NULL;
}
if(num_trans != NULL)
{
*num_trans = info_ptr->num_trans;
return (PNG_INFO_tRNS);
retval |= PNG_INFO_tRNS;
}
return (0);
}
return (retval);
}
#endif

View File

@ -1,11 +1,11 @@
/* pngmem.c - stub functions for memory allocation
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file provides a location for all memory allocation. Users which
* need special memory handling are expected to modify the code in this file
@ -297,7 +297,7 @@ PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
# if defined(_MSC_VER) && defined(MAXSEG_64K)
ret = halloc(size, 1);
# else
ret = malloc(size);
ret = malloc((size_t)size);
# endif
#endif

View File

@ -1,12 +1,12 @@
/* pngpread.c - read a png file in push mode
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL

View File

@ -1,12 +1,12 @@
/* pngread.c - read a PNG file
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file contains routines that an application calls directly to
* read a PNG file or stream.

View File

@ -1,12 +1,12 @@
/* pngrio.c - functions for data input
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file provides a location for all input. Users which need
* special handling are expected to write a function which has the same

View File

@ -1,12 +1,12 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG.
@ -771,8 +771,9 @@ png_init_read_transformations(png_structp png_ptr)
}
}
}
else
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN)*/
else
/* color_type != PNG_COLOR_TYPE_PALETTE */
{
double g, gs, m;
@ -799,6 +800,7 @@ png_init_read_transformations(png_structp png_ptr)
if (color_type & PNG_COLOR_MASK_COLOR)
{
/* RGB or RGBA */
png_ptr->background_1.red = (png_uint_16)(pow(
(double)png_ptr->background.red / m, g) * m + .5);
png_ptr->background_1.green = (png_uint_16)(pow(
@ -814,6 +816,7 @@ png_init_read_transformations(png_structp png_ptr)
}
else
{
/* GRAY or GRAY ALPHA */
png_ptr->background_1.gray = (png_uint_16)(pow(
(double)png_ptr->background.gray / m, g) * m + .5);
png_ptr->background.gray = (png_uint_16)(pow(
@ -822,6 +825,7 @@ png_init_read_transformations(png_structp png_ptr)
}
}
else
/* transformation does not include PNG_BACKGROUND */
#endif
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
@ -844,6 +848,7 @@ png_init_read_transformations(png_structp png_ptr)
#endif
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
/* No GAMMA transformation */
if (png_ptr->transformations & PNG_BACKGROUND &&
color_type == PNG_COLOR_TYPE_PALETTE)
{
@ -1130,16 +1135,16 @@ png_do_read_transformations(png_structp png_ptr)
(png_uint_32)png_ptr->filler, png_ptr->flags);
#endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_READ_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
@ -1516,10 +1521,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row + row_info->rowbytes;
i < row_info->width; i++)
{
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
}
/* This inverts the alpha channel in RRGGBBAA */
@ -1531,20 +1536,20 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row + row_info->rowbytes;
i < row_info->width; i++)
{
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
/* This inverts the alpha channel in AG */
/* This inverts the alpha channel in GA */
if (row_info->bit_depth == 8)
{
png_bytep sp, dp;
@ -1553,11 +1558,11 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row + row_info->rowbytes;
i < row_info->width; i++)
{
*(--dp) = *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = *(--sp);
}
}
/* This inverts the alpha channel in AAGG */
/* This inverts the alpha channel in GGAA */
else
{
png_bytep sp, dp;
@ -1566,10 +1571,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row + row_info->rowbytes;
i < row_info->width; i++)
{
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = 255 - *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
}
}
@ -1919,7 +1924,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
back.green = (png_byte)png_ptr->background.green;
back.blue = (png_byte)png_ptr->background.blue;
for (i = 0; i < (int)png_ptr->num_trans && i < num_palette; i++)
for (i = 0; i < (int)png_ptr->num_trans; i++)
{
if (png_ptr->trans[i] == 0)
{
@ -1986,7 +1991,6 @@ png_do_background(png_row_infop row_info, png_bytep row,
{
case PNG_COLOR_TYPE_GRAY:
{
/* We currently don't do gamma correction for 2 and 4 bit */
switch (row_info->bit_depth)
{
case 1:

View File

@ -6,7 +6,7 @@
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file contains routines which are only called from within
* libpng itself during the course of reading an image.
@ -258,6 +258,20 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->mode |= PNG_HAVE_PLTE;
#if defined (PNG_READ_tRNS_SUPPORTED)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{
if (png_ptr->num_trans > png_ptr->num_palette)
{
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
png_ptr->num_trans = png_ptr->num_palette;
}
}
}
#endif
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{
@ -1419,8 +1433,8 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->chunk_name[0] & 0x20))
{
png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
}

View File

@ -1,12 +1,12 @@
/* pngset.c - storage of image information into info struct
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data

View File

@ -1,12 +1,12 @@
/* pngtest.c - a simple test program to test libpng
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This program reads in a PNG image, writes it out again, and then
* compares the two files. If the files are identical, this shows that
@ -37,10 +37,6 @@
#include "png.h"
#ifdef PNGTEST_MEMORY_DEBUG
#include <unistd.h>
#endif
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
#ifdef __TURBOC__
@ -52,6 +48,7 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
#define STDERR stdout /* for DOS */
static int verbose = 0;
static int wrote_question = 0;
#if defined(PNG_NO_STDIO)
/* START of code to validate stdio-free compilation */
@ -686,9 +683,20 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
fprintf(STDERR, "Files %s and %s are of a different size\n",
inname, outname);
if(wrote_question == 0)
{
fprintf(STDERR,
" Was %s written with the same chunk size (8k),",inname);
fprintf(STDERR,
" filtering\n heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default)\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question=1;
}
fclose(fpin);
fclose(fpout);
return (1);
return (0);
}
if (!num_in)
@ -697,9 +705,20 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (png_memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "Files %s and %s are different\n", inname, outname);
if(wrote_question == 0)
{
fprintf(STDERR,
" Was %s written with the same chunk size (8k),",inname);
fprintf(STDERR,
" filtering\n heuristic (libpng default), compression");
fprintf(STDERR,
" level (zlib default)\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question=1;
}
fclose(fpin);
fclose(fpout);
return (1);
return (0);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -1,12 +1,12 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL

View File

@ -1,12 +1,12 @@
/* pngwio.c - functions for data output
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*
* This file provides a location for all output. Users which need
* special handling are expected to write functions which have the same

View File

@ -1,12 +1,12 @@
/* pngwrite.c - general routines to write a PNG file
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
/* get internal access to png.h */

View File

@ -1,12 +1,12 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL
@ -42,14 +42,14 @@ png_do_write_transformations(png_structp png_ptr)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_ALPHA)
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR)
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
@ -227,7 +227,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
channels++;
}
/* with low row dephts, could only be grayscale, so one channel */
/* with low row depths, could only be grayscale, so one channel */
if (row_info->bit_depth < 8)
{
png_bytep bp;

View File

@ -1,12 +1,12 @@
/* pngwutil.c - utilities to write a PNG file
*
* libpng 0.99d
* libpng 0.99e
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson
* February 8, 1998
* February 28, 1998
*/
#define PNG_INTERNAL