[CHG] libpng updated to version 1.5.1

This commit is contained in:
Crayon2000 2011-02-07 19:16:42 +00:00
parent 05adb413a2
commit 4623c28590
14 changed files with 523 additions and 380 deletions

View file

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_5_0 Your_png_h_is_not_version_1_5_0;
typedef png_libpng_version_1_5_1 Your_png_h_is_not_version_1_5_1;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -547,7 +547,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_const_timep ptime)
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
png_const_charp PNGAPI
png_get_copyright(png_structp png_ptr)
png_get_copyright(png_const_structp png_ptr)
{
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
#ifdef PNG_STRING_COPYRIGHT
@ -555,13 +555,13 @@ png_get_copyright(png_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.5.0 - January 6, 2011" PNG_STRING_NEWLINE \
"libpng version 1.5.1 - February 3, 2011" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2011 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;
# else
return "libpng version 1.5.0 - January 6, 2011\
return "libpng version 1.5.1 - February 3, 2011\
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -578,14 +578,14 @@ png_get_copyright(png_structp png_ptr)
* it is guaranteed that png.c uses the correct version of png.h.
*/
png_const_charp PNGAPI
png_get_libpng_ver(png_structp png_ptr)
png_get_libpng_ver(png_const_structp png_ptr)
{
/* Version of *.c files used when building libpng */
return png_get_header_ver(png_ptr);
}
png_const_charp PNGAPI
png_get_header_ver(png_structp png_ptr)
png_get_header_ver(png_const_structp png_ptr)
{
/* Version of *.h files used when building libpng */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
@ -593,7 +593,7 @@ png_get_header_ver(png_structp png_ptr)
}
png_const_charp PNGAPI
png_get_header_version(png_structp png_ptr)
png_get_header_version(png_const_structp png_ptr)
{
/* Returns longer string containing both version and date */
PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
@ -1031,10 +1031,10 @@ int
png_check_fp_string(png_const_charp string, png_size_t size)
{
int state=0;
png_size_t index=0;
png_size_t char_index=0;
return png_check_fp_number(string, size, &state, &index) &&
(index == size || string[index] == 0);
return png_check_fp_number(string, size, &state, &char_index) &&
(char_index == size || string[char_index] == 0);
}
#endif /* pCAL or sCAL */
@ -1108,46 +1108,46 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
if (fp >= DBL_MIN && fp <= DBL_MAX)
{
int exp; /* A base 10 exponent */
double base; /* 10^exp */
int exp_b10; /* A base 10 exponent */
double base; /* 10^exp_b10 */
/* First extract a base 10 exponent of the number,
* the calculation below rounds down when converting
* from base 2 to base 10 (multiply by log10(2) -
* 0.3010, but 77/256 is 0.3008, so exp needs to
* 0.3010, but 77/256 is 0.3008, so exp_b10 needs to
* be increased. Note that the arithmetic shift
* performs a floor() unlike C arithmetic - using a
* C multiply would break the following for negative
* exponents.
*/
(void)frexp(fp, &exp); /* exponent to base 2 */
(void)frexp(fp, &exp_b10); /* exponent to base 2 */
exp = (exp * 77) >> 8; /* <= exponent to base 10 */
exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */
/* Avoid underflow here. */
base = png_pow10(exp); /* May underflow */
base = png_pow10(exp_b10); /* May underflow */
while (base < DBL_MIN || base < fp)
{
/* And this may overflow. */
double test = png_pow10(exp+1);
double test = png_pow10(exp_b10+1);
if (test <= DBL_MAX)
++exp, base = test;
++exp_b10, base = test;
else
break;
}
/* Normalize fp and correct exp, after this fp is in the
* range [.1,1) and exp is both the exponent and the digit
/* Normalize fp and correct exp_b10, after this fp is in the
* range [.1,1) and exp_b10 is both the exponent and the digit
* *before* which the decimal point should be inserted
* (starting with 0 for the first digit). Note that this
* works even if 10^exp is out of range because of the
* works even if 10^exp_b10 is out of range because of the
* test on DBL_MAX above.
*/
fp /= base;
while (fp >= 1) fp /= 10, ++exp;
while (fp >= 1) fp /= 10, ++exp_b10;
/* Because of the code above fp may, at this point, be
* less than .1, this is ok because the code below can
@ -1162,10 +1162,10 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
/* Allow up to two leading zeros - this will not lengthen
* the number compared to using E-n.
*/
if (exp < 0 && exp > -3) /* PLUS 3 TOTAL 4 */
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
{
czero = -exp; /* PLUS 2 digits: TOTAL 3 */
exp = 0; /* Dot added below before first output. */
czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */
exp_b10 = 0; /* Dot added below before first output. */
}
else
czero = 0; /* No zeros to add */
@ -1207,17 +1207,17 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
{
int ch = *--ascii;
if (exp != (-1))
++exp;
if (exp_b10 != (-1))
++exp_b10;
else if (ch == 46)
{
ch = *--ascii, ++size;
/* Advance exp to '1', so that the
/* Advance exp_b10 to '1', so that the
* decimal point happens after the
* previous digit.
*/
exp = 1;
exp_b10 = 1;
}
--cdigits;
@ -1230,7 +1230,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
*/
if (d > 9) /* cdigits == 0 */
{
if (exp == (-1))
if (exp_b10 == (-1))
{
/* Leading decimal point (plus zeros?), if
* we lose the decimal point here it must
@ -1239,14 +1239,14 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
int ch = *--ascii;
if (ch == 46)
++size, exp = 1;
++size, exp_b10 = 1;
/* Else lost a leading zero, so 'exp' is
/* Else lost a leading zero, so 'exp_b10' is
* still ok at (-1)
*/
}
else
++exp;
++exp_b10;
/* In all cases we output a '1' */
d = 1;
@ -1269,23 +1269,24 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
while (czero > 0)
{
/* exp == (-1) means we just output the decimal
* place - after the DP don't adjust 'exp' any
/* exp_b10 == (-1) means we just output the decimal
* place - after the DP don't adjust 'exp_b10' any
* more!
*/
if (exp != (-1))
if (exp_b10 != (-1))
{
if (exp == 0) *ascii++ = 46, --size;
if (exp_b10 == 0) *ascii++ = 46, --size;
/* PLUS 1: TOTAL 4 */
--exp;
--exp_b10;
}
*ascii++ = 48, --czero;
}
if (exp != (-1))
if (exp_b10 != (-1))
{
if (exp == 0) *ascii++ = 46, --size; /* counted above */
--exp;
if (exp_b10 == 0) *ascii++ = 46, --size; /* counted
above */
--exp_b10;
}
*ascii++ = (char)(48 + (int)d), ++cdigits;
}
@ -1296,12 +1297,12 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
/* Check for an exponent, if we don't need one we are
* done and just need to terminate the string. At
* this point exp==(-1) is effectively if flag - it got
* this point exp_b10==(-1) is effectively if flag - it got
* to '-1' because of the decrement after outputing
* the decimal point above (the exponent required is
* *not* -1!)
*/
if (exp >= (-1) && exp <= 2)
if (exp_b10 >= (-1) && exp_b10 <= 2)
{
/* The following only happens if we didn't output the
* leading zeros above for negative exponent, so this
@ -1310,7 +1311,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
* zeros were *not* output, so this doesn't increase
* the output count.
*/
while (--exp >= 0) *ascii++ = 48;
while (--exp_b10 >= 0) *ascii++ = 48;
*ascii = 0;
@ -1329,18 +1330,18 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
size -= cdigits;
*ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision*/
if (exp < 0)
if (exp_b10 < 0)
{
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
exp = -exp;
exp_b10 = -exp_b10;
}
cdigits = 0;
while (exp > 0)
while (exp_b10 > 0)
{
exponent[cdigits++] = (char)(48 + exp % 10);
exp /= 10;
exponent[cdigits++] = (char)(48 + exp_b10 % 10);
exp_b10 /= 10;
}
/* Need another size check here for the exponent digits, so
@ -1459,11 +1460,10 @@ png_fixed(png_structp png_ptr, double fp, png_const_charp text)
{
double r = floor(100000 * fp + .5);
if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r;
if (r > 2147483647. || r < -2147483648.)
png_fixed_error(png_ptr, text);
png_fixed_error(png_ptr, text);
/*NOT REACHED*/
return (png_fixed_point)r;
}
#endif
@ -1477,10 +1477,10 @@ png_fixed(png_structp png_ptr, double fp, png_const_charp text)
*/
int
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 div)
png_int_32 divisor)
{
/* Return a * times / div, rounded. */
if (div != 0)
/* Return a * times / divisor, rounded. */
if (divisor != 0)
{
if (a == 0 || times == 0)
{
@ -1492,7 +1492,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = a;
r *= times;
r /= div;
r /= divisor;
r = floor(r+.5);
/* A png_fixed_point is a 32 bit integer. */
@ -1516,10 +1516,10 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
else
T = times;
if (div < 0)
negative = !negative, D = -div;
if (divisor < 0)
negative = !negative, D = -divisor;
else
D = div;
D = divisor;
/* Following can't overflow because the arguments only
* have 31 bits each, however the result may be 32 bits.
@ -1596,11 +1596,11 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
*/
png_fixed_point
png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times,
png_int_32 div)
png_int_32 divisor)
{
png_fixed_point result;
if (png_muldiv(&result, a, times, div))
if (png_muldiv(&result, a, times, divisor))
return result;
png_warning(png_ptr, "fixed point overflow ignored");
@ -1791,7 +1791,7 @@ png_8bit_l2[128] =
static png_int_32
png_log8bit(unsigned int x)
{
unsigned int log = 0;
unsigned int lg2 = 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
@ -1802,16 +1802,16 @@ png_log8bit(unsigned int x)
return 0xffffffff;
if ((x & 0xf0) == 0)
log = 4, x <<= 4;
lg2 = 4, x <<= 4;
if ((x & 0xc0) == 0)
log += 2, x <<= 2;
lg2 += 2, x <<= 2;
if ((x & 0x80) == 0)
log += 1, x <<= 1;
lg2 += 1, x <<= 1;
/* result is at most 19 bits, so this cast is safe: */
return (png_int_32)((log << 16) + ((png_8bit_l2[x-128]+32768)>>16));
return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16));
}
/* The above gives exact (to 16 binary places) log2 values for 8 bit images,
@ -1847,29 +1847,29 @@ png_log8bit(unsigned int x)
static png_int_32
png_log16bit(png_uint_32 x)
{
unsigned int log = 0;
unsigned int lg2 = 0;
/* As above, but now the input has 16 bits. */
if ((x &= 0xffff) == 0)
return 0xffffffff;
if ((x & 0xff00) == 0)
log = 8, x <<= 8;
lg2 = 8, x <<= 8;
if ((x & 0xf000) == 0)
log += 4, x <<= 4;
lg2 += 4, x <<= 4;
if ((x & 0xc000) == 0)
log += 2, x <<= 2;
lg2 += 2, x <<= 2;
if ((x & 0x8000) == 0)
log += 1, x <<= 1;
lg2 += 1, x <<= 1;
/* Calculate the base logarithm from the top 8 bits as a 28 bit fractional
* value.
*/
log <<= 28;
log += (png_8bit_l2[(x>>8)-128]+8) >> 4;
lg2 <<= 28;
lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4;
/* Now we need to interpolate the factor, this requires a division by the top
* 8 bits. Do this with maximum precision.
@ -1880,19 +1880,19 @@ png_log16bit(png_uint_32 x)
* the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly
* 16 bits to interpolate to get the low bits of the result. Round the
* answer. Note that the end point values are scaled by 64 to retain overall
* precision and that 'log' is current scaled by an extra 12 bits, so adjust
* precision and that 'lg2' is current scaled by an extra 12 bits, so adjust
* the overall scaling by 6-12. Round at every step.
*/
x -= 1U << 24;
if (x <= 65536U) /* <= '257' */
log += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12);
lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12);
else
log -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);
lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);
/* Safe, because the result can't have more than 20 bits: */
return (png_int_32)((log + 2048) >> 12);
return (png_int_32)((lg2 + 2048) >> 12);
}
/* The 'exp()' case must invert the above, taking a 20 bit fixed point
@ -1987,10 +1987,10 @@ png_exp(png_fixed_point x)
}
static png_byte
png_exp8bit(png_fixed_point log)
png_exp8bit(png_fixed_point lg2)
{
/* Get a 32 bit value: */
png_uint_32 x = png_exp(log);
png_uint_32 x = png_exp(lg2);
/* Convert the 32 bit value to 0..255 by multiplying by 256-1, note that the
* second, rounding, step can't overflow because of the first, subtraction,
@ -2001,10 +2001,10 @@ png_exp8bit(png_fixed_point log)
}
static png_uint_16
png_exp16bit(png_fixed_point log)
png_exp16bit(png_fixed_point lg2)
{
/* Get a 32 bit value: */
png_uint_32 x = png_exp(log);
png_uint_32 x = png_exp(lg2);
/* Convert the 32 bit value to 0..65535 by multiplying by 65536-1: */
x -= x >> 16;
@ -2013,18 +2013,18 @@ png_exp16bit(png_fixed_point log)
#endif /* FLOATING_ARITHMETIC */
png_byte
png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma)
png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
{
if (value > 0 && value < 255)
{
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = floor(255*pow(value/255.,gamma*.00001)+.5);
double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);
return (png_byte)r;
# else
png_int_32 log = png_log8bit(value);
png_int_32 lg2 = png_log8bit(value);
png_fixed_point res;
if (png_muldiv(&res, gamma, log, PNG_FP_1))
if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
return png_exp8bit(res);
/* Overflow. */
@ -2036,18 +2036,18 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma)
}
png_uint_16
png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma)
png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
{
if (value > 0 && value < 65535)
{
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = floor(65535*pow(value/65535.,gamma*.00001)+.5);
double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);
return (png_uint_16)r;
# else
png_int_32 log = png_log16bit(value);
png_int_32 lg2 = png_log16bit(value);
png_fixed_point res;
if (png_muldiv(&res, gamma, log, PNG_FP_1))
if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
return png_exp16bit(res);
/* Overflow. */
@ -2065,23 +2065,23 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma)
*/
png_uint_16 /* PRIVATE */
png_gamma_correct(png_structp png_ptr, unsigned int value,
png_fixed_point gamma)
png_fixed_point gamma_val)
{
if (png_ptr->bit_depth == 8)
return png_gamma_8bit_correct(value, gamma);
return png_gamma_8bit_correct(value, gamma_val);
else
return png_gamma_16bit_correct(value, gamma);
return png_gamma_16bit_correct(value, gamma_val);
}
/* This is the shared test on whether a gamma value is 'significant' - whether
* it is worth doing gamma correction.
*/
int /* PRIVATE */
png_gamma_significant(png_fixed_point gamma)
png_gamma_significant(png_fixed_point gamma_val)
{
return gamma < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||
gamma > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;
return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||
gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;
}
/* Internal function to build a single 16 bit table - the table consists of
@ -2094,7 +2094,7 @@ png_gamma_significant(png_fixed_point gamma)
*/
static void
png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma)
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
{
/* Various values derived from 'shift': */
PNG_CONST unsigned int num = 1U << (8U - shift);
@ -2113,7 +2113,7 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
/* The 'threshold' test is repeated here because it can arise for one of
* the 16 bit tables even if the others don't hit it.
*/
if (png_gamma_significant(gamma))
if (png_gamma_significant(gamma_val))
{
/* The old code would overflow at the end and this would cause the
* 'pow' function to return a result >1, resulting in an
@ -2129,13 +2129,13 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
png_uint_32 ig = (j << (8-shift)) + i;
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* Inline the 'max' scaling operation: */
double d = floor(65535*pow(ig/(double)max, gamma*.00001)+.5);
double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);
sub_table[j] = (png_uint_16)d;
# else
if (shift)
ig = (ig * 65535U + max_by_2)/max;
sub_table[j] = png_gamma_16bit_correct(ig, gamma);
sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);
# endif
}
}
@ -2162,7 +2162,7 @@ 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 int shift, PNG_CONST png_fixed_point gamma)
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
{
PNG_CONST unsigned int num = 1U << (8U - shift);
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
@ -2180,7 +2180,7 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * png_sizeof(png_uint_16));
/* 'gamma' is set to the reciprocal of the value calculated above, so
/* 'gamma_val' is set to the reciprocal of the value calculated above, so
* pow(out,g) is an *input* value. 'last' is the last input value set.
*
* In the loop 'i' is used to find output values. Since the output is 8
@ -2203,7 +2203,7 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
png_uint_16 out = (png_uint_16)(i * 257U); /* 16 bit output value */
/* Find the boundary value in 16 bits: */
png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma);
png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);
/* Adjust (round) to (16-shift) bits: */
bound = (bound * max + 32768U)/65535U + 1U;
@ -2229,13 +2229,13 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
*/
static void
png_build_8bit_table(png_structp png_ptr, png_bytepp ptable,
PNG_CONST png_fixed_point gamma)
PNG_CONST png_fixed_point gamma_val)
{
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++)
table[i] = png_gamma_8bit_correct(i, gamma);
if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++)
table[i] = png_gamma_8bit_correct(i, gamma_val);
else for (i=0; i<256; ++i)
table[i] = (png_byte)i;

