Imported from libpng-0.99d.tar

This commit is contained in:
Glenn Randers-Pehrson 1998-02-08 20:56:40 -06:00
parent 0f881d62b3
commit a357b99113
24 changed files with 3267 additions and 1198 deletions

12
CHANGES
View File

@ -223,5 +223,13 @@ version 0.99b [February 4, 1998]
version 0.99c [February 7, 1998] version 0.99c [February 7, 1998]
More type casting. Removed erroneous overflow test in pngmem.c. More type casting. Removed erroneous overflow test in pngmem.c.
Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes.
Added UNIX manual pages libpng.3, initially created by R. P. C. Rodgers, Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5.
U.S. National Library of Medicine (rodgers@nlm.nih.gov), and png.5. version 0.99d [February 8, 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.

2
README
View File

@ -1,4 +1,4 @@
[NOTE: this is still beta version 0.99c; the text below has already [NOTE: this is still beta version 0.99d; the text below has already
been updated in anticipation of the imminent 1.0 release.] been updated in anticipation of the imminent 1.0 release.]

2632
libpng.3

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
png.5
View File

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

5
png.c
View File

@ -1,12 +1,12 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -200,6 +200,7 @@ png_create_info_struct(png_structp png_ptr)
png_infop info_ptr; png_infop info_ptr;
png_debug(1, "in png_create_info_struct\n"); png_debug(1, "in png_create_info_struct\n");
if(png_ptr == NULL) return (NULL);
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL)
{ {
png_info_init(info_ptr); png_info_init(info_ptr);

16
png.h
View File

@ -1,12 +1,12 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng 0.99c beta * libpng 0.99d beta
* For conditions of distribution and use, see the COPYRIGHT NOTICE below. * For conditions of distribution and use, see the COPYRIGHT NOTICE below.
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998 Glenn Randers-Pehrson * Copyright (c) 1998 Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* Note about libpng version numbers: * Note about libpng version numbers:
* *
@ -30,6 +30,7 @@
* 0.99a 0.99 2.0.99 * 0.99a 0.99 2.0.99
* 0.99b 0.99 2.0.99 * 0.99b 0.99 2.0.99
* 0.99c 0.99 2.0.99 * 0.99c 0.99 2.0.99
* 0.99d 0.99 2.0.99
* 1.0 1.00 2.1.0 * 1.0 1.00 2.1.0
* *
* Henceforth the source version will match the shared-library minor * Henceforth the source version will match the shared-library minor
@ -1109,10 +1110,10 @@ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
/* frees a pointer allocated by png_malloc() */ /* frees a pointer allocated by png_malloc() */
extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
extern PNG_EXPORT(void,png_buffered_memcpy) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
png_voidp s1, png_voidp s2, png_uint_32 size)); png_voidp s1, png_voidp s2, png_uint_32 size));
extern PNG_EXPORT(void,png_buffered_memset) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
png_voidp s1, int value, png_uint_32 size)); png_voidp s1, int value, png_uint_32 size));
#ifdef PNGTEST_MEMORY_DEBUG #ifdef PNGTEST_MEMORY_DEBUG
@ -1123,7 +1124,8 @@ extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
png_voidp ptr)); png_voidp ptr));
#endif #endif
#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ #if defined(USE_FAR_KEYWORD) /* memory model conversion function */
extern void *far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,int check)); extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
int check));
#endif /* USE_FAR_KEYWORD */ #endif /* USE_FAR_KEYWORD */
/* Fatal error in PNG image of libpng - can't continue */ /* Fatal error in PNG image of libpng - can't continue */
@ -1475,8 +1477,8 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#define PNG_FLAG_FREE_PALETTE 0x1000 #define PNG_FLAG_FREE_PALETTE 0x1000
#define PNG_FLAG_FREE_TRANS 0x2000 #define PNG_FLAG_FREE_TRANS 0x2000
#define PNG_FLAG_FREE_HIST 0x4000 #define PNG_FLAG_FREE_HIST 0x4000
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000 #define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
#define PNG_FLAG_WROTE_tIME 0x10000 #define PNG_FLAG_WROTE_tIME 0x10000L
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN) PNG_FLAG_CRC_ANCILLARY_NOWARN)

View File

@ -1,12 +1,12 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
/* Any machine specific code is near the front of this file, so if you /* Any machine specific code is near the front of this file, so if you
@ -525,8 +525,8 @@ typedef z_stream FAR * png_zstreamp;
/* use this to make far-to-near assignments */ /* use this to make far-to-near assignments */
# define CHECK 1 # define CHECK 1
# define NOCHECK 0 # define NOCHECK 0
# define CVT_PTR(ptr) (far_to_near(png_ptr,ptr,CHECK)) # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
# define CVT_PTR_NOCHECK(ptr) (far_to_near(png_ptr,ptr,NOCHECK)) # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
# define png_strlen _fstrlen # define png_strlen _fstrlen
# define png_memcmp _fmemcmp /* SJT: added */ # define png_memcmp _fmemcmp /* SJT: added */
# define png_memcpy _fmemcpy # define png_memcpy _fmemcpy

View File

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

View File

