Imported from libpng-0.99c.tar

This commit is contained in:
Glenn Randers-Pehrson 1998-02-07 10:20:57 -06:00
parent b212002101
commit 0f881d62b3
26 changed files with 1197 additions and 239 deletions

13
CHANGES
View File

@ -214,5 +214,14 @@ version 0.99 [January 30, 1998]
define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined
added type casting to all png_malloc() function calls
version 0.99a [January 31, 1998]
added type casts and parentheses to all returns that return a value.(Tim W.)
Added type casts and parentheses to all returns that return a value.(Tim W.)
version 0.99b [February 4, 1998]
Added type cast png_uint_32 on malloc function calls where needed.
Changed type of num_hist from png_uint_32 to int (same as num_palette).
Added checks for rowbytes overflow, in case png_size_t is less than 32 bits.
Renamed makefile.elf to makefile.lnx.
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, initially created by R. P. C. Rodgers,
U.S. National Library of Medicine (rodgers@nlm.nih.gov), and png.5.

2
README
View File

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

102
libpng.3 Normal file
View File

@ -0,0 +1,102 @@
.TH PNG 5 "February 7, 1998"
.SH NAME
libpng \- Portable Network Graphics (PNG) format
.SH SYNOPSIS
[see
.I png.h
for full description]
.SH DESCRIPTION
The
.I libpng
library supports encoding, decoding, and various manipulations of
the Portable Network Graphics (PNG) format image files. It uses the
.IR zlib(3)
compression library.
.SH "SEE ALSO"
.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
.I libpng
or at
.br
ftp://ftp.uu.net/pub/archiving/zip/zlib
.br
http://www.cdrom.com/pub/infozip/zlib
.LP
PNG specification:
RFC 2083
.IP
(generally) at the same location as
.I libpng
or at
.br
ftp://ds.internic.net/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
.SH AUTHORS
This man page: R. P. C. Rodgers and Glenn Randers-Pehrson
.LP
Libpng version 0.99c (February 7, 1998):
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
.LP
Supported by the PNG development group
.br
(png-implement@dworkin.wustl.edu).
.LP
.SH COPYRIGHT NOTICE
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
.br
Copyright (c) 1996, 1997 Andreas Dilger
.br
Copyright (c) 1998 Glenn Randers-Pehrson
.br
.LP
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
.LP
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
.br
1. The origin of this source code must not be misrepresented.
.br
2. Altered versions must be plainly marked as such and must not be
misrepresented as being the original source.
.br
3. This Copyright notice may not be removed or altered from any source or
altered source distribution.
.br
.LP
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
.LP
The
.IR zlib (3)
library, version 1.0.8,
is copyright (C) 1995-1998 by Jean-loup Gailly and Mark Adler.
.LP
.\" end of man page

View File

@ -1,9 +1,9 @@
libpng.txt - a description on how to use and modify libpng
libpng version 0.99a
libpng version 0.99c
Updated and distributed by Glenn Randers-Pehrson <randeg@alumni.rpi.edu>
Copyright (c) 1998, Glenn Randers-Pehrson
January 31, 1998
February 7, 1998
based on:
@ -35,7 +35,7 @@ Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs. The PNG specification is available
as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
W3C Recommendation <http://www.w3.org/pub/WWW/TR/REC.png.html>. Some
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
additional chunks are described in the special-purpose public chunks
documents at <ftp://ftp.uu.net/graphics/png/documents/>. Other information
about PNG can be found at the PNG home page, <http://www.cdrom.com/pub/png/>.

View File

@ -5,7 +5,7 @@
# ------------- Microsoft C 5.1 and later -------------
MODEL=-AL
CFLAGS=-Oait -Gs -nologo -W2 $(MODEL) -I..\zlib
CFLAGS=-Oait -Gs -nologo -W3 $(MODEL) -I..\zlib
#-Ox generates bad code with MSC 5.1
CC=cl
LD=link

44
png.5 Normal file
View File

@ -0,0 +1,44 @@
.TH PNG 5 "February 7, 1998"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
PNG (Portable Network Graphics) is an extensible file format for the
lossless, portable, well-compressed storage of raster images. PNG provides
a patent-free replacement for GIF and can also replace many
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
supported, plus an optional alpha channel. Sample depths range from
1 to 16 bits.
.br
PNG is designed to work well in online viewing applications, such as the
World Wide Web, so it is fully streamable with a progressive display
option. PNG is robust, providing both full file integrity checking and
fast, simple detection of common transmission errors. Also, PNG can store
gamma and chromaticity data for improved color matching on heterogeneous
platforms.
.SH "SEE ALSO"
.IR libpng(3), zlib(3), deflate(5), and zlib(5)
.LP
PNG specification:
RFC 2083
.IP
.br
ftp://ds.internic.net/rfc/rfc2083.txt
.br
or (as a W3C Recommendation) at
.br
http://www.w3.org/TR/REC-png.html
.SH AUTHORS
This man page: Glenn Randers-Pehrson
.LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list@dworkin.wustl.edu).
.LP
.SH COPYRIGHT NOTICE
The PNG specification is copyright (c) 1996 Massachussets Institute of
Technology. See the specification for conditions of use and distribution.
.LP
.\" end of man page

8
png.c
View File

