Imported from libpng-0.99c.tar
This commit is contained in:
parent
b212002101
commit
0f881d62b3
13
CHANGES
13
CHANGES
@ -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
2
README
@ -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
102
libpng.3
Normal 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
|
||||
|
@ -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/>.
|
||||
|
@ -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
44
png.5
Normal 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
8
png.c
@ -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
40
png.h
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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++] = ' ';
|
||||
|
34
pngget.c
34
pngget.c
@ -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);
|
||||
|
53
pngmem.c
53
pngmem.c
@ -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);
|
||||
}
|
||||
}
|
||||
|
57
pngpread.c
57
pngpread.c
@ -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;
|
||||
|
21
pngread.c
21
pngread.c
@ -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);
|
||||
|
6
pngrio.c
6
pngrio.c
@ -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");
|
||||
}
|
||||
|
112
pngrtran.c
112
pngrtran.c
@ -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) |