View file

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5.0 - January 6, 2011
* libpng version 1.5.1 - February 3, 2011
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.5.0 - January 6, 2011: Glenn
* libpng versions 0.97, January 1998, through 1.5.1 - February 3, 2011: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -144,6 +144,9 @@
* 1.5.0beta01-58 15 10500 15.so.15.0[.0]
* 1.5.0rc01-07 15 10500 15.so.15.0[.0]
* 1.5.0 15 10500 15.so.15.0[.0]
* 1.5.1beta01-11 15 10501 15.so.15.1[.0]
* 1.5.1rc01-02 15 10501 15.so.15.1[.0]
* 1.5.1 15 10501 15.so.15.1[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -175,7 +178,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.5.0, January 6, 2011, are
* libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, 2011, are
* Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -287,13 +290,13 @@
* Y2K compliance in libpng:
* =========================
*
* January 6, 2011
* February 3, 2011
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.5.0 are Y2K compliant. It is my belief that
* upward through 1.5.1 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
@ -349,9 +352,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.5.0"
#define PNG_LIBPNG_VER_STRING "1.5.1"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.0 - January 6, 2011\n"
" libpng version 1.5.1 - February 3, 2011\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@ -359,7 +362,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 5
#define PNG_LIBPNG_VER_RELEASE 0
#define PNG_LIBPNG_VER_RELEASE 1
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/
@ -389,7 +392,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10500 /* 1.5.0 */
#define PNG_LIBPNG_VER 10501 /* 1.5.1 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -506,7 +509,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_5_0;
typedef char* png_libpng_version_1_5_1;
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to
@ -662,6 +665,7 @@ typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
typedef struct png_info_def png_info;
typedef png_info FAR * png_infop;
typedef PNG_CONST png_info FAR * png_const_infop;
typedef png_info FAR * FAR * png_infopp;
/* Maximum positive integer used in PNG is (2^31)-1 */
@ -789,6 +793,7 @@ typedef png_row_info FAR * FAR * png_row_infopp;
* expected to return the read data in the buffer.
*/
typedef struct png_struct_def png_struct;
typedef PNG_CONST png_struct FAR * png_const_structp;
typedef png_struct FAR * png_structp;
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp), );
@ -944,7 +949,7 @@ PNG_EXPORTA(5, png_structp, png_create_write_struct,
PNG_ALLOCATED);
PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
(png_structp png_ptr));
(png_const_structp png_ptr));
PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr,
png_size_t size));
@ -1064,14 +1069,17 @@ PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/* Expand the grayscale to 24-bit RGB if necessary. */
PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
/* Reduce RGB to grayscale. */
PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
int error_action, double red, double green));
PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr,
int error_action, png_fixed_point red, png_fixed_point green));
PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_structp png_ptr));
PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
png_ptr));
#endif
PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
@ -1408,7 +1416,7 @@ PNG_EXPORT(75, void, png_set_error_fn,
png_error_ptr error_fn, png_error_ptr warning_fn));
/* Return the user pointer associated with the error functions */
PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_structp png_ptr));
PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr));
/* Replace the default data output functions with a user supplied one(s).
* If buffered output is not used, then output_flush_fn can be set to NULL.
@ -1441,7 +1449,7 @@ PNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr,
PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn));
/* Return the user pointer associated with the memory functions */
PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_structp png_ptr));
PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr));
#endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
@ -1454,19 +1462,31 @@ PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr,
png_user_transform_ptr write_user_transform_fn));
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
PNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr,
png_voidp user_transform_ptr, int user_transform_depth,
int user_transform_channels));
/* Return the user pointer associated with the user transform functions */
PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_structp png_ptr));
PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
(png_const_structp png_ptr));
#endif
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
/* Return information about the row currently being processed. Note that these
* APIs do not fail but will return unexpected results if called outside a user
* transform callback. Also note that when transforming an interlaced image the
* row number is still the row in the final, de-interlaced, image but the row
* only contains the data of the current pass - consult png_row_info for the
* actual width of the row!
*/
PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));
PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));
#endif
#ifdef PNG_USER_CHUNKS_SUPPORTED
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr,
png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_structp png_ptr));
PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr));
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@ -1478,13 +1498,30 @@ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr,
png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
/* Returns the user pointer associated with the push read functions */
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_structp png_ptr));
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr));
/* Function to be called when data becomes available */
PNG_EXPORT(92, void, png_process_data,
(png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size));
/* A function which may be called *only* within png_process_data to stop the
* processing of any more data. The function returns the number of bytes
* remaining, excluding any that libpng has cached internally. A subsequent
* call to png_process_data must supply these bytes again. If the argument
* 'save' is set to true the routine will first save all the pending data and
* will always return 0.
*/
PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
/* A function which may be called *only* outside (after) a call to
* png_process_data. It returns the number of bytes of data to skip in the
* input. Normally it will return 0, but if it returns a non-zero value the
* application must skip than number of bytes of input data and pass the
* following data to the next call to png_process_data.
*/
PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
/* 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
@ -1604,92 +1641,92 @@ PNG_EXPORT(109, void, png_set_benign_errors,
*/
/* Returns "flag" if chunk data is valid in info_ptr. */
PNG_EXPORT(110, png_uint_32, png_get_valid,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 flag));
/* Returns number of bytes needed to hold a transformed row. */
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr,
png_const_infop info_ptr));
#ifdef PNG_INFO_IMAGE_SUPPORTED
/* Returns row_pointers, which is an array of pointers to scanlines that was
* returned from png_read_png().
*/
PNG_EXPORT(112, png_bytepp, png_get_rows,
(png_structp png_ptr, png_infop info_ptr));
(png_const_structp png_ptr, png_const_infop info_ptr));
/* Set row_pointers, which is an array of pointers to scanlines for use
* by png_write_png().
*/
PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr, png_infop info_ptr,
png_bytepp row_pointers));
PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr,
png_infop info_ptr, png_bytepp row_pointers));
#endif
/* Returns number of color channels in image. */
PNG_EXPORT(114, png_byte, png_get_channels,
(png_structp png_ptr, png_infop info_ptr));
(png_const_structp png_ptr, png_const_infop info_ptr));
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Returns image width in pixels. */
PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image height in pixels. */
PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image bit_depth. */
PNG_EXPORT(117, png_byte, png_get_bit_depth,
(png_structp png_ptr, png_infop info_ptr));
(png_const_structp png_ptr, png_const_infop info_ptr));
/* Returns image color_type. */
PNG_EXPORT(118, png_byte, png_get_color_type, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image filter_type. */
PNG_EXPORT(119, png_byte, png_get_filter_type, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image interlace_type. */
PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image compression_type. */
PNG_EXPORT(121, png_byte, png_get_compression_type, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr,
png_const_infop info_ptr));
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
(png_const_structp png_ptr, png_const_infop info_ptr));
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_structp png_ptr,
png_infop info_ptr));
PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,
(png_structp png_ptr, png_infop info_ptr));
(png_const_structp png_ptr, png_const_infop info_ptr));
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
(png_const_structp png_ptr, png_const_infop info_ptr));
#endif /* PNG_EASY_ACCESS_SUPPORTED */
/* Returns pointer to signature string read from PNG header */
PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(130, png_const_bytep, png_get_signature,
(png_const_structp png_ptr, png_infop info_ptr));
#ifdef PNG_bKGD_SUPPORTED
PNG_EXPORT(131, png_uint_32, png_get_bKGD,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_infop info_ptr,
png_color_16p *background));
#endif
@ -1699,13 +1736,14 @@ PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr,
#endif
#ifdef PNG_cHRM_SUPPORTED
PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_structp png_ptr,
png_infop info_ptr, double *white_x, double *white_y, double *red_x,
PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
png_const_infop info_ptr, double *white_x, double *white_y, double *red_x,
double *red_y, double *green_x, double *green_y, double *blue_x,
double *blue_y));
#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_structp png_ptr,
png_infop info_ptr, png_fixed_point *int_white_x,
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
(png_const_structp png_ptr,
png_const_infop info_ptr, png_fixed_point *int_white_x,
png_fixed_point *int_white_y, png_fixed_point *int_red_x,
png_fixed_point *int_red_y, png_fixed_point *int_green_x,
png_fixed_point *int_green_y, png_fixed_point *int_blue_x,
@ -1728,28 +1766,29 @@ PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr,
#ifdef PNG_gAMA_SUPPORTED
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
double *file_gamma));
PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_structp png_ptr,
png_infop info_ptr, png_fixed_point *int_file_gamma));
PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *int_file_gamma));
#endif
#ifdef PNG_gAMA_SUPPORTED
PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr, png_infop info_ptr,
double file_gamma));
PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr,
png_infop info_ptr, double file_gamma));
PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr,
png_infop info_ptr, png_fixed_point int_file_gamma));
#endif
#ifdef PNG_hIST_SUPPORTED
PNG_EXPORT(141, png_uint_32, png_get_hIST,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_16p *hist));
#endif
#ifdef PNG_hIST_SUPPORTED
PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr, png_infop info_ptr,
png_const_uint_16p hist));
PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr,
png_infop info_ptr, png_const_uint_16p hist));
#endif
PNG_EXPORT(143, png_uint_32, png_get_IHDR,
@ -1764,7 +1803,7 @@ PNG_EXPORT(144, void, png_set_IHDR,
#ifdef PNG_oFFs_SUPPORTED
PNG_EXPORT(145, png_uint_32, png_get_oFFs,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));
#endif
@ -1776,21 +1815,22 @@ PNG_EXPORT(146, void, png_set_oFFs,
#ifdef PNG_pCAL_SUPPORTED
PNG_EXPORT(147, png_uint_32, png_get_pCAL,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type,
int *nparams,
png_charp *units, png_charpp *params));
#endif
#ifdef PNG_pCAL_SUPPORTED
PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr, png_infop info_ptr,
PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr,
png_infop info_ptr,
png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
int nparams, png_const_charp units, png_charpp params));
#endif
#ifdef PNG_pHYs_SUPPORTED
PNG_EXPORT(149, png_uint_32, png_get_pHYs,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
#endif
@ -1801,7 +1841,7 @@ PNG_EXPORT(150, void, png_set_pHYs,
#endif
PNG_EXPORT(151, png_uint_32, png_get_PLTE,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_colorp *palette, int *num_palette));
PNG_EXPORT(152, void, png_set_PLTE,
@ -1810,7 +1850,7 @@ PNG_EXPORT(152, void, png_set_PLTE,
#ifdef PNG_sBIT_SUPPORTED
PNG_EXPORT(153, png_uint_32, png_get_sBIT,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_infop info_ptr,
png_color_8p *sig_bit));
#endif
@ -1820,20 +1860,20 @@ PNG_EXPORT(154, void, png_set_sBIT,
#endif
#ifdef PNG_sRGB_SUPPORTED
PNG_EXPORT(155, png_uint_32, png_get_sRGB,
(png_structp png_ptr, png_infop info_ptr, int *intent));
PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr,
png_const_infop info_ptr, int *file_srgb_intent));
#endif
#ifdef PNG_sRGB_SUPPORTED
PNG_EXPORT(156, void, png_set_sRGB,
(png_structp png_ptr, png_infop info_ptr, int intent));
(png_structp png_ptr, png_infop info_ptr, int srgb_intent));
PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr,
png_infop info_ptr, int intent));
png_infop info_ptr, int srgb_intent));
#endif
#ifdef PNG_iCCP_SUPPORTED
PNG_EXPORT(158, png_uint_32, png_get_iCCP,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_charpp name, int *compression_type, png_bytepp profile,
png_uint_32 *proflen));
#endif
@ -1847,7 +1887,7 @@ PNG_EXPORT(159, void, png_set_iCCP,
#ifdef PNG_sPLT_SUPPORTED
PNG_EXPORT(160, png_uint_32, png_get_sPLT,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_sPLT_tpp entries));
#endif
@ -1860,7 +1900,7 @@ PNG_EXPORT(161, void, png_set_sPLT,
#ifdef PNG_TEXT_SUPPORTED
/* png_get_text also returns the number of text chunks in *num_text */
PNG_EXPORT(162, png_uint_32, png_get_text,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
png_textp *text_ptr, int *num_text));
#endif
@ -1879,7 +1919,7 @@ PNG_EXPORT(163, void, png_set_text,
#ifdef PNG_tIME_SUPPORTED
PNG_EXPORT(164, png_uint_32, png_get_tIME,
(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time));
#endif
#ifdef PNG_tIME_SUPPORTED
@ -1889,7 +1929,7 @@ PNG_EXPORT(165, void, png_set_tIME,
#ifdef PNG_tRNS_SUPPORTED
PNG_EXPORT(166, png_uint_32, png_get_tRNS,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_infop info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color));
#endif
@ -1902,7 +1942,7 @@ PNG_EXPORT(167, void, png_set_tRNS,
#ifdef PNG_sCAL_SUPPORTED
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
(png_structp png_ptr, png_infop info_ptr,
(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, double *width, double *height));
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* NOTE: this API is currently implemented using floating point arithmetic,
@ -1910,13 +1950,14 @@ PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
* In any case the range of values supported by png_fixed_point is small and it
* is highly recommended that png_get_sCAL_s be used instead.
*/
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_structp png_ptr,
png_infop info_ptr, int *unit, png_fixed_point *width,
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
(png_structp png_ptr, png_const_infop info_ptr, int *unit,
png_fixed_point *width,
png_fixed_point *height));
#endif
PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
(png_structp png_ptr,
png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, png_charpp swidth, png_charpp sheight));
PNG_FP_EXPORT(170, void, png_set_sCAL,
(png_structp png_ptr, png_infop info_ptr,
@ -1947,11 +1988,12 @@ PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr,
#endif
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr,
png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns));
PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_structp png_ptr,
png_infop info_ptr, int chunk, int location));
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkpp entries));
png_infop info_ptr, png_const_unknown_chunkp unknowns,
int num_unknowns));
PNG_EXPORT(175, void, png_set_unknown_chunk_location,
(png_structp png_ptr, png_infop info_ptr, int chunk, int location));
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr,
png_const_infop info_ptr, png_unknown_chunkpp entries));
#endif
/* Png_free_data() will turn off the "valid" flag for anything it frees.
@ -1969,10 +2011,14 @@ PNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr,
int transforms, png_voidp params));
#endif
PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_structp png_ptr));
PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_structp png_ptr));
PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_structp png_ptr));
PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_structp png_ptr));
PNG_EXPORT(180, png_const_charp, png_get_copyright,
(png_const_structp png_ptr));
PNG_EXPORT(181, png_const_charp, png_get_header_ver,
(png_const_structp png_ptr));
PNG_EXPORT(182, png_const_charp, png_get_header_version,
(png_const_structp png_ptr));
PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
(png_const_structp png_ptr));
#ifdef PNG_MNG_FEATURES_SUPPORTED
PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr,
@ -1998,46 +2044,49 @@ PNG_EXPORT(185, void, png_set_strip_error_numbers,
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
PNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr,
png_uint_32 user_width_max, png_uint_32 user_height_max));
PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_structp png_ptr));
PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_structp png_ptr));
PNG_EXPORT(187, png_uint_32, png_get_user_width_max,
(png_const_structp png_ptr));
PNG_EXPORT(188, png_uint_32, png_get_user_height_max,
(png_const_structp png_ptr));
/* Added in libpng-1.4.0 */
PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr,
png_uint_32 user_chunk_cache_max));
PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_structp png_ptr));
PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,
(png_const_structp png_ptr));
/* Added in libpng-1.4.1 */
PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr,
png_alloc_size_t user_chunk_cache_max));
PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,
(png_structp png_ptr));
(png_const_structp png_ptr));
#endif
#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)
PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,
(png_const_structp png_ptr, png_const_infop info_ptr));
PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_structp png_ptr,
png_infop info_ptr));
PNG_FP_EXPORT(196, float, png_get_x_offset_inches,
(png_const_structp png_ptr, png_const_infop info_ptr));
#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,
(png_structp png_ptr, png_infop info_ptr));
(png_structp png_ptr, png_const_infop info_ptr));
#endif
PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_structp png_ptr,
png_infop info_ptr));
PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr,
png_const_infop info_ptr));
#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
(png_structp png_ptr, png_infop info_ptr));
(png_structp png_ptr, png_const_infop info_ptr));
#endif
# ifdef PNG_pHYs_SUPPORTED
PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_structp png_ptr,
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structp png_ptr,
png_const_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
int *unit_type));
# endif /* PNG_pHYs_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
@ -2046,7 +2095,10 @@ PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_structp png_ptr,
#ifdef PNG_IO_STATE_SUPPORTED
PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_structp png_ptr));
PNG_EXPORT(200, png_const_bytep, png_get_io_chunk_name, (png_structp png_ptr));
PNG_EXPORTA(200, png_const_bytep, png_get_io_chunk_name,
(png_structp png_ptr), PNG_DEPRECATED);
PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
(png_const_structp png_ptr));
/* The flags returned by png_get_io_state() are the following: */
# define PNG_IO_NONE 0x0000 /* no I/O at this moment */
@ -2155,31 +2207,6 @@ PNG_EXPORT(200, png_const_bytep, png_get_io_chunk_name, (png_structp png_ptr));
(png_uint_32)32767) / (png_uint_32)65535L)
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
#ifdef PNG_USE_READ_MACROS
/* Inline macros to do direct reads of bytes from the input buffer.
* The png_get_int_32() routine assumes we are using two's complement
* format for negative values, which is almost certainly true.
*/
# define png_get_uint_32(buf) \
(((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
/* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
* function) incorrectly returned a value of type png_uint_32.
*/
# define png_get_uint_16(buf) \
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((unsigned int)(*((buf) + 1)))))
# define png_get_int_32(buf) \
((png_int_32)((*(buf) & 0x80) \
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
: (png_int_32)png_get_uint_32(buf)))
#endif
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
@ -2207,15 +2234,41 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
/* No png_save_int_16 -- may be added if there's a real need for it. */
#endif
#ifdef PNG_USE_READ_MACROS
/* Inline macros to do direct reads of bytes from the input buffer.
* The png_get_int_32() routine assumes we are using two's complement
* format for negative values, which is almost certainly true.
*/
# define png_get_uint_32(buf) \
(((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \
((png_uint_32)(*((buf) + 2)) << 8) + \
((png_uint_32)(*((buf) + 3))))
/* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
* function) incorrectly returned a value of type png_uint_32.
*/
# define png_get_uint_16(buf) \
((png_uint_16) \
(((unsigned int)(*(buf)) << 8) + \
((unsigned int)(*((buf) + 1)))))
# define png_get_int_32(buf) \
((png_int_32)((*(buf) & 0x80) \
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
: (png_int_32)png_get_uint_32(buf)))
#endif
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/
/* The last ordinal number (this is the *last* one already used; the next
* one to use is one more than this.)
* one to use is one more than this.) Maintainer, remember to add an entry to
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(215);
PNG_EXPORT_LAST_ORDINAL(220);
#endif
#ifdef __cplusplus

View file

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.0 - January 6, 2011
* libpng version 1.5.1 - February 3, 2011
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View file

@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -423,7 +423,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr)
png_get_error_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return NULL;

View file

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -17,7 +17,8 @@
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
png_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 flag)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->valid & flag);
@ -26,7 +27,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
}
png_size_t PNGAPI
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
png_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->rowbytes);
@ -36,7 +37,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_INFO_IMAGE_SUPPORTED
png_bytepp PNGAPI
png_get_rows(png_structp png_ptr, png_infop info_ptr)
png_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->row_pointers);
@ -48,7 +49,7 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Easy access to info, added in libpng-0.99 */
png_uint_32 PNGAPI
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
png_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
@ -57,7 +58,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
png_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
@ -66,7 +67,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
png_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
@ -75,7 +76,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
png_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
@ -84,7 +85,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
png_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
@ -93,7 +94,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
png_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
@ -102,7 +103,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
}
png_byte PNGAPI
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
png_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
@ -111,7 +112,7 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@ -128,7 +129,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@ -145,7 +146,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
}
png_uint_32 PNGAPI
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@ -163,7 +164,7 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
@ -182,7 +183,8 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr)
png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
png_const_infop info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
@ -208,7 +210,7 @@ png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr)
#endif
png_int_32 PNGAPI
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@ -224,7 +226,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@ -240,7 +242,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@ -256,7 +258,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
}
png_int_32 PNGAPI
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
@ -305,19 +307,19 @@ ppi_from_ppm(png_uint_32 ppm)
}
png_uint_32 PNGAPI
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));
}
png_uint_32 PNGAPI
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));
}
png_uint_32 PNGAPI
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
png_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)
{
return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));
}
@ -335,7 +337,8 @@ png_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)
}
png_fixed_point PNGAPI
png_get_x_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_inches_fixed(png_structp png_ptr,
png_const_infop info_ptr)
{
return png_fixed_inches_from_microns(png_ptr,
png_get_x_offset_microns(png_ptr, info_ptr));
@ -344,7 +347,8 @@ png_get_x_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
png_get_y_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_inches_fixed(png_structp png_ptr,
png_const_infop info_ptr)
{
return png_fixed_inches_from_microns(png_ptr,
png_get_y_offset_microns(png_ptr, info_ptr));
@ -353,7 +357,7 @@ png_get_y_offset_inches_fixed(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
/* To avoid the overflow do the conversion directly in floating
* point.
@ -364,7 +368,7 @@ png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
png_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)
{
/* To avoid the overflow do the conversion directly in floating
* point.
@ -375,7 +379,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -419,7 +423,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
#endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte PNGAPI
png_get_channels(png_structp png_ptr, png_infop info_ptr)
png_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->channels);
@ -428,7 +432,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
}
png_const_bytep PNGAPI
png_get_signature(png_structp png_ptr, png_infop info_ptr)
png_get_signature(png_const_structp png_ptr, png_infop info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
return(info_ptr->signature);
@ -438,7 +442,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_bKGD_SUPPORTED
png_uint_32 PNGAPI
png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
png_color_16p *background)
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
@ -457,7 +461,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_cHRM_SUPPORTED
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
@ -490,7 +494,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
# ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
png_fixed_point *blue_x, png_fixed_point *blue_y)
@ -525,7 +529,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_gAMA_SUPPORTED
png_uint_32 PNGFAPI
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,
png_fixed_point *file_gamma)
{
png_debug1(1, "in %s retrieval function", "gAMA");
@ -541,7 +545,8 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
}
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,
double *file_gamma)
{
png_fixed_point igamma;
png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);
@ -557,7 +562,8 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
#ifdef PNG_sRGB_SUPPORTED
png_uint_32 PNGAPI
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
png_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,
int *file_srgb_intent)
{
png_debug1(1, "in %s retrieval function", "sRGB");
@ -574,7 +580,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
#ifdef PNG_iCCP_SUPPORTED
png_uint_32 PNGAPI
png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
png_charpp name, int *compression_type,
png_bytepp profile, png_uint_32 *proflen)
{
@ -599,7 +605,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sPLT_SUPPORTED
png_uint_32 PNGAPI
png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,
png_sPLT_tpp spalettes)
{
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
@ -614,7 +620,8 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
png_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_16p *hist)
{
png_debug1(1, "in %s retrieval function", "hIST");
@ -670,7 +677,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_oFFs_SUPPORTED
png_uint_32 PNGAPI
png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{
png_debug1(1, "in %s retrieval function", "oFFs");
@ -690,7 +697,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pCAL_SUPPORTED
png_uint_32 PNGAPI
png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
png_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params)
{
@ -718,7 +725,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
# ifdef PNG_FIXED_POINT_SUPPORTED
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL_fixed(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -738,7 +745,7 @@ png_get_sCAL_fixed(png_structp png_ptr, png_infop info_ptr,
# endif /* FIXED_POINT */
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -754,7 +761,7 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
}
# endif /* FLOATING POINT */
png_uint_32 PNGAPI
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,
int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL &&
@ -772,7 +779,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_pHYs_SUPPORTED
png_uint_32 PNGAPI
png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
png_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{
png_uint_32 retval = 0;
@ -806,8 +813,8 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
#endif /* pHYs */
png_uint_32 PNGAPI
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
int *num_palette)
png_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,
png_colorp *palette, int *num_palette)
{
png_debug1(1, "in %s retrieval function", "PLTE");
@ -825,7 +832,8 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
#ifdef PNG_sBIT_SUPPORTED
png_uint_32 PNGAPI
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
png_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,
png_color_8p *sig_bit)
{
png_debug1(1, "in %s retrieval function", "sBIT");
@ -842,8 +850,8 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#ifdef PNG_TEXT_SUPPORTED
png_uint_32 PNGAPI
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text)
png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
png_textp *text_ptr, int *num_text)
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
@ -869,7 +877,7 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
#ifdef PNG_tIME_SUPPORTED
png_uint_32 PNGAPI
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
png_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
{
png_debug1(1, "in %s retrieval function", "tIME");
@ -886,7 +894,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
#ifdef PNG_tRNS_SUPPORTED
png_uint_32 PNGAPI
png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
@ -931,7 +939,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
int PNGAPI
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,
png_unknown_chunkpp unknowns)
{
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
@ -946,7 +954,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI
png_get_rgb_to_gray_status (png_structp png_ptr)
png_get_rgb_to_gray_status (png_const_structp png_ptr)
{
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
}
@ -954,14 +962,14 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
#ifdef PNG_USER_CHUNKS_SUPPORTED
png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr)
png_get_user_chunk_ptr(png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_ptr : NULL);
}
#endif
png_size_t PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
png_get_compression_buffer_size(png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->zbuf_size : 0L);
}
@ -971,27 +979,27 @@ png_get_compression_buffer_size(png_structp png_ptr)
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
png_uint_32 PNGAPI
png_get_user_width_max (png_structp png_ptr)
png_get_user_width_max (png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->user_width_max : 0);
}
png_uint_32 PNGAPI
png_get_user_height_max (png_structp png_ptr)
png_get_user_height_max (png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->user_height_max : 0);
}
/* This function was added to libpng 1.4.0 */
png_uint_32 PNGAPI
png_get_chunk_cache_max (png_structp png_ptr)
png_get_chunk_cache_max (png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
}
/* This function was added to libpng 1.4.1 */
png_alloc_size_t PNGAPI
png_get_chunk_malloc_max (png_structp png_ptr)
png_get_chunk_malloc_max (png_const_structp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
}
@ -1005,6 +1013,15 @@ png_get_io_state (png_structp png_ptr)
return png_ptr->io_state;
}
png_uint_32 PNGAPI
png_get_io_chunk_type (png_const_structp png_ptr)
{
return ((png_ptr->chunk_name[0] << 24) +
(png_ptr->chunk_name[1] << 16) +
(png_ptr->chunk_name[2] << 8) +
(png_ptr->chunk_name[3]));
}
png_const_bytep PNGAPI
png_get_io_chunk_name (png_structp png_ptr)
{

View file

@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -647,7 +647,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
* pointer before png_write_destroy and png_read_destroy are called.
*/
png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr)
png_get_mem_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