@ -1,12 +1,12 @@
/* png.c - location for general purpose libpng functions
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL
@ -16,7 +16,7 @@
/* Version information for C files. This had better match the version
* string defined in png.h.
*/
char png_libpng_ver[6] = "0.99";
char png_libpng_ver[5] = "0.99";
/* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@ -268,7 +268,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
png_free(png_ptr, info_ptr->pcal_units);
if (info_ptr->pcal_params != NULL)
{
for (i = 0; i < info_ptr->pcal_nparams; i++)
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{
png_free(png_ptr, info_ptr->pcal_params[i]);
}

40
png.h
View File

@ -1,12 +1,12 @@
/* png.h - header file for PNG reference library
*
* libpng 0.99a beta
* For conditions of distribution and use, see copyright notice in png.h
* libpng 0.99c 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
* January 31, 1998
* February 7, 1998
*
* Note about libpng version numbers:
*
@ -28,6 +28,8 @@
* 0.98 0.98 2.0.98
* 0.99 0.99 2.0.99
* 0.99a 0.99 2.0.99
* 0.99b 0.99 2.0.99
* 0.99c 0.99 2.0.99
* 1.0 1.00 2.1.0
*
* Henceforth the source version will match the shared-library minor
@ -47,12 +49,12 @@
*
* See libpng.txt for more information. The PNG specification is available
* as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
* and as a W3C Recommendation <http://www.w3.org/pub/WWW/TR/REC.png.html>
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
*
* Contributing Authors:
* John Bowler
* Sam Bushell
* Kevin Bracey
* Sam Bushell
* Andreas Dilger
* Magnus Holmgren
* Tom Lane
@ -70,6 +72,8 @@
*
* Thanks to Frank J. T. Wojcik for helping with the documentation.
*
* COPYRIGHT NOTICE:
*
* The PNG Reference Library is supplied "AS IS". The Contributing Authors
* and Group 42, Inc. disclaim all warranties, expressed or implied,
* including, without limitation, the warranties of merchantability and of
@ -247,7 +251,7 @@ typedef struct png_info_struct
png_uint_32 width; /* width of image in pixels (from IHDR) */
png_uint_32 height; /* height of image in pixels (from IHDR) */
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
@ -481,7 +485,7 @@ typedef png_info FAR * FAR * png_infopp;
typedef struct png_row_info_struct
{
png_uint_32 width; /* width of row */
png_size_t rowbytes; /* number of bytes in row */
png_uint_32 rowbytes; /* number of bytes in row */
png_byte color_type; /* color type of row */
png_byte bit_depth; /* bit depth of row */
png_byte channels; /* number of channels (1, 2, 3, or 4) */
@ -544,8 +548,8 @@ struct png_struct_def
png_uint_32 height; /* height of image in pixels */
png_uint_32 num_rows; /* number of rows in current pass */
png_uint_32 usr_width; /* width of row at start of write */
png_size_t rowbytes; /* size of row in bytes */
png_size_t irowbytes; /* size of current interlaced row in bytes */
png_uint_32 rowbytes; /* size of row in bytes */
png_uint_32 irowbytes; /* size of current interlaced row in bytes */
png_uint_32 iwidth; /* width of current interlaced row in pixels */
png_uint_32 row_number; /* current row in interlace pass */
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
@ -1105,6 +1109,12 @@ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
/* 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_buffered_memcpy) PNGARG((png_structp png_ptr,
png_voidp s1, png_voidp s2, png_uint_32 size));
extern PNG_EXPORT(void,png_buffered_memset) PNGARG((png_structp png_ptr,
png_voidp s1, int value, png_uint_32 size));
#ifdef PNGTEST_MEMORY_DEBUG
/* debugging versions of png_malloc() and png_free() */
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
@ -1434,10 +1444,10 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#define PNG_GAMMA 0x2000
#define PNG_GRAY_TO_RGB 0x4000
#define PNG_FILLER 0x8000
#define PNG_PACKSWAP 0x10000
#define PNG_SWAP_ALPHA 0x20000
#define PNG_STRIP_ALPHA 0x40000
#define PNG_INVERT_ALPHA 0x80000
#define PNG_PACKSWAP 0x10000L
#define PNG_SWAP_ALPHA 0x20000L
#define PNG_STRIP_ALPHA 0x40000L
#define PNG_INVERT_ALPHA 0x80000L
/* flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
@ -1483,7 +1493,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
abs((int)((c1).blue) - (int)((c2).blue)))
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
#ifndef PNG_NO_EXTERN
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
/* place to hold the signature string for a PNG file. */
extern png_byte FARDATA png_sig[8];
@ -1677,7 +1687,7 @@ PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
#if defined(PNG_WRITE_hIST_SUPPORTED)
PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
png_uint_32 num_hist));
int num_hist));
#endif
#if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)

View File

@ -1,12 +1,12 @@
/* pngconf.c - machine configurable file for libpng
/* pngconf.h - machine configurable file for libpng
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
/* Any machine specific code is near the front of this file, so if you

View File

@ -1,12 +1,12 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*
* This file provides a location for all error handling. Users which
* need special error handling are expected to write replacement functions
@ -81,7 +81,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
}
if (message == NULL)
buffer[iout++] = 0;
buffer[iout] = 0;
else {
buffer[iout++] = ':';
buffer[iout++] = ' ';

View File

@ -1,12 +1,12 @@
/* pngget.c - retrieval of values from info struct
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL
@ -126,14 +126,14 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
{
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0)
return (0.0);
return ((float)0.0);
else
return ((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit);
}
else
#endif
return (0.0);
return ((float)0.0);
}
png_uint_32
@ -209,7 +209,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
if (info_ptr != NULL)
return(info_ptr->channels);
else
return(0);
return (0);
}
png_bytep
@ -218,7 +218,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
if (info_ptr != NULL)
return(info_ptr->signature);
else
return(NULL);
return (NULL);
}
#if defined(PNG_READ_bKGD_SUPPORTED)
@ -322,6 +322,10 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
if (info_ptr != NULL && width != NULL && height != NULL &&
bit_depth != NULL && color_type != NULL)
{
png_uint_32 rowbytes;
int pixel_depth, channels;
png_uint_32 rowbytes_per_pixel;
png_debug1(1, "in %s retrieval function\n", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
@ -333,6 +337,24 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
*filter_type = info_ptr->filter_type;
if (interlace_type != NULL)
*interlace_type = info_ptr->interlace_type;
/* check for potential overflow of rowbytes */
if (*color_type == PNG_COLOR_TYPE_PALETTE)
channels = 1;
else if (*color_type & PNG_COLOR_MASK_COLOR)
channels = 3;
else
channels = 1;
if (*color_type & PNG_COLOR_MASK_ALPHA)
channels++;
pixel_depth = *bit_depth * channels;
rowbytes_per_pixel = (pixel_depth + 7) >> 3;
rowbytes = *width * rowbytes_per_pixel;
if ((*width > (png_uint_32)2147483647L/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large for libpng to process image data.");
}
return (1);
}
return (0);

View File

