mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[devel]Made all API functions that have const arguments and constant string
literal pointers declare them (John Bowler). Many APIs did not change their arguments but were not declared using PNG_CONST. This change corrects this. In a few cases APIs that return constant string literal pointers have also been changed to declare this. Unlike the argument change this may require app changes; however the results could never be written to (the app would crash on some platforms where strings are not writable), so this seems advisable.
This commit is contained in:
parent
21b4b339d9
commit
e600c51355
8
ANNOUNCE
8
ANNOUNCE
@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.5.0beta42 - August 13, 2010
|
||||
Libpng 1.5.0beta42 - August 11, 2010
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@ -226,7 +226,7 @@ version 1.5.0beta24 [May 7, 2010]
|
||||
offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf.
|
||||
Added more blank lines for readability.
|
||||
|
||||
version 1.5.0beta25 [August 13, 2010]
|
||||
version 1.5.0beta25 [August 11, 2010]
|
||||
In pngpread.c: png_push_have_row() add check for new_row > height
|
||||
Removed the now-redundant check for out-of-bounds new_row from example.c
|
||||
|
||||
@ -344,8 +344,10 @@ version 1.5.0beta41 [August 11, 2010]
|
||||
Don't try to use version-script with cygwin/mingw.
|
||||
Revised contrib/gregbook to work under cygwin/mingw.
|
||||
|
||||
version 1.5.0beta42 [August 13, 2010]
|
||||
version 1.5.0beta42 [August 11, 2010]
|
||||
Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
|
||||
Made all API functions that have const arguments and constant string
|
||||
literal pointers declare them (John Bowler).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
|
||||
(subscription required; visit
|
||||
|
||||
4
CHANGES
4
CHANGES
@ -2826,8 +2826,10 @@ version 1.5.0beta41 [August 11, 2010]
|
||||
Don't try to use version-script with cygwin/mingw.
|
||||
Revised contrib/gregbook to work under cygwin/mingw.
|
||||
|
||||
version 1.5.0beta42 [August 13, 2010]
|
||||
version 1.5.0beta42 [August 11, 2010]
|
||||
Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov)
|
||||
Made all API functions that have const arguments and constant string
|
||||
literal pointers declare them (John Bowler).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
98
png.c
98
png.c
@ -50,7 +50,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
* PNG signature (this is the same behaviour as strcmp, memcmp, etc).
|
||||
*/
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
@ -120,7 +120,7 @@ png_reset_crc(png_structp png_ptr)
|
||||
* trouble of calculating it.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
|
||||
png_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length)
|
||||
{
|
||||
int need_crc = 1;
|
||||
|
||||
@ -513,8 +513,8 @@ png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
* a "Creation Time" or other text-based time string.
|
||||
*/
|
||||
png_charp PNGAPI
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
png_const_charp PNGAPI
|
||||
png_convert_to_rfc1123(png_structp png_ptr, png_const_timep ptime)
|
||||
{
|
||||
static PNG_CONST char short_months[12][4] =
|
||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
@ -545,13 +545,13 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
# endif
|
||||
return ((png_charp)png_ptr->time_buffer);
|
||||
return png_ptr->time_buffer;
|
||||
}
|
||||
# endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||
|
||||
png_charp PNGAPI
|
||||
png_const_charp PNGAPI
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||
@ -559,17 +559,17 @@ png_get_copyright(png_structp png_ptr)
|
||||
return PNG_STRING_COPYRIGHT
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return ((png_charp) PNG_STRING_NEWLINE \
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.5.0beta42 - August 11, 2010" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE);
|
||||
PNG_STRING_NEWLINE;
|
||||
# else
|
||||
return ((png_charp) "libpng version 1.5.0beta42 - August 11, 2010\
|
||||
return "libpng version 1.5.0beta42 - August 11, 2010\
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@ -582,34 +582,34 @@ png_get_copyright(png_structp png_ptr)
|
||||
* png_get_header_ver(). Due to the version_nn_nn_nn typedef guard,
|
||||
* it is guaranteed that png.c uses the correct version of png.h.
|
||||
*/
|
||||
png_charp PNGAPI
|
||||
png_const_charp PNGAPI
|
||||
png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
return png_get_header_ver(png_ptr);
|
||||
}
|
||||
|
||||
png_charp PNGAPI
|
||||
png_const_charp PNGAPI
|
||||
png_get_header_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.h files used when building libpng */
|
||||
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||
return PNG_LIBPNG_VER_STRING;
|
||||
}
|
||||
|
||||
png_charp PNGAPI
|
||||
png_const_charp PNGAPI
|
||||
png_get_header_version(png_structp png_ptr)
|
||||
{
|
||||
/* Returns longer string containing both version and date */
|
||||
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||
#ifdef __STDC__
|
||||
return ((png_charp) PNG_HEADER_VERSION_STRING
|
||||
return PNG_HEADER_VERSION_STRING
|
||||
# ifndef PNG_READ_SUPPORTED
|
||||
" (NO READ SUPPORT)"
|
||||
# endif
|
||||
PNG_STRING_NEWLINE);
|
||||
PNG_STRING_NEWLINE;
|
||||
#else
|
||||
return ((png_charp) PNG_HEADER_VERSION_STRING);
|
||||
return PNG_HEADER_VERSION_STRING;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -906,7 +906,7 @@ png_check_IHDR(png_structp png_ptr,
|
||||
#define PNG_FP_E 12 /* [Ee] */
|
||||
|
||||
int /* PRIVATE */
|
||||
png_check_fp_number(png_charp string, png_size_t size, int *statep,
|
||||
png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
png_size_tp whereami)
|
||||
{
|
||||
int state = *statep;
|
||||
@ -1033,7 +1033,7 @@ PNG_FP_End:
|
||||
|
||||
/* The same but for a complete string. */
|
||||
int
|
||||
png_check_fp_string(png_charp string, png_size_t size)
|
||||
png_check_fp_string(png_const_charp string, png_size_t size)
|
||||
{
|
||||
int state=0;
|
||||
png_size_t index=0;
|
||||
@ -1058,7 +1058,10 @@ png_pow10(int power)
|
||||
* 10 is exact whereas .1 is inexact in base 2
|
||||
*/
|
||||
if (power < 0)
|
||||
{
|
||||
if (power < DBL_MIN_10_EXP) return 0;
|
||||
recip = 1, power = -power;
|
||||
}
|
||||
|
||||
if (power > 0)
|
||||
{
|
||||
@ -1084,7 +1087,7 @@ png_pow10(int power)
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
|
||||
double fp, unsigned precision)
|
||||
double fp, unsigned int precision)
|
||||
{
|
||||
/* We use standard functions from math.h, but not printf because
|
||||
* that would require stdio. The caller must supply a buffer of
|
||||
@ -1402,13 +1405,13 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,
|
||||
|
||||
if (num <= 0x80000000U) /* else overflowed */
|
||||
{
|
||||
unsigned ndigits = 0, first = 16/*flag value*/;
|
||||
unsigned int ndigits = 0, first = 16/*flag value*/;
|
||||
char digits[10];
|
||||
|
||||
while (num)
|
||||
{
|
||||
/* Split the low digit off num: */
|
||||
unsigned tmp = num/10;
|
||||
unsigned int tmp = num/10;
|
||||
num -= tmp*10;
|
||||
digits[ndigits++] = (char)(48 + num);
|
||||
/* Record the first non-zero digit, note that this is a number
|
||||
@ -1428,7 +1431,7 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,
|
||||
*/
|
||||
if (first <= 5)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned int i;
|
||||
*ascii++ = 46; /* decimal point */
|
||||
/* ndigits may be <5 for small numbers, output leading zeros
|
||||
* then ndigits digits to first:
|
||||
@ -1790,9 +1793,9 @@ png_8bit_l2[128] =
|
||||
};
|
||||
|
||||
static png_uint_32
|
||||
png_log8bit(unsigned x)
|
||||
png_log8bit(unsigned int x)
|
||||
{
|
||||
unsigned log = 0;
|
||||
unsigned int log = 0;
|
||||
/* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log,
|
||||
* because the log is actually negate that means adding 1. The final
|
||||
* returned value thus has the range 0 (for 255 input) to 7.994 (for 1
|
||||
@ -1847,7 +1850,7 @@ png_log8bit(unsigned x)
|
||||
static png_uint_32
|
||||
png_log16bit(png_uint_32 x)
|
||||
{
|
||||
unsigned log = 0;
|
||||
unsigned int log = 0;
|
||||
|
||||
/* As above, but now the input has 16 bits. */
|
||||
if ((x &= 0xffff) == 0)
|
||||
@ -2007,12 +2010,13 @@ png_exp16bit(png_uint_32 log)
|
||||
#endif /* FLOATING_ARITHMETIC */
|
||||
|
||||
png_byte
|
||||
png_gamma_8bit_correct(unsigned value, png_fixed_point gamma)
|
||||
png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma)
|
||||
{
|
||||
if (value > 0 && value < 255)
|
||||
{
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
return (png_byte)floor(255*pow(value/255.,gamma*.00001)+.5);
|
||||
double r = floor(255*pow(value/255.,gamma*.00001)+.5);
|
||||
return (png_byte)r;
|
||||
# else
|
||||
png_uint_32 log = png_log8bit(value);
|
||||
png_fixed_point res;
|
||||
@ -2029,13 +2033,13 @@ png_gamma_8bit_correct(unsigned value, png_fixed_point gamma)
|
||||
}
|
||||
|
||||
png_uint_16
|
||||
png_gamma_16bit_correct(unsigned value, png_fixed_point gamma)
|
||||
png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma)
|
||||
{
|
||||
if (value > 0 && value < 65535)
|
||||
{
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
return (png_uint_16)floor(65535*pow(value/65535.,gamma*.00001)+.5);
|
||||
|
||||
double r = floor(65535*pow(value/65535.,gamma*.00001)+.5);
|
||||
return (png_uint_16)r;
|
||||
# else
|
||||
png_uint_32 log = png_log16bit(value);
|
||||
png_fixed_point res;
|
||||
@ -2057,7 +2061,8 @@ png_gamma_16bit_correct(unsigned value, png_fixed_point gamma)
|
||||
* 8 bit (as are the arguments.)
|
||||
*/
|
||||
png_uint_16 /* PRIVATE */
|
||||
png_gamma_correct(png_structp png_ptr, unsigned value, png_fixed_point gamma)
|
||||
png_gamma_correct(png_structp png_ptr, unsigned int value,
|
||||
png_fixed_point gamma)
|
||||
{
|
||||
if (png_ptr->bit_depth == 8)
|
||||
return png_gamma_8bit_correct(value, gamma);
|
||||
@ -2086,13 +2091,13 @@ png_gamma_significant(png_fixed_point gamma)
|
||||
*/
|
||||
static void
|
||||
png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
|
||||
PNG_CONST unsigned shift, PNG_CONST png_fixed_point gamma)
|
||||
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma)
|
||||
{
|
||||
/* Various values derived from 'shift': */
|
||||
PNG_CONST unsigned num = 1U << (8U - shift);
|
||||
PNG_CONST unsigned max = (1U << (16U - shift))-1U;
|
||||
PNG_CONST unsigned max_by_2 = 1U << (15U-shift);
|
||||
unsigned i;
|
||||
PNG_CONST unsigned int num = 1U << (8U - shift);
|
||||
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
|
||||
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
|
||||
unsigned int i;
|
||||
|
||||
png_uint_16pp table = *ptable =
|
||||
(png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));
|
||||
@ -2115,15 +2120,14 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
|
||||
* We want input * 65535/max, rounded, the arithmetic fits in 32
|
||||
* bits (unsigned) so long as max <= 32767.
|
||||
*/
|
||||
unsigned j;
|
||||
unsigned int j;
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
png_uint_32 ig = (j << (8-shift)) + i;
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* Inline the 'max' scaling operation: */
|
||||
sub_table[j] = (png_uint_16)floor(65535*pow(ig/(double)max,
|
||||
gamma*.00001)+.5);
|
||||
|
||||
double d = floor(65535*pow(ig/(double)max, gamma*.00001)+.5);
|
||||
sub_table[j] = (png_uint_16)d;
|
||||
# else
|
||||
if (shift)
|
||||
ig = (ig * 65535U + max_by_2)/max;
|
||||
@ -2135,7 +2139,7 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
|
||||
else
|
||||
{
|
||||
/* We must still build a table, but do it the fast way. */
|
||||
unsigned j;
|
||||
unsigned int j;
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
@ -2155,11 +2159,11 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
|
||||
*/
|
||||
static void
|
||||
png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
|
||||
PNG_CONST unsigned shift, PNG_CONST png_fixed_point gamma)
|
||||
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma)
|
||||
{
|
||||
PNG_CONST unsigned num = 1U << (8U - shift);
|
||||
PNG_CONST unsigned max = (1U << (16U - shift))-1U;
|
||||
unsigned i;
|
||||
PNG_CONST unsigned int num = 1U << (8U - shift);
|
||||
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int i;
|
||||
png_uint_32 last;
|
||||
|
||||
png_uint_16pp table = *ptable =
|
||||
@ -2224,7 +2228,7 @@ static void
|
||||
png_build_8bit_table(png_structp png_ptr, png_bytepp ptable,
|
||||
PNG_CONST png_fixed_point gamma)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned int i;
|
||||
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
|
||||
|
||||
if (png_gamma_significant(gamma)) for (i=0; i<256; i++)
|
||||
|
||||
117
png.h
117
png.h
@ -507,6 +507,7 @@ typedef struct png_color_struct
|
||||
png_byte blue;
|
||||
} png_color;
|
||||
typedef png_color FAR * png_colorp;
|
||||
typedef PNG_CONST png_color FAR * png_const_colorp;
|
||||
typedef png_color FAR * FAR * png_colorpp;
|
||||
|
||||
typedef struct png_color_16_struct
|
||||
@ -518,6 +519,7 @@ typedef struct png_color_16_struct
|
||||
png_uint_16 gray; /* for use in grayscale files */
|
||||
} png_color_16;
|
||||
typedef png_color_16 FAR * png_color_16p;
|
||||
typedef PNG_CONST png_color_16 FAR * png_const_color_16p;
|
||||
typedef png_color_16 FAR * FAR * png_color_16pp;
|
||||
|
||||
typedef struct png_color_8_struct
|
||||
@ -529,6 +531,7 @@ typedef struct png_color_8_struct
|
||||
png_byte alpha; /* for alpha channel files */
|
||||
} png_color_8;
|
||||
typedef png_color_8 FAR * png_color_8p;
|
||||
typedef PNG_CONST png_color_8 FAR * png_const_color_8p;
|
||||
typedef png_color_8 FAR * FAR * png_color_8pp;
|
||||
|
||||
/*
|
||||
@ -544,6 +547,7 @@ typedef struct png_sPLT_entry_struct
|
||||
png_uint_16 frequency;
|
||||
} png_sPLT_entry;
|
||||
typedef png_sPLT_entry FAR * png_sPLT_entryp;
|
||||
typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp;
|
||||
typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
|
||||
|
||||
/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
|
||||
@ -559,6 +563,7 @@ typedef struct png_sPLT_struct
|
||||
png_int_32 nentries; /* number of palette entries */
|
||||
} png_sPLT_t;
|
||||
typedef png_sPLT_t FAR * png_sPLT_tp;
|
||||
typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp;
|
||||
typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@ -588,6 +593,7 @@ typedef struct png_text_struct
|
||||
chars or a NULL pointer */
|
||||
} png_text;
|
||||
typedef png_text FAR * png_textp;
|
||||
typedef PNG_CONST png_text FAR * png_const_textp;
|
||||
typedef png_text FAR * FAR * png_textpp;
|
||||
#endif
|
||||
|
||||
@ -617,6 +623,7 @@ typedef struct png_time_struct
|
||||
png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
|
||||
} png_time;
|
||||
typedef png_time FAR * png_timep;
|
||||
typedef PNG_CONST png_time FAR * png_const_timep;
|
||||
typedef png_time FAR * FAR * png_timepp;
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
@ -637,6 +644,7 @@ typedef struct png_unknown_chunk_t
|
||||
}
|
||||
png_unknown_chunk;
|
||||
typedef png_unknown_chunk FAR * png_unknown_chunkp;
|
||||
typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;
|
||||
typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
|
||||
#endif
|
||||
|
||||
@ -764,7 +772,9 @@ typedef png_row_info FAR * FAR * png_row_infopp;
|
||||
* that allow the user to override the default I/O functions with his or her
|
||||
* own. The png_error_ptr type should match that of user-supplied warning
|
||||
* and error functions, while the png_rw_ptr type should match that of the
|
||||
* user read/write data functions.
|
||||
* user read/write data functions. Note that the 'write' function must not
|
||||
* modify the buffer it is passed, the 'read' function, on the other hand, is
|
||||
* expected to return the read data in the buffer.
|
||||
*/
|
||||
typedef struct png_struct_def png_struct;
|
||||
typedef png_struct FAR * png_structp;
|
||||
@ -882,7 +892,7 @@ PNG_EXPORT(void,png_set_sig_bytes,(png_structp png_ptr, int num_bytes),,2);
|
||||
* signature, and non-zero otherwise. Having num_to_check == 0 or
|
||||
* start > 7 will always fail (ie return non-zero).
|
||||
*/
|
||||
PNG_EXPORT(int,png_sig_cmp,(png_bytep sig, png_size_t start,
|
||||
PNG_EXPORT(int,png_sig_cmp,(png_const_bytep sig, png_size_t start,
|
||||
png_size_t num_to_check),,3);
|
||||
|
||||
/* Simple signature checking function. This is the same as calling
|
||||
@ -952,15 +962,15 @@ PNG_EXPORT(png_structp,png_create_write_struct_2,(png_const_charp user_png_ver,
|
||||
PNG_EXPORT(void,png_write_sig,(png_structp png_ptr),,13);
|
||||
|
||||
/* Write a PNG chunk - size, type, (optional) data, CRC. */
|
||||
PNG_EXPORT(void,png_write_chunk,(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_bytep data, png_size_t length),,14);
|
||||
PNG_EXPORT(void,png_write_chunk,(png_structp png_ptr, png_const_bytep
|
||||
chunk_name, png_const_bytep data, png_size_t length),,14);
|
||||
|
||||
/* Write the start of a PNG chunk - length and chunk name. */
|
||||
PNG_EXPORT(void,png_write_chunk_start,(png_structp png_ptr,
|
||||
png_bytep chunk_name, png_uint_32 length),,15);
|
||||
png_const_bytep chunk_name, png_uint_32 length),,15);
|
||||
|
||||
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
|
||||
PNG_EXPORT(void,png_write_chunk_data,(png_structp png_ptr, png_bytep data,
|
||||
PNG_EXPORT(void,png_write_chunk_data,(png_structp png_ptr, png_const_bytep data,
|
||||
png_size_t length),,16);
|
||||
|
||||
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
|
||||
@ -984,14 +994,14 @@ PNG_EXPORT(void,png_read_info,(png_structp png_ptr, png_infop info_ptr),,22);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
PNG_EXPORT(png_charp,png_convert_to_rfc1123,(png_structp png_ptr,
|
||||
png_timep ptime),,23);
|
||||
PNG_EXPORT(png_const_charp,png_convert_to_rfc1123,(png_structp png_ptr,
|
||||
png_const_timep ptime),,23);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* Convert from a struct tm to png_time */
|
||||
PNG_EXPORT(void,png_convert_from_struct_tm,(png_timep ptime,
|
||||
struct tm FAR * ttime),,24);
|
||||
PNG_CONST struct tm FAR * ttime),,24);
|
||||
|
||||
/* Convert from time_t to png_time. Uses gmtime() */
|
||||
PNG_EXPORT(void,png_convert_from_time_t,(png_timep ptime, time_t ttime),,25);
|
||||
@ -1070,8 +1080,8 @@ PNG_EXPORT(void,png_set_packswap,(png_structp png_ptr),,43);
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
/* Converts files to legal bit depths. */
|
||||
PNG_EXPORT(void,png_set_shift,(png_structp png_ptr, png_color_8p true_bits),,
|
||||
44);
|
||||
PNG_EXPORT(void,png_set_shift,(png_structp png_ptr, png_const_color_8p
|
||||
true_bits),,44);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||
@ -1106,11 +1116,11 @@ PNG_EXPORT(void,png_set_invert_mono,(png_structp png_ptr),,46);
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* Handle alpha and tRNS by replacing with a background color. */
|
||||
PNG_FP_EXPORT(void,png_set_background,(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code, int need_expand,
|
||||
double background_gamma),,47);
|
||||
png_const_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, double background_gamma),,47);
|
||||
PNG_FIXED_EXPORT(void,png_set_background_fixed,(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code, int need_expand,
|
||||
png_fixed_point background_gamma),,217);
|
||||
png_const_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, png_fixed_point background_gamma),,217);
|
||||
#endif
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
# define PNG_BACKGROUND_GAMMA_UNKNOWN 0
|
||||
@ -1129,7 +1139,7 @@ PNG_EXPORT(void,png_set_strip_16,(png_structp png_ptr),,48);
|
||||
* available.
|
||||
*/
|
||||
PNG_EXPORT(void,png_set_quantize,(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int num_palette, int maximum_colors, png_const_uint_16p histogram,
|
||||
int full_quantize),,49);
|
||||
#endif
|
||||
|
||||
@ -1179,9 +1189,13 @@ PNG_EXPORT(void,png_read_image,(png_structp png_ptr, png_bytepp image),,57);
|
||||
#endif
|
||||
|
||||
/* Write a row of image data */
|
||||
PNG_EXPORT(void,png_write_row,(png_structp png_ptr, png_bytep row),,58);
|
||||
PNG_EXPORT(void,png_write_row,(png_structp png_ptr, png_const_bytep row),,58);
|
||||
|
||||
/* Write a few rows of image data */
|
||||
/* Write a few rows of image data: (*row) is not written, however the type is
|
||||
* declared as writeable to maintain compatibility with previous versions of
|
||||
* libpng and to allow the 'display_row' array from read_rows to be passed
|
||||
* unchanged to write_rows.
|
||||
*/
|
||||
PNG_EXPORT(void,png_write_rows,(png_structp png_ptr, png_bytepp row,
|
||||
png_uint_32 num_rows),,59);
|
||||
|
||||
@ -1296,11 +1310,11 @@ PNG_EXPORT(void,png_set_filter,(png_structp png_ptr, int method, int filters),,
|
||||
* to the UNWEIGHTED method, but with added encoding time/computation.
|
||||
*/
|
||||
PNG_FP_EXPORT(void,png_set_filter_heuristics,(png_structp png_ptr,
|
||||
int heuristic_method, int num_weights, png_doublep filter_weights,
|
||||
png_doublep filter_costs),,68);
|
||||
int heuristic_method, int num_weights, png_const_doublep filter_weights,
|
||||
png_const_doublep filter_costs),,68);
|
||||
PNG_FIXED_EXPORT(void,png_set_filter_heuristics_fixed,(png_structp png_ptr,
|
||||
int heuristic_method, int num_weights, png_fixed_point_p filter_weights,
|
||||
png_fixed_point_p filter_costs),,209);
|
||||
int heuristic_method, int num_weights, png_const_fixed_point_p
|
||||
filter_weights, png_const_fixed_point_p filter_costs),,209);
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
|
||||
/* Heuristic used for row filter selection. These defines should NOT be
|
||||
@ -1434,11 +1448,12 @@ PNG_EXPORT(png_voidp,png_get_progressive_ptr,(png_structp png_ptr),,91);
|
||||
PNG_EXPORT(void,png_process_data,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size),,92);
|
||||
|
||||
/* Function that combines rows. Not very much different than the
|
||||
* png_combine_row() call. Is this even used?????
|
||||
/* Function that combines rows. 'new_row' is a flag that should come from the
|
||||
* callback and be non-NULL if anything needs to be done, the library stores its
|
||||
* own version of the new data internally and ignores the passed in value.
|
||||
*/
|
||||
PNG_EXPORT(void,png_progressive_combine_row,(png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row),,93);
|
||||
png_bytep old_row, png_const_bytep new_row),,93);
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
PNG_EXPORT(png_voidp,png_malloc,(png_structp png_ptr, png_alloc_size_t size),
|
||||
@ -1624,7 +1639,7 @@ PNG_EXPORT(png_int_32, png_get_y_offset_microns,(png_structp png_ptr,
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
PNG_EXPORT(png_bytep,png_get_signature,(png_structp png_ptr,
|
||||
PNG_EXPORT(png_const_bytep,png_get_signature,(png_structp png_ptr,
|
||||
png_infop info_ptr),,130);
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
@ -1634,7 +1649,7 @@ PNG_EXPORT(png_uint_32,png_get_bKGD,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_bKGD,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_16p background),,132);
|
||||
png_const_color_16p background),,132);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
@ -1685,7 +1700,7 @@ PNG_EXPORT(png_uint_32,png_get_hIST,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_hIST,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_16p hist),,142);
|
||||
png_const_uint_16p hist),,142);
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(png_uint_32,png_get_IHDR,(png_structp png_ptr, png_infop info_ptr,
|
||||
@ -1714,8 +1729,8 @@ PNG_EXPORT(png_uint_32,png_get_pCAL,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
PNG_EXPORT(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),,148);
|
||||
png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
|
||||
int nparams, png_const_charp units, png_charpp params),,148);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
@ -1732,7 +1747,7 @@ PNG_EXPORT(png_uint_32,png_get_PLTE,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp *palette, int *num_palette),,151);
|
||||
|
||||
PNG_EXPORT(void,png_set_PLTE,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp palette, int num_palette),,152);
|
||||
png_const_colorp palette, int num_palette),,152);
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
PNG_EXPORT(png_uint_32,png_get_sBIT,(png_structp png_ptr, png_infop info_ptr,
|
||||
@ -1741,7 +1756,7 @@ PNG_EXPORT(png_uint_32,png_get_sBIT,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_sBIT,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_8p sig_bit),,154);
|
||||
png_const_color_8p sig_bit),,154);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
@ -1764,7 +1779,7 @@ PNG_EXPORT(png_uint_32,png_get_iCCP,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_iCCP,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp name, int compression_type, png_bytep profile,
|
||||
png_const_charp name, int compression_type, png_const_bytep profile,
|
||||
png_uint_32 proflen),,159);
|
||||
#endif
|
||||
|
||||
@ -1775,7 +1790,7 @@ PNG_EXPORT(png_uint_32,png_get_sPLT,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_sPLT,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_sPLT_tp entries, int nentries),,161);
|
||||
png_const_sPLT_tp entries, int nentries),,161);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
@ -1793,7 +1808,7 @@ PNG_EXPORT(png_uint_32,png_get_text,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_text,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_textp text_ptr, int num_text),,163);
|
||||
png_const_textp text_ptr, int num_text),,163);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
@ -1803,7 +1818,7 @@ PNG_EXPORT(png_uint_32,png_get_tIME,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_tIME,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_timep mod_time),,165);
|
||||
png_const_timep mod_time),,165);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
@ -1813,7 +1828,8 @@ PNG_EXPORT(png_uint_32,png_get_tRNS,(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
PNG_EXPORT(void,png_set_tRNS,(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep trans_alpha, int num_trans, png_color_16p trans_color),,167);
|
||||
png_const_bytep trans_alpha, int num_trans,
|
||||
png_const_color_16p trans_color),,167);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
@ -1838,7 +1854,7 @@ PNG_FIXED_EXPORT(void,png_set_sCAL_fixed,(png_structp png_ptr,
|
||||
png_infop info_ptr, int unit, png_fixed_point width,
|
||||
png_fixed_point height),,213);
|
||||
PNG_EXPORT(void,png_set_sCAL_s,(png_structp png_ptr, png_infop info_ptr,
|
||||
int unit, png_charp swidth, png_charp sheight),,171);
|
||||
int unit, png_const_charp swidth, png_const_charp sheight),,171);
|
||||
#endif /* PNG_sCAL_SUPPORTED */
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
@ -1852,13 +1868,14 @@ PNG_EXPORT(void,png_set_sCAL_s,(png_structp png_ptr, png_infop info_ptr,
|
||||
= 3: keep even if unsafe-to-copy
|
||||
*/
|
||||
PNG_EXPORT(void, png_set_keep_unknown_chunks,(png_structp png_ptr, int keep,
|
||||
png_bytep chunk_list, int num_chunks),,172);
|
||||
png_const_bytep chunk_list, int num_chunks),,172);
|
||||
PNG_EXPORT(int,png_handle_as_unknown,(png_structp png_ptr,
|
||||
png_const_bytep chunk_name),,173);
|
||||
#endif
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
PNG_EXPORT(void, png_set_unknown_chunks,(png_structp png_ptr,
|
||||
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns),,174);
|
||||
png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns),,
|
||||
174);
|
||||
PNG_EXPORT(void, png_set_unknown_chunk_location, (png_structp png_ptr,
|
||||
png_infop info_ptr, int chunk, int location),,175);
|
||||
PNG_EXPORT(png_uint_32,png_get_unknown_chunks,(png_structp png_ptr,
|
||||
@ -1880,10 +1897,10 @@ PNG_EXPORT(void, png_write_png,(png_structp png_ptr, png_infop info_ptr,
|
||||
int transforms, png_voidp params),,179);
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(png_charp,png_get_copyright,(png_structp png_ptr),,180);
|
||||
PNG_EXPORT(png_charp,png_get_header_ver,(png_structp png_ptr),,181);
|
||||
PNG_EXPORT(png_charp,png_get_header_version,(png_structp png_ptr),,182);
|
||||
PNG_EXPORT(png_charp,png_get_libpng_ver,(png_structp png_ptr),,183);
|
||||
PNG_EXPORT(png_const_charp,png_get_copyright,(png_structp png_ptr),,180);
|
||||
PNG_EXPORT(png_const_charp,png_get_header_ver,(png_structp png_ptr),,181);
|
||||
PNG_EXPORT(png_const_charp,png_get_header_version,(png_structp png_ptr),,182);
|
||||
PNG_EXPORT(png_const_charp,png_get_libpng_ver,(png_structp png_ptr),,183);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
PNG_EXPORT(png_uint_32,png_permit_mng_features,(png_structp png_ptr,
|
||||
@ -1956,7 +1973,7 @@ PNG_EXPORT(png_uint_32,png_get_pHYs_dpi,(png_structp png_ptr,
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
PNG_EXPORT(png_uint_32,png_get_io_state,(png_structp png_ptr),,199);
|
||||
|
||||
PNG_EXPORT(png_bytep,png_get_io_chunk_name,(png_structp png_ptr),,200);
|
||||
PNG_EXPORT(png_const_bytep,png_get_io_chunk_name,(png_structp png_ptr),,200);
|
||||
|
||||
/* The flags returned by png_get_io_state() are the following: */
|
||||
# define PNG_IO_NONE 0x0000 /* no I/O at this moment */
|
||||
@ -2032,13 +2049,13 @@ PNG_EXPORT(png_bytep,png_get_io_chunk_name,(png_structp png_ptr),,200);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
PNG_EXPORT(png_uint_32,png_get_uint_32,(png_bytep buf),,201);
|
||||
PNG_EXPORT(png_uint_16,png_get_uint_16,(png_bytep buf),,202);
|
||||
PNG_EXPORT(png_int_32,png_get_int_32,(png_bytep buf),,203);
|
||||
PNG_EXPORT(png_uint_32,png_get_uint_32,(png_const_bytep buf),,201);
|
||||
PNG_EXPORT(png_uint_16,png_get_uint_16,(png_const_bytep buf),,202);
|
||||
PNG_EXPORT(png_int_32,png_get_int_32,(png_const_bytep buf),,203);
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(png_uint_32,png_get_uint_31,(png_structp png_ptr, png_bytep buf),,
|
||||
204);
|
||||
PNG_EXPORT(png_uint_32,png_get_uint_31,(png_structp png_ptr,
|
||||
png_const_bytep buf),,204);
|
||||
/* No png_get_int_16 -- may be added if there's a real need for it. */
|
||||
|
||||
/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */
|
||||
|
||||
32
pngconf.h
32
pngconf.h
@ -552,24 +552,32 @@ typedef size_t png_size_t;
|
||||
typedef png_int_32 png_fixed_point;
|
||||
|
||||
/* Add typedefs for pointers */
|
||||
typedef void FAR * png_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef char FAR * png_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
typedef png_size_t FAR * png_size_tp;
|
||||
typedef void FAR * png_voidp;
|
||||
typedef PNG_CONST void FAR * png_const_voidp;
|
||||
typedef png_byte FAR * png_bytep;
|
||||
typedef PNG_CONST png_byte FAR * png_const_bytep;
|
||||
typedef png_uint_32 FAR * png_uint_32p;
|
||||
typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p;
|
||||
typedef png_int_32 FAR * png_int_32p;
|
||||
typedef PNG_CONST png_int_32 FAR * png_const_int_32p;
|
||||
typedef png_uint_16 FAR * png_uint_16p;
|
||||
typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p;
|
||||
typedef png_int_16 FAR * png_int_16p;
|
||||
typedef PNG_CONST png_int_16 FAR * png_const_int_16p;
|
||||
typedef char FAR * png_charp;
|
||||
typedef PNG_CONST char FAR * png_const_charp;
|
||||
typedef png_fixed_point FAR * png_fixed_point_p;
|
||||
typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;
|
||||
typedef png_size_t FAR * png_size_tp;
|
||||
typedef PNG_CONST png_size_t FAR * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double FAR * png_doublep;
|
||||
typedef double FAR * png_doublep;
|
||||
typedef PNG_CONST double FAR * png_const_doublep;
|
||||
#endif
|
||||
|
||||
/* Pointers to pointers; i.e. arrays */
|
||||
|
||||
4
pngget.c
4
pngget.c
@ -465,7 +465,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
png_bytep PNGAPI
|
||||
png_const_bytep PNGAPI
|
||||
png_get_signature(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
@ -1035,7 +1035,7 @@ png_get_io_state (png_structp png_ptr)
|
||||
return png_ptr->io_state;
|
||||
}
|
||||
|
||||
png_bytep PNGAPI
|
||||
png_const_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
|
||||
@ -1741,8 +1741,8 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_progressive_combine_row (png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row)
|
||||
png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
|
||||
png_const_bytep new_row)
|
||||
{
|
||||
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
|
||||
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
|
||||
153
pngpriv.h
153
pngpriv.h
@ -24,6 +24,11 @@
|
||||
#ifndef PNGPRIV_H
|
||||
#define PNGPRIV_H
|
||||
|
||||
/* This is required for the definition of abort(), used as a last ditch
|
||||
* error handler when all else fails.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PNGLIB_BUILD
|
||||
#ifdef PNG_USER_CONFIG
|
||||
# include "pngusr.h"
|
||||
@ -32,10 +37,10 @@
|
||||
#include "pnginfo.h"
|
||||
#include "pngstruct.h"
|
||||
|
||||
/* This is required for the definition of abort(), used as a last ditch
|
||||
* error handler when all else fails.
|
||||
/* This is used for 16 bit gamma tables - only the top level pointers are const,
|
||||
* this could be changed:
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
|
||||
|
||||
/* Added at libpng-1.2.9 */
|
||||
/* Moved to pngpriv.h at libpng-1.5.0 */
|
||||
@ -484,8 +489,8 @@ PNG_EXTERN void PNGCBAPI png_default_flush PNGARG((png_structp png_ptr));
|
||||
PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
|
||||
|
||||
/* Write the "data" buffer to whatever output you are using */
|
||||
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
|
||||
png_size_t length));
|
||||
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr,
|
||||
png_const_bytep data, png_size_t length));
|
||||
|
||||
/* Read the chunk header (length + type name) */
|
||||
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
||||
@ -516,8 +521,8 @@ PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
|
||||
* passing a maximum of 64K on systems that have this as a memory limit,
|
||||
* since this is the maximum buffer size we can specify.
|
||||
*/
|
||||
PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
|
||||
png_size_t length));
|
||||
PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr,
|
||||
png_const_bytep ptr, png_size_t length));
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
|
||||
@ -533,8 +538,8 @@ PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
|
||||
int bit_depth, int color_type, int compression_method, int filter_method,
|
||||
int interlace_method));
|
||||
|
||||
PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
|
||||
png_uint_32 num_pal));
|
||||
PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr,
|
||||
png_const_colorp palette, png_uint_32 num_pal));
|
||||
|
||||
PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
|
||||
png_size_t length));
|
||||
@ -552,8 +557,8 @@ PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_sBIT_SUPPORTED
|
||||
PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
|
||||
int color_type));
|
||||
PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr,
|
||||
png_const_color_8p sbit, int color_type));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_cHRM_SUPPORTED
|
||||
@ -577,56 +582,57 @@ PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
|
||||
png_charp name, int compression_type,
|
||||
png_charp profile, int proflen));
|
||||
png_const_charp name, int compression_type,
|
||||
png_const_charp profile, int proflen));
|
||||
/* Note to maintainer: profile should be png_bytep */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_sPLT_SUPPORTED
|
||||
PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
|
||||
png_sPLT_tp palette));
|
||||
png_const_sPLT_tp palette));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
|
||||
png_color_16p values, int number, int color_type));
|
||||
PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr,
|
||||
png_const_bytep trans, png_const_color_16p values, int number,
|
||||
int color_type));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_bKGD_SUPPORTED
|
||||
PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
|
||||
png_color_16p values, int color_type));
|
||||
png_const_color_16p values, int color_type));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
|
||||
int num_hist));
|
||||
PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr,
|
||||
png_const_uint_16p hist, int num_hist));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
|
||||
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
|
||||
png_charp key, png_charpp new_key));
|
||||
png_const_charp key, png_charpp new_key));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_tEXt_SUPPORTED
|
||||
PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
|
||||
png_charp text, png_size_t text_len));
|
||||
PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_const_charp key,
|
||||
png_const_charp text, png_size_t text_len));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
|
||||
png_charp text, png_size_t text_len, int compression));
|
||||
PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_const_charp key,
|
||||
png_const_charp text, png_size_t text_len, int compression));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
|
||||
int compression, png_charp key, png_charp lang, png_charp lang_key,
|
||||
png_charp text));
|
||||
int compression, png_const_charp key, png_const_charp lang,
|
||||
png_const_charp lang_key, png_const_charp text));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
|
||||
PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_textp text_ptr, int num_text));
|
||||
png_infop info_ptr, png_const_textp text_ptr, int num_text));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_oFFs_SUPPORTED
|
||||
@ -637,7 +643,7 @@ PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
|
||||
#ifdef PNG_WRITE_pCAL_SUPPORTED
|
||||
PNG_EXTERN void png_write_pCAL PNGARG((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));
|
||||
png_const_charp units, png_charpp params));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_pHYs_SUPPORTED
|
||||
@ -648,12 +654,12 @@ PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
|
||||
png_timep mod_time));
|
||||
png_const_timep mod_time));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_sCAL_SUPPORTED
|
||||
PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
|
||||
int unit, png_charp width, png_charp height));
|
||||
int unit, png_const_charp width, png_const_charp height));
|
||||
#endif
|
||||
|
||||
/* Called when finished processing a row of data */
|
||||
@ -662,11 +668,6 @@ PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
|
||||
/* Internal use only. Called before first row of data */
|
||||
PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
|
||||
png_byte bit_depth));
|
||||
#endif
|
||||
|
||||
/* Combine a row of data, dealing with alpha, etc. if requested */
|
||||
PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
|
||||
int mask));
|
||||
@ -690,7 +691,8 @@ PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
|
||||
|
||||
/* Unfilter a row */
|
||||
PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
|
||||
png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
|
||||
png_row_infop row_info, png_bytep row, png_const_bytep prev_row,
|
||||
int filter));
|
||||
|
||||
/* Choose the best filter to use and filter the row data */
|
||||
PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
|
||||
@ -741,17 +743,19 @@ PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
|
||||
defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
|
||||
row_info, png_bytep row));
|
||||
PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr,
|
||||
png_row_infop row_info, png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
@ -760,25 +764,29 @@ PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
|
||||
png_color_8p sig_bits));
|
||||
PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_const_color_8p sig_bits));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
|
||||
PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
PNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_bytep palette_lookup, png_bytep quantize_lookup));
|
||||
png_bytep row, png_const_bytep palette_lookup,
|
||||
png_const_bytep quantize_lookup));
|
||||
|
||||
# ifdef PNG_CORRECT_PALETTE_SUPPORTED
|
||||
PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
|
||||
@ -787,7 +795,8 @@ PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
|
||||
PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info,
|
||||
png_bytep row));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
@ -796,35 +805,38 @@ PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
|
||||
png_color_8p bit_depth));
|
||||
PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_const_color_8p bit_depth));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
# ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_color, 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));
|
||||
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_const_color_16p trans_color,
|
||||
png_const_color_16p background, png_const_color_16p background_1,
|
||||
png_const_bytep gamma_table, png_const_bytep gamma_from_1,
|
||||
png_const_bytep gamma_to_1, png_const_uint_16pp gamma_16,
|
||||
png_const_uint_16pp gamma_16_from_1, png_const_uint_16pp gamma_16_to_1,
|
||||
int gamma_shift));
|
||||
# else
|
||||
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_color, png_color_16p background));
|
||||
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_const_color_16p trans_color,
|
||||
png_const_color_16p background));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
|
||||
png_bytep gamma_table, png_uint_16pp gamma_16_table,
|
||||
int gamma_shift));
|
||||
PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep gamma_table,
|
||||
png_const_uint_16pp gamma_16_table, int gamma_shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
|
||||
png_bytep row, png_const_colorp palette, png_const_bytep trans,
|
||||
int num_trans));
|
||||
PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
|
||||
png_bytep row, png_color_16p trans_value));
|
||||
png_bytep row, png_const_color_16p trans_color));
|
||||
#endif
|
||||
|
||||
/* The following decodes the appropriate chunks, and does error correction,
|
||||
@ -928,7 +940,7 @@ PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 length));
|
||||
|
||||
PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
|
||||
png_bytep chunk_name));
|
||||
png_const_bytep chunk_name));
|
||||
|
||||
/* Handle the transformations for reading and writing */
|
||||
PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
|
||||
@ -1044,7 +1056,7 @@ PNG_EXTERN PNG_FUNCTION(void, png_fixed_error, (png_structp png_ptr,
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_EXTERN void png_ascii_from_fp PNGARG((png_structp png_ptr, png_charp ascii,
|
||||
png_size_t size, double fp, unsigned precision));
|
||||
png_size_t size, double fp, unsigned int precision));
|
||||
#endif /* FLOATING_POINT */
|
||||
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
@ -1117,13 +1129,14 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
|
||||
* that omits the last character (i.e. set the size to the index of
|
||||
* the problem character.) This has not been tested within libpng.
|
||||
*/
|
||||
PNG_EXTERN int png_check_fp_number PNGARG((png_charp string, png_size_t size,
|
||||
int *statep, png_size_tp whereami));
|
||||
PNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string,
|
||||
png_size_t size, int *statep, png_size_tp whereami));
|
||||
|
||||
/* This is the same but it checks a complete string and returns true
|
||||
* only if it just contains a floating point number.
|
||||
*/
|
||||
PNG_EXTERN int png_check_fp_string PNGARG((png_charp string, png_size_t size));
|
||||
PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,
|
||||
png_size_t size));
|
||||
#endif /* pCAL || sCAL */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
@ -1168,11 +1181,11 @@ PNG_EXTERN png_fixed_point png_reciprocal2 PNGARG((png_fixed_point a,
|
||||
* correct bit value - 0..255 or 0..65535 as required.
|
||||
*/
|
||||
PNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr,
|
||||
unsigned value, png_fixed_point gamma));
|
||||
unsigned int value, png_fixed_point gamma));
|
||||
PNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma));
|
||||
PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned value,
|
||||
PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value,
|
||||
png_fixed_point gamma));
|
||||
PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned value,
|
||||
PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value,
|
||||
png_fixed_point gamma));
|
||||
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
|
||||
png_byte bit_depth));
|
||||
|
||||
29
pngrtran.c
29
pngrtran.c
@ -92,7 +92,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
/* Handle alpha and tRNS via a background color */
|
||||
void PNGFAPI
|
||||
png_set_background_fixed(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code,
|
||||
png_const_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, png_fixed_point background_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_background_fixed");
|
||||
@ -117,7 +117,7 @@ png_set_background_fixed(png_structp png_ptr,
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_background(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code,
|
||||
png_const_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, double background_gamma)
|
||||
{
|
||||
png_set_background_fixed(png_ptr, background_color, background_gamma_code,
|
||||
@ -174,7 +174,7 @@ typedef png_dsort FAR * FAR * png_dsortpp;
|
||||
|
||||
void PNGAPI
|
||||
png_set_quantize(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int num_palette, int maximum_colors, png_const_uint_16p histogram,
|
||||
int full_quantize)
|
||||
{
|
||||
png_debug(1, "in png_set_quantize");
|
||||
@ -1531,7 +1531,7 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
{
|
||||
png_do_quantize((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_do_quantize(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->quantize_index);
|
||||
|
||||
if (png_ptr->row_info.rowbytes == (png_uint_32)0)
|
||||
@ -1727,7 +1727,8 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
* the values back to 0 through 31.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p sig_bits)
|
||||
{
|
||||
png_debug(1, "in png_do_unshift");
|
||||
|
||||
@ -2679,12 +2680,12 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_color, png_color_16p background
|
||||
png_const_color_16p trans_color, png_const_color_16p background
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
, 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
|
||||
, png_const_color_16p background_1, png_const_bytep gamma_table,
|
||||
png_const_bytep gamma_from_1, png_const_bytep gamma_to_1,
|
||||
png_const_uint_16pp gamma_16, png_const_uint_16pp gamma_16_from_1,
|
||||
png_const_uint_16pp gamma_16_to_1, int gamma_shift
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@ -3425,7 +3426,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
png_bytep gamma_table, png_uint_16pp gamma_16_table,
|
||||
png_const_bytep gamma_table, png_const_uint_16pp gamma_16_table,
|
||||
int gamma_shift)
|
||||
{
|
||||
png_bytep sp;
|
||||
@ -3620,7 +3621,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
png_colorp palette, png_bytep trans_alpha, int num_trans)
|
||||
png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytep sp, dp;
|
||||
@ -3772,7 +3773,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_value)
|
||||
png_const_color_16p trans_value)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytep sp, dp;
|
||||
@ -3996,7 +3997,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_do_quantize(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep quantize_lookup)
|
||||
png_const_bytep palette_lookup, png_const_bytep quantize_lookup)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
28
pngrutil.c
28
pngrutil.c
@ -20,7 +20,7 @@
|
||||
|
||||
# define png_strtod(p,a,b) strtod(a,b)
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
||||
png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 i = png_get_uint_32(buf);
|
||||
if (i > PNG_UINT_31_MAX)
|
||||
@ -36,8 +36,8 @@ png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
||||
*/
|
||||
#define PNG_FIXED_ERROR (-1)
|
||||
|
||||
png_fixed_point /* PRIVATE */
|
||||
png_get_fixed_point(png_structp png_ptr, png_bytep buf)
|
||||
static png_fixed_point /* PRIVATE */
|
||||
png_get_fixed_point(png_structp png_ptr, png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 u = png_get_uint_32(buf);
|
||||
if (u <= PNG_UINT_31_MAX)
|
||||
@ -57,7 +57,7 @@ png_get_fixed_point(png_structp png_ptr, png_bytep buf)
|
||||
*/
|
||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||
png_uint_32 (PNGAPI
|
||||
png_get_uint_32)(png_bytep buf)
|
||||
png_get_uint_32)(png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 i =
|
||||
((png_uint_32)(*(buf )) << 24) +
|
||||
@ -74,7 +74,7 @@ png_get_uint_32)(png_bytep buf)
|
||||
* the following code does a two's complement to native conversion.
|
||||
*/
|
||||
png_int_32 (PNGAPI
|
||||
png_get_int_32)(png_bytep buf)
|
||||
png_get_int_32)(png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 u = png_get_uint_32(buf);
|
||||
if ((u & 0x80000000) == 0) /* non-negative */
|
||||
@ -86,7 +86,7 @@ png_get_int_32)(png_bytep buf)
|
||||
|
||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||
png_uint_16 (PNGAPI
|
||||
png_get_uint_16)(png_bytep buf)
|
||||
png_get_uint_16)(png_const_bytep buf)
|
||||
{
|
||||
png_uint_16 i =
|
||||
((png_uint_32)(*buf) << 8) +
|
||||
@ -236,12 +236,12 @@ png_crc_error(png_structp png_ptr)
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
|
||||
defined(PNG_READ_iCCP_SUPPORTED)
|
||||
static png_size_t
|
||||
png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
||||
png_inflate(png_structp png_ptr, png_bytep data, png_size_t size,
|
||||
png_bytep output, png_size_t output_size)
|
||||
{
|
||||
png_size_t count = 0;
|
||||
|
||||
png_ptr->zstream.next_in = (png_bytep)data; /* const_cast: VALID */
|
||||
png_ptr->zstream.next_in = data;
|
||||
png_ptr->zstream.avail_in = size;
|
||||
|
||||
while (1)
|
||||
@ -2478,7 +2478,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
|
||||
png_check_chunk_name(png_structp png_ptr, png_const_bytep chunk_name)
|
||||
{
|
||||
png_debug(1, "in png_check_chunk_name");
|
||||
if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) ||
|
||||
@ -2956,7 +2956,7 @@ png_do_read_interlace(png_structp png_ptr)
|
||||
|
||||
void /* PRIVATE */
|
||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
png_bytep prev_row, int filter)
|
||||
png_const_bytep prev_row, int filter)
|
||||
{
|
||||
png_debug(1, "in png_read_filter_row");
|
||||
png_debug2(2, "row = %u, filter = %d", png_ptr->row_number, filter);
|
||||
@ -2985,7 +2985,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
@ -2998,7 +2998,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep lp = row;
|
||||
png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
png_uint_32 istop = row_info->rowbytes - bpp;
|
||||
@ -3022,9 +3022,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
png_uint_32 i;
|
||||
png_bytep rp = row;
|
||||
png_bytep pp = prev_row;
|
||||
png_const_bytep pp = prev_row;
|
||||
png_bytep lp = row;
|
||||
png_bytep cp = prev_row;
|
||||
png_const_bytep cp = prev_row;
|
||||
png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
png_uint_32 istop=row_info->rowbytes - bpp;
|
||||
|
||||
|
||||
42
pngset.c
42
pngset.c
@ -22,7 +22,8 @@
|
||||
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr,
|
||||
png_const_color_16p background)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "bKGD");
|
||||
|
||||
@ -122,7 +123,7 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -231,8 +232,8 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
void PNGAPI
|
||||
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_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
|
||||
int nparams, png_const_charp units, png_charpp params)
|
||||
{
|
||||
png_size_t length;
|
||||
int i;
|
||||
@ -320,7 +321,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||
int unit, png_charp swidth, png_charp sheight)
|
||||
int unit, png_const_charp swidth, png_const_charp sheight)
|
||||
{
|
||||
png_size_t lengthw = 0, lengthh = 0;
|
||||
|
||||
@ -454,7 +455,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
void PNGAPI
|
||||
png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
png_colorp palette, int num_palette)
|
||||
png_const_colorp palette, int num_palette)
|
||||
{
|
||||
|
||||
png_debug1(1, "in %s storage function", "PLTE");
|
||||
@ -499,7 +500,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||
png_color_8p sig_bit)
|
||||
png_const_color_8p sig_bit)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "sBIT");
|
||||
|
||||
@ -555,8 +556,8 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
png_charp name, int compression_type,
|
||||
png_bytep profile, png_uint_32 proflen)
|
||||
png_const_charp name, int compression_type,
|
||||
png_const_bytep profile, png_uint_32 proflen)
|
||||
{
|
||||
png_charp new_iccp_name;
|
||||
png_bytep new_iccp_profile;
|
||||
@ -603,7 +604,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
png_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr,
|
||||
int num_text)
|
||||
{
|
||||
int ret;
|
||||
@ -614,8 +615,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
}
|
||||
|
||||
int /* PRIVATE */
|
||||
png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
png_set_text_2(png_structp png_ptr, png_infop info_ptr,
|
||||
png_const_textp text_ptr, int num_text)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -788,7 +789,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "tIME");
|
||||
|
||||
@ -804,7 +805,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep trans_alpha, int num_trans, png_color_16p trans_color)
|
||||
png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "tRNS");
|
||||
|
||||
@ -861,7 +862,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sPLT(png_structp png_ptr,
|
||||
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||
png_infop info_ptr, png_const_sPLT_tp entries, int nentries)
|
||||
/*
|
||||
* entries - array of png_sPLT_t structures
|
||||
* to be added to the list of palettes
|
||||
@ -895,7 +896,7 @@ png_set_sPLT(png_structp png_ptr,
|
||||
for (i = 0; i < nentries; i++)
|
||||
{
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_sPLT_tp from = entries + i;
|
||||
png_const_sPLT_tp from = entries + i;
|
||||
png_uint_32 length;
|
||||
|
||||
length = png_strlen(from->name) + 1;
|
||||
@ -938,7 +939,7 @@ png_set_sPLT(png_structp png_ptr,
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_structp png_ptr,
|
||||
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
|
||||
png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
int i;
|
||||
@ -966,10 +967,9 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
{
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_unknown_chunkp from = unknowns + i;
|
||||
png_const_unknown_chunkp from = unknowns + i;
|
||||
|
||||
png_memcpy((png_charp)to->name, (png_charp)from->name,
|
||||
png_sizeof(from->name));
|
||||
png_memcpy(to->name, from->name, png_sizeof(from->name));
|
||||
to->name[png_sizeof(to->name)-1] = '\0';
|
||||
to->size = from->size;
|
||||
/* Note our location in the read or write sequence */
|
||||
@ -1028,7 +1028,7 @@ png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep
|
||||
chunk_list, int num_chunks)
|
||||
{
|
||||
png_bytep new_list, p;
|
||||
|
||||
11
pngtrans.c
11
pngtrans.c
@ -79,7 +79,7 @@ png_set_packswap(png_structp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
@ -395,18 +395,19 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep rp, end, table;
|
||||
png_bytep rp;
|
||||
png_const_bytep end, table;
|
||||
|
||||
end = row + row_info->rowbytes;
|
||||
|
||||
if (row_info->bit_depth == 1)
|
||||
table = (png_bytep)onebppswaptable;
|
||||
table = onebppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 2)
|
||||
table = (png_bytep)twobppswaptable;
|
||||
table = twobppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 4)
|
||||
table = (png_bytep)fourbppswaptable;
|
||||
table = fourbppswaptable;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
37
pngvalid.c
37
pngvalid.c
@ -118,9 +118,9 @@ next_format(png_bytep colour_type, png_bytep bit_depth)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
static unsigned int
|
||||
sample(png_byte *row, png_byte colour_type, png_byte bit_depth, png_uint_32 x,
|
||||
unsigned sample)
|
||||
unsigned int sample)
|
||||
{
|
||||
png_uint_32 index, result;
|
||||
|
||||
@ -578,7 +578,7 @@ typedef struct png_modifier
|
||||
|
||||
/* Test values */
|
||||
double *gammas;
|
||||
unsigned ngammas;
|
||||
unsigned int ngammas;
|
||||
|
||||
/* Lowest sbit to test (libpng fails for sbit < 8) */
|
||||
png_byte sbitlow;
|
||||
@ -603,10 +603,10 @@ typedef struct png_modifier
|
||||
|
||||
/* Flags: */
|
||||
/* When to use the use_input_precision option: */
|
||||
unsigned use_input_precision :1;
|
||||
unsigned use_input_precision_sbit :1;
|
||||
unsigned use_input_precision_16to8 :1;
|
||||
unsigned log :1; /* Log max error */
|
||||
unsigned int use_input_precision :1;
|
||||
unsigned int use_input_precision_sbit :1;
|
||||
unsigned int use_input_precision_16to8 :1;
|
||||
unsigned int log :1; /* Log max error */
|
||||
|
||||
/* Buffer information, the buffer size limits the size of the chunks that can
|
||||
* be modified - they must fit (including header and CRC) into the buffer!
|
||||
@ -1006,7 +1006,7 @@ set_modifier_for_read(png_modifier *pm, png_infopp ppi, png_uint_32 id,
|
||||
#define STD_WIDTH 128U
|
||||
#define STD_ROWMAX (STD_WIDTH*8U)
|
||||
|
||||
static unsigned
|
||||
static unsigned int
|
||||
bit_size(png_structp pp, png_byte colour_type, png_byte bit_depth)
|
||||
{
|
||||
switch (colour_type)
|
||||
@ -1189,7 +1189,7 @@ make_standard(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
|
||||
if (colour_type == 3) /* palette */
|
||||
{
|
||||
unsigned i = 0;
|
||||
unsigned int i = 0;
|
||||
png_color pal[256];
|
||||
do
|
||||
pal[i].red = pal[i].green = pal[i].blue = (png_byte)i;
|
||||
@ -1540,7 +1540,7 @@ gamma_test(png_modifier *pm, PNG_CONST png_byte colour_type,
|
||||
{
|
||||
PNG_CONST png_byte out_ct = png_get_color_type(pp, pi);
|
||||
PNG_CONST png_byte out_bd = png_get_bit_depth(pp, pi);
|
||||
PNG_CONST unsigned outmax = (1U<<out_bd)-1;
|
||||
PNG_CONST unsigned int outmax = (1U<<out_bd)-1;
|
||||
PNG_CONST png_uint_32 w = png_get_image_width(pp, pi);
|
||||
PNG_CONST png_uint_32 h = png_get_image_height(pp, pi);
|
||||
PNG_CONST size_t cb = png_get_rowbytes(pp, pi); /* For memcmp below. */
|
||||
@ -1588,12 +1588,12 @@ gamma_test(png_modifier *pm, PNG_CONST png_byte colour_type,
|
||||
PNG_CONST int processing = (fabs(screen_gamma*file_gamma-1) >=
|
||||
PNG_GAMMA_THRESHOLD && !threshold_test && !speed && colour_type != 3)
|
||||
|| bit_depth != out_bd;
|
||||
PNG_CONST unsigned samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
PNG_CONST double gamma = 1/(file_gamma*screen_gamma); /* Overall */
|
||||
|
||||
for (y=0; y<h; ++y) /* just one pass - no interlacing */
|
||||
{
|
||||
unsigned s, x;
|
||||
unsigned int s, x;
|
||||
png_byte std[STD_ROWMAX];
|
||||
png_byte display[STD_ROWMAX];
|
||||
|
||||
@ -1603,9 +1603,10 @@ gamma_test(png_modifier *pm, PNG_CONST png_byte colour_type,
|
||||
if (processing) for (x=0; x<w; ++x) for (s=0; s<samples_per_pixel; ++s)
|
||||
{
|
||||
/* Input sample values: */
|
||||
PNG_CONST unsigned id = sample(std, colour_type, bit_depth, x, s);
|
||||
PNG_CONST unsigned od = sample(display, out_ct, out_bd, x, s);
|
||||
PNG_CONST unsigned isbit = id >> (bit_depth-sbit);
|
||||
PNG_CONST unsigned int id =
|
||||
sample(std, colour_type, bit_depth, x, s);
|
||||
PNG_CONST unsigned int od = sample(display, out_ct, out_bd, x, s);
|
||||
PNG_CONST unsigned int isbit = id >> (bit_depth-sbit);
|
||||
double i, sample, encoded_sample, output, encoded_error, error;
|
||||
double es_lo, es_hi;
|
||||
|
||||
@ -1849,7 +1850,7 @@ static void perform_gamma_transform_tests(png_modifier *pm, int speed)
|
||||
*/
|
||||
while (next_format(&colour_type, &bit_depth)) if (colour_type != 3)
|
||||
{
|
||||
unsigned i, j;
|
||||
unsigned int i, j;
|
||||
|
||||
for (i=0; i<pm->ngammas; ++i) for (j=0; j<pm->ngammas; ++j) if (i != j)
|
||||
{
|
||||
@ -1870,7 +1871,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm, int speed)
|
||||
*/
|
||||
for (sbit=pm->sbitlow; sbit<16; ++sbit)
|
||||
{
|
||||
unsigned i, j;
|
||||
unsigned int i, j;
|
||||
for (i=0; i<pm->ngammas; ++i) for (j=0; j<pm->ngammas; ++j)
|
||||
if (i != j)
|
||||
{
|
||||
@ -1906,7 +1907,7 @@ static void perform_gamma_strip16_tests(png_modifier *pm, int speed)
|
||||
* proceed *without* gamma correction, and the tests above will fail (but not
|
||||
* by much) - this could be fixed, it only appears with the -g option.
|
||||
*/
|
||||
unsigned i, j;
|
||||
unsigned int i, j;
|
||||
for (i=0; i<pm->ngammas; ++i) for (j=0; j<pm->ngammas; ++j)
|
||||
if (i != j && fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD)
|
||||
{
|
||||
|
||||
5
pngwio.c
5
pngwio.c
@ -30,10 +30,11 @@
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
{
|
||||
/* NOTE: write_data_fn must not change the buffer! */
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
(*(png_ptr->write_data_fn))(png_ptr, data, length);
|
||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
|
||||
11
pngwrite.c
11
pngwrite.c
@ -412,7 +412,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* "tm" structure is not supported on WindowsCE */
|
||||
void PNGAPI
|
||||
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
|
||||
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm FAR * ttime)
|
||||
{
|
||||
png_debug(1, "in png_convert_from_struct_tm");
|
||||
|
||||
@ -643,7 +643,7 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
|
||||
/* Called by user to write a row of image data */
|
||||
void PNGAPI
|
||||
png_write_row(png_structp png_ptr, png_bytep row)
|
||||
png_write_row(png_structp png_ptr, png_const_bytep row)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@ -1284,7 +1284,8 @@ png_init_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
int num_weights, png_doublep filter_weights, png_doublep filter_costs)
|
||||
int num_weights, png_const_doublep filter_weights,
|
||||
png_const_doublep filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics");
|
||||
|
||||
@ -1338,8 +1339,8 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method,
|
||||
int num_weights, png_fixed_point_p filter_weights,
|
||||
png_fixed_point_p filter_costs)
|
||||
int num_weights, png_const_fixed_point_p filter_weights,
|
||||
png_const_fixed_point_p filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics_fixed");
|
||||
|
||||
|
||||
@ -236,7 +236,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||
* data to 0 to 15.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_shift");
|
||||
|
||||
|
||||
175
pngwutil.c
175
pngwutil.c
@ -92,8 +92,8 @@ png_write_sig(png_structp png_ptr)
|
||||
* functions instead.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_bytep data, png_size_t length)
|
||||
png_write_chunk(png_structp png_ptr, png_const_bytep chunk_name,
|
||||
png_const_bytep data, png_size_t length)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@ -107,7 +107,7 @@ png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||
* passing in png_write_chunk_data().
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_name,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_byte buf[8];
|
||||
@ -149,7 +149,8 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
||||
* given to png_write_chunk_start().
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_write_chunk_data(png_structp png_ptr, png_const_bytep data,
|
||||
png_size_t length)
|
||||
{
|
||||
/* Write the data, and run the CRC over it */
|
||||
if (png_ptr == NULL)
|
||||
@ -195,17 +196,17 @@ png_write_chunk_end(png_structp png_ptr)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *input; /* The uncompressed input data */
|
||||
png_const_bytep input; /* The uncompressed input data */
|
||||
int input_len; /* Its length */
|
||||
int num_output_ptr; /* Number of output pointers used */
|
||||
int max_output_ptr; /* Size of output_ptr */
|
||||
png_charpp output_ptr; /* Array of pointers to output */
|
||||
png_bytep *output_ptr; /* Array of pointers to output */
|
||||
} compression_state;
|
||||
|
||||
/* Compress given text into storage in the png_ptr structure */
|
||||
static int /* PRIVATE */
|
||||
png_text_compress(png_structp png_ptr,
|
||||
png_charp text, png_size_t text_len, int compression,
|
||||
png_const_charp text, png_size_t text_len, int compression,
|
||||
compression_state *comp)
|
||||
{
|
||||
int ret;
|
||||
@ -219,7 +220,7 @@ png_text_compress(png_structp png_ptr,
|
||||
/* We may just want to pass the text right through */
|
||||
if (compression == PNG_TEXT_COMPRESSION_NONE)
|
||||
{
|
||||
comp->input = text;
|
||||
comp->input = (png_const_bytep)text;
|
||||
comp->input_len = text_len;
|
||||
return((int)text_len);
|
||||
}
|
||||
@ -283,10 +284,10 @@ png_text_compress(png_structp png_ptr,
|
||||
comp->max_output_ptr = comp->num_output_ptr + 4;
|
||||
if (comp->output_ptr != NULL)
|
||||
{
|
||||
png_charpp old_ptr;
|
||||
png_bytepp old_ptr;
|
||||
|
||||
old_ptr = comp->output_ptr;
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)
|
||||
(comp->max_output_ptr * png_sizeof(png_charpp)));
|
||||
png_memcpy(comp->output_ptr, old_ptr, old_max
|
||||
@ -294,14 +295,14 @@ png_text_compress(png_structp png_ptr,
|
||||
png_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)
|
||||
(comp->max_output_ptr * png_sizeof(png_charp)));
|
||||
}
|
||||
|
||||
/* Save the data */
|
||||
comp->output_ptr[comp->num_output_ptr] =
|
||||
(png_charp)png_malloc(png_ptr,
|
||||
(png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)png_ptr->zbuf_size);
|
||||
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
@ -334,11 +335,11 @@ png_text_compress(png_structp png_ptr,
|
||||
comp->max_output_ptr = comp->num_output_ptr + 4;
|
||||
if (comp->output_ptr != NULL)
|
||||
{
|
||||
png_charpp old_ptr;
|
||||
png_bytepp old_ptr;
|
||||
|
||||
old_ptr = comp->output_ptr;
|
||||
/* This could be optimized to realloc() */
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)(comp->max_output_ptr *
|
||||
png_sizeof(png_charp)));
|
||||
png_memcpy(comp->output_ptr, old_ptr,
|
||||
@ -347,14 +348,14 @@ png_text_compress(png_structp png_ptr,
|
||||
}
|
||||
|
||||
else
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)(comp->max_output_ptr *
|
||||
png_sizeof(png_charp)));
|
||||
}
|
||||
|
||||
/* Save the data */
|
||||
comp->output_ptr[comp->num_output_ptr] =
|
||||
(png_charp)png_malloc(png_ptr,
|
||||
(png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)png_ptr->zbuf_size);
|
||||
|
||||
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
|
||||
@ -395,8 +396,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
/* Handle the no-compression case */
|
||||
if (comp->input)
|
||||
{
|
||||
png_write_chunk_data(png_ptr, (png_bytep)comp->input,
|
||||
(png_size_t)comp->input_len);
|
||||
png_write_chunk_data(png_ptr, comp->input, (png_size_t)comp->input_len);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -404,7 +404,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
||||
/* Write saved output buffers, if any */
|
||||
for (i = 0; i < comp->num_output_ptr; i++)
|
||||
{
|
||||
png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i],
|
||||
png_write_chunk_data(png_ptr, comp->output_ptr[i],
|
||||
(png_size_t)png_ptr->zbuf_size);
|
||||
|
||||
png_free(png_ptr, comp->output_ptr[i]);
|
||||
@ -564,7 +564,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
buf[12] = (png_byte)interlace_type;
|
||||
|
||||
/* Write the chunk */
|
||||
png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
|
||||
png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||
|
||||
/* Initialize zlib with PNG info */
|
||||
png_ptr->zstream.zalloc = png_zalloc;
|
||||
@ -635,11 +635,12 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
* structure.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
||||
png_write_PLTE(png_structp png_ptr, png_const_colorp palette,
|
||||
png_uint_32 num_pal)
|
||||
{
|
||||
PNG_PLTE;
|
||||
png_uint_32 i;
|
||||
png_colorp pal_ptr;
|
||||
png_const_colorp pal_ptr;
|
||||
png_byte buf[3];
|
||||
|
||||
png_debug(1, "in png_write_PLTE");
|
||||
@ -673,8 +674,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
||||
png_ptr->num_palette = (png_uint_16)num_pal;
|
||||
png_debug1(3, "num_palette = %d", png_ptr->num_palette);
|
||||
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE,
|
||||
(png_uint_32)(num_pal * 3));
|
||||
png_write_chunk_start(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
|
||||
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
|
||||
@ -754,7 +754,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
"Invalid zlib compression method or flags in IDAT");
|
||||
}
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
|
||||
png_write_chunk(png_ptr, png_IDAT, data, length);
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
}
|
||||
|
||||
@ -766,7 +766,7 @@ png_write_IEND(png_structp png_ptr)
|
||||
|
||||
png_debug(1, "in png_write_IEND");
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0);
|
||||
png_write_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);
|
||||
png_ptr->mode |= PNG_HAVE_IEND;
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
|
||||
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
png_save_uint_32(buf, (png_uint_32)file_gamma);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -801,15 +801,15 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
||||
"Invalid sRGB rendering intent specified");
|
||||
|
||||
buf[0]=(png_byte)srgb_intent;
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
|
||||
png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
/* Write an iCCP chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
png_charp profile, int profile_len)
|
||||
png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
|
||||
png_const_charp profile, int profile_len)
|
||||
{
|
||||
PNG_iCCP;
|
||||
png_size_t name_len;
|
||||
@ -836,10 +836,10 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
|
||||
if (profile_len > 3)
|
||||
embedded_profile_len =
|
||||
((*( (png_bytep)profile ))<<24) |
|
||||
((*( (png_bytep)profile + 1))<<16) |
|
||||
((*( (png_bytep)profile + 2))<< 8) |
|
||||
((*( (png_bytep)profile + 3)) );
|
||||
((*( (png_const_bytep)profile ))<<24) |
|
||||
((*( (png_const_bytep)profile + 1))<<16) |
|
||||
((*( (png_const_bytep)profile + 2))<< 8) |
|
||||
((*( (png_const_bytep)profile + 3)) );
|
||||
|
||||
if (embedded_profile_len < 0)
|
||||
{
|
||||
@ -869,7 +869,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
(png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);
|
||||
|
||||
/* Make sure we include the NULL after the name and the compression type */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
|
||||
png_write_chunk_start(png_ptr, png_iCCP,
|
||||
(png_uint_32)(name_len + profile_len + 2));
|
||||
|
||||
new_name[name_len + 1] = 0x00;
|
||||
@ -888,7 +888,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
#ifdef PNG_WRITE_sPLT_SUPPORTED
|
||||
/* Write a sPLT chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||
png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)
|
||||
{
|
||||
PNG_sPLT;
|
||||
png_size_t name_len;
|
||||
@ -907,13 +907,13 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||
return;
|
||||
|
||||
/* Make sure we include the NULL after the name */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
|
||||
png_write_chunk_start(png_ptr, png_sPLT,
|
||||
(png_uint_32)(name_len + 2 + palette_size));
|
||||
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name,
|
||||
(png_size_t)(name_len + 1));
|
||||
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1);
|
||||
png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1);
|
||||
|
||||
/* Loop through each palette entry, writing appropriately */
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
@ -971,7 +971,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
||||
#ifdef PNG_WRITE_sBIT_SUPPORTED
|
||||
/* Write the sBIT chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
||||
png_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type)
|
||||
{
|
||||
PNG_sBIT;
|
||||
png_byte buf[4];
|
||||
@ -1022,7 +1022,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
||||
buf[size++] = sbit->alpha;
|
||||
}
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);
|
||||
png_write_chunk(png_ptr, png_sBIT, buf, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1057,7 +1057,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
||||
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
|
||||
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
||||
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1065,8 +1065,8 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
/* Write the tRNS chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
|
||||
int num_trans, int color_type)
|
||||
png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
|
||||
png_const_color_16p tran, int num_trans, int color_type)
|
||||
{
|
||||
PNG_tRNS;
|
||||
png_byte buf[6];
|
||||
@ -1082,8 +1082,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
|
||||
}
|
||||
|
||||
/* Write the chunk out as it is */
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans_alpha,
|
||||
(png_size_t)num_trans);
|
||||
png_write_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans);
|
||||
}
|
||||
|
||||
else if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
@ -1096,7 +1095,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
|
||||
return;
|
||||
}
|
||||
png_save_uint_16(buf, tran->gray);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
|
||||
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
|
||||
}
|
||||
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
@ -1111,7 +1110,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
|
||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
|
||||
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
|
||||
}
|
||||
|
||||
else
|
||||
@ -1124,7 +1123,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
|
||||
#ifdef PNG_WRITE_bKGD_SUPPORTED
|
||||
/* Write the background chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
|
||||
{
|
||||
PNG_bKGD;
|
||||
png_byte buf[6];
|
||||
@ -1145,7 +1144,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
}
|
||||
|
||||
buf[0] = back->index;
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
|
||||
}
|
||||
|
||||
else if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
@ -1160,7 +1159,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
|
||||
}
|
||||
|
||||
else
|
||||
@ -1173,7 +1172,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
return;
|
||||
}
|
||||
png_save_uint_16(buf, back->gray);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1181,7 +1180,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
/* Write the histogram */
|
||||
void /* PRIVATE */
|
||||
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
png_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist)
|
||||
{
|
||||
PNG_hIST;
|
||||
int i;
|
||||
@ -1198,8 +1197,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
return;
|
||||
}
|
||||
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_hIST,
|
||||
(png_uint_32)(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]);
|
||||
@ -1222,9 +1220,10 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
||||
* static keywords without having to have duplicate copies of the strings.
|
||||
*/
|
||||
png_size_t /* PRIVATE */
|
||||
png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
png_check_keyword(png_structp png_ptr, png_const_charp key, png_charpp new_key)
|
||||
{
|
||||
png_size_t key_len;
|
||||
png_const_charp ikp;
|
||||
png_charp kp, dp;
|
||||
int kflag;
|
||||
int kwarn=0;
|
||||
@ -1250,16 +1249,16 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
}
|
||||
|
||||
/* Replace non-printing characters with a blank and print a warning */
|
||||
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
|
||||
for (ikp = key, dp = *new_key; *ikp != '\0'; ikp++, dp++)
|
||||
{
|
||||
if ((png_byte)*kp < 0x20 ||
|
||||
((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1))
|
||||
if ((png_byte)*ikp < 0x20 ||
|
||||
((png_byte)*ikp > 0x7E && (png_byte)*ikp < 0xA1))
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
char msg[40];
|
||||
|
||||
png_snprintf(msg, 40,
|
||||
"invalid keyword character 0x%02X", (png_byte)*kp);
|
||||
"invalid keyword character 0x%02X", (png_byte)*ikp);
|
||||
png_warning(png_ptr, msg);
|
||||
#else
|
||||
png_warning(png_ptr, "invalid character in keyword");
|
||||
@ -1269,7 +1268,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
|
||||
else
|
||||
{
|
||||
*dp = *kp;
|
||||
*dp = *ikp;
|
||||
}
|
||||
}
|
||||
*dp = '\0';
|
||||
@ -1347,7 +1346,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
#ifdef PNG_WRITE_tEXt_SUPPORTED
|
||||
/* Write a tEXt chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
|
||||
png_size_t text_len)
|
||||
{
|
||||
PNG_tEXt;
|
||||
@ -1366,7 +1365,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
text_len = png_strlen(text);
|
||||
|
||||
/* Make sure we include the 0 after the key */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_tEXt,
|
||||
png_write_chunk_start(png_ptr, png_tEXt,
|
||||
(png_uint_32)(key_len + text_len + 1));
|
||||
/*
|
||||
* We leave it to the application to meet PNG-1.0 requirements on the
|
||||
@ -1378,7 +1377,8 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
(png_size_t)(key_len + 1));
|
||||
|
||||
if (text_len)
|
||||
png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text,
|
||||
(png_size_t)text_len);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
png_free(png_ptr, new_key);
|
||||
@ -1388,12 +1388,12 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
#ifdef PNG_WRITE_zTXt_SUPPORTED
|
||||
/* Write a compressed text chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
|
||||
png_size_t text_len, int compression)
|
||||
{
|
||||
PNG_zTXt;
|
||||
png_size_t key_len;
|
||||
char buf[1];
|
||||
png_byte buf;
|
||||
png_charp new_key;
|
||||
compression_state comp;
|
||||
|
||||
@ -1425,7 +1425,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
&comp);
|
||||
|
||||
/* Write start of chunk */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt,
|
||||
png_write_chunk_start(png_ptr, png_zTXt,
|
||||
(png_uint_32)(key_len+text_len + 2));
|
||||
|
||||
/* Write key */
|
||||
@ -1434,10 +1434,10 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
|
||||
png_free(png_ptr, new_key);
|
||||
|
||||
buf[0] = (png_byte)compression;
|
||||
buf = (png_byte)compression;
|
||||
|
||||
/* Write compression */
|
||||
png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
|
||||
png_write_chunk_data(png_ptr, &buf, (png_size_t)1);
|
||||
|
||||
/* Write the compressed data */
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
@ -1450,8 +1450,8 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
#ifdef PNG_WRITE_iTXt_SUPPORTED
|
||||
/* Write an iTXt chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
png_charp lang, png_charp lang_key, png_charp text)
|
||||
png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key,
|
||||
png_const_charp lang, png_const_charp lang_key, png_const_charp text)
|
||||
{
|
||||
PNG_iTXt;
|
||||
png_size_t lang_len, key_len, lang_key_len, text_len;
|
||||
@ -1497,8 +1497,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
/* Make sure we include the compression flag, the compression byte,
|
||||
* and the NULs after the key, lang, and lang_key parts */
|
||||
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
|
||||
(png_uint_32)(
|
||||
png_write_chunk_start(png_ptr, png_iTXt, (png_uint_32)(
|
||||
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
|
||||
+ key_len
|
||||
+ lang_len
|
||||
@ -1510,8 +1509,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
|
||||
* The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
|
||||
*/
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key,
|
||||
(png_size_t)(key_len + 1));
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key, (png_size_t)(key_len + 1));
|
||||
|
||||
/* Set the compression flag */
|
||||
if (compression == PNG_ITXT_COMPRESSION_NONE ||
|
||||
@ -1527,10 +1525,10 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
png_write_chunk_data(png_ptr, cbuf, (png_size_t)2);
|
||||
|
||||
cbuf[0] = 0;
|
||||
png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf),
|
||||
png_write_chunk_data(png_ptr, (new_lang ? (png_const_bytep)new_lang : cbuf),
|
||||
(png_size_t)(lang_len + 1));
|
||||
|
||||
png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf),
|
||||
png_write_chunk_data(png_ptr, (lang_key ? (png_const_bytep)lang_key : cbuf),
|
||||
(png_size_t)(lang_key_len + 1));
|
||||
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
@ -1560,14 +1558,15 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
|
||||
png_save_int_32(buf + 4, y_offset);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
|
||||
png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_WRITE_pCAL_SUPPORTED
|
||||
/* Write the pCAL chunk (described in the PNG extensions document) */
|
||||
void /* PRIVATE */
|
||||
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)
|
||||
png_int_32 X1, int type, int nparams, png_const_charp units,
|
||||
png_charpp params)
|
||||
{
|
||||
PNG_pCAL;
|
||||
png_size_t purpose_len, units_len, total_len;
|
||||
@ -1602,21 +1601,21 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
}
|
||||
|
||||
png_debug1(3, "pCAL total length = %d", (int)total_len);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_purpose,
|
||||
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)new_purpose,
|
||||
(png_size_t)purpose_len);
|
||||
png_save_int_32(buf, X0);
|
||||
png_save_int_32(buf + 4, X1);
|
||||
buf[8] = (png_byte)type;
|
||||
buf[9] = (png_byte)nparams;
|
||||
png_write_chunk_data(png_ptr, buf, (png_size_t)10);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)units, (png_size_t)units_len);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);
|
||||
|
||||
png_free(png_ptr, new_purpose);
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
png_write_chunk_data(png_ptr, (png_bytep)params[i],
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)params[i],
|
||||
(png_size_t)params_len[i]);
|
||||
}
|
||||
|
||||
@ -1628,8 +1627,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
#ifdef PNG_WRITE_sCAL_SUPPORTED
|
||||
/* Write the sCAL chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
|
||||
png_charp height)
|
||||
png_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width,
|
||||
png_const_charp height)
|
||||
{
|
||||
PNG_sCAL;
|
||||
png_byte buf[64];
|
||||
@ -1652,7 +1651,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
|
||||
png_memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */
|
||||
|
||||
png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
|
||||
png_write_chunk(png_ptr, png_sCAL, buf, total_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1675,7 +1674,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
|
||||
png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1684,7 +1683,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
||||
* or png_convert_from_time_t(), or fill in the structure yourself.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
||||
png_write_tIME(png_structp png_ptr, png_const_timep mod_time)
|
||||
{
|
||||
PNG_tIME;
|
||||
png_byte buf[7];
|
||||
@ -1706,7 +1705,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
||||
buf[5] = mod_time->minute;
|
||||
buf[6] = mod_time->second;
|
||||
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
|
||||
png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user