View file

@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -41,6 +41,64 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
}
}
png_size_t PNGAPI
png_process_data_pause(png_structp png_ptr, int save)
{
if (png_ptr != NULL)
{
/* It's easiest for the caller if we do the save, then the caller doesn't
* have to supply the same data again:
*/
if (save)
png_push_save_buffer(png_ptr);
else
{
/* This includes any pending saved bytes: */
png_size_t remaining = png_ptr->buffer_size;
png_ptr->buffer_size = 0;
/* So subtract the saved buffer size, unless all the data
* is actually 'saved', in which case we just return 0
*/
if (png_ptr->save_buffer_size < remaining)
return remaining - png_ptr->save_buffer_size;
}
}
return 0;
}
png_uint_32 PNGAPI
png_process_data_skip(png_structp png_ptr)
{
png_uint_32 remaining = 0;
if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
png_ptr->skip_length > 0)
{
/* At the end of png_process_data the buffer size must be 0 (see the loop
* above) so we can detect a broken call here:
*/
if (png_ptr->buffer_size != 0)
png_error(png_ptr,
"png_process_data_skip called inside png_process_data");
/* If is impossible for there to be a saved buffer at this point -
* otherwise we could not be in SKIP mode. This will also happen if
* png_process_skip is called inside png_process_data (but only very
* rarely.)
*/
if (png_ptr->save_buffer_size != 0)
png_error(png_ptr, "png_process_data_skip called with saved data");
remaining = png_ptr->skip_length;
png_ptr->skip_length = 0;
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
return remaining;
}
/* What we do with the incoming data depends on what we were previously
* doing before we ran out of data...
*/
@ -582,10 +640,10 @@ png_push_crc_finish(png_structp png_ptr)
{
if (png_ptr->skip_length && png_ptr->save_buffer_size)
{
png_size_t save_size = png_ptr->current_buffer_size;
png_size_t save_size = png_ptr->save_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
/* We want the smaller of 'skip_length' and 'current_buffer_size', but
/* We want the smaller of 'skip_length' and 'save_buffer_size', but
* they are of different types and we don't know which variable has the
* fewest bits. Carefully select the smaller and cast it to the type of
* the larger - this cannot overflow. Do not cast in the following test
@ -609,10 +667,8 @@ png_push_crc_finish(png_structp png_ptr)
png_size_t save_size = png_ptr->current_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
/* We want the smaller of 'skip_length' and 'current_buffer_size', but
* they are of different types and we don't know which variable has the
* fewest bits. Carefully select the smaller and cast it to the type of
* the larger - this cannot overflow.
/* We want the smaller of 'skip_length' and 'current_buffer_size', here,
* the same problem exists as above and the same solution.
*/
if (skip_length < save_size)
save_size = (png_size_t)skip_length;
@ -1788,7 +1844,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
}
png_voidp PNGAPI
png_get_progressive_ptr(png_structp png_ptr)
png_get_progressive_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);