@ -1,11 +1,11 @@
/* pngmem.c - stub functions for memory allocation
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 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
@ -261,14 +261,11 @@ png_destroy_struct(png_voidp struct_ptr)
{
#if defined(__TURBOC__) && !defined(__FLAT__)
farfree(struct_ptr);
struct_ptr = NULL;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(struct_ptr);
struct_ptr = NULL;
# else
free(struct_ptr);
struct_ptr = NULL;
# endif
#endif
}
@ -285,21 +282,27 @@ png_voidp
PNG_MALLOC(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
png_size_t length;
if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL);
#ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L)
if (png_size > (png_uint_32)65536L)
png_error(png_ptr, "Cannot Allocate > 64K");
#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__)
ret = farmalloc((png_size_t)size);
ret = farmalloc(length);
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
ret = halloc(size, 1);
ret = halloc(length, 1);
# else
ret = malloc(size);
ret = malloc(length);
# endif
#endif
@ -322,17 +325,43 @@ PNG_FREE(png_structp png_ptr, png_voidp ptr)
#if defined(__TURBOC__) && !defined(__FLAT__)
farfree(ptr);
ptr = NULL;
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
hfree(ptr);
ptr = NULL;
# else
free(ptr);
ptr = NULL;
# endif
#endif
}
#endif /* Not Borland DOS special memory handler */
void
png_buffered_memcpy (png_structp png_ptr, png_voidp s1, png_voidp s2,
png_uint_32 length)
{
png_size_t size;
png_uint_32 i;
for (i=0; i<length; i+=65530)
{
size = (png_size_t)(length - i);
if (size > (png_size_t)65530L)
size=(png_size_t)65530L;
png_memcpy (s1, s2, size);
}
}
void
png_buffered_memset (png_structp png_ptr, png_voidp s1, int value,
png_uint_32 length)
{
png_size_t size;
png_uint_32 i;
for (i=0; i<length; i+=65530)
{
size = length - i;
if (size > 65530)
size=65530;
png_memset (s1, value, size);
}
}

View File

@ -1,12 +1,12 @@
/* pngpread.c - read a png file in push mode
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL
@ -466,7 +466,8 @@ png_push_save_buffer(png_structp png_ptr)
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
old_buffer = png_ptr->save_buffer;
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, new_max);
png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
(png_uint_32)new_max);
png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
@ -527,7 +528,12 @@ png_push_read_IDAT(png_structp png_ptr)
png_size_t save_size;
if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size)
save_size = png_ptr->idat_size;
{
save_size = (png_size_t)png_ptr->idat_size;
/* check for overflow */
if((png_uint_32)save_size != png_ptr->idat_size)
png_error(png_ptr, "save_size overflowed in pngpread");
}
else
save_size = png_ptr->save_buffer_size;
@ -544,7 +550,12 @@ png_push_read_IDAT(png_structp png_ptr)
png_size_t save_size;
if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size)
save_size = png_ptr->idat_size;
{
save_size = (png_size_t)png_ptr->idat_size;
/* check for overflow */
if((png_uint_32)save_size != png_ptr->idat_size)
png_error(png_ptr, "save_size overflowed in pngpread");
}
else
save_size = png_ptr->current_buffer_size;
@ -619,6 +630,7 @@ png_push_process_row(png_structp png_ptr)
png_ptr->row_info.channels = png_ptr->channels;
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
@ -626,7 +638,8 @@ png_push_process_row(png_structp png_ptr)
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
(int)(png_ptr->row_buf[0]));
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
png_buffered_memcpy(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1);
if (png_ptr->transformations)
png_do_read_transformations(png_ptr);
@ -761,7 +774,8 @@ png_read_push_finish_row(png_structp png_ptr)
if (png_ptr->interlaced)
{
png_ptr->row_number = 0;
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_buffered_memset(png_ptr, png_ptr->prev_row, 0,
(png_size_t)png_ptr->rowbytes + 1);
do
{
png_ptr->pass++;
@ -771,8 +785,7 @@ png_read_push_finish_row(png_structp png_ptr)
png_pass_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
png_ptr->irowbytes = ((png_ptr->iwidth *
png_ptr->pixel_depth + 7) >> 3) + 1;
png_ptr->irowbytes = ((png_ptr->pixel_depth + 7) >> 3) + 1;
if (!(png_ptr->transformations & PNG_INTERLACE))
{
png_ptr->num_rows = (png_ptr->height +
@ -806,11 +819,12 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = length;
png_ptr->current_text_left = length;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_tEXt_MODE;
}
@ -857,7 +871,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
if (text != key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key;
text_ptr->text = text;
@ -889,11 +903,12 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length+1);
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(length+1));
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = length;
png_ptr->current_text_left = length;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_zTXt_MODE;
}
@ -978,8 +993,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
if (text == NULL)
{
text = (png_charp)png_malloc(png_ptr,
png_ptr->zbuf_size - png_ptr->zstream.avail_out +
key_size + 1);
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out +
key_size + 1));
png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size);
@ -993,7 +1008,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
tmp = text;
text = (png_charp)png_malloc(png_ptr, text_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
+ 1));
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
@ -1029,9 +1045,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
png_free(png_ptr, key);
key = text;
text += key_size;
text_size -= key_size;
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->key = key;
text_ptr->text = text;

View File