@ -1,12 +1,12 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -15,7 +15,7 @@
png_uint_32 png_uint_32
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->valid & flag); return(info_ptr->valid & flag);
else else
return(0); return(0);
@ -24,7 +24,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
png_uint_32 png_uint_32
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes); return(info_ptr->rowbytes);
else else
return(0); return(0);
@ -35,7 +35,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
png_uint_32 png_uint_32
png_get_image_width(png_structp png_ptr, png_infop info_ptr) png_get_image_width(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->width; return info_ptr->width;
} }
@ -45,7 +45,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
png_uint_32 png_uint_32
png_get_image_height(png_structp png_ptr, png_infop info_ptr) png_get_image_height(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->height; return info_ptr->height;
} }
@ -55,7 +55,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->bit_depth; return info_ptr->bit_depth;
} }
@ -65,7 +65,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_color_type(png_structp png_ptr, png_infop info_ptr) png_get_color_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->color_type; return info_ptr->color_type;
} }
@ -75,7 +75,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_filter_type(png_structp png_ptr, png_infop info_ptr) png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->filter_type; return info_ptr->filter_type;
} }
@ -85,7 +85,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->interlace_type; return info_ptr->interlace_type;
} }
@ -95,7 +95,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_compression_type(png_structp png_ptr, png_infop info_ptr) png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
{ {
return info_ptr->compression_type; return info_ptr->compression_type;
} }
@ -106,7 +106,7 @@ png_uint_32
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED) #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
if (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"); 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)
@ -122,7 +122,7 @@ float
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED) #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
if (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"); png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0) if (info_ptr->x_pixels_per_unit == 0)
@ -140,7 +140,7 @@ png_uint_32
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
if (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"); png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
@ -156,7 +156,7 @@ png_uint_32
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
if (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"); png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
@ -172,7 +172,7 @@ png_uint_32
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
if (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"); png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
@ -188,7 +188,7 @@ png_uint_32
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
if (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"); png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
@ -206,7 +206,7 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_byte png_byte
png_get_channels(png_structp png_ptr, png_infop info_ptr) png_get_channels(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->channels); return(info_ptr->channels);
else else
return (0); return (0);
@ -215,7 +215,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
png_bytep png_bytep
png_get_signature(png_structp png_ptr, png_infop info_ptr) png_get_signature(png_structp png_ptr, png_infop info_ptr)
{ {
if (info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->signature); return(info_ptr->signature);
else else
return (NULL); return (NULL);
@ -226,7 +226,7 @@ png_uint_32
png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_color_16p *background) png_color_16p *background)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_bKGD && if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_bKGD &&
background != NULL) background != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "bKGD"); png_debug1(1, "in %s retrieval function\n", "bKGD");
@ -243,7 +243,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 *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y) double *green_x, double *green_y, double *blue_x, double *blue_y)
{ {
if (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"); png_debug1(1, "in %s retrieval function\n", "cHRM");
if (white_x != NULL) if (white_x != NULL)
@ -272,7 +272,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
png_uint_32 png_uint_32
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA && if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_gAMA &&
file_gamma != NULL) file_gamma != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "gAMA"); png_debug1(1, "in %s retrieval function\n", "gAMA");
@ -287,7 +287,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_uint_32 png_uint_32
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB && if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sRGB &&
file_srgb_intent != NULL) file_srgb_intent != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "sRGB"); png_debug1(1, "in %s retrieval function\n", "sRGB");
@ -302,7 +302,8 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_uint_32 png_uint_32
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
{ {
if (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"); png_debug1(1, "in %s retrieval function\n", "hIST");
*hist = info_ptr->hist; *hist = info_ptr->hist;
@ -319,10 +320,9 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
int *filter_type) int *filter_type)
{ {
if (info_ptr != NULL && width != NULL && height != NULL && if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
bit_depth != NULL && color_type != NULL) bit_depth != NULL && color_type != NULL)
{ {
png_uint_32 rowbytes;
int pixel_depth, channels; int pixel_depth, channels;
png_uint_32 rowbytes_per_pixel; png_uint_32 rowbytes_per_pixel;
@ -349,7 +349,6 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
channels++; channels++;
pixel_depth = *bit_depth * channels; pixel_depth = *bit_depth * channels;
rowbytes_per_pixel = (pixel_depth + 7) >> 3; rowbytes_per_pixel = (pixel_depth + 7) >> 3;
rowbytes = *width * rowbytes_per_pixel;
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel)) if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
{ {
png_warning(png_ptr, png_warning(png_ptr,
@ -365,7 +364,7 @@ png_uint_32
png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type) png_uint_32 *offset_x, png_uint_32 *offset_y, int *unit_type)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs && if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_oFFs &&
offset_x != NULL && offset_y != NULL && unit_type != NULL) offset_x != NULL && offset_y != NULL && unit_type != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "oFFs"); png_debug1(1, "in %s retrieval function\n", "oFFs");
@ -384,7 +383,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params) png_charp *units, png_charpp *params)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL && if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_pCAL &&
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
nparams != NULL && units != NULL && params != NULL) nparams != NULL && units != NULL && params != NULL)
{ {
@ -409,7 +408,7 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
{ {
png_uint_32 retval = 0; png_uint_32 retval = 0;
if (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", "pHYs"); png_debug1(1, "in %s retrieval function\n", "pHYs");
if (res_x != NULL && res_y != NULL) if (res_x != NULL && res_y != NULL)
@ -433,7 +432,8 @@ png_uint_32
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
int *num_palette) int *num_palette)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE && palette != NULL) if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_PLTE &&
palette != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "PLTE"); png_debug1(1, "in %s retrieval function\n", "PLTE");
*palette = info_ptr->palette; *palette = info_ptr->palette;
@ -448,7 +448,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
png_uint_32 png_uint_32
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT && sig_bit != NULL) if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_sBIT &&
sig_bit != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "sBIT"); png_debug1(1, "in %s retrieval function\n", "sBIT");
*sig_bit = &(info_ptr->sig_bit); *sig_bit = &(info_ptr->sig_bit);
@ -463,7 +464,7 @@ png_uint_32
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text) int *num_text)
{ {
if ((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_debug1(1, "in %s retrieval function\n",
(png_ptr->chunk_name[0] == '\0' ? "text" (png_ptr->chunk_name[0] == '\0' ? "text"
@ -482,7 +483,8 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
png_uint_32 png_uint_32
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME && mod_time != NULL) if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tIME &&
mod_time != NULL)
{ {
png_debug1(1, "in %s retrieval function\n", "tIME"); png_debug1(1, "in %s retrieval function\n", "tIME");
*mod_time = &(info_ptr->mod_time); *mod_time = &(info_ptr->mod_time);
@ -497,7 +499,7 @@ png_uint_32
png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep *trans, int *num_trans, png_color_16p *trans_values) png_bytep *trans, int *num_trans, png_color_16p *trans_values)
{ {
if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS) if (png_ptr != NULL && info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{ {
png_debug1(1, "in %s retrieval function\n", "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 && trans != NULL)

View File

@ -1,11 +1,11 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file provides a location for all memory allocation. Users which * This file provides a location for all memory allocation. Users which
* need special memory handling are expected to modify the code in this file * need special memory handling are expected to modify the code in this file
@ -282,27 +282,22 @@ png_voidp
PNG_MALLOC(png_structp png_ptr, png_uint_32 size) PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
{ {
png_voidp ret; png_voidp ret;
png_size_t length;
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL); return ((png_voidp)NULL);
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if (png_size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
png_error(png_ptr, "Cannot Allocate > 64K"); png_error(png_ptr, "Cannot Allocate > 64K");
#endif #endif
length = (png_size_t)size;
if ((png_uint_32)length != size)
png_error(png_ptr, "Cannot Allocate > size_t");
#if defined(__TURBOC__) && !defined(__FLAT__) #if defined(__TURBOC__) && !defined(__FLAT__)
ret = farmalloc(length); ret = farmalloc(size);
#else #else
# if defined(_MSC_VER) && defined(MAXSEG_64K) # if defined(_MSC_VER) && defined(MAXSEG_64K)
ret = halloc(length, 1); ret = halloc(size, 1);
# else # else
ret = malloc(length); ret = malloc(size);
# endif # endif
#endif #endif
@ -336,32 +331,29 @@ PNG_FREE(png_structp png_ptr, png_voidp ptr)
#endif /* Not Borland DOS special memory handler */ #endif /* Not Borland DOS special memory handler */
void png_voidp
png_buffered_memcpy (png_structp png_ptr, png_voidp s1, png_voidp s2, png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
png_uint_32 length) png_uint_32 length)
{ {
png_size_t size; png_size_t size;
png_uint_32 i;
for (i=0; i<length; i+=65530) size = (png_size_t)length;
{ if ((png_uint_32)size != length)
size = (png_size_t)(length - i); png_error(png_ptr,"Overflow in png_memcpy_check.");
if (size > (png_size_t)65530L)
size=(png_size_t)65530L; return(png_memcpy (s1, s2, size));
png_memcpy (s1, s2, size);
}
} }
void png_voidp
png_buffered_memset (png_structp png_ptr, png_voidp s1, int value, png_memset_check (png_structp png_ptr, png_voidp s1, int value,
png_uint_32 length) png_uint_32 length)
{ {
png_size_t size; png_size_t size;
png_uint_32 i;
for (i=0; i<length; i+=65530) size = (png_size_t)length;
{ if ((png_uint_32)size != length)
size = length - i; png_error(png_ptr,"Overflow in png_memset_check.");
if (size > 65530)
size=65530; return (png_memset (s1, value, size));
png_memset (s1, value, size);
}
} }

View File

@ -1,12 +1,12 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -638,7 +638,7 @@ png_push_process_row(png_structp png_ptr)
png_ptr->row_buf + 1, png_ptr->prev_row + 1, png_ptr->row_buf + 1, png_ptr->prev_row + 1,
(int)(png_ptr->row_buf[0])); (int)(png_ptr->row_buf[0]));
png_buffered_memcpy(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1); png_ptr->rowbytes + 1);
if (png_ptr->transformations) if (png_ptr->transformations)
@ -774,8 +774,8 @@ png_read_push_finish_row(png_structp png_ptr)
if (png_ptr->interlaced) if (png_ptr->interlaced)
{ {
png_ptr->row_number = 0; png_ptr->row_number = 0;
png_buffered_memset(png_ptr, png_ptr->prev_row, 0, png_memset_check(png_ptr, png_ptr->prev_row, 0,
(png_size_t)png_ptr->rowbytes + 1); png_ptr->rowbytes + 1);
do do
{ {
png_ptr->pass++; png_ptr->pass++;
@ -806,7 +806,11 @@ void
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND) if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
png_error(png_ptr, "Out of place tEXt"); {
png_error(png_ptr, "Out of place tEXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
}
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */ png_ptr->skip_length = 0; /* This may not be necessary */
@ -888,7 +892,11 @@ void
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND) if (png_ptr->mode == PNG_BEFORE_IHDR || png_ptr->mode & PNG_HAVE_IEND)
png_error(png_ptr, "Out of place zTXt"); {
png_error(png_ptr, "Out of place zTXt");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
}
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
/* We can't handle zTXt chunks > 64K, since we don't have enough space /* We can't handle zTXt chunks > 64K, since we don't have enough space
@ -1073,6 +1081,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
{ {
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet some compiler warnings */
if(info_ptr == NULL) return;
} }
png_push_crc_skip(png_ptr, length); png_push_crc_skip(png_ptr, length);

View File

@ -1,12 +1,12 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file contains routines that an application calls directly to * This file contains routines that an application calls directly to
* read a PNG file or stream. * read a PNG file or stream.
@ -418,7 +418,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_ptr->row_buf + 1, png_ptr->prev_row + 1, png_ptr->row_buf + 1, png_ptr->prev_row + 1,
(int)(png_ptr->row_buf[0])); (int)(png_ptr->row_buf[0]));
png_buffered_memcpy(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1); png_ptr->rowbytes + 1);
if (png_ptr->transformations) if (png_ptr->transformations)

View File

@ -1,12 +1,12 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file provides a location for all input. Users which need * This file provides a location for all input. Users which need
* special handling are expected to write a function which has the same * 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 /* pngrtran.c - transforms the data in a row for PNG readers
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file contains functions optionally called by an application * This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG. * in order to tell libpng how to handle data when reading a PNG.
@ -1913,24 +1913,21 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
{ {
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
int i;
png_color back; png_color back;
back.red = (png_byte)png_ptr->background.red; back.red = (png_byte)png_ptr->background.red;
back.green = (png_byte)png_ptr->background.green; back.green = (png_byte)png_ptr->background.green;
back.blue = (png_byte)png_ptr->background.blue; back.blue = (png_byte)png_ptr->background.blue;
for (i = 0; i < num_palette; i++) for (i = 0; i < (int)png_ptr->num_trans && i < num_palette; i++)
{ {
if (i >= (int)png_ptr->num_trans || if (png_ptr->trans[i] == 0)
png_ptr->trans[i] == 0)
{ {
palette[i].red = back.red; palette[i].red = back.red;
palette[i].green = back.green; palette[i].green = back.green;
palette[i].blue = back.blue; palette[i].blue = back.blue;
} }
else if (i < (int)png_ptr->num_trans || else if (png_ptr->trans[i] != 0xff)
png_ptr->trans[i] != 0xff)
{ {
png_composite(palette[i].red, png_ptr->palette[i].red, png_composite(palette[i].red, png_ptr->palette[i].red,
png_ptr->trans[i], back.red); png_ptr->trans[i], back.red);

View File

@ -6,7 +6,7 @@
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file contains routines which are only called from within * This file contains routines which are only called from within
* libpng itself during the course of reading an image. * libpng itself during the course of reading an image.
@ -345,6 +345,10 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
{ {
png_error(png_ptr, "No image in file"); png_error(png_ptr, "No image in file");
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
} }
png_ptr->mode |= PNG_AFTER_IDAT | PNG_HAVE_IEND; png_ptr->mode |= PNG_AFTER_IDAT | PNG_HAVE_IEND;
@ -722,7 +726,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS) else if (info_ptr != NULL && info_ptr->valid & PNG_INFO_tRNS)
{ {
png_warning(png_ptr, "Duplcate tRNS chunk"); png_warning(png_ptr, "Duplicate tRNS chunk");
png_crc_finish(png_ptr, length); png_crc_finish(png_ptr, length);
return; return;
} }
@ -1022,6 +1026,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_byte type, nparams; png_byte type, nparams;
png_charp buf, units, endptr; png_charp buf, units, endptr;
png_charpp params; png_charpp params;
png_size_t slength;
int i; int i;
png_debug(1, "in png_handle_pCAL\n"); png_debug(1, "in png_handle_pCAL\n");
@ -1044,7 +1049,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(2, "Allocating and reading pCAL chunk data (%d bytes)\n", png_debug1(2, "Allocating and reading pCAL chunk data (%d bytes)\n",
length + 1); length + 1);
purpose = (png_charp)png_malloc(png_ptr, length + 1); purpose = (png_charp)png_malloc(png_ptr, length + 1);
png_crc_read(png_ptr, (png_bytep)purpose, (png_size_t)length); slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)purpose, slength);
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
{ {
@ -1052,13 +1058,13 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return; return;
} }
purpose[length] = '\0'; /* null terminate the last string */ purpose[slength] = 0x00; /* null terminate the last string */
png_debug(3, "Finding end of pCAL purpose string\n"); png_debug(3, "Finding end of pCAL purpose string\n");
for (buf = purpose; *buf != '\0'; buf++) for (buf = purpose; *buf != '\0'; buf++)
/* empty loop */; /* empty loop */;
endptr = purpose + length; endptr = purpose + slength;
/* We need to have at least 12 bytes after the purpose string /* We need to have at least 12 bytes after the purpose string
in order to get the parameter information. */ in order to get the parameter information. */
@ -1094,7 +1100,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
/* Empty loop to move past the units string. */ /* Empty loop to move past the units string. */
for (buf = units; *buf != '\0'; buf++); for (buf = units; *buf != 0x00; buf++);
png_debug(3, "Allocating pCAL parameters array\n"); png_debug(3, "Allocating pCAL parameters array\n");
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
@ -1107,7 +1113,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(3, "Reading pCAL parameter %d\n", i); png_debug1(3, "Reading pCAL parameter %d\n", i);
/* Empty loop to move past each paramter string */ /* Empty loop to move past each paramter string */
for (params[i] = buf; *buf != '\0' && buf <= endptr; buf++); for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++);
/* Make sure we haven't run out of data yet */ /* Make sure we haven't run out of data yet */
if (buf > endptr) if (buf > endptr)
@ -1179,6 +1185,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp key; png_charp key;
png_charp text; png_charp text;
png_uint_32 skip = 0; png_uint_32 skip = 0;
png_size_t slength;
png_debug(1, "in png_handle_tEXt\n"); png_debug(1, "in png_handle_tEXt\n");
@ -1198,7 +1205,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
key = (png_charp)png_malloc(png_ptr, length + 1); key = (png_charp)png_malloc(png_ptr, length + 1);
png_crc_read(png_ptr, (png_bytep)key, (png_size_t)length); slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)key, slength);
if (png_crc_finish(png_ptr, skip)) if (png_crc_finish(png_ptr, skip))
{ {
@ -1206,12 +1214,12 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return; return;
} }
key[length] = '\0'; key[slength] = 0x00;
for (text = key; *text; text++) for (text = key; *text; text++)
/* empty loop to find end of key */ ; /* empty loop to find end of key */ ;
if (text != key + (png_size_t)length) if (text != key + slength)
text++; text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
@ -1235,6 +1243,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp key; png_charp key;
png_charp text; png_charp text;
int comp_type = PNG_TEXT_COMPRESSION_NONE; int comp_type = PNG_TEXT_COMPRESSION_NONE;
png_size_t slength;
png_debug(1, "in png_handle_zTXt\n"); png_debug(1, "in png_handle_zTXt\n");
@ -1256,20 +1265,21 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
key = (png_charp)png_malloc(png_ptr, length + 1); key = (png_charp)png_malloc(png_ptr, length + 1);
png_crc_read(png_ptr, (png_bytep)key, (png_size_t)length); slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)key, slength);
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
{ {
png_free(png_ptr, key); png_free(png_ptr, key);
return; return;
} }
key[length] = '\0'; key[slength] = 0x00;
for (text = key; *text; text++) for (text = key; *text; text++)
/* empty loop */ ; /* empty loop */ ;
/* zTXt must have some text after the keyword */ /* zTXt must have some text after the keyword */
if (text == key + (png_size_t)length) if (text == key + slength)
{ {
png_warning(png_ptr, "Zero length zTXt chunk"); png_warning(png_ptr, "Zero length zTXt chunk");
} }
@ -1283,7 +1293,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size; png_ptr->zstream.avail_out = png_ptr->zbuf_size;
key_size = text - key; key_size = (png_size_t)(text - key);
text_size = 0; text_size = 0;
text = NULL; text = NULL;
@ -1308,10 +1318,10 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_memcpy(text, key, key_size); png_memcpy(text, key, key_size);
} }
text[text_size - 1] = '\0'; text[text_size - 1] = 0x00;
/* Copy what we can of the error message into the text chunk */ /* Copy what we can of the error message into the text chunk */
text_size = (png_size_t)length - (text - key) - 1; text_size = (png_size_t)(slength - (text - key) - 1);
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg); text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
png_memcpy(text + key_size, msg, text_size + 1); png_memcpy(text + key_size, msg, text_size + 1);
break; break;
@ -1328,7 +1338,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_memcpy(text, key, key_size); png_memcpy(text, key, key_size);
text_size = key_size + png_ptr->zbuf_size - text_size = key_size + png_ptr->zbuf_size -
png_ptr->zstream.avail_out; png_ptr->zstream.avail_out;
*(text + text_size) = '\0'; *(text + text_size) = 0x00;
} }
else else
{ {
@ -1342,7 +1352,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_memcpy(text + text_size, png_ptr->zbuf, png_memcpy(text + text_size, png_ptr->zbuf,
(png_ptr->zbuf_size - png_ptr->zstream.avail_out)); (png_ptr->zbuf_size - png_ptr->zstream.avail_out));
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
*(text + text_size) = '\0'; *(text + text_size) = 0x00;
} }
if (ret != Z_STREAM_END) if (ret != Z_STREAM_END)
{ {
@ -1376,7 +1386,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
/* Copy what we can of the error message into the text chunk */ /* Copy what we can of the error message into the text chunk */
text_size = (png_size_t)length - (text - key) - 1; text_size = (png_size_t)(slength - (text - key) - 1);
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg); text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
png_memcpy(text, msg, text_size + 1); png_memcpy(text, msg, text_size + 1);
} }
@ -1409,12 +1419,17 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
{ {
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
} }
if (png_ptr->mode & PNG_HAVE_IDAT) if (png_ptr->mode & PNG_HAVE_IDAT)
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;
png_crc_finish(png_ptr, length); png_crc_finish(png_ptr, length);
} }
/* This function is called to verify that a chunk name is valid. /* This function is called to verify that a chunk name is valid.
@ -1847,8 +1862,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
pixel_bytes = (row_info->pixel_depth >> 3); pixel_bytes = (row_info->pixel_depth >> 3);
sp = row + (row_info->width - 1) * pixel_bytes; sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
dp = row + (final_width - 1) * pixel_bytes; dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
for (i = row_info->width; i; i--) for (i = row_info->width; i; i--)
{ {
png_byte v[8]; png_byte v[8];
@ -1993,7 +2008,7 @@ png_read_finish_row(png_structp png_ptr)
if (png_ptr->interlaced) if (png_ptr->interlaced)
{ {
png_ptr->row_number = 0; png_ptr->row_number = 0;
png_buffered_memset(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
do do
{ {
png_ptr->pass++; png_ptr->pass++;
@ -2203,7 +2218,7 @@ png_read_start_row(png_structp png_ptr)
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1)); png_ptr->rowbytes + 1));
png_buffered_memset(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %d,\n", png_ptr->width); png_debug1(3, "width = %d,\n", png_ptr->width);
png_debug1(3, "height = %d,\n", png_ptr->height); png_debug1(3, "height = %d,\n", png_ptr->height);

View File

@ -1,12 +1,12 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* The functions here are used during reads to store data from the file * The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data * into the info struct, and during writes to store application data
@ -22,7 +22,7 @@ void
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
{ {
png_debug1(1, "in %s storage function\n", "bKGD"); png_debug1(1, "in %s storage function\n", "bKGD");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
png_memcpy(&(info_ptr->background), background, sizeof(png_color_16)); png_memcpy(&(info_ptr->background), background, sizeof(png_color_16));
@ -37,7 +37,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double green_x, double green_y, double blue_x, double blue_y) double green_x, double green_y, double blue_x, double blue_y)
{ {
png_debug1(1, "in %s storage function\n", "cHRM"); png_debug1(1, "in %s storage function\n", "cHRM");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->x_white = (float)white_x; info_ptr->x_white = (float)white_x;
@ -57,7 +57,7 @@ void
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{ {
png_debug1(1, "in %s storage function\n", "gAMA"); png_debug1(1, "in %s storage function\n", "gAMA");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->gamma = (float)file_gamma; info_ptr->gamma = (float)file_gamma;
@ -70,7 +70,7 @@ void
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
{ {
png_debug1(1, "in %s storage function\n", "hIST"); png_debug1(1, "in %s storage function\n", "hIST");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->hist = hist; info_ptr->hist = hist;
@ -86,7 +86,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
{ {
int rowbytes_per_pixel; int rowbytes_per_pixel;
png_debug1(1, "in %s storage function\n", "IHDR"); png_debug1(1, "in %s storage function\n", "IHDR");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->width = width; info_ptr->width = width;
@ -123,7 +123,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type) png_uint_32 offset_x, png_uint_32 offset_y, int unit_type)
{ {
png_debug1(1, "in %s storage function\n", "oFFs"); png_debug1(1, "in %s storage function\n", "oFFs");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->x_offset = offset_x; info_ptr->x_offset = offset_x;
@ -140,10 +140,10 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_charp units, png_charpp params) png_charp units, png_charpp params)
{ {
png_uint_32 length; png_uint_32 length;
png_uint_32 i; int i;
png_debug1(1, "in %s storage function\n", "pCAL"); png_debug1(1, "in %s storage function\n", "pCAL");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
length = png_strlen(purpose) + 1; length = png_strlen(purpose) + 1;
@ -184,7 +184,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type) png_uint_32 res_x, png_uint_32 res_y, int unit_type)
{ {
png_debug1(1, "in %s storage function\n", "pHYs"); png_debug1(1, "in %s storage function\n", "pHYs");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->x_pixels_per_unit = res_x; info_ptr->x_pixels_per_unit = res_x;
@ -199,7 +199,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
png_colorp palette, int num_palette) png_colorp palette, int num_palette)
{ {
png_debug1(1, "in %s storage function\n", "PLTE"); png_debug1(1, "in %s storage function\n", "PLTE");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->palette = palette; info_ptr->palette = palette;
@ -213,7 +213,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit) png_color_8p sig_bit)
{ {
png_debug1(1, "in %s storage function\n", "sBIT"); png_debug1(1, "in %s storage function\n", "sBIT");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8)); png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8));
@ -226,7 +226,7 @@ void
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{ {
png_debug1(1, "in %s storage function\n", "sRGB"); png_debug1(1, "in %s storage function\n", "sRGB");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->srgb_intent = (png_byte)intent; info_ptr->srgb_intent = (png_byte)intent;
@ -243,7 +243,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
#endif #endif
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
png_set_sRGB(png_ptr, info_ptr, intent); png_set_sRGB(png_ptr, info_ptr, intent);
@ -281,7 +281,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
"text" : (png_const_charp)png_ptr->chunk_name)); "text" : (png_const_charp)png_ptr->chunk_name));
if (info_ptr == NULL || num_text == 0) if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
return; return;
/* Make sure we have enough space in the "text" array in info_struct /* Make sure we have enough space in the "text" array in info_struct
@ -298,7 +298,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->max_text = info_ptr->num_text + num_text + 8; info_ptr->max_text = info_ptr->num_text + num_text + 8;
old_text = info_ptr->text; old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc(png_ptr, info_ptr->text = (png_textp)png_malloc(png_ptr,
info_ptr->max_text * sizeof (png_text)); (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
sizeof(png_text))); sizeof(png_text)));
png_free(png_ptr, old_text); png_free(png_ptr, old_text);
@ -344,7 +344,7 @@ void
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{ {
png_debug1(1, "in %s storage function\n", "tIME"); png_debug1(1, "in %s storage function\n", "tIME");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time)); png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time));
@ -358,7 +358,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values) png_bytep trans, int num_trans, png_color_16p trans_values)
{ {
png_debug1(1, "in %s storage function\n", "tRNS"); png_debug1(1, "in %s storage function\n", "tRNS");
if (info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (trans != NULL) if (trans != NULL)

View File

@ -1,12 +1,12 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This program reads in a PNG image, writes it out again, and then * 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 * compares the two files. If the files are identical, this shows that
@ -39,7 +39,6 @@
#ifdef PNGTEST_MEMORY_DEBUG #ifdef PNGTEST_MEMORY_DEBUG
#include <unistd.h> #include <unistd.h>
void *sbrk (ssize_t incr);
#endif #endif
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname); int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
@ -857,7 +856,6 @@ main(int argc, char *argv[])
pinfo = pinfo->next; pinfo = pinfo->next;
} }
} }
fprintf(STDERR, "sbrk(0)=%d\n",sbrk(0));
#endif #endif
} }
#ifdef PNGTEST_MEMORY_DEBUG #ifdef PNGTEST_MEMORY_DEBUG

View File

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

View File

@ -1,12 +1,12 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
* *
* This file provides a location for all output. Users which need * This file provides a location for all output. Users which need
* special handling are expected to write functions which have the same * special handling are expected to write functions which have the same
@ -180,7 +180,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
#if defined(USE_FAR_KEYWORD) #if defined(USE_FAR_KEYWORD)
#if defined(_MSC_VER) #if defined(_MSC_VER)
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check) void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
{ {
void *near_ptr; void *near_ptr;
void FAR *far_ptr; void FAR *far_ptr;
@ -192,7 +192,7 @@ void *far_to_near(png_structp png_ptr,png_voidp ptr, int check)
return(near_ptr); return(near_ptr);
} }
# else # else
void *far_to_near(png_structp png_ptr,png_voidp ptr, int check) void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
{ {
void *near_ptr; void *near_ptr;
void FAR *far_ptr; void FAR *far_ptr;

View File

@ -1,12 +1,12 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
/* get internal access to png.h */ /* get internal access to png.h */
@ -502,7 +502,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes); png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */ /* Copy user's row into buffer, leaving room for filter byte. */
png_buffered_memcpy(png_ptr, png_ptr->row_buf + 1, row, png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row,
png_ptr->row_info.rowbytes); png_ptr->row_info.rowbytes);
#if defined(PNG_WRITE_INTERLACING_SUPPORTED) #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
@ -831,10 +831,10 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
if (png_ptr->filter_weights == NULL) if (png_ptr->filter_weights == NULL)
{ {
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, png_ptr->filter_weights = png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * num_weights)); (png_uint_32)(sizeof(png_uint_16) * num_weights));
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, png_ptr->inv_filter_weights = png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * num_weights)); (png_uint_32)(sizeof(png_uint_16) * num_weights));
for (i = 0; i < num_weights; i++) for (i = 0; i < num_weights; i++)
@ -866,7 +866,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
*/ */
if (png_ptr->filter_costs == NULL) if (png_ptr->filter_costs == NULL)
{ {
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, png_ptr->filter_costs = png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,

View File

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

View File

@ -1,12 +1,12 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* libpng 0.99c * libpng 0.99d
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger * Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, Glenn Randers-Pehrson * Copyright (c) 1998, Glenn Randers-Pehrson
* February 7, 1998 * February 8, 1998
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@ -1358,7 +1358,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
i += png_pass_inc[pass]) i += png_pass_inc[pass])
{ {
/* find out where the original pixel is */ /* find out where the original pixel is */
sp = row + i * pixel_bytes; sp = row + (png_size_t)i * pixel_bytes;
/* move the pixel */ /* move the pixel */
if (dp != sp) if (dp != sp)
png_memcpy(dp, sp, pixel_bytes); png_memcpy(dp, sp, pixel_bytes);

View File

@ -1,687 +0,0 @@
Synopsis, for man pages:
void *far_to_near (png_structp png_ptr,png_voidp ptr,int
check);
png_voidp png_buffered_memcpy (png_structp png_ptr, png_voidp
s1, png_voidp s2, png_uint_32 size);
png_voidp png_buffered_memset (png_structp png_ptr, png_voidp
s1, int value, png_uint_32 size);
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
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);
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);
void png_debug_free (png_structp png_ptr, png_voidp ptr);
png_voidp png_debug_malloc (png_structp png_ptr, png_uint_32
size);
void png_destroy_info_struct (png_structp png_ptr, png_infopp
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_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
info_ptr);
png_uint_32 png_get_bKGD (png_structp png_ptr, png_infop
info_ptr, png_color_16p *background);
png_byte png_get_channels (png_structp png_ptr, png_infop
info_ptr);
png_uint_32 png_get_cHRM (png_structp png_ptr, png_infop
info_ptr, double *white_x, double *white_y, double *red_x,
double *red_y, double *green_x, double *green_y, double
*blue_x, double *blue_y);
png_byte png_get_color_type (png_structp png_ptr, png_infop
info_ptr);
png_byte png_get_compression_type (png_structp png_ptr,
png_infop info_ptr);
png_voidp png_get_error_ptr (png_structp png_ptr);
png_byte png_get_filter_type (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);
png_uint_32 png_get_hIST (png_structp png_ptr, png_infop
info_ptr, png_uint_16p *hist);
png_uint_32 png_get_image_height (png_structp png_ptr,
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);
png_voidp png_get_io_ptr (png_structp png_ptr);
png_uint_32 png_get_IHDR (png_structp png_ptr, png_infop
info_ptr, png_uint_32 *width, png_uint_32 *height, int
*bit_depth, int *color_type, int *interlace_type, int
*compression_type, int *filter_type);
png_uint_32 png_get_oFFs (png_structp png_ptr, png_infop
info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y, int
*unit_type);
png_uint_32 png_get_pCAL (png_structp png_ptr, png_infop
info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
int *type, int *nparams, png_charp *units, png_charpp *params);
png_uint_32 png_get_pHYs (png_structp png_ptr, png_infop
info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int
*unit_type);
float png_get_pixel_aspect_ratio (png_structp png_ptr,
png_infop info_ptr);
png_uint_32 png_get_pixels_per_meter (png_structp png_ptr,
png_infop info_ptr);
png_voidp png_get_progressive_ptr (png_structp png_ptr);
png_uint_32 png_get_PLTE (png_structp png_ptr, png_infop
info_ptr, png_colorp *palette, int *num_palette);
png_uint_32 png_get_rowbytes (png_structp png_ptr, png_infop
info_ptr);
png_uint_32 png_get_sBIT (png_structp png_ptr, png_infop
info_ptr, png_color_8p *sig_bit);
png_bytep png_get_signature (png_structp png_ptr, png_infop
info_ptr);
png_uint_32 png_get_sRGB (png_structp png_ptr, png_infop
info_ptr, int *intent);
png_uint_32 png_get_text (png_structp png_ptr, png_infop
info_ptr, png_textp *text_ptr, int *num_text);
png_uint_32 png_get_tIME (png_structp png_ptr, png_infop
info_ptr, png_timep *mod_time);
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);
png_uint_32 png_get_x_offset_microns (png_structp png_ptr,
png_infop info_ptr);
png_uint_32 png_get_x_offset_pixels (png_structp png_ptr,
png_infop info_ptr);
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);
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);
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);
void png_set_bgr (png_structp png_ptr);
void png_set_bKGD (png_structp png_ptr, png_infop info_ptr,
png_color_16p background);
void png_set_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);
void png_set_compression_level (png_structp png_ptr, int
level);
void png_set_compression_mem_level) (png_structp png_ptr, int
mem_level);
void png_set_compression_method (png_structp png_ptr, int
method);
void png_set_compression_strategy) (png_structp png_ptr, int
strategy);
void png_set_compression_window_bits) (png_structp png_ptr, int
window_bits);
void png_set_crc_action (png_structp png_ptr, int crit_action,
int ancil_action);
void png_set_dither (png_structp png_ptr, png_colorp palette,
int num_palette, int maximum_colors, png_uint_16p histogram,
int full_dither);
void png_set_error_fn (png_structp png_ptr, png_voidp
error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn);
void png_set_expand (png_structp png_ptr);
void png_set_filler (png_structp png_ptr, png_uint_32 filler,
int flags);
void png_set_filter (png_structp png_ptr, int method, int
filters);
void png_set_filter_heuristics (png_structp png_ptr, int
heuristic_method, int num_weights, png_doublep filter_weights,
png_doublep filter_costs);
void png_set_flush (png_structp png_ptr, int nrows);
void png_set_gamma (png_structp png_ptr, double screen_gamma,
double default_file_gamma);
void png_set_gAMA (png_structp png_ptr, png_infop info_ptr,
double file_gamma);
void png_set_gray_to_rgb (png_structp png_ptr);
void png_set_hIST (png_structp png_ptr, png_infop info_ptr,
png_uint_16p hist);
int png_set_interlace_handling (png_structp png_ptr);
void png_set_invert_alpha (png_structp png_ptr);
void png_set_invert_mono (png_structp png_ptr);
void png_set_IHDR (png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth, int
color_type, int interlace_type, int compression_type, int
filter_type);
void png_set_oFFs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 offset_x, png_uint_32 offset_y, int unit_type);
void png_set_packing (png_structp png_ptr);
void png_set_packswap (png_structp png_ptr);
void png_set_pCAL (png_structp png_ptr, png_infop info_ptr,
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int
nparams, png_charp units, png_charpp params);
void png_set_pHYs (png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type);
void png_set_progressive_read_fn (png_structp png_ptr,
png_voidp progressive_ptr, png_progressive_info_ptr info_fn,
png_progressive_row_ptr row_fn, png_progressive_end_ptr
end_fn);
void png_set_PLTE (png_structp png_ptr, png_infop info_ptr,
png_colorp palette, int num_palette);
void png_set_read_fn (png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn);
void png_set_rgb_to_gray (png_structp png_ptr);
void png_set_sBIT (png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit);
void png_set_shift (png_structp png_ptr, png_color_8p
true_bits);
void png_set_sig_bytes (png_structp png_ptr, int num_bytes);
void png_set_sRGB (png_structp png_ptr, png_infop info_ptr, int
intent);
void png_set_sRGB_gAMA_and_cHRM (png_structp png_ptr, png_infop
info_ptr, int intent);
void png_set_strip_16 (png_structp png_ptr);
void png_set_strip_alpha (png_structp png_ptr);
void png_set_swap (png_structp png_ptr);
void png_set_swap_alpha (png_structp png_ptr);
void png_set_text (png_structp png_ptr, png_infop info_ptr,
png_textp text_ptr, int num_text);
void png_set_tIME (png_structp png_ptr, png_infop info_ptr,
png_timep mod_time);
void png_set_tRNS (png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values);
void png_set_write_fn (png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn);
int png_sig_cmp (png_bytep sig, png_size_t start, png_size_t
num_to_check);
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);
void png_write_chunk_data (png_structp png_ptr, png_bytep data,
png_size_t length);
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);