View file

@ -83,14 +83,13 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
# define PNG_MAX_MALLOC_64K
#endif
/* Unused formal parameter errors are removed using the following macro
* which is expected to have no bad effects on performance. Note that
* if you replace it with something other than whitespace, you must include
* the terminating semicolon.
/* Unused formal parameter warnings are silenced using the following macro
* which is expected to have no bad effects on performance (optimizing
* compilers will probably remove it entirely). Note that if you replace
* it with something other than whitespace, you must include the terminating
* semicolon.
*/
#ifndef PNG_UNUSED
# define PNG_UNUSED(param) param = param;
#endif
#define PNG_UNUSED(param) (void)param;
/* Just a little check that someone hasn't tried to define something
* contradictory.

View file

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [$RDATE%]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -841,7 +841,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
}
else
{
if (!(png_ptr->transformations & PNG_INTERLACE))
if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE))
{
/* Caller called png_start_read_image or png_read_update_info without
* first turning on the PNG_INTERLACE transform. We can fix this here,

View file

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -692,8 +692,13 @@ png_set_gray_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_to_rgb");
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
if (png_ptr != NULL)
{
/* Because rgb must be 8 bits or more: */
png_set_expand_gray_1_2_4_to_8(png_ptr);
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
}
#endif
@ -2427,7 +2432,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_debug(1, "in png_do_rgb_to_gray");
if (
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
@ -3778,7 +3783,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
row_info->rowbytes = row_width;
}
else if (row_info->bit_depth == 8)
if (row_info->bit_depth == 8)
{
{
if (trans_alpha != NULL)

View file

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -608,7 +608,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
png_debug1(3, "channels = %d", png_ptr->channels);
png_debug1(3, "rowbytes = %u", png_ptr->rowbytes);
png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes);
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
}
@ -1248,7 +1248,9 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_snprintf2(umsg, 80,
"Ignoring iCCP chunk with declared size = %u "
"and actual length = %u", profile_size, profile_length);
"and actual length = %u",
(unsigned int) profile_size,
(unsigned int) profile_length);
png_warning(png_ptr, umsg);
}
#else
@ -1960,7 +1962,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void /* PRIVATE */
png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_size_t slength, index;
png_size_t slength, i;
int state;
png_debug(1, "in png_handle_sCAL");
@ -2017,21 +2019,21 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Validate the ASCII numbers, need two ASCII numbers separated by
* a '\0' and they need to fit exactly in the chunk data.
*/
index = 0;
i = 0;
state = 0;
if (png_ptr->chunkdata[1] == 45 /* negative width */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) ||
index >= slength || png_ptr->chunkdata[index++] != 0)
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
i >= slength || png_ptr->chunkdata[i++] != 0)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format");
else
{
png_size_t heighti = index;
png_size_t heighti = i;
if (png_ptr->chunkdata[index] == 45 /* negative height */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) ||
index != slength)
if (png_ptr->chunkdata[i] == 45 /* negative height */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
i != slength)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format");
else
@ -3605,9 +3607,9 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_debug1(3, "height = %u,", png_ptr->height);
png_debug1(3, "iwidth = %u,", png_ptr->iwidth);
png_debug1(3, "num_rows = %u,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %u,", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %u",
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu",
(unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}

View file

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -87,7 +87,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_gAMA_SUPPORTED
void PNGFAPI
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
gamma)
file_gamma)
{
png_debug1(1, "in %s storage function", "gAMA");
@ -98,15 +98,15 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
* wrong, therefore storing them (and setting PNG_INFO_gAMA)
* must be wrong too.
*/
if (gamma > (png_fixed_point)PNG_UINT_31_MAX)
if (file_gamma > (png_fixed_point)PNG_UINT_31_MAX)
png_warning(png_ptr, "Gamma too large, ignored");
else if (gamma <= 0)
else if (file_gamma <= 0)
png_warning(png_ptr, "Negative or zero gamma ignored");
else
{
info_ptr->gamma = gamma;
info_ptr->gamma = file_gamma;
info_ptr->valid |= PNG_INFO_gAMA;
}
}
@ -352,7 +352,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
++lengthw;
png_debug1(3, "allocating unit for info (%u bytes)", lengthw);
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw);
@ -366,7 +366,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
++lengthh;
png_debug1(3, "allocating unit for info (%u bytes)", lengthh);
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh);
@ -522,27 +522,27 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_sRGB_SUPPORTED
void PNGAPI
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int srgb_intent)
{
png_debug1(1, "in %s storage function", "sRGB");
if (png_ptr == NULL || info_ptr == NULL)
return;
info_ptr->srgb_intent = (png_byte)intent;
info_ptr->srgb_intent = (png_byte)srgb_intent;
info_ptr->valid |= PNG_INFO_sRGB;
}
void PNGAPI
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int intent)
int srgb_intent)
{
png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
png_set_sRGB(png_ptr, info_ptr, intent);
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
# ifdef PNG_gAMA_SUPPORTED
png_set_gAMA_fixed(png_ptr, info_ptr, 45455L);
@ -751,10 +751,10 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
if (textp->key == NULL)
return(1);
png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
png_debug2(2, "Allocated %lu bytes at %p in png_set_text",
(unsigned long)(png_uint_32)
(key_len + lang_len + lang_key_len + text_length + 4),
(int)textp->key);
textp->key);
png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
*(textp->key + key_len) = '\0';