@ -1,12 +1,12 @@
/* pngread.c - read a PNG file
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*
* This file contains routines that an application calls directly to
* read a PNG file or stream.
@ -17,7 +17,7 @@
/* Create a PNG structure for reading, and allocate any memory needed. */
png_structp
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
png_create_read_struct(png_const_charp user_png_ver, voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn)
{
png_structp png_ptr;
@ -58,7 +58,8 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_ptr->zstream.zalloc = png_zalloc;
png_ptr->zstream.zfree = png_zfree;
png_ptr->zstream.opaque = (voidpf)png_ptr;
@ -100,7 +101,8 @@ png_read_init(png_structp png_ptr)
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_ptr->zstream.zalloc = png_zalloc;
png_ptr->zstream.zfree = png_zfree;
png_ptr->zstream.opaque = (voidpf)png_ptr;
@ -407,14 +409,17 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_ptr->row_info.channels = png_ptr->channels;
png_ptr->row_info.bit_depth = png_ptr->bit_depth;
png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
{
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
}
png_read_filter_row(png_ptr, &(png_ptr->row_info),
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
(int)(png_ptr->row_buf[0]));
png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
png_buffered_memcpy(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1);
if (png_ptr->transformations)
png_do_read_transformations(png_ptr);

View File

@ -1,12 +1,12 @@
/* pngrio.c - functions for data input
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*
* This file provides a location for all input. Users which need
* special handling are expected to write a function which has the same
@ -99,7 +99,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
}
while (remaining != 0);
}
if (check != length)
if ((png_uint_32)check != (png_uint_32)length)
{
png_error(png_ptr, "read Error");
}

View File

@ -1,12 +1,12 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*
* This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG.
@ -184,7 +184,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
int i;
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
num_palette * sizeof (png_byte));
(png_uint_32)(num_palette * sizeof (png_byte)));
for (i = 0; i < num_palette; i++)
png_ptr->dither_index[i] = (png_byte)i;
}
@ -200,7 +200,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
png_bytep sort;
/* initialize an array to sort colors */
sort = (png_bytep)png_malloc(png_ptr, num_palette * sizeof (png_byte));
sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette
* sizeof (png_byte)));
/* initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -243,11 +244,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
move the others */
for (i = 0, j = num_palette; i < maximum_colors; i++)
{
if (sort[i] >= maximum_colors)
if ((int)sort[i] >= maximum_colors)
{
do
j--;
while (sort[j] >= maximum_colors);
while ((int)sort[j] >= maximum_colors);
palette[i] = palette[j];
}
}
@ -261,13 +262,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
for (i = 0, j = num_palette; i < maximum_colors; i++)
{
/* only move the colors we need to */
if (sort[i] >= maximum_colors)
if ((int)sort[i] >= maximum_colors)
{
png_color tmp_color;
do
j--;
while (sort[j] >= maximum_colors);
while ((int)sort[j] >= maximum_colors);
tmp_color = palette[j];
palette[j] = palette[i];
@ -281,7 +282,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
/* find closest color for those colors we are not using */
for (i = 0; i < num_palette; i++)
{
if (png_ptr->dither_index[i] >= maximum_colors)
if ((int)png_ptr->dither_index[i] >= maximum_colors)
{
int min_d, k, min_k, d_index;
@ -328,9 +329,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
/* initialize palette index arrays */
index_to_palette = (png_bytep)png_malloc(png_ptr,
num_palette * sizeof (png_byte));
(png_uint_32)(num_palette * sizeof (png_byte)));
palette_to_index = (png_bytep)png_malloc(png_ptr,
num_palette * sizeof (png_byte));
(png_uint_32)(num_palette * sizeof (png_byte)));
/* initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -339,7 +340,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
palette_to_index[i] = (png_byte)i;
}
hash = (png_dsortpp)png_malloc(png_ptr, 769 * sizeof (png_dsortp));
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
sizeof (png_dsortp)));
for (i = 0; i < 769; i++)
hash[i] = NULL;
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
@ -372,7 +374,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
{
png_dsortp t;
t = (png_dsortp)png_malloc(png_ptr, sizeof (png_dsort));
t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof
(png_dsort)));
t->next = hash[d];
t->left = (png_byte)i;
t->right = (png_byte)j;
@ -389,8 +392,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
for (p = hash[i]; p; p = p->next)
{
if (index_to_palette[p->left] < num_new_palette &&
index_to_palette[p->right] < num_new_palette)
if ((int)index_to_palette[p->left] < num_new_palette &&
(int)index_to_palette[p->right] < num_new_palette)
{
int j, next_j;
@ -417,7 +420,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
index_to_palette[j])
png_ptr->dither_index[k] =
index_to_palette[next_j];
if (png_ptr->dither_index[k] ==
if ((int)png_ptr->dither_index[k] ==
num_new_palette)
png_ptr->dither_index[k] =
index_to_palette[j];
@ -488,11 +491,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
num_entries = ((png_size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
num_entries * sizeof (png_byte));
(png_uint_32)(num_entries * sizeof (png_byte)));
png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
distance = (png_bytep)png_malloc(png_ptr, num_entries * sizeof(png_byte));
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
sizeof(png_byte)));
png_memset(distance, 0xff, num_entries * sizeof(png_byte));
@ -527,7 +531,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
dmax = ((dm > db) ? dm : db);
d = dmax + dt + db;
if (d < distance[d_index])
if (d < (int)distance[d_index])
{
distance[d_index] = (png_byte)d;
png_ptr->palette_lookup[d_index] = (png_byte)i;
@ -656,7 +660,7 @@ png_init_read_transformations(png_structp png_ptr)
/* invert the alpha channel (in tRNS) unless the pixels are
going to be expanded, in which case leave it for later */
int i;
for (i=0; i<png_ptr->num_trans; i++)
for (i=0; i<(int)png_ptr->num_trans; i++)
png_ptr->trans[i] = 255 - png_ptr->trans[i];
}
}
@ -852,7 +856,7 @@ png_init_read_transformations(png_structp png_ptr)
back.green = (png_byte)png_ptr->background.green;
back.blue = (png_byte)png_ptr->background.blue;
for (i = 0; i < png_ptr->num_trans; i++)
for (i = 0; i < (int)png_ptr->num_trans; i++)
{
if (png_ptr->trans[i] == 0)
{
@ -995,8 +999,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
info_ptr->bit_depth);
info_ptr->rowbytes =
(png_size_t)((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
}
/* Transform the row. The order of transformations is significant,
@ -1085,6 +1088,8 @@ png_do_read_transformations(png_structp png_ptr)
{
png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
png_ptr->palette_lookup, png_ptr->dither_index);
if(png_ptr->row_info.rowbytes == (png_uint_32)0)
png_error(png_ptr, "png_do_dither returned rowbytes=0");
}
#endif
@ -1227,7 +1232,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->rowbytes = (png_size_t)row_info->width * row_info->channels;
row_info->rowbytes = row_info->width * row_info->channels;
}
}
#endif
@ -1286,7 +1291,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
case 2:
{
png_bytep bp;
png_size_t i;
png_uint_32 i;
for (bp = row, i = 0; i < row_info->rowbytes; i++, bp++)
{
@ -1299,7 +1304,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
{
png_bytep bp;
png_byte mask;
png_size_t i;
png_uint_32 i;
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
(png_byte)((int)0xf >> shift[0]);
@ -1313,11 +1318,11 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
case 8:
{
png_bytep bp;
png_size_t i;
png_uint_32 i;
for (bp = row, i = 0; i < row_info->width; i++)
{
for (c = 0; c < row_info->channels; c++, bp++)
for (c = 0; c < (int)row_info->channels; c++, bp++)
{
*bp >>= shift[c];
}
@ -1331,7 +1336,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
for (bp = row, i = 0; i < row_info->width; i++)
{
for (c = 0; c < row_info->channels; c++, bp += 2)
for (c = 0; c < (int)row_info->channels; c++, bp += 2)
{
value = (png_uint_16)((*bp << 8) + *(bp + 1));
value >>= shift[c];
@ -1395,7 +1400,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
row_info->rowbytes = (png_size_t)row_info->width * row_info->channels;
row_info->rowbytes = row_info->width * row_info->channels;
}
}
#endif
@ -1604,7 +1609,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = (png_byte)filler;
row_info->channels = 4;
row_info->pixel_depth = 32;
row_info->rowbytes = (png_size_t)row_info->width * 4;
row_info->rowbytes = row_info->width * 4;
}
/* This changes the data from RGB to XRGB */
else
@ -1621,7 +1626,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
}
row_info->channels = 4;
row_info->pixel_depth = 32;
row_info->rowbytes = (png_size_t)row_info->width * 4;
row_info->rowbytes = row_info->width * 4;
}
}
}
@ -1715,7 +1720,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
row_info->color_type |= PNG_COLOR_MASK_COLOR;
row_info->pixel_depth = (png_byte)(row_info->channels *
row_info->bit_depth);
row_info->rowbytes = (png_size_t)((row_info->width *
row_info->rowbytes = ((row_info->width *
row_info->pixel_depth + 7) >> 3);
}
}
@ -1993,7 +1998,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 7;
for (i = 0; i < row_info->width; i++)
{
if (((*sp >> shift) & 0x1) == trans_values->gray)
if ((png_uint_16)((*sp >> shift) & 0x1)
== trans_values->gray)
{
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
*sp |= (png_byte)(background->gray << shift);
@ -2014,7 +2020,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 6;
for (i = 0; i < row_info->width; i++)
{
if (((*sp >> shift) & 0x3) == trans_values->gray)
if ((png_uint_16)((*sp >> shift) & 0x3)
== trans_values->gray)
{
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
*sp |= (png_byte)(background->gray << shift);
@ -2035,7 +2042,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
shift = 4;
for (i = 0; i < row_info->width; i++)
{
if (((*sp >> shift) & 0xf) == trans_values->gray)
if ((png_uint_16)((*sp >> shift) & 0xf)
== trans_values->gray)
{
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
*sp |= (png_byte)(background->gray << shift);
@ -2543,7 +2551,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
row_info->channels--;
row_info->pixel_depth = (png_byte)(row_info->channels *
row_info->bit_depth);
row_info->rowbytes = (png_size_t)((row_info->width *
row_info->rowbytes = ((row_info->width *
row_info->pixel_depth + 7) >> 3);
}
}
@ -2824,7 +2832,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
row_info->rowbytes = (png_size_t)row_info->width;
row_info->rowbytes = row_info->width;
}
switch (row_info->bit_depth)
{
@ -2848,7 +2856,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
row_info->bit_depth = 8;
row_info->pixel_depth = 32;
row_info->rowbytes = (png_size_t)row_info->width * 4;
row_info->rowbytes = row_info->width * 4;
row_info->color_type = 6;
row_info->channels = 4;
}
@ -2866,7 +2874,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
row_info->bit_depth = 8;
row_info->pixel_depth = 24;
row_info->rowbytes = (png_size_t)row_info->width * 3;
row_info->rowbytes = row_info->width * 3;
row_info->color_type = 2;
row_info->channels = 3;
}
@ -2972,7 +2980,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
row_info->rowbytes = (png_size_t)row_info->width;
row_info->rowbytes = row_info->width;
}
if (trans_value != NULL)
@ -3015,7 +3023,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_info->channels = 2;
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
row_info->rowbytes =
(png_size_t)((row_info->width * row_info->pixel_depth) >> 3);
((row_info->width * row_info->pixel_depth) >> 3);
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
@ -3070,7 +3078,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_info->channels = 4;
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
row_info->rowbytes =
(png_size_t)((row_info->width * row_info->pixel_depth) >> 3);
((row_info->width * row_info->pixel_depth) >> 3);
}
}
}
@ -3123,7 +3131,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
row_info->channels = 1;
row_info->pixel_depth = row_info->bit_depth;
row_info->rowbytes =
((row_info->width * row_info->pixel_depth + 7) >> 3);
((row_info->width * row_info->pixel_depth + 7) >> 3);
}
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
palette_lookup != NULL && row_info->bit_depth == 8)
@ -3153,7 +3161,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
row_info->channels = 1;
row_info->pixel_depth = row_info->bit_depth;
row_info->rowbytes =
(png_size_t)((row_info->width * row_info->pixel_depth + 7) >> 3);
((row_info->width * row_info->pixel_depth + 7) >> 3);
}
else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
dither_lookup && row_info->bit_depth == 8)
@ -3267,7 +3275,7 @@ png_build_gamma_table(png_structp png_ptr)
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
num * sizeof (png_uint_16p));
(png_uint_32)(num * sizeof (png_uint_16p)));
if ((png_ptr->transformations & PNG_16_TO_8) &&
!(png_ptr->transformations & PNG_BACKGROUND))
@ -3278,7 +3286,7 @@ png_build_gamma_table(png_structp png_ptr)
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * sizeof (png_uint_16));
(png_uint_32)(256 * sizeof (png_uint_16)));
}
g = 1.0 / g;
@ -3308,7 +3316,7 @@ png_build_gamma_table(png_structp png_ptr)
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * sizeof (png_uint_16));
(png_uint_32)(256 * sizeof (png_uint_16)));
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
@ -3326,12 +3334,12 @@ png_build_gamma_table(png_structp png_ptr)
g = 1.0 / (png_ptr->gamma);
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
num * sizeof (png_uint_16p ));
(png_uint_32)(num * sizeof (png_uint_16p )));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
256 * sizeof (png_uint_16));
(png_uint_32)(256 * sizeof (png_uint_16)));
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
@ -3345,12 +3353,12 @@ png_build_gamma_table(png_structp png_ptr)
g = 1.0 / (png_ptr->screen_gamma);
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
num * sizeof (png_uint_16p));
(png_uint_32)(num * sizeof (png_uint_16p)));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
256 * sizeof (png_uint_16));
(png_uint_32)(256 * sizeof (png_uint_16)));
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);

View File

@ -1,12 +1,12 @@
/* pngrutil.c - utilities to read a PNG file
*
* libpng 0.99a
* libpng 0.99
* 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
* January 31, 1998
* February 7, 1998
*
* This file contains routines which are only called from within
* libpng itself during the course of reading an image.
@ -226,7 +226,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* set up other useful info */
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
png_ptr->channels);
png_ptr->channels);
png_ptr->rowbytes = ((png_ptr->width *
(png_uint_32)png_ptr->pixel_depth + 7) >> 3);
png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
@ -909,7 +909,7 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
num = (int)length / 2;
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
num * sizeof (png_uint_16));
(png_uint_32)(num * sizeof (png_uint_16)));
png_ptr->flags |= PNG_FLAG_FREE_HIST;
for (i = 0; i < num; i++)
{
@ -1097,10 +1097,11 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
for (buf = units; *buf != '\0'; buf++);
png_debug(3, "Allocating pCAL parameters array\n");
params = (png_charpp)png_malloc(png_ptr, nparams*sizeof(png_charp)) ;
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
*sizeof(png_charp))) ;
/* Get pointers to the start of each parameter string. */
for (i = 0; i < nparams; i++)
for (i = 0; i < (int)nparams; i++)
{
buf++; /* Skip the null string terminator from previous parameter. */
@ -1213,7 +1214,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (text != key + (png_size_t)length)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key;
text_ptr->text = text;
@ -1303,14 +1304,14 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (text == NULL)
{
text_size = key_size + sizeof(msg) + 1;
text = (png_charp)png_malloc(png_ptr, text_size);
text = (png_charp)png_malloc(png_ptr, (png_uint_32)text_size);
png_memcpy(text, key, key_size);
}
text[text_size - 1] = '\0';
/* Copy what we can of the error message into the text chunk */
text_size = length - (text - key) - 1;
text_size = (png_size_t)length - (text - key) - 1;
text_size = sizeof(msg) > text_size ? text_size : sizeof(msg);
png_memcpy(text + key_size, msg, text_size + 1);
break;
@ -1320,8 +1321,8 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (text == NULL)
{
text = (png_charp)png_malloc(png_ptr,
png_ptr->zbuf_size - png_ptr->zstream.avail_out +
key_size + 1);
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
+ key_size + 1));
png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size);
@ -1334,8 +1335,8 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp tmp;
tmp = text;
text = (png_charp)png_malloc(png_ptr, text_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1);
text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
@ -1361,7 +1362,6 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_free(png_ptr, key);
key = text;
text += key_size;
text_size -= key_size;
}
else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */
{
@ -1381,7 +1381,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_memcpy(text, msg, text_size + 1);
}
text_ptr = (png_textp)png_malloc(png_ptr, sizeof(png_text));
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = comp_type;
text_ptr->key = key;
text_ptr->text = text;
@ -1879,6 +1879,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_debug(1, "in png_read_filter_row\n");
png_debug2(2,"row = %d, filter = %d\n", png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@ -1992,7 +1993,7 @@ png_read_finish_row(png_structp png_ptr)
if (png_ptr->interlaced)
{
png_ptr->row_number = 0;
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_buffered_memset(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
do
{
png_ptr->pass++;
@ -2002,8 +2003,9 @@ png_read_finish_row(png_structp png_ptr)
png_pass_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
png_ptr->irowbytes = ((png_ptr->iwidth *
png_ptr->pixel_depth + 7) >> 3) + 1;
png_ptr->irowbytes = ((png_ptr->iwidth *
(png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
if (!(png_ptr->transformations & PNG_INTERLACE))
{
png_ptr->num_rows = (png_ptr->height +
@ -2104,8 +2106,12 @@ png_read_start_row(png_structp png_ptr)
png_pass_inc[png_ptr->pass] - 1 -
png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
png_ptr->irowbytes = ((png_ptr->iwidth *
png_ptr->pixel_depth + 7) >> 3) + 1;
rowbytes = ((png_ptr->iwidth *
(png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1;
png_ptr->irowbytes = (png_size_t)rowbytes;
if((png_uint_32)png_ptr->irowbytes != rowbytes)
png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
}
else
{
@ -2194,9 +2200,10 @@ png_read_start_row(png_structp png_ptr)
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
png_error(png_ptr, "This image requires a row greater than 64KB");
#endif
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_buffered_memset(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %d,\n", png_ptr->width);
png_debug1(3, "height = %d,\n", png_ptr->height);

View File

@ -1,12 +1,12 @@
/* pngset.c - storage of image information into info struct
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 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
@ -84,6 +84,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type)
{
int rowbytes_per_pixel;
png_debug1(1, "in %s storage function\n", "IHDR");
if (info_ptr == NULL)
return;
@ -104,7 +105,16 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
info_ptr->channels++;
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
/* check for overflow */
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
info_ptr->rowbytes = info_ptr->width * rowbytes_per_pixel;
if (( width > (png_uint_32)2147483647L/rowbytes_per_pixel))
{
png_warning(png_ptr,
"Width too large to process image data; rowbytes will overflow.");
info_ptr->rowbytes = (png_size_t)0;
}
}
#if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
@ -129,8 +139,8 @@ 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)
{
png_size_t length;
int i;
png_uint_32 length;
png_uint_32 i;
png_debug1(1, "in %s storage function\n", "pCAL");
if (info_ptr == NULL)
@ -139,7 +149,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(purpose) + 1;
png_debug1(3, "allocating purpose for info (%d bytes)\n", length);
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_purpose, purpose, length);
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
png_debug(3, "storing X0, X1, type, and nparams in info\n");
info_ptr->pcal_X0 = X0;
@ -150,10 +160,10 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(units) + 1;
png_debug1(3, "allocating units for info (%d bytes)\n", length);
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_units, units, length);
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
(nparams + 1) * sizeof(png_charp));
(png_uint_32)((nparams + 1) * sizeof(png_charp)));
info_ptr->pcal_params[nparams] = NULL;
for (i = 0; i < nparams; i++)
@ -161,7 +171,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(params[i]) + 1;
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length);
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_params[i], params[i], length);
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
}
info_ptr->valid |= PNG_INFO_pCAL;
@ -289,7 +299,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc(png_ptr,
info_ptr->max_text * sizeof (png_text));
png_memcpy(info_ptr->text, old_text, old_max * sizeof(png_text));
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
sizeof(png_text)));
png_free(png_ptr, old_text);
}
else
@ -297,7 +308,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->max_text = num_text + 8;
info_ptr->num_text = 0;
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_debug1(3, "allocated %d entries for info_ptr->text\n",
info_ptr->max_text);

View File

@ -1,12 +1,12 @@
/* pngtest.c - a simple test program to test libpng
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 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
@ -284,7 +284,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size) {
return (NULL);
}
if (size == 0)
return (NULL);
return (png_voidp)(NULL);
/* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */
@ -299,7 +299,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size) {
pinformation = pinfo;
/* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size);
return ((png_voidp)pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
}
@ -612,6 +612,7 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_debug(0, "\nWriting info struct\n");
png_write_info(write_ptr, write_info_ptr);
png_debug(0, "\nAllocating row buffer \n");
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
if (row_buf == NULL)
@ -623,12 +624,14 @@ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
fclose(fpout);
return (1);
}
png_debug(0, "Writing row data\n");
num_pass = png_set_interlace_handling(read_ptr);
png_set_interlace_handling(write_ptr);
for (pass = 0; pass < num_pass; pass++)
{
png_debug1(0, "Writing row data for pass %d\n",pass);
for (y = 0; y < height; y++)
{
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1);
@ -867,5 +870,5 @@ main(int argc, char *argv[])
fprintf(STDERR, "libpng passes test\n");
else
fprintf(STDERR, "libpng FAILS test\n");
return ((int)(ierror != 0));
return (int)(ierror != 0);
}

View File

@ -1,12 +1,12 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL

View File

@ -1,12 +1,12 @@
/* pngwio.c - functions for data output
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 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.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
/* get internal access to png.h */
@ -77,7 +77,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
int j;
for (j=0; j<info_ptr->num_trans; j++)
for (j=0; j<(int)info_ptr->num_trans; j++)
info_ptr->trans[j] = 255 - info_ptr->trans[j];
}
#endif
@ -230,7 +230,8 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
if (png_ptr->time_buffer == NULL)
{
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, 29*sizeof(char));
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
sizeof(char)));
}
#ifdef USE_FAR_KEYWORD
@ -320,7 +321,8 @@ png_create_write_struct(png_const_charp user_png_ver, voidp error_ptr,
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
@ -351,7 +353,8 @@ png_write_init(png_structp png_ptr)
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -487,6 +490,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels);
png_ptr->row_info.rowbytes = ((png_ptr->row_info.width *
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
@ -498,7 +502,8 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
png_buffered_memcpy(png_ptr, png_ptr->row_buf + 1, row,
png_ptr->row_info.rowbytes);
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* handle interlacing */
@ -611,7 +616,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
if (info_ptr->pcal_params != NULL)
{
int i;
for (i = 0; i < info_ptr->pcal_nparams; i++)
for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{
png_free(png_ptr, info_ptr->pcal_params[i]);
}
@ -714,7 +719,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
if (png_ptr->do_filter & PNG_FILTER_SUB && png_ptr->sub_row == NULL)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
@ -728,7 +733,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
else
{
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
}
@ -743,7 +748,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
else
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
}
@ -759,7 +764,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
else
{
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
@ -815,7 +820,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
if (png_ptr->prev_filters == NULL)
{
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
sizeof(png_byte) * num_weights);
(png_uint_32)(sizeof(png_byte) * num_weights));
/* To make sure that the weighting starts out fairly */
for (i = 0; i < num_weights; i++)
@ -827,10 +832,10 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
if (png_ptr->filter_weights == NULL)
{
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
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,
sizeof(png_uint_16) * num_weights);
(png_uint_32)(sizeof(png_uint_16) * num_weights));
for (i = 0; i < num_weights; i++)
{
@ -862,10 +867,10 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
if (png_ptr->filter_costs == NULL)
{
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
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,
sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST);
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
{

View File

@ -1,12 +1,12 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL

View File

@ -1,12 +1,12 @@
/* pngwutil.c - utilities to write a PNG file
*
* libpng 0.99a
* libpng 0.99c
* 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
* January 31, 1998
* February 7, 1998
*/
#define PNG_INTERNAL
@ -375,7 +375,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
/* make sure we don't depend upon the order of PNG_COLOR_8 */
if (color_type & PNG_COLOR_MASK_COLOR)
{
int maxbits;
png_byte maxbits;
maxbits = color_type==PNG_COLOR_TYPE_PALETTE ? 8:png_ptr->usr_bit_depth;
if (sbit->red == 0 || sbit->red > maxbits ||
@ -486,7 +486,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
png_debug(1, "in png_write_tRNS\n");
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (num_trans <= 0 || num_trans > png_ptr->num_palette)
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
{
png_warning(png_ptr,"Invalid number of transparent colors specified");
return;
@ -551,13 +551,13 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
#if defined(PNG_WRITE_hIST_SUPPORTED)
/* write the histogram */
void
png_write_hIST(png_structp png_ptr, png_uint_16p hist, png_uint_32 num_hist)
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
{
png_uint_32 i;
int i;
png_byte buf[3];
png_debug(1, "in png_write_hIST\n");
if (num_hist > png_ptr->num_palette)
if (num_hist > (int)png_ptr->num_palette)
{
png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist,
png_ptr->num_palette);
@ -565,7 +565,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, png_uint_32 num_hist)
return;
}
png_write_chunk_start(png_ptr, png_hIST, num_hist * 2);
png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
for (i = 0; i < num_hist; i++)
{
png_save_uint_16(buf, hist[i]);
@ -604,7 +604,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
png_debug1(2, "Keyword to be checked is '%s'\n", key);
*new_key = (png_charp)png_malloc(png_ptr, key_len + 1);
*new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 1));
/* Replace non-printing characters with a blank and print a warning */
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
@ -815,18 +815,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
old_ptr = output_ptr;
output_ptr = (png_charpp)png_malloc(png_ptr,
max_output_ptr * sizeof (png_charpp));
(png_uint_32)(max_output_ptr * sizeof (png_charpp)));
png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
output_ptr = (png_charpp)png_malloc(png_ptr,
max_output_ptr * sizeof (png_charp));
(png_uint_32)(max_output_ptr * sizeof (png_charp)));
}
/* save the data */
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
png_ptr->zbuf_size);
(png_uint_32)png_ptr->zbuf_size);
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
num_output_ptr++;
@ -869,18 +869,18 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
old_ptr = output_ptr;
/* This could be optimized to realloc() */
output_ptr = (png_charpp)png_malloc(png_ptr,
max_output_ptr * sizeof (png_charpp));
(png_uint_32)(max_output_ptr * sizeof (png_charpp)));
png_memcpy(output_ptr, old_ptr, old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
output_ptr = (png_charpp)png_malloc(png_ptr,
max_output_ptr * sizeof (png_charp));
(png_uint_32)(max_output_ptr * sizeof (png_charp)));
}
/* save off the data */
output_ptr[num_output_ptr] = (png_charp)png_malloc(png_ptr,
png_ptr->zbuf_size);
(png_uint_32)png_ptr->zbuf_size);
png_memcpy(output_ptr[num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
num_output_ptr++;
@ -968,7 +968,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
png_debug1(3, "pCAL units length = %d\n", units_len);
total_len = purpose_len + units_len + 10;
params_len = (png_uint_32p)png_malloc(png_ptr, nparams*sizeof(png_uint_32));
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
*sizeof(png_uint_32)));
/* Find the length of each parameter, making sure we don't count the
null terminator for the last parameter. */
@ -980,7 +981,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
}
png_debug1(3, "pCAL total length = %d\n", total_len);
png_write_chunk_start(png_ptr, png_pCAL, total_len);
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
png_save_int_32(buf, X0);
png_save_int_32(buf + 4, X1);
@ -1063,14 +1064,14 @@ png_write_start_row(png_structp png_ptr)
png_ptr->usr_bit_depth + 7) >> 3) + 1);
/* set up row buffer */
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
/* set up filtering buffer, if using this filter */
if (png_ptr->do_filter & PNG_FILTER_SUB)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
@ -1078,27 +1079,27 @@ png_write_start_row(png_structp png_ptr)
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
{
/* set up previous row buffer */
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, buf_size);
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
png_memset(png_ptr->prev_row, 0, buf_size);
if (png_ptr->do_filter & PNG_FILTER_UP)
{
png_ptr->up_row = (png_bytep )png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
if (png_ptr->do_filter & PNG_FILTER_AVG)
{
png_ptr->avg_row = (png_bytep )png_malloc(png_ptr,
png_ptr->rowbytes + 1);
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
if (png_ptr->do_filter & PNG_FILTER_PAETH)
{
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
png_ptr->rowbytes + 1);
(png_ptr->rowbytes + 1));
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
@ -1372,9 +1373,8 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
png_pass_inc[pass] - 1 -
png_pass_start[pass]) /
png_pass_inc[pass];
row_info->rowbytes = ((row_info->width *
row_info->pixel_depth + 7) >> 3);
row_info->rowbytes = ((row_info->width *
row_info->pixel_depth + 7) >> 3);
}
}
#endif
@ -1421,7 +1421,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep rp;
png_uint_32 sum = 0;
png_size_t i;
png_uint_32 i;
int v;
for (i = 0, rp = row_buf + 1; i < row_info->rowbytes; i++, rp++)
@ -1438,7 +1438,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */
/* Reduce the sum if we match any of the previous rows */
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_NONE)
{
@ -1472,7 +1472,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep rp, dp, lp;
png_uint_32 sum = 0, lmins = mins;
png_size_t i;
png_uint_32 i;
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -1486,7 +1486,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
{
@ -1516,7 +1516,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
sum += (v < 128) ? v : 256 - v;
}
for (lp = row_buf + 1; i < row_info->rowbytes; i++, rp++, lp++, dp++)
for (lp = row_buf + 1; i < row_info->rowbytes;
i++, rp++, lp++, dp++)
{
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
@ -1533,7 +1534,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_SUB)
{
@ -1568,7 +1569,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep rp, dp, pp;
png_uint_32 sum = 0, lmins = mins;
png_size_t i;
png_uint_32 i;
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -1578,7 +1579,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_UP)
{
@ -1602,7 +1603,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
pp = prev_row + 1; i < row_info->rowbytes; i++, rp++, pp++, dp++)
pp = prev_row + 1; i < row_info->rowbytes;
i++, rp++, pp++, dp++)
{
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
@ -1619,7 +1621,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
sumlo = sum & PNG_LOMASK;
sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_UP)
{
@ -1654,7 +1656,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep rp, dp, pp, lp;
png_uint_32 sum = 0, lmins = mins;
png_size_t i;
png_uint_32 i;
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -1664,7 +1666,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
lmlo = lmins & PNG_LOMASK;
lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;
for (i = 0; i < png_ptr->num_prev_filters; i++)
for (i = 0; i < (png_uint_32)png_ptr->num_prev_filters; i++)
{
if (png_ptr->prev_filters[i] == PNG_FILTER_VALUE_AVG)
{
@ -1747,7 +1749,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{
png_bytep rp, dp, pp, cp, lp;
png_uint_32 sum = 0, lmins = mins;
png_size_t i;
png_uint_32 i;
int v;
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
@ -1781,7 +1783,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
pp = prev_row + 1; i < bpp; i++, rp++, pp++, dp++)
pp = prev_row + 1; (unsigned)i < bpp; i++, rp++, pp++, dp++)
{
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
@ -1859,9 +1861,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
/* Save the type of filter we picked this time for future calculations */
if (png_ptr->num_prev_filters > 0)
{
png_byte i;
int i;
for (i = 1; i < png_ptr->num_prev_filters; i++)
for (i = 1; i < (int)png_ptr->num_prev_filters; i++)
{
png_ptr->prev_filters[i] = png_ptr->prev_filters[i - 1];
}
@ -1930,4 +1932,3 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
}
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
}

687
synopsis.txt Normal file
View File

@ -0,0 +1,687 @@
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);