View file

@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -672,6 +672,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
void PNGAPI
png_set_user_transform_info(png_structp png_ptr, png_voidp
user_transform_ptr, int user_transform_depth, int user_transform_channels)
@ -680,33 +681,42 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
if (png_ptr == NULL)
return;
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
#else
if (user_transform_ptr || user_transform_depth || user_transform_channels)
png_warning(png_ptr,
"This version of libpng does not support user transform info");
#endif
}
#endif
/* This function returns a pointer to the user_transform_ptr associated with
* the user transform functions. The application should free any memory
* associated with this pointer before png_write_destroy and png_read_destroy
* are called.
*/
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr)
png_get_user_transform_ptr(png_const_structp png_ptr)
{
if (png_ptr == NULL)
return (NULL);
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
return ((png_voidp)png_ptr->user_transform_ptr);
#else
return (NULL);
}
#endif
png_uint_32 PNGAPI
png_get_current_row_number(png_const_structp png_ptr)
{
if (png_ptr != NULL)
return png_ptr->row_number;
return PNG_UINT_32_MAX; /* help the app not to fail silently */
}
png_byte PNGAPI
png_get_current_pass_number(png_const_structp png_ptr)
{
if (png_ptr != NULL)
return png_ptr->pass;
return 8; /* invalid */
}
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */

View file

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.5.0 [January 6, 2011]
* Last changed in libpng 1.5.1 [February 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -783,7 +783,8 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %u", png_ptr->row_info.rowbytes);
png_debug1(3, "row_info->rowbytes = %lu",
(unsigned long)png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);