mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Fixed more indentation to comply with our coding style.
This commit is contained in:
parent
9743d58bc0
commit
096dbf8335
34
example.c
34
example.c
@ -97,7 +97,7 @@ int main(int argc, const char **argv)
|
||||
*/
|
||||
if (buffer != NULL &&
|
||||
png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
{
|
||||
/* Now write the image out to the second argument. In the write
|
||||
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
|
||||
@ -105,7 +105,7 @@ int main(int argc, const char **argv)
|
||||
* to the 8-bit format.
|
||||
*/
|
||||
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
|
||||
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
|
||||
{
|
||||
/* The image has been written successfully. */
|
||||
exit(0);
|
||||
@ -295,7 +295,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
* was compiled with a compatible version of the library. REQUIRED
|
||||
*/
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
@ -419,10 +419,10 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
|
||||
if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
|
||||
png_set_background(png_ptr, image_background,
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
else
|
||||
png_set_background(png_ptr, &my_background,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
|
||||
|
||||
/* Some suggestions as to how to get a screen gamma value
|
||||
*
|
||||
@ -481,7 +481,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
png_color std_color_cube[MAX_SCREEN_COLORS];
|
||||
|
||||
png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
MAX_SCREEN_COLORS, NULL, 0);
|
||||
}
|
||||
/* This reduces the image to the palette supplied in the file */
|
||||
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
|
||||
@ -491,7 +491,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
png_get_hIST(png_ptr, info_ptr, &histogram);
|
||||
|
||||
png_set_quantize(png_ptr, palette, num_palette,
|
||||
max_screen_colors, histogram, 0);
|
||||
max_screen_colors, histogram, 0);
|
||||
}
|
||||
}
|
||||
#endif /* READ_QUANTIZE */
|
||||
@ -552,7 +552,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||
info_ptr));
|
||||
info_ptr));
|
||||
|
||||
/* Now it's time to read the image. One of these methods is REQUIRED */
|
||||
#ifdef entire /* Read the entire image in one go */
|
||||
@ -574,10 +574,10 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
|
||||
{
|
||||
#ifdef sparkle /* Read the image using the "sparkle" effect. */
|
||||
png_read_rows(png_ptr, &row_pointers[y], NULL,
|
||||
number_of_rows);
|
||||
number_of_rows);
|
||||
#else no_sparkle /* Read the image using the "rectangle" effect */
|
||||
png_read_rows(png_ptr, NULL, &row_pointers[y],
|
||||
number_of_rows);
|
||||
number_of_rows);
|
||||
#endif no_sparkle /* Use only one of these two methods */
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
* linked libraries.
|
||||
*/
|
||||
*png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (*png_ptr == NULL)
|
||||
{
|
||||
@ -649,14 +649,14 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
|
||||
* the function png_get_progressive_ptr(png_ptr).
|
||||
*/
|
||||
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
|
||||
info_callback, row_callback, end_callback);
|
||||
info_callback, row_callback, end_callback);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
int
|
||||
process_data(png_structp *png_ptr, png_infop *info_ptr,
|
||||
png_bytep buffer, png_uint_32 length)
|
||||
png_bytep buffer, png_uint_32 length)
|
||||
{
|
||||
if (setjmp(png_jmpbuf((*png_ptr))))
|
||||
{
|
||||
@ -691,7 +691,7 @@ info_callback(png_structp png_ptr, png_infop info)
|
||||
}
|
||||
|
||||
row_callback(png_structp png_ptr, png_bytep new_row,
|
||||
png_uint_32 row_num, int pass)
|
||||
png_uint_32 row_num, int pass)
|
||||
{
|
||||
/*
|
||||
* This function is called for every row in the image. If the
|
||||
@ -780,7 +780,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
png_voidp user_error_ptr, user_error_fn, user_warning_fn);
|
||||
|
||||
if (png_ptr == NULL)
|
||||
{
|
||||
@ -819,7 +819,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* png_init_io() here you would call
|
||||
*/
|
||||
png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
|
||||
user_IO_flush_function);
|
||||
user_IO_flush_function);
|
||||
/* where user_io_ptr is a structure you want available to the callbacks */
|
||||
#endif no_streams /* Only use one initialization method */
|
||||
|
||||
@ -842,7 +842,7 @@ void write_png(char *file_name /* , ... other image information ... */)
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
|
||||
*/
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* Set the palette if there is one. REQUIRED for indexed-color images */
|
||||
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
|
||||
|
154
png.c
154
png.c
@ -81,7 +81,7 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
|
||||
if (items >= (~(png_alloc_size_t)0)/size)
|
||||
{
|
||||
png_warning(png_voidcast(png_structrp, png_ptr),
|
||||
"Potential overflow in png_zalloc()");
|
||||
"Potential overflow in png_zalloc()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
if (png_user_version_check(&create_struct, user_png_ver) != 0)
|
||||
{
|
||||
png_structrp png_ptr = png_voidcast(png_structrp,
|
||||
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
|
||||
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -352,7 +352,7 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
|
||||
* has always been done in 'example.c'.
|
||||
*/
|
||||
info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
|
||||
(sizeof *info_ptr)));
|
||||
(sizeof *info_ptr)));
|
||||
|
||||
if (info_ptr != NULL)
|
||||
memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
@ -399,7 +399,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
|
||||
|
||||
void PNGAPI
|
||||
png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
||||
int num)
|
||||
int num)
|
||||
{
|
||||
png_debug(1, "in png_free_data");
|
||||
|
||||
@ -704,14 +704,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta83 - July 4, 2016" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta83 - July 15, 2016" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2016 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.7.0beta83 - July 4, 2016\
|
||||
return "libpng version 1.7.0beta83 - July 15, 2016\
|
||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
@ -933,7 +933,7 @@ png_zstream_error(z_stream *zstream, int ret)
|
||||
#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */
|
||||
static int
|
||||
png_colorspace_check_gamma(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA, int from)
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA, int from)
|
||||
/* This is called to check a new gamma value against an existing one. The
|
||||
* routine returns false if the new gamma value should not be written.
|
||||
*
|
||||
@ -953,7 +953,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
|
||||
png_fixed_point gtest;
|
||||
|
||||
if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
(png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
|
||||
(png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
|
||||
gtest < PNG_FP_1 - 1000 || gtest > PNG_FP_1 + 1000))
|
||||
{
|
||||
/* Either this is an sRGB image, in which case the calculated gamma
|
||||
@ -965,7 +965,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
|
||||
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)
|
||||
{
|
||||
png_chunk_report(png_ptr, "gamma value does not match sRGB",
|
||||
PNG_CHUNK_ERROR);
|
||||
PNG_CHUNK_ERROR);
|
||||
/* Do not overwrite an sRGB value */
|
||||
return from == 2;
|
||||
}
|
||||
@ -973,7 +973,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
|
||||
else /* sRGB tag not involved */
|
||||
{
|
||||
png_chunk_report(png_ptr, "gamma value does not match libpng estimate",
|
||||
PNG_CHUNK_WARNING);
|
||||
PNG_CHUNK_WARNING);
|
||||
return from == 1;
|
||||
}
|
||||
}
|
||||
@ -983,7 +983,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr,
|
||||
|
||||
void /* PRIVATE */
|
||||
png_colorspace_set_gamma(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA)
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA)
|
||||
{
|
||||
/* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
|
||||
* occur. Since the fixed point representation is asymmetrical it is
|
||||
@ -1573,8 +1573,8 @@ static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
|
||||
|
||||
static int
|
||||
png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
|
||||
int preferred)
|
||||
png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
|
||||
int preferred)
|
||||
{
|
||||
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
||||
return 0;
|
||||
@ -1621,7 +1621,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_chromaticities(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, const png_xy *xy, int preferred)
|
||||
png_colorspacerp colorspace, const png_xy *xy, int preferred)
|
||||
{
|
||||
/* We must check the end points to ensure they are reasonable - in the past
|
||||
* color management systems have crashed as a result of getting bogus
|
||||
@ -1635,7 +1635,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
|
||||
{
|
||||
case 0: /* success */
|
||||
return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,
|
||||
preferred);
|
||||
preferred);
|
||||
|
||||
case 1:
|
||||
/* We can't invert the chromaticities so we can't produce value XYZ
|
||||
@ -1659,7 +1659,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_endpoints(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
|
||||
png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
|
||||
{
|
||||
png_XYZ XYZ = *XYZ_in;
|
||||
png_xy xy;
|
||||
@ -1668,7 +1668,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr,
|
||||
{
|
||||
case 0:
|
||||
return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,
|
||||
preferred);
|
||||
preferred);
|
||||
|
||||
case 1:
|
||||
/* End points are invalid. */
|
||||
@ -1726,7 +1726,7 @@ is_ICC_signature(png_alloc_size_t it)
|
||||
|
||||
static int
|
||||
png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_alloc_size_t value, png_const_charp reason)
|
||||
png_const_charp name, png_alloc_size_t value, png_const_charp reason)
|
||||
{
|
||||
size_t pos;
|
||||
char message[196]; /* see below for calculation */
|
||||
@ -1751,8 +1751,8 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/
|
||||
|
||||
pos = png_safecat(message, (sizeof message), pos,
|
||||
png_format_number(number, number+(sizeof number),
|
||||
PNG_NUMBER_FORMAT_x, value));
|
||||
png_format_number(number, number+(sizeof number),
|
||||
PNG_NUMBER_FORMAT_x, value));
|
||||
pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/
|
||||
}
|
||||
# endif
|
||||
@ -1766,7 +1766,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* application errors the PNG won't be written.)
|
||||
*/
|
||||
png_chunk_report(png_ptr, message,
|
||||
(colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
|
||||
(colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1775,7 +1775,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
int intent)
|
||||
int intent)
|
||||
{
|
||||
/* sRGB sets known gamma, end points and (from the chunk) intent. */
|
||||
/* IMPORTANT: these are not necessarily the values found in an ICC profile
|
||||
@ -1812,10 +1812,10 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
*/
|
||||
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
|
||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||
(unsigned)intent, "invalid sRGB rendering intent");
|
||||
(unsigned)intent, "invalid sRGB rendering intent");
|
||||
|
||||
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
|
||||
colorspace->rendering_intent != intent)
|
||||
colorspace->rendering_intent != intent)
|
||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||
(unsigned)intent, "inconsistent rendering intents");
|
||||
|
||||
@ -1829,8 +1829,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* warn but overwrite the value with the correct one.
|
||||
*/
|
||||
if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
|
||||
!png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
|
||||
100))
|
||||
!png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
|
||||
100))
|
||||
png_chunk_report(png_ptr, "cHRM chunk does not match sRGB",
|
||||
PNG_CHUNK_ERROR);
|
||||
|
||||
@ -1838,7 +1838,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* returns true when the 'from' argument corresponds to sRGB (2).
|
||||
*/
|
||||
(void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,
|
||||
2/*from sRGB*/);
|
||||
2/*from sRGB*/);
|
||||
|
||||
/* intent: bugs in GCC force 'int' to be used as the parameter type. */
|
||||
colorspace->rendering_intent = png_check_u16(png_ptr, intent);
|
||||
@ -1873,23 +1873,23 @@ static const png_byte D50_nCIEXYZ[12] =
|
||||
|
||||
int /* PRIVATE */
|
||||
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length)
|
||||
png_const_charp name, png_uint_32 profile_length)
|
||||
{
|
||||
if (profile_length < 132)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||
"too short");
|
||||
"too short");
|
||||
|
||||
if (profile_length & 3)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||
"invalid length");
|
||||
"invalid length");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int /* PRIVATE */
|
||||
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile/* first 132 bytes only */, int is_color)
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile/* first 132 bytes only */, int is_color)
|
||||
{
|
||||
png_uint_32 temp;
|
||||
|
||||
@ -1901,13 +1901,13 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
temp = png_get_uint_32(profile);
|
||||
if (temp != profile_length)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"length does not match profile");
|
||||
"length does not match profile");
|
||||
|
||||
temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
|
||||
if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
|
||||
profile_length < 132+12*temp) /* truncated tag table */
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"tag count too large");
|
||||
"tag count too large");
|
||||
|
||||
/* The 'intent' must be valid or we can't store it, ICC limits the intent to
|
||||
* 16 bits.
|
||||
@ -1915,14 +1915,14 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
temp = png_get_uint_32(profile+64);
|
||||
if (temp >= 0xffff) /* The ICC limit */
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"invalid rendering intent");
|
||||
"invalid rendering intent");
|
||||
|
||||
/* This is just a warning because the profile may be valid in future
|
||||
* versions.
|
||||
*/
|
||||
if (temp >= PNG_sRGB_INTENT_LAST)
|
||||
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
|
||||
"intent outside defined range");
|
||||
"intent outside defined range");
|
||||
|
||||
/* At this point the tag table can't be checked because it hasn't necessarily
|
||||
* been loaded; however, various header fields can be checked. These checks
|
||||
@ -1939,7 +1939,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
temp = png_get_uint_32(profile+36); /* signature 'ascp' */
|
||||
if (temp != 0x61637370)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"invalid signature");
|
||||
"invalid signature");
|
||||
|
||||
/* Currently the PCS illuminant/adopted white point (the computational
|
||||
* white point) are required to be D50,
|
||||
@ -1950,7 +1950,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
*/
|
||||
if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)
|
||||
(void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,
|
||||
"PCS illuminant is not D50");
|
||||
"PCS illuminant is not D50");
|
||||
|
||||
/* The PNG spec requires this:
|
||||
* "If the iCCP chunk is present, the image samples conform to the colour
|
||||
@ -1978,18 +1978,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
case 0x52474220: /* 'RGB ' */
|
||||
if (!is_color)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"RGB color space not permitted on grayscale PNG");
|
||||
"RGB color space not permitted on grayscale PNG");
|
||||
break;
|
||||
|
||||
case 0x47524159: /* 'GRAY' */
|
||||
if (is_color)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"Gray color space not permitted on RGB PNG");
|
||||
"Gray color space not permitted on RGB PNG");
|
||||
break;
|
||||
|
||||
default:
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"invalid ICC profile color space");
|
||||
"invalid ICC profile color space");
|
||||
}
|
||||
|
||||
/* It is up to the application to check that the profile class matches the
|
||||
@ -2014,7 +2014,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
case 0x61627374: /* 'abst' */
|
||||
/* May not be embedded in an image */
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"invalid embedded Abstract ICC profile");
|
||||
"invalid embedded Abstract ICC profile");
|
||||
|
||||
case 0x6C696E6B: /* 'link' */
|
||||
/* DeviceLink profiles cannot be interpreted in a non-device specific
|
||||
@ -2024,7 +2024,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* PNG.
|
||||
*/
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"unexpected DeviceLink ICC profile class");
|
||||
"unexpected DeviceLink ICC profile class");
|
||||
|
||||
case 0x6E6D636C: /* 'nmcl' */
|
||||
/* A NamedColor profile is also device specific, however it doesn't
|
||||
@ -2032,7 +2032,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* certainly it will fail the tests below.
|
||||
*/
|
||||
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
|
||||
"unexpected NamedColor ICC profile class");
|
||||
"unexpected NamedColor ICC profile class");
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2042,7 +2042,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* understood profiles.
|
||||
*/
|
||||
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
|
||||
"unrecognized ICC profile class");
|
||||
"unrecognized ICC profile class");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2058,7 +2058,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
|
||||
default:
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, temp,
|
||||
"unexpected ICC PCS encoding");
|
||||
"unexpected ICC PCS encoding");
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -2066,8 +2066,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile /* header plus whole tag table */)
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile /* header plus whole tag table */)
|
||||
{
|
||||
png_uint_32 tag_count = png_get_uint_32(profile+128);
|
||||
png_uint_32 itag;
|
||||
@ -2095,7 +2095,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
* alignment.
|
||||
*/
|
||||
(void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
|
||||
"ICC profile tag start not a multiple of 4");
|
||||
"ICC profile tag start not a multiple of 4");
|
||||
}
|
||||
|
||||
/* This is a hard error; potentially it can cause read outside the
|
||||
@ -2103,7 +2103,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
*/
|
||||
if (tag_start > profile_length || tag_length > profile_length - tag_start)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
|
||||
"ICC profile tag outside profile");
|
||||
"ICC profile tag outside profile");
|
||||
}
|
||||
|
||||
return 1; /* success, maybe with warnings */
|
||||
@ -2131,22 +2131,22 @@ static const struct
|
||||
*/
|
||||
/* adler32, crc32, MD5[4], intent, date, length, file-name */
|
||||
PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
|
||||
PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
|
||||
"2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
|
||||
PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
|
||||
"2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
|
||||
|
||||
/* ICC sRGB v2 perceptual no black-compensation: */
|
||||
PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
|
||||
PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
|
||||
"2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
|
||||
PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
|
||||
"2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
|
||||
|
||||
PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
|
||||
PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
|
||||
"2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
|
||||
PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
|
||||
"2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
|
||||
|
||||
/* ICC sRGB v4 perceptual */
|
||||
PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
|
||||
PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
|
||||
"2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
|
||||
PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
|
||||
"2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
|
||||
|
||||
/* The following profiles have no known MD5 checksum. If there is a match
|
||||
* on the (empty) MD5 the other fields are used to attempt a match and
|
||||
@ -2154,8 +2154,8 @@ static const struct
|
||||
* which suggests that they were also made by Hewlett Packard.
|
||||
*/
|
||||
PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
|
||||
"2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
|
||||
"2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
|
||||
|
||||
/* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not
|
||||
* match the D50 PCS illuminant in the header (it is in fact the D65 values,
|
||||
@ -2165,17 +2165,17 @@ static const struct
|
||||
* chromaticAdaptationTag.
|
||||
*/
|
||||
PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
|
||||
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
|
||||
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
|
||||
|
||||
PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
|
||||
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
|
||||
PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
|
||||
"1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
|
||||
};
|
||||
|
||||
static int
|
||||
png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
png_const_bytep profile, uLong adler)
|
||||
png_const_bytep profile, uLong adler)
|
||||
{
|
||||
/* The quick check is to verify just the MD5 signature and trust the
|
||||
* rest of the data. Because the profile has already been verified for
|
||||
@ -2257,7 +2257,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
* which is made irrelevant by this error.
|
||||
*/
|
||||
png_chunk_report(png_ptr, "known incorrect sRGB profile",
|
||||
PNG_CHUNK_ERROR);
|
||||
PNG_CHUNK_ERROR);
|
||||
}
|
||||
|
||||
/* Warn that this being done; this isn't even an error since
|
||||
@ -2267,8 +2267,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
else if (png_sRGB_checks[i].have_md5 == 0)
|
||||
{
|
||||
png_chunk_report(png_ptr,
|
||||
"out-of-date sRGB profile with no signature",
|
||||
PNG_CHUNK_WARNING);
|
||||
"out-of-date sRGB profile with no signature",
|
||||
PNG_CHUNK_WARNING);
|
||||
}
|
||||
|
||||
return 1+png_sRGB_checks[i].is_broken;
|
||||
@ -2294,7 +2294,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||
|
||||
void /* PRIVATE */
|
||||
png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
|
||||
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
|
||||
{
|
||||
/* Is this profile one of the known ICC sRGB profiles? If it is, just set
|
||||
* the sRGB information.
|
||||
@ -2308,17 +2308,17 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
|
||||
int is_color)
|
||||
png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
|
||||
int is_color)
|
||||
{
|
||||
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
||||
return 0;
|
||||
|
||||
if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
||||
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
||||
is_color) != 0 &&
|
||||
is_color) != 0 &&
|
||||
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
||||
profile) != 0)
|
||||
profile) != 0)
|
||||
{
|
||||
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* If no sRGB support, don't try storing sRGB information */
|
||||
@ -2471,9 +2471,9 @@ png_copy_row(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_IHDR(png_const_structrp png_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
int filter_type)
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
int color_type, int interlace_type, int compression_type,
|
||||
int filter_type)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
@ -2629,7 +2629,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
|
||||
png_size_tp whereami)
|
||||
png_size_tp whereami)
|
||||
{
|
||||
int state = *statep;
|
||||
png_size_t i = *whereami;
|
||||
|
28
pngerror.c
28
pngerror.c
@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
png_const_charp warning_message));
|
||||
#endif /* WARNINGS */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
@ -38,7 +38,7 @@ png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
PNG_NORETURN)
|
||||
{
|
||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
|
||||
@ -71,7 +71,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
||||
*/
|
||||
size_t
|
||||
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
|
||||
png_const_charp string)
|
||||
png_const_charp string)
|
||||
{
|
||||
if (buffer != NULL && pos < bufsize)
|
||||
{
|
||||
@ -93,7 +93,7 @@ png_safecat(png_charp buffer, size_t bufsize, size_t pos,
|
||||
#define PNG_HAVE_FORMAT_NUMBER /* for the code below */
|
||||
png_charp
|
||||
png_format_number(png_const_charp start, png_charp end, int format,
|
||||
png_alloc_size_t number)
|
||||
png_alloc_size_t number)
|
||||
{
|
||||
int count = 0; /* number of digits output */
|
||||
int mincount = 1; /* minimum number required */
|
||||
@ -180,7 +180,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
int offset = 0;
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
|
||||
warning_message + offset);
|
||||
warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
@ -192,7 +192,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
||||
*/
|
||||
void
|
||||
png_warning_parameter(png_warning_parameters p, int number,
|
||||
png_const_charp string)
|
||||
png_const_charp string)
|
||||
{
|
||||
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
|
||||
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
|
||||
@ -200,7 +200,7 @@ png_warning_parameter(png_warning_parameters p, int number,
|
||||
|
||||
void
|
||||
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
png_alloc_size_t value)
|
||||
png_alloc_size_t value)
|
||||
{
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
|
||||
@ -208,7 +208,7 @@ png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
|
||||
void
|
||||
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
png_int_32 value)
|
||||
png_int_32 value)
|
||||
{
|
||||
png_alloc_size_t u;
|
||||
png_charp str;
|
||||
@ -229,7 +229,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
|
||||
void
|
||||
png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
@ -433,7 +433,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL || png_ptr->chunk_name == 0U)
|
||||
@ -596,7 +596,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
|
||||
else
|
||||
{
|
||||
png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,
|
||||
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||
png_malloc_warn(png_ptr, jmp_buf_size));
|
||||
|
||||
if (png_ptr->jmp_buf_ptr == NULL)
|
||||
return NULL; /* new NULL return on OOM */
|
||||
@ -685,7 +685,7 @@ png_free_jmpbuf(png_structrp png_ptr)
|
||||
*/
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
{
|
||||
@ -789,7 +789,7 @@ png_get_error_ptr(png_const_structrp png_ptr)
|
||||
*/
|
||||
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
@ -812,7 +812,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
/* Missing longjmp buffer, the following is to help debugging: */
|
||||
{
|
||||
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
|
||||
"bad longjmp: ");
|
||||
"bad longjmp: ");
|
||||
png_safecat(image->message, (sizeof image->message), pos,
|
||||
error_message);
|
||||
}
|
||||
|
52
pngget.c
52
pngget.c
@ -499,7 +499,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
#ifdef PNG_bKGD_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_16p *background)
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
|
||||
@ -539,28 +539,28 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
if (white_x != NULL)
|
||||
*white_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
if (white_y != NULL)
|
||||
*white_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||
if (red_x != NULL)
|
||||
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
|
||||
"cHRM red X");
|
||||
"cHRM red X");
|
||||
if (red_y != NULL)
|
||||
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
|
||||
"cHRM red Y");
|
||||
"cHRM red Y");
|
||||
if (green_x != NULL)
|
||||
*green_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||
if (green_y != NULL)
|
||||
*green_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||
if (blue_x != NULL)
|
||||
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
|
||||
"cHRM blue X");
|
||||
"cHRM blue X");
|
||||
if (blue_y != NULL)
|
||||
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||
"cHRM blue Y");
|
||||
"cHRM blue Y");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@ -569,42 +569,42 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
double *red_X, double *red_Y, double *red_Z, double *green_X,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||
"cHRM red X");
|
||||
"cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
|
||||
"cHRM red Y");
|
||||
"cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
|
||||
"cHRM red Z");
|
||||
"cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@ -694,8 +694,8 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
@ -717,7 +717,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
"png_get_gAMA");
|
||||
"png_get_gAMA");
|
||||
return (PNG_INFO_gAMA);
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*/
|
||||
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
|
||||
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
|
||||
"sCAL height");
|
||||
"sCAL height");
|
||||
return (PNG_INFO_sCAL);
|
||||
}
|
||||
|
||||
|
14
pngmem.c
14
pngmem.c
@ -67,7 +67,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
/* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
|
||||
* allocators have also been removed in 1.6.0, so any 16-bit system now has
|
||||
@ -112,7 +112,7 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
@ -125,7 +125,7 @@ png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
affirm(nelements > 0 && element_size > 0);
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
@ -133,7 +133,7 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
affirm(add_elements > 0 && element_size > 0 && old_elements >= 0 &&
|
||||
@ -145,7 +145,7 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
@ -156,7 +156,7 @@ png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
@ -201,7 +201,7 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
*/
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED)
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ png_process_data_skip(png_structrp png_ptr)
|
||||
|
||||
static void
|
||||
png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
|
||||
png_size_t buffer_length)
|
||||
png_size_t buffer_length)
|
||||
{
|
||||
png_ptr->current_buffer_size = buffer_length;
|
||||
png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;
|
||||
|
168
pngread.c
168
pngread.c
@ -28,10 +28,10 @@ png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, NULL, NULL, NULL);
|
||||
error_fn, warn_fn, NULL, NULL, NULL);
|
||||
#else
|
||||
return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
|
||||
warn_fn, NULL, NULL, NULL);
|
||||
warn_fn, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Alternate create PNG structure for reading, and allocate any memory
|
||||
@ -43,7 +43,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
|
||||
{
|
||||
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* USER_MEM */
|
||||
|
||||
if (png_ptr != NULL)
|
||||
@ -245,7 +245,7 @@ png_start_read_image(png_structrp png_ptr)
|
||||
*/
|
||||
else
|
||||
png_app_error(png_ptr,
|
||||
"png_start_read_image/png_read_update_info: duplicate call");
|
||||
"png_start_read_image/png_read_update_info: duplicate call");
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,7 +779,7 @@ png_gt(size_t a, size_t b)
|
||||
|
||||
void PNGAPI
|
||||
png_read_png(png_structrp png_ptr, png_inforp info_ptr, int transforms,
|
||||
voidp params)
|
||||
voidp params)
|
||||
{
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
@ -1055,7 +1055,7 @@ png_image_read_init(png_imagep image)
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_controlp control = png_voidcast(png_controlp,
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
@ -1242,12 +1242,12 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file)
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_stdio: invalid argument");
|
||||
"png_image_begin_read_from_stdio: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1280,12 +1280,12 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_file: invalid argument");
|
||||
"png_image_begin_read_from_file: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1334,7 +1334,7 @@ image_init_memory_io(png_voidp param)
|
||||
|
||||
int PNGAPI
|
||||
png_image_begin_read_from_memory(png_imagep image, png_const_voidp memory,
|
||||
png_size_t size)
|
||||
png_size_t size)
|
||||
{
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
@ -1356,12 +1356,12 @@ png_image_begin_read_from_memory(png_imagep image, png_const_voidp memory,
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_memory: invalid argument");
|
||||
"png_image_begin_read_from_memory: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1407,11 +1407,11 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
* IHDR, PLTE, tRNS, IDAT, and IEND chunks.
|
||||
*/
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,
|
||||
NULL, -1);
|
||||
NULL, -1);
|
||||
|
||||
/* But do not ignore image data handling chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
|
||||
chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
|
||||
chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1614,7 +1614,7 @@ decode_gamma(png_image_read_control *display, png_uint_32 value,
|
||||
|
||||
default:
|
||||
png_impossiblepp(display->image->opaque->png_ptr,
|
||||
"unexpected encoding");
|
||||
"unexpected encoding");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1623,9 +1623,9 @@ decode_gamma(png_image_read_control *display, png_uint_32 value,
|
||||
|
||||
static png_uint_32
|
||||
png_colormap_compose(png_image_read_control *display,
|
||||
png_uint_32 foreground, unsigned int foreground_significant_bits,
|
||||
int foreground_encoding, png_uint_32 alpha,
|
||||
png_uint_32 background, int encoding)
|
||||
png_uint_32 foreground, unsigned int foreground_significant_bits,
|
||||
int foreground_encoding, png_uint_32 alpha,
|
||||
png_uint_32 background, int encoding)
|
||||
{
|
||||
/* The file value is composed on the background, the background has the given
|
||||
* encoding and so does the result, the file is encoded with P_FILE and the
|
||||
@ -1662,21 +1662,21 @@ png_colormap_compose(png_image_read_control *display,
|
||||
*/
|
||||
static void
|
||||
png_create_colormap_entry(png_image_read_control *display,
|
||||
png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
|
||||
png_uint_32 alpha, int encoding)
|
||||
png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,
|
||||
png_uint_32 alpha, int encoding)
|
||||
{
|
||||
png_imagep image = display->image;
|
||||
# define png_ptr image->opaque->png_ptr /* for error messages */
|
||||
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
P_LINEAR : P_sRGB;
|
||||
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(red != green || green != blue);
|
||||
(red != green || green != blue);
|
||||
int use_sBIT = encoding == P_FILE;
|
||||
|
||||
affirm(ip <= 255);
|
||||
implies(encoding != P_LINEAR, red <= 255U && green <= 255U && blue <= 255U
|
||||
&& display->sBIT[0] <= 8U && display->sBIT[1] <= 8U
|
||||
&& display->sBIT[2] <= 8U && display->sBIT[3] <= 8U);
|
||||
&& display->sBIT[0] <= 8U && display->sBIT[1] <= 8U
|
||||
&& display->sBIT[2] <= 8U && display->sBIT[3] <= 8U);
|
||||
|
||||
/* This is a hack for the grayscale colormap below. */
|
||||
if (encoding == P_FILE8)
|
||||
@ -1701,11 +1701,11 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
if (convert_to_Y != 0 || output_encoding == P_LINEAR)
|
||||
{
|
||||
red = convert_to_linear(display, red,
|
||||
use_sBIT ? display->sBIT[0] : 8U);
|
||||
use_sBIT ? display->sBIT[0] : 8U);
|
||||
green = convert_to_linear(display, green,
|
||||
use_sBIT ? display->sBIT[1] : 8U);
|
||||
use_sBIT ? display->sBIT[1] : 8U);
|
||||
blue = convert_to_linear(display, blue,
|
||||
use_sBIT ? display->sBIT[2] : 8U);
|
||||
use_sBIT ? display->sBIT[2] : 8U);
|
||||
alpha *= 257U;
|
||||
if (use_sBIT)
|
||||
alpha = update_for_sBIT(alpha, display->sBIT[3], 16U);
|
||||
@ -1717,11 +1717,11 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
else
|
||||
{
|
||||
red = convert_to_sRGB(display, red,
|
||||
use_sBIT ? display->sBIT[0] : 8U);
|
||||
use_sBIT ? display->sBIT[0] : 8U);
|
||||
green = convert_to_sRGB(display, green,
|
||||
use_sBIT ? display->sBIT[1] : 8U);
|
||||
use_sBIT ? display->sBIT[1] : 8U);
|
||||
blue = convert_to_sRGB(display, blue,
|
||||
use_sBIT ? display->sBIT[2] : 8U);
|
||||
use_sBIT ? display->sBIT[2] : 8U);
|
||||
if (use_sBIT)
|
||||
alpha = update_for_sBIT(alpha, display->sBIT[3], 8U);
|
||||
encoding = P_sRGB;
|
||||
@ -1830,7 +1830,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
# define afirst 0
|
||||
# endif
|
||||
@ -2007,7 +2007,7 @@ make_ga_colormap(png_image_read_control *display)
|
||||
|
||||
for (g=0; g<6; ++g)
|
||||
png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,
|
||||
P_sRGB);
|
||||
P_sRGB);
|
||||
}
|
||||
|
||||
return i;
|
||||
@ -2031,7 +2031,7 @@ make_rgb_colormap(png_image_read_control *display)
|
||||
|
||||
for (b=0; b<6; ++b)
|
||||
png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,
|
||||
P_sRGB);
|
||||
P_sRGB);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2084,7 +2084,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
else if (display->background == NULL /* no way to remove it */)
|
||||
png_error(png_ptr,
|
||||
"a background color must be supplied to remove alpha/transparency");
|
||||
"background color must be supplied to remove alpha/transparency");
|
||||
|
||||
/* Get a copy of the background color (this avoids repeating the checks
|
||||
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
|
||||
@ -2184,7 +2184,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
*/
|
||||
if (i != trans)
|
||||
png_create_colormap_entry(display, i, val, val, val, 255,
|
||||
P_FILE/*8-bit with file gamma*/);
|
||||
P_FILE/*8-bit with file gamma*/);
|
||||
|
||||
/* Else this entry is transparent. The colors don't matter if
|
||||
* there is an alpha channel (back_alpha == 0), but it does no
|
||||
@ -2199,10 +2199,10 @@ png_image_read_colormap(png_voidp argument)
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity says back_r|g|b might be 16-bit values */
|
||||
png_affirmpp(png_ptr, back_r < 256 && back_g < 256 &&
|
||||
back_b < 256);
|
||||
back_b < 256);
|
||||
#endif
|
||||
png_create_colormap_entry(display, i, back_r, back_g, back_b,
|
||||
back_alpha, output_encoding);
|
||||
back_alpha, output_encoding);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2268,7 +2268,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
* matches.
|
||||
*/
|
||||
png_create_colormap_entry(display, gray, back_g, back_g,
|
||||
back_g, 65535, P_LINEAR);
|
||||
back_g, 65535, P_LINEAR);
|
||||
}
|
||||
|
||||
/* The background passed to libpng, however, must be the
|
||||
@ -2276,15 +2276,15 @@ png_image_read_colormap(png_voidp argument)
|
||||
*/
|
||||
c.index = 0; /*unused*/
|
||||
c.gray = c.red = c.green = c.blue =
|
||||
png_check_u16(png_ptr, gray);
|
||||
png_check_u16(png_ptr, gray);
|
||||
|
||||
/* NOTE: does this work without expanding tRNS to alpha?
|
||||
* It should be the color->gray case below apparently
|
||||
* doesn't.
|
||||
*/
|
||||
png_set_background_fixed(png_ptr, &c,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
|
||||
output_processing = PNG_CMAP_NONE;
|
||||
break;
|
||||
@ -2316,7 +2316,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
back_b < 256);
|
||||
#endif
|
||||
png_create_colormap_entry(display, 254, back_r, back_g, back_b,
|
||||
back_alpha, output_encoding);
|
||||
back_alpha, output_encoding);
|
||||
}
|
||||
|
||||
else
|
||||
@ -2384,7 +2384,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
/* And make sure the corresponding palette entry matches. */
|
||||
png_create_colormap_entry(display, gray, back_g, back_g,
|
||||
back_g, 65535, P_LINEAR);
|
||||
back_g, 65535, P_LINEAR);
|
||||
}
|
||||
|
||||
/* The background passed to libpng, however, must be the sRGB
|
||||
@ -2394,8 +2394,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
c.gray = c.red = c.green = c.blue = png_check_u16(png_ptr, gray);
|
||||
|
||||
png_set_background_fixed(png_ptr, &c,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
|
||||
output_processing = PNG_CMAP_NONE;
|
||||
}
|
||||
@ -2415,7 +2415,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
{
|
||||
png_uint_32 gray = (i * 256 + 115) / 231;
|
||||
png_create_colormap_entry(display, i++, gray, gray, gray,
|
||||
255, P_sRGB);
|
||||
255, P_sRGB);
|
||||
}
|
||||
|
||||
/* NOTE: this preserves the full precision of the application
|
||||
@ -2493,7 +2493,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
* png_set_tRNS_to_alpha before png_set_background_fixed.
|
||||
*/
|
||||
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,
|
||||
-1);
|
||||
-1);
|
||||
data_encoding = P_sRGB;
|
||||
|
||||
/* The output will now be one or two 8-bit gray or gray+alpha
|
||||
@ -2601,8 +2601,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
*/
|
||||
expand_tRNS = 1;
|
||||
png_set_background_fixed(png_ptr, &c,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
}
|
||||
|
||||
output_processing = PNG_CMAP_NONE;
|
||||
@ -2636,7 +2636,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
/* Add a transparent entry. */
|
||||
png_create_colormap_entry(display, cmap_entries, 255, 255,
|
||||
255, 0, P_sRGB);
|
||||
255, 0, P_sRGB);
|
||||
|
||||
/* This is stored as the background index for the processing
|
||||
* algorithm.
|
||||
@ -2657,7 +2657,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
*/
|
||||
for (b=0; b<256; b = (b << 1) | 0x7f)
|
||||
png_create_colormap_entry(display, cmap_entries++,
|
||||
r, g, b, 128, P_sRGB);
|
||||
r, g, b, 128, P_sRGB);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2684,7 +2684,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
cmap_entries = make_rgb_colormap(display);
|
||||
|
||||
png_create_colormap_entry(display, cmap_entries, back_r,
|
||||
back_g, back_b, 0/*unused*/, output_encoding);
|
||||
back_g, back_b, 0/*unused*/, output_encoding);
|
||||
|
||||
if (output_encoding == P_LINEAR)
|
||||
{
|
||||
@ -2706,9 +2706,9 @@ png_image_read_colormap(png_voidp argument)
|
||||
* index.
|
||||
*/
|
||||
if (memcmp((png_const_bytep)display->colormap +
|
||||
sample_size * cmap_entries,
|
||||
(png_const_bytep)display->colormap +
|
||||
sample_size * PNG_RGB_INDEX(r,g,b),
|
||||
sample_size * cmap_entries,
|
||||
(png_const_bytep)display->colormap +
|
||||
sample_size * PNG_RGB_INDEX(r,g,b),
|
||||
sample_size) != 0)
|
||||
{
|
||||
/* The background color must be added. */
|
||||
@ -2750,8 +2750,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
c.blue = png_check_u16(png_ptr, back_b);
|
||||
|
||||
png_set_background_fixed(png_ptr, &c,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
|
||||
output_processing = PNG_CMAP_RGB;
|
||||
}
|
||||
@ -2803,7 +2803,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
{
|
||||
if (trans[i] == 0)
|
||||
png_create_colormap_entry(display, i, back_r, back_g,
|
||||
back_b, 0, output_encoding);
|
||||
back_b, 0, output_encoding);
|
||||
|
||||
else
|
||||
{
|
||||
@ -2928,7 +2928,7 @@ static int
|
||||
png_image_read_and_map(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display = png_voidcast(png_image_read_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
int passes;
|
||||
@ -3065,7 +3065,7 @@ png_image_read_and_map(png_voidp argument)
|
||||
|
||||
if (alpha >= 196)
|
||||
*outrow = PNG_RGB_INDEX(inrow[0], inrow[1],
|
||||
inrow[2]);
|
||||
inrow[2]);
|
||||
|
||||
else if (alpha < 64)
|
||||
*outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND;
|
||||
@ -3117,7 +3117,7 @@ static int
|
||||
png_image_read_colormapped(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display = png_voidcast(png_image_read_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_controlp control = image->opaque;
|
||||
png_structrp png_ptr = control->png_ptr;
|
||||
@ -3255,7 +3255,7 @@ static int
|
||||
png_image_read_composite(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display = png_voidcast(png_image_read_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
int passes;
|
||||
@ -3383,7 +3383,7 @@ static int
|
||||
png_image_read_background(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display = png_voidcast(png_image_read_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
@ -3442,8 +3442,7 @@ png_image_read_background(png_voidp argument)
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_bytep row = png_voidcast(png_bytep,
|
||||
display->first_row);
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
unsigned int startx, stepx, stepy;
|
||||
png_uint_32 y;
|
||||
|
||||
@ -3471,7 +3470,7 @@ png_image_read_background(png_voidp argument)
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = png_voidcast(png_bytep,
|
||||
display->local_row);
|
||||
display->local_row);
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width;
|
||||
|
||||
@ -3517,7 +3516,7 @@ png_image_read_background(png_voidp argument)
|
||||
for (; y<height; y += stepy)
|
||||
{
|
||||
png_bytep inrow = png_voidcast(png_bytep,
|
||||
display->local_row);
|
||||
display->local_row);
|
||||
png_bytep outrow = first_row + y * step_row;
|
||||
png_const_bytep end_row = outrow + width;
|
||||
|
||||
@ -3565,7 +3564,7 @@ png_image_read_background(png_voidp argument)
|
||||
*/
|
||||
{
|
||||
png_uint_16p first_row = png_voidcast(png_uint_16p,
|
||||
display->first_row);
|
||||
display->first_row);
|
||||
/* The division by two is safe because the caller passed in a
|
||||
* stride which was multiplied by 2 (below) to get row_bytes.
|
||||
*/
|
||||
@ -3615,7 +3614,7 @@ png_image_read_background(png_voidp argument)
|
||||
|
||||
/* Read the row, which is packed: */
|
||||
png_read_row(png_ptr, png_voidcast(png_bytep,
|
||||
display->local_row), NULL);
|
||||
display->local_row), NULL);
|
||||
inrow = png_voidcast(png_const_uint_16p, display->local_row);
|
||||
|
||||
/* Now do the pre-multiplication on each pixel in this row.
|
||||
@ -3660,7 +3659,7 @@ static int
|
||||
png_image_read_direct(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display = png_voidcast(png_image_read_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
@ -3711,7 +3710,7 @@ png_image_read_direct(png_voidp argument)
|
||||
do_local_background = 1/*maybe*/;
|
||||
|
||||
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
|
||||
PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
|
||||
PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);
|
||||
}
|
||||
|
||||
change &= PNG_BIC_MASK(PNG_FORMAT_FLAG_COLOR);
|
||||
@ -3830,8 +3829,8 @@ png_image_read_direct(png_voidp argument)
|
||||
* pixels.
|
||||
*/
|
||||
png_set_background_fixed(png_ptr, &c,
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,
|
||||
0/*gamma: not used*/);
|
||||
}
|
||||
|
||||
else /* compose on row: implemented below. */
|
||||
@ -4073,7 +4072,7 @@ png_image_read_direct(png_voidp argument)
|
||||
|
||||
int PNGAPI
|
||||
png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
void *buffer, ptrdiff_t row_stride, void *colormap)
|
||||
void *buffer, ptrdiff_t row_stride, void *colormap)
|
||||
{
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
@ -4138,15 +4137,16 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
* all the setup has already been done.
|
||||
*/
|
||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
result = png_safe_execute(image,
|
||||
png_image_read_colormap, &display) &&
|
||||
png_safe_execute(image,
|
||||
png_image_read_colormapped, &display);
|
||||
result =
|
||||
png_safe_execute(image,
|
||||
png_image_read_colormap, &display) &&
|
||||
png_safe_execute(image,
|
||||
png_image_read_colormapped, &display);
|
||||
|
||||
else
|
||||
result =
|
||||
png_safe_execute(image,
|
||||
png_image_read_direct, &display);
|
||||
png_image_read_direct, &display);
|
||||
|
||||
png_image_free(image);
|
||||
return result;
|
||||
@ -4154,27 +4154,27 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read[color-map]: no color-map");
|
||||
"png_image_finish_read[color-map]: no color-map");
|
||||
}
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read: image too large");
|
||||
"png_image_finish_read: image too large");
|
||||
}
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read: invalid argument");
|
||||
"png_image_finish_read: invalid argument");
|
||||
}
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read: row_stride too large");
|
||||
"png_image_finish_read: row_stride too large");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
|
||||
"png_image_finish_read: damaged PNG_IMAGE_VERSION");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
2
pngrio.c
2
pngrio.c
@ -91,7 +91,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
12
pngrtran.c
12
pngrtran.c
@ -3436,7 +3436,7 @@ png_init_gamma(png_transformp *transform, png_transform_controlp tc)
|
||||
|
||||
static png_fixed_point
|
||||
translate_gamma_flags(png_const_structrp png_ptr, png_fixed_point gamma,
|
||||
int is_screen)
|
||||
int is_screen)
|
||||
/* If 'is_screen' is set this returns the inverse of the supplied value; i.e.
|
||||
* this routine always returns an encoding value.
|
||||
*/
|
||||
@ -3511,7 +3511,7 @@ add_gamma_transform(png_structrp png_ptr, unsigned int order,
|
||||
|
||||
void PNGFAPI
|
||||
png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
png_fixed_point file_gamma)
|
||||
png_fixed_point file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma_fixed");
|
||||
|
||||
@ -3566,7 +3566,7 @@ void PNGAPI
|
||||
png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
|
||||
convert_gamma_value(png_ptr, file_gamma));
|
||||
convert_gamma_value(png_ptr, file_gamma));
|
||||
}
|
||||
#endif /* FLOATING_POINT */
|
||||
#endif /* READ_GAMMA */
|
||||
@ -4044,7 +4044,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
|
||||
void PNGAPI
|
||||
png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
|
||||
double green)
|
||||
double green)
|
||||
{
|
||||
png_set_rgb_to_gray_fixed(png_ptr, error_action,
|
||||
png_fixed(png_ptr, red, "rgb to gray red coefficient"),
|
||||
@ -5490,7 +5490,7 @@ png_set_background(png_structrp png_ptr,
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
void PNGFAPI
|
||||
png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
png_fixed_point output_gamma)
|
||||
png_fixed_point output_gamma)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -5603,7 +5603,7 @@ void PNGAPI
|
||||
png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
|
||||
{
|
||||
png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
|
||||
output_gamma));
|
||||
output_gamma));
|
||||
}
|
||||
#endif /* FLOATING_POINT */
|
||||
#endif /* READ_ALPHA_MODE */
|
||||
|
129
pngrutil.c
129
pngrutil.c
@ -507,7 +507,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
||||
png_uint_32 avail_in = *input_size_ptr;
|
||||
png_alloc_size_t avail_out = *output_size_ptr;
|
||||
int ret = png_zlib_inflate(png_ptr, owner, finish,
|
||||
&input, &avail_in, &output, &avail_out);
|
||||
&input, &avail_in, &output, &avail_out);
|
||||
|
||||
/* And implement the non-zlib semantics (the size values are updated to the
|
||||
* amounts consumed and written, not the amount remaining.)
|
||||
@ -525,9 +525,9 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
||||
*/
|
||||
static int
|
||||
png_decompress_chunk(png_structrp png_ptr,
|
||||
png_uint_32 chunklength, png_uint_32 prefix_size,
|
||||
png_alloc_size_t *newlength /* must be initialized to the maximum! */,
|
||||
int terminate /*add a '\0' to the end of the uncompressed data*/)
|
||||
png_uint_32 chunklength, png_uint_32 prefix_size,
|
||||
png_alloc_size_t *newlength /* must be initialized to the maximum! */,
|
||||
int terminate /*add a '\0' to the end of the uncompressed data*/)
|
||||
{
|
||||
/* TODO: implement different limits for different types of chunk.
|
||||
*
|
||||
@ -564,8 +564,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
png_uint_32 lzsize = chunklength - prefix_size;
|
||||
|
||||
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
||||
/* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
|
||||
/* output: */ NULL, newlength);
|
||||
/* input: */ png_ptr->read_buffer + prefix_size, &lzsize,
|
||||
/* output: */ NULL, newlength);
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
{
|
||||
@ -585,15 +585,15 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
*/
|
||||
png_alloc_size_t new_size = *newlength;
|
||||
png_alloc_size_t buffer_size = prefix_size + new_size +
|
||||
(terminate != 0);
|
||||
(terminate != 0);
|
||||
png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr,
|
||||
buffer_size));
|
||||
buffer_size));
|
||||
|
||||
if (text != NULL)
|
||||
{
|
||||
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
||||
png_ptr->read_buffer + prefix_size, &lzsize,
|
||||
text + prefix_size, newlength);
|
||||
png_ptr->read_buffer + prefix_size, &lzsize,
|
||||
text + prefix_size, newlength);
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
{
|
||||
@ -638,8 +638,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
* the extra space may otherwise be used as a Trojan Horse.
|
||||
*/
|
||||
if (ret == Z_STREAM_END &&
|
||||
chunklength - prefix_size != lzsize)
|
||||
png_chunk_benign_error(png_ptr, "extra compressed data");
|
||||
chunklength - prefix_size != lzsize)
|
||||
png_chunk_benign_error(png_ptr, "extra compressed data");
|
||||
}
|
||||
|
||||
else
|
||||
@ -688,8 +688,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
*/
|
||||
static int
|
||||
png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
||||
png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
|
||||
int finish)
|
||||
png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,
|
||||
int finish)
|
||||
{
|
||||
if (png_ptr->zowner == png_ptr->chunk_name)
|
||||
{
|
||||
@ -729,7 +729,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
||||
* streams.
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream,
|
||||
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH :
|
||||
Z_SYNC_FLUSH));
|
||||
}
|
||||
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
|
||||
|
||||
@ -763,7 +764,7 @@ png_handle_skip(png_structrp png_ptr)
|
||||
static void
|
||||
png_handle_error(png_structrp png_ptr
|
||||
# ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
, png_const_charp error
|
||||
, png_const_charp error
|
||||
# else
|
||||
# define png_handle_error(pp,e) png_handle_error(pp)
|
||||
# endif
|
||||
@ -1111,7 +1112,7 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
(void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,
|
||||
1/*prefer cHRM values*/);
|
||||
1/*prefer cHRM values*/);
|
||||
png_colorspace_sync(png_ptr, info_ptr);
|
||||
}
|
||||
#else
|
||||
@ -1234,8 +1235,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);
|
||||
png_ptr->zstream.avail_in = read_length;
|
||||
(void)png_inflate_read(png_ptr, local_buffer,
|
||||
(sizeof local_buffer), &length, profile_header, &size,
|
||||
0/*finish: don't, because the output is too small*/);
|
||||
(sizeof local_buffer), &length, profile_header, &size,
|
||||
0/*finish: don't, because the output is too small*/);
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
@ -1245,14 +1246,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_get_uint_32(profile_header);
|
||||
|
||||
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
|
||||
keyword, profile_length))
|
||||
keyword, profile_length))
|
||||
{
|
||||
/* The length is apparently ok, so we can check the 132
|
||||
* byte header.
|
||||
*/
|
||||
if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
|
||||
keyword, profile_length, profile_header,
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0))
|
||||
keyword, profile_length, profile_header,
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0))
|
||||
{
|
||||
/* Now read the tag table; a variable size buffer is
|
||||
* needed at this point, allocate one for the whole
|
||||
@ -1260,20 +1261,20 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* that none of these stuff will overflow.
|
||||
*/
|
||||
const png_uint_32 tag_count = png_get_uint_32(
|
||||
profile_header+128);
|
||||
profile_header+128);
|
||||
png_bytep profile = png_read_buffer(png_ptr,
|
||||
profile_length, 2/*silent*/);
|
||||
profile_length, 2/*silent*/);
|
||||
|
||||
if (profile != NULL)
|
||||
{
|
||||
memcpy(profile, profile_header,
|
||||
(sizeof profile_header));
|
||||
(sizeof profile_header));
|
||||
|
||||
size = 12 * tag_count;
|
||||
|
||||
(void)png_inflate_read(png_ptr, local_buffer,
|
||||
(sizeof local_buffer), &length,
|
||||
profile + (sizeof profile_header), &size, 0);
|
||||
(sizeof local_buffer), &length,
|
||||
profile + (sizeof profile_header), &size, 0);
|
||||
|
||||
/* Still expect a buffer error because we expect
|
||||
* there to be some tag data!
|
||||
@ -1281,26 +1282,26 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (size == 0)
|
||||
{
|
||||
if (png_icc_check_tag_table(png_ptr,
|
||||
&png_ptr->colorspace, keyword, profile_length,
|
||||
profile))
|
||||
&png_ptr->colorspace, keyword, profile_length,
|
||||
profile))
|
||||
{
|
||||
/* The profile has been validated for basic
|
||||
* security issues, so read the whole thing in.
|
||||
*/
|
||||
size = profile_length - (sizeof profile_header)
|
||||
- 12 * tag_count;
|
||||
- 12 * tag_count;
|
||||
|
||||
(void)png_inflate_read(png_ptr, local_buffer,
|
||||
(sizeof local_buffer), &length,
|
||||
profile + (sizeof profile_header) +
|
||||
12 * tag_count, &size, 1/*finish*/);
|
||||
(sizeof local_buffer), &length,
|
||||
profile + (sizeof profile_header) +
|
||||
12 * tag_count, &size, 1/*finish*/);
|
||||
|
||||
if (length > 0
|
||||
# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
&& png_ptr->benign_error_action ==
|
||||
PNG_ERROR
|
||||
&& png_ptr->benign_error_action ==
|
||||
PNG_ERROR
|
||||
# endif /* BENIGN_READ_ERRORS */
|
||||
)
|
||||
)
|
||||
errmsg = "extra compressed data";
|
||||
|
||||
/* But otherwise allow extra data: */
|
||||
@ -1312,7 +1313,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* keep going.
|
||||
*/
|
||||
png_chunk_warning(png_ptr,
|
||||
"extra compressed data");
|
||||
"extra compressed data");
|
||||
}
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
@ -1321,23 +1322,23 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* Check for a match against sRGB */
|
||||
png_icc_set_sRGB(png_ptr,
|
||||
&png_ptr->colorspace, profile,
|
||||
png_ptr->zstream.adler);
|
||||
&png_ptr->colorspace, profile,
|
||||
png_ptr->zstream.adler);
|
||||
# endif
|
||||
|
||||
/* Steal the profile for info_ptr. */
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_free_data(png_ptr, info_ptr,
|
||||
PNG_FREE_ICCP, 0);
|
||||
PNG_FREE_ICCP, 0);
|
||||
|
||||
info_ptr->iccp_name = png_voidcast(char*,
|
||||
png_malloc_base(png_ptr,
|
||||
keyword_length+1));
|
||||
png_malloc_base(png_ptr,
|
||||
keyword_length+1));
|
||||
if (info_ptr->iccp_name != NULL)
|
||||
{
|
||||
memcpy(info_ptr->iccp_name, keyword,
|
||||
keyword_length+1);
|
||||
keyword_length+1);
|
||||
info_ptr->iccp_profile = profile;
|
||||
png_ptr->read_buffer = NULL; /*steal*/
|
||||
info_ptr->free_me |= PNG_FREE_ICCP;
|
||||
@ -1347,7 +1348,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr)
|
||||
else
|
||||
{
|
||||
png_ptr->colorspace.flags |=
|
||||
PNG_COLORSPACE_INVALID;
|
||||
PNG_COLORSPACE_INVALID;
|
||||
errmsg = "out of memory";
|
||||
}
|
||||
}
|
||||
@ -1970,7 +1971,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,
|
||||
(png_charp)units, params);
|
||||
(png_charp)units, params);
|
||||
|
||||
png_free(png_ptr, params);
|
||||
}
|
||||
@ -2004,7 +2005,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
|
||||
length + 1);
|
||||
length + 1);
|
||||
|
||||
buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
|
||||
|
||||
@ -2055,7 +2056,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr)
|
||||
else
|
||||
/* This is the (only) success case. */
|
||||
png_set_sCAL_s(png_ptr, info_ptr, buffer[0],
|
||||
(png_charp)buffer+1, (png_charp)buffer+heighti);
|
||||
(png_charp)buffer+1, (png_charp)buffer+heighti);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -2237,7 +2238,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* and text chunks.
|
||||
*/
|
||||
if (png_decompress_chunk(png_ptr, length, keyword_length+2,
|
||||
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
|
||||
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
|
||||
{
|
||||
png_text text;
|
||||
|
||||
@ -2371,7 +2372,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* iCCP and text chunks.
|
||||
*/
|
||||
if (png_decompress_chunk(png_ptr, length, prefix_length,
|
||||
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
|
||||
&uncompressed_length, 1/*terminate*/) == Z_STREAM_END)
|
||||
buffer = png_ptr->read_buffer;
|
||||
|
||||
else
|
||||
@ -2485,7 +2486,7 @@ png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
|
||||
/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
|
||||
static void
|
||||
png_make_unknown_chunk(png_structrp png_ptr, png_unknown_chunkp chunk,
|
||||
png_bytep data)
|
||||
png_bytep data)
|
||||
{
|
||||
chunk->data = data;
|
||||
chunk->size = png_ptr->chunk_length;
|
||||
@ -2498,7 +2499,7 @@ png_make_unknown_chunk(png_structrp png_ptr, png_unknown_chunkp chunk,
|
||||
/* Handle an unknown, or known but disabled, chunk */
|
||||
void /* PRIVATE */
|
||||
png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep chunk_data)
|
||||
png_bytep chunk_data)
|
||||
{
|
||||
png_debug(1, "in png_handle_unknown");
|
||||
|
||||
@ -2560,7 +2561,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
keep = png_ptr->unknown_default;
|
||||
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
switch (png_ptr->user_chunk_cache_max)
|
||||
@ -2588,9 +2589,9 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_unknown_chunk unknown_chunk;
|
||||
|
||||
png_make_unknown_chunk(png_ptr, &unknown_chunk,
|
||||
chunk_data);
|
||||
chunk_data);
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &unknown_chunk,
|
||||
1);
|
||||
1);
|
||||
return;
|
||||
}
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
@ -3461,7 +3462,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
|
||||
static void
|
||||
png_read_filter_row_sub(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
{
|
||||
while (row_bytes >= bpp)
|
||||
{
|
||||
@ -3480,7 +3481,7 @@ png_read_filter_row_sub(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
|
||||
static void
|
||||
png_read_filter_row_up(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
{
|
||||
while (row_bytes > 0)
|
||||
{
|
||||
@ -3496,7 +3497,7 @@ png_read_filter_row_up(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
|
||||
static void
|
||||
png_read_filter_row_avg(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
png_bytep row, png_const_bytep prev_row, png_const_bytep prev_pixels)
|
||||
{
|
||||
while (row_bytes >= bpp)
|
||||
{
|
||||
@ -3514,8 +3515,8 @@ png_read_filter_row_avg(png_alloc_size_t row_bytes, unsigned int bpp,
|
||||
|
||||
static void
|
||||
png_read_filter_row_paeth_1byte_pixel(png_alloc_size_t row_bytes,
|
||||
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
|
||||
png_const_bytep prev_pixels)
|
||||
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
|
||||
png_const_bytep prev_pixels)
|
||||
{
|
||||
png_const_bytep rp_end = row + row_bytes;
|
||||
png_byte a, c;
|
||||
@ -3563,8 +3564,8 @@ png_read_filter_row_paeth_1byte_pixel(png_alloc_size_t row_bytes,
|
||||
|
||||
static void
|
||||
png_read_filter_row_paeth_multibyte_pixel(png_alloc_size_t row_bytes,
|
||||
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
|
||||
png_const_bytep prev_pixels)
|
||||
unsigned int bpp, png_bytep row, png_const_bytep prev_row,
|
||||
png_const_bytep prev_pixels)
|
||||
{
|
||||
png_bytep rp_end = row + bpp;
|
||||
|
||||
@ -3700,7 +3701,7 @@ png_inflate_IDAT(png_structrp png_ptr, int finish,
|
||||
png_uint_32 avail_in = png_ptr->zstream.avail_in;
|
||||
|
||||
ret = png_zlib_inflate(png_ptr, png_IDAT, finish,
|
||||
&next_in, &avail_in, &output, &output_size/*remaining*/);
|
||||
&next_in, &avail_in, &output, &output_size/*remaining*/);
|
||||
|
||||
debug(next_in == png_ptr->zstream.next_in);
|
||||
debug(avail_in == png_ptr->zstream.avail_in);
|
||||
@ -3872,7 +3873,7 @@ png_read_start_IDAT(png_structrp png_ptr)
|
||||
*/
|
||||
png_row_op /*PRIVATE*/
|
||||
png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
|
||||
png_bytep display_row, int save_row)
|
||||
png_bytep display_row, int save_row)
|
||||
{
|
||||
/* Common sub-expressions. These are all constant across the whole PNG, but
|
||||
* are recalculated here each time because this is fast and it only happens
|
||||
@ -4548,7 +4549,7 @@ png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
png_int_32 /* PRIVATE */
|
||||
png_read_setting(png_structrp png_ptr, png_uint_32 setting,
|
||||
png_uint_32 parameter, png_int_32 value)
|
||||
png_uint_32 parameter, png_int_32 value)
|
||||
{
|
||||
/* Caller checks the arguments for basic validity */
|
||||
int only_get = (setting & PNG_SF_GET) != 0U;
|
||||
|
90
pngset.c
90
pngset.c
@ -105,14 +105,14 @@ png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
double green_x, double green_y, double blue_x, double blue_y)
|
||||
{
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
png_fixed(png_ptr, white_x, "cHRM White X"),
|
||||
png_fixed(png_ptr, white_y, "cHRM White Y"),
|
||||
png_fixed(png_ptr, red_x, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, green_x, "cHRM Green X"),
|
||||
png_fixed(png_ptr, green_y, "cHRM Green Y"),
|
||||
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
|
||||
png_fixed(png_ptr, white_x, "cHRM White X"),
|
||||
png_fixed(png_ptr, white_y, "cHRM White Y"),
|
||||
png_fixed(png_ptr, red_x, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, green_x, "cHRM Green X"),
|
||||
png_fixed(png_ptr, green_y, "cHRM Green Y"),
|
||||
png_fixed(png_ptr, blue_x, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
@ -121,15 +121,15 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
double blue_X, double blue_Y, double blue_Z)
|
||||
{
|
||||
png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
|
||||
png_fixed(png_ptr, red_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, green_X, "cHRM Green X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
|
||||
png_fixed(png_ptr, red_X, "cHRM Red X"),
|
||||
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
|
||||
png_fixed(png_ptr, green_X, "cHRM Green X"),
|
||||
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
|
||||
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
|
||||
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
|
||||
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
|
||||
}
|
||||
# endif /* FLOATING_POINT */
|
||||
|
||||
@ -386,7 +386,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw);
|
||||
|
||||
info_ptr->scal_s_width = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, lengthw));
|
||||
png_malloc_warn(png_ptr, lengthw));
|
||||
|
||||
if (info_ptr->scal_s_width == NULL)
|
||||
{
|
||||
@ -402,7 +402,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh);
|
||||
|
||||
info_ptr->scal_s_height = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, lengthh));
|
||||
png_malloc_warn(png_ptr, lengthh));
|
||||
|
||||
if (info_ptr->scal_s_height == NULL)
|
||||
{
|
||||
@ -442,9 +442,9 @@ png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
|
||||
char sheight[PNG_sCAL_MAX_DIGITS+1];
|
||||
|
||||
png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
|
||||
PNG_sCAL_PRECISION);
|
||||
PNG_sCAL_PRECISION);
|
||||
png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
|
||||
PNG_sCAL_PRECISION);
|
||||
PNG_sCAL_PRECISION);
|
||||
|
||||
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
|
||||
}
|
||||
@ -644,7 +644,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
{
|
||||
int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
|
||||
proflen, profile, (info_ptr->format & PNG_FORMAT_FLAG_COLOR) != 0);
|
||||
proflen, profile, (info_ptr->format & PNG_FORMAT_FLAG_COLOR) != 0);
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
||||
@ -654,7 +654,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
/* But do write the gAMA and cHRM chunks from the profile. */
|
||||
info_ptr->colorspace.flags |=
|
||||
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
|
||||
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
|
||||
}
|
||||
|
||||
length = strlen(name)+1;
|
||||
@ -669,7 +669,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
memcpy(new_iccp_name, name, length);
|
||||
new_iccp_profile = png_voidcast(png_bytep,
|
||||
png_malloc_warn(png_ptr, proflen));
|
||||
png_malloc_warn(png_ptr, proflen));
|
||||
|
||||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
@ -819,14 +819,14 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
* the overflow checks.
|
||||
*/
|
||||
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
|
||||
info_ptr->text, old_num_text, max_text-old_num_text,
|
||||
sizeof *new_text));
|
||||
info_ptr->text, old_num_text, max_text-old_num_text,
|
||||
sizeof *new_text));
|
||||
}
|
||||
|
||||
if (new_text == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many text chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -854,7 +854,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
png_chunk_report(png_ptr, "text compression mode is out of range",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
# else /* iTXt */
|
||||
{
|
||||
png_chunk_report(png_ptr, "iTXt chunk not supported",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
@ -921,7 +921,7 @@ png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (textp->key == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "text chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1031,7 +1031,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if ((info_ptr->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
png_chunk_report(png_ptr,
|
||||
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
|
||||
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
|
||||
|
||||
else if ((info_ptr->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
{
|
||||
@ -1057,7 +1057,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (num_trans > max_num)
|
||||
{
|
||||
png_chunk_report(png_ptr, "png_set_tRNS: num_trans too large",
|
||||
PNG_CHUNK_ERROR);
|
||||
PNG_CHUNK_ERROR);
|
||||
/* If control returns simply limit it; the behavior prior to 1.7 was to
|
||||
* issue a warning and skip the palette in png_write_tRNS.
|
||||
*/
|
||||
@ -1074,11 +1074,11 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
* indices.
|
||||
*/
|
||||
info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH));
|
||||
PNG_MAX_PALETTE_LENGTH));
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
|
||||
memcpy(info_ptr->trans_alpha, trans_alpha,
|
||||
(unsigned)/*SAFE*/num_trans);
|
||||
(unsigned)/*SAFE*/num_trans);
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = png_check_bits(png_ptr, num_trans, 9);
|
||||
}
|
||||
@ -1109,8 +1109,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
else
|
||||
png_chunk_report(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth",
|
||||
PNG_CHUNK_ERROR);
|
||||
"tRNS chunk has out-of-range samples for bit_depth",
|
||||
PNG_CHUNK_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1138,8 +1138,8 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
* overflows. Notice that the parameters are (int) and (size_t)
|
||||
*/
|
||||
np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
|
||||
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
|
||||
sizeof *np));
|
||||
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
|
||||
sizeof *np));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
@ -1200,7 +1200,7 @@ png_set_sPLT(png_structrp png_ptr,
|
||||
* checked it when doing the allocation.
|
||||
*/
|
||||
memcpy(np->entries, entries->entries,
|
||||
entries->nentries * sizeof (png_sPLT_entry));
|
||||
entries->nentries * sizeof (png_sPLT_entry));
|
||||
|
||||
/* Note that 'continue' skips the advance of the out pointer and out
|
||||
* count, so an invalid entry is not added.
|
||||
@ -1230,10 +1230,10 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
{
|
||||
/* Write struct, so unknown chunks come from the app */
|
||||
png_app_warning(png_ptr,
|
||||
"png_set_unknown_chunks now expects a valid location");
|
||||
"png_set_unknown_chunks now expects a valid location");
|
||||
/* Use the old behavior */
|
||||
location = png_check_byte(png_ptr, png_ptr->mode &
|
||||
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
|
||||
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
|
||||
}
|
||||
|
||||
/* This need not be an internal error - if the app calls
|
||||
@ -1256,7 +1256,7 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
|
||||
@ -1326,12 +1326,12 @@ png_set_unknown_chunks(png_structrp png_ptr,
|
||||
else
|
||||
{
|
||||
np->data = png_voidcast(png_bytep,
|
||||
png_malloc_base(png_ptr, unknowns->size));
|
||||
png_malloc_base(png_ptr, unknowns->size));
|
||||
|
||||
if (np->data == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "unknown chunk: out of memory",
|
||||
PNG_CHUNK_ERROR);
|
||||
PNG_CHUNK_ERROR);
|
||||
/* But just skip storing the unknown chunk */
|
||||
continue;
|
||||
}
|
||||
@ -1536,7 +1536,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
||||
for (i=0; i<num_chunks; ++i)
|
||||
{
|
||||
old_num_chunks = add_one_chunk(png_ptr, new_list, old_num_chunks,
|
||||
chunk_list+5*i, keep);
|
||||
chunk_list+5*i, keep);
|
||||
}
|
||||
|
||||
/* Now remove any spurious 'default' entries. */
|
||||
|
186
pngtest.c
186
pngtest.c
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.5.25 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
@ -345,10 +345,10 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op);
|
||||
png_uint_32 io_op);
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op)
|
||||
png_uint_32 io_op)
|
||||
{
|
||||
png_uint_32 io_state = png_get_io_state(png_ptr);
|
||||
int err = 0;
|
||||
@ -532,7 +532,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
memory_infop pinfo;
|
||||
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
|
||||
pinfo = (memory_infop)png_malloc(png_ptr,
|
||||
(sizeof *pinfo));
|
||||
(sizeof *pinfo));
|
||||
pinfo->size = size;
|
||||
current_allocation += size;
|
||||
total_allocation += size;
|
||||
@ -562,7 +562,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
|
||||
if (verbose != 0)
|
||||
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
|
||||
pinfo->pointer);
|
||||
pinfo->pointer);
|
||||
|
||||
return (png_voidp)(pinfo->pointer);
|
||||
}
|
||||
@ -769,9 +769,9 @@ write_vpAg_chunk(png_structp write_ptr)
|
||||
|
||||
if (verbose != 0)
|
||||
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
|
||||
(unsigned long)user_chunk_data.vpAg_width,
|
||||
(unsigned long)user_chunk_data.vpAg_height,
|
||||
user_chunk_data.vpAg_units);
|
||||
(unsigned long)user_chunk_data.vpAg_width,
|
||||
(unsigned long)user_chunk_data.vpAg_height,
|
||||
user_chunk_data.vpAg_units);
|
||||
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
|
||||
@ -812,7 +812,7 @@ write_chunks(png_structp write_ptr, int location)
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
static void
|
||||
pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
|
||||
int num_text)
|
||||
int num_text)
|
||||
{
|
||||
while (num_text > 0)
|
||||
{
|
||||
@ -894,26 +894,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
pngtest_debug("Allocating read and write structures");
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
read_ptr =
|
||||
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
||||
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
|
||||
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
||||
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
|
||||
#else
|
||||
read_ptr =
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
|
||||
pngtest_warning);
|
||||
pngtest_warning);
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
write_ptr =
|
||||
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
||||
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
|
||||
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
|
||||
NULL, NULL, NULL, png_debug_malloc, png_debug_free);
|
||||
#else
|
||||
write_ptr =
|
||||
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#endif
|
||||
png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
|
||||
pngtest_warning);
|
||||
pngtest_warning);
|
||||
#endif
|
||||
pngtest_debug("Allocating read_info, write_info and end_info structures");
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
@ -1001,9 +1001,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data,
|
||||
# ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
pngtest_flush);
|
||||
pngtest_flush);
|
||||
# else
|
||||
NULL);
|
||||
NULL);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@ -1043,11 +1043,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
*/
|
||||
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
NULL, 0);
|
||||
#endif
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
NULL, 0);
|
||||
NULL, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1071,7 +1071,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
&color_type, &interlace_type, &compression_type, &filter_type) != 0)
|
||||
{
|
||||
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
|
||||
color_type, interlace_type, compression_type, filter_type);
|
||||
color_type, interlace_type, compression_type, filter_type);
|
||||
/* num_passes may not be available below if interlace support is not
|
||||
* provided by libpng for both read and write.
|
||||
*/
|
||||
@ -1098,13 +1098,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
{
|
||||
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
|
||||
blue_y;
|
||||
blue_y;
|
||||
|
||||
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
|
||||
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
{
|
||||
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1121,13 +1121,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
{
|
||||
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
|
||||
blue_y;
|
||||
blue_y;
|
||||
|
||||
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
&red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
|
||||
{
|
||||
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
red_y, green_x, green_y, blue_x, blue_y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1149,10 +1149,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int compression_type;
|
||||
|
||||
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
|
||||
&profile, &proflen) != 0)
|
||||
&profile, &proflen) != 0)
|
||||
{
|
||||
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
|
||||
profile, proflen);
|
||||
profile, proflen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1209,10 +1209,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int type, nparams;
|
||||
|
||||
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
|
||||
&nparams, &units, ¶ms) != 0)
|
||||
&nparams, &units, ¶ms) != 0)
|
||||
{
|
||||
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
|
||||
nparams, units, params);
|
||||
nparams, units, params);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1242,7 +1242,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
double scal_width, scal_height;
|
||||
|
||||
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
|
||||
&scal_height) != 0)
|
||||
&scal_height) != 0)
|
||||
{
|
||||
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
|
||||
}
|
||||
@ -1254,7 +1254,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_charp scal_width, scal_height;
|
||||
|
||||
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
|
||||
&scal_height) != 0)
|
||||
&scal_height) != 0)
|
||||
{
|
||||
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
|
||||
scal_height);
|
||||
@ -1295,7 +1295,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,7 +1332,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
png_color_16p trans_color;
|
||||
|
||||
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
|
||||
&trans_color) != 0)
|
||||
&trans_color) != 0)
|
||||
{
|
||||
int sample_max = (1 << bit_depth);
|
||||
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
|
||||
@ -1351,12 +1351,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_unknown_chunkp unknowns;
|
||||
int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
|
||||
&unknowns);
|
||||
&unknowns);
|
||||
|
||||
if (num_unknowns != 0)
|
||||
{
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
@ -1366,7 +1366,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1396,7 +1396,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
#ifdef SINGLE_ROWBUF_ALLOC
|
||||
pngtest_debug("Allocating row buffer...");
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
|
||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||
@ -1410,10 +1410,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
*/
|
||||
if (png_set_interlace_handling(read_ptr) != num_passes)
|
||||
png_error(write_ptr,
|
||||
"png_set_interlace_handling(read): wrong pass count ");
|
||||
"png_set_interlace_handling(read): wrong pass count ");
|
||||
if (png_set_interlace_handling(write_ptr) != num_passes)
|
||||
png_error(write_ptr,
|
||||
"png_set_interlace_handling(write): wrong pass count ");
|
||||
"png_set_interlace_handling(write): wrong pass count ");
|
||||
#else /* png_set_interlace_handling not called on either read or write */
|
||||
# define calc_pass_height
|
||||
#endif /* not using libpng interlace handling */
|
||||
@ -1450,10 +1450,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
|
||||
|
||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
|
||||
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
(unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
|
||||
|
||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
|
||||
@ -1511,7 +1511,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
for (i=0; i<num_text; i++)
|
||||
{
|
||||
printf(" Text compression[%d]=%d\n",
|
||||
i, text_ptr[i].compression);
|
||||
i, text_ptr[i].compression);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1545,12 +1545,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
{
|
||||
png_unknown_chunkp unknowns;
|
||||
int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
|
||||
&unknowns);
|
||||
&unknowns);
|
||||
|
||||
if (num_unknowns != 0)
|
||||
{
|
||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||
num_unknowns);
|
||||
num_unknowns);
|
||||
#if PNG_LIBPNG_VER < 10600
|
||||
/* Copy the locations from the read_info_ptr. The automatically
|
||||
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
|
||||
@ -1560,7 +1560,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
int i;
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||
unknowns[i].location);
|
||||
unknowns[i].location);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1594,7 +1594,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||
fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
|
||||
(unsigned long)iwidth, (unsigned long)iheight);
|
||||
(unsigned long)iwidth, (unsigned long)iheight);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1627,7 +1627,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
* above, but this is safe.
|
||||
*/
|
||||
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
|
||||
inname, error_count, warning_count);
|
||||
inname, error_count, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
@ -1638,14 +1638,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
else if (unsupported_chunks > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
|
||||
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
|
||||
inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
|
||||
}
|
||||
# endif
|
||||
|
||||
else if (warning_count > 0)
|
||||
{
|
||||
fprintf(STDERR, "\n %s: %d libpng warnings found",
|
||||
inname, warning_count);
|
||||
inname, warning_count);
|
||||
|
||||
if (strict != 0)
|
||||
return (1);
|
||||
@ -1681,18 +1681,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (num_in != num_out)
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
|
||||
inname, outname);
|
||||
inname, outname);
|
||||
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
" Was %s written with the same maximum IDAT"
|
||||
" chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
|
||||
@ -1712,17 +1713,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
if (memcmp(inbuf, outbuf, num_in))
|
||||
{
|
||||
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
|
||||
outname);
|
||||
outname);
|
||||
|
||||
if (wrote_question == 0 && unsupported_chunks == 0)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" Was %s written with the same maximum IDAT chunk size (%d bytes),",
|
||||
" Was %s written with the same maximum"
|
||||
" IDAT chunk size (%d bytes),",
|
||||
inname, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR,
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
"\n filtering heuristic (libpng default), compression");
|
||||
fprintf(STDERR,
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
" level (zlib default),\n and zlib version (%s)?\n\n",
|
||||
ZLIB_VERSION);
|
||||
wrote_question = 1;
|
||||
}
|
||||
@ -1773,12 +1775,12 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, "%s", png_get_copyright(NULL));
|
||||
/* Show the version of libpng used in building the library */
|
||||
fprintf(STDERR, " library (%lu):%s",
|
||||
(unsigned long)png_access_version_number(),
|
||||
png_get_header_version(NULL));
|
||||
(unsigned long)png_access_version_number(),
|
||||
png_get_header_version(NULL));
|
||||
|
||||
/* Show the version of libpng used in building the application */
|
||||
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
|
||||
PNG_HEADER_VERSION_STRING);
|
||||
PNG_HEADER_VERSION_STRING);
|
||||
|
||||
/* Do some consistency checking on the memory allocation settings, I'm
|
||||
* not sure this matters, but it is nice to know, the first of these
|
||||
@ -1796,7 +1798,7 @@ main(int argc, char *argv[])
|
||||
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
|
||||
{
|
||||
fprintf(STDERR,
|
||||
"Warning: versions are different between png.h and png.c\n");
|
||||
"Warning: versions are different between png.h and png.c\n");
|
||||
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
|
||||
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
|
||||
++ierror;
|
||||
@ -1884,7 +1886,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||
(unsigned long)zero_samples);
|
||||
(unsigned long)zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
@ -1904,20 +1906,20 @@ main(int argc, char *argv[])
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation - allocation_now);
|
||||
current_allocation - allocation_now);
|
||||
|
||||
if (current_allocation != 0)
|
||||
{
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
current_allocation);
|
||||
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR, " %lu bytes at %p\n",
|
||||
(unsigned long)pinfo->size,
|
||||
pinfo->pointer);
|
||||
(unsigned long)pinfo->size,
|
||||
pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
@ -1925,13 +1927,13 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
|
||||
current_allocation);
|
||||
current_allocation);
|
||||
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
|
||||
maximum_allocation);
|
||||
maximum_allocation);
|
||||
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
|
||||
total_allocation);
|
||||
total_allocation);
|
||||
fprintf(STDERR, " Number of allocations: %10d\n",
|
||||
num_allocations);
|
||||
num_allocations);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1966,7 +1968,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||
(unsigned long)zero_samples);
|
||||
(unsigned long)zero_samples);
|
||||
#else
|
||||
fprintf(STDERR, " PASS\n");
|
||||
#endif
|
||||
@ -1993,19 +1995,19 @@ main(int argc, char *argv[])
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
if (allocation_now != current_allocation)
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
|
||||
current_allocation - allocation_now);
|
||||
current_allocation - allocation_now);
|
||||
|
||||
if (current_allocation != 0)
|
||||
{
|
||||
memory_infop pinfo = pinformation;
|
||||
|
||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||
current_allocation);
|
||||
current_allocation);
|
||||
|
||||
while (pinfo != NULL)
|
||||
{
|
||||
fprintf(STDERR, " %lu bytes at %p\n",
|
||||
(unsigned long)pinfo->size, pinfo->pointer);
|
||||
(unsigned long)pinfo->size, pinfo->pointer);
|
||||
pinfo = pinfo->next;
|
||||
}
|
||||
}
|
||||
@ -2013,13 +2015,13 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
|
||||
current_allocation);
|
||||
current_allocation);
|
||||
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
|
||||
maximum_allocation);
|
||||
maximum_allocation);
|
||||
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
|
||||
total_allocation);
|
||||
total_allocation);
|
||||
fprintf(STDERR, " Number of allocations: %10d\n",
|
||||
num_allocations);
|
||||
num_allocations);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2028,13 +2030,13 @@ main(int argc, char *argv[])
|
||||
t_misc += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
fprintf(STDERR, " CPU time used = %.3f seconds",
|
||||
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
|
||||
(t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
|
||||
fprintf(STDERR, " (decoding %.3f,\n",
|
||||
t_decode/(float)CLOCKS_PER_SEC);
|
||||
t_decode/(float)CLOCKS_PER_SEC);
|
||||
fprintf(STDERR, " encoding %.3f ,",
|
||||
t_encode/(float)CLOCKS_PER_SEC);
|
||||
t_encode/(float)CLOCKS_PER_SEC);
|
||||
fprintf(STDERR, " other %.3f seconds)\n\n",
|
||||
t_misc/(float)CLOCKS_PER_SEC);
|
||||
t_misc/(float)CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
if (ierror == 0)
|
||||
@ -2046,19 +2048,19 @@ main(int argc, char *argv[])
|
||||
dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
fprintf(STDERR, " Default limits:\n");
|
||||
fprintf(STDERR, " width_max = %lu\n",
|
||||
(unsigned long) png_get_user_width_max(dummy_ptr));
|
||||
(unsigned long) png_get_user_width_max(dummy_ptr));
|
||||
fprintf(STDERR, " height_max = %lu\n",
|
||||
(unsigned long) png_get_user_height_max(dummy_ptr));
|
||||
(unsigned long) png_get_user_height_max(dummy_ptr));
|
||||
if (png_get_chunk_cache_max(dummy_ptr) == 0)
|
||||
fprintf(STDERR, " cache_max = unlimited\n");
|
||||
else
|
||||
fprintf(STDERR, " cache_max = %lu\n",
|
||||
(unsigned long) png_get_chunk_cache_max(dummy_ptr));
|
||||
(unsigned long) png_get_chunk_cache_max(dummy_ptr));
|
||||
if (png_get_chunk_malloc_max(dummy_ptr) == 0)
|
||||
fprintf(STDERR, " malloc_max = unlimited\n");
|
||||
else
|
||||
fprintf(STDERR, " malloc_max = %lu\n",
|
||||
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
|
||||
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
|
||||
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
|
||||
|
||||
return (int)(ierror != 0);
|
||||
@ -2068,7 +2070,7 @@ int
|
||||
main(void)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
/* And skip this test */
|
||||
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
|
||||
}
|
||||
|
@ -3579,7 +3579,7 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp ptr, int depth,
|
||||
}
|
||||
else
|
||||
png_app_error(png_ptr,
|
||||
"cannot change user info after image start");
|
||||
"cannot change user info after image start");
|
||||
}
|
||||
# else /* !READ_USER_TRANSFORM */
|
||||
PNG_UNUSED(depth)
|
||||
|
4
pngwio.c
4
pngwio.c
@ -45,7 +45,7 @@ png_write_data(png_structrp png_ptr, png_const_voidp data, png_size_t length)
|
||||
*/
|
||||
if (png_ptr->rw_data_fn != NULL )
|
||||
png_ptr->rw_data_fn(png_ptr,
|
||||
png_constcast(png_bytep,png_voidcast(png_const_bytep,data)), length);
|
||||
png_constcast(png_bytep,png_voidcast(png_const_bytep,data)), length);
|
||||
|
||||
else
|
||||
png_app_error(png_ptr, "No write function");
|
||||
@ -130,7 +130,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
if (write_data_fn == NULL)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"API change: png_set_write_fn requires a function");
|
||||
"API change: png_set_write_fn requires a function");
|
||||
return;
|
||||
}
|
||||
|
||||
|
164
pngwrite.c
164
pngwrite.c
@ -24,7 +24,7 @@
|
||||
/* Write out all the unknown chunks for the current given location */
|
||||
static void
|
||||
write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
unsigned int where)
|
||||
unsigned int where)
|
||||
{
|
||||
if (info_ptr->unknown_chunks_num != 0)
|
||||
{
|
||||
@ -169,7 +169,7 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
png_ptr->mng_features_permitted != 0)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"MNG features are not allowed in a PNG datastream");
|
||||
"MNG features are not allowed in a PNG datastream");
|
||||
/* Recovery: disable MNG features: */
|
||||
png_ptr->mng_features_permitted = 0;
|
||||
}
|
||||
@ -177,8 +177,8 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
/* Write IHDR information. */
|
||||
png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
|
||||
info_ptr->bit_depth, color_type, info_ptr->compression_type,
|
||||
info_ptr->filter_type, info_ptr->interlace_type);
|
||||
info_ptr->bit_depth, color_type, info_ptr->compression_type,
|
||||
info_ptr->filter_type, info_ptr->interlace_type);
|
||||
|
||||
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* This are used for checking later on: */
|
||||
@ -235,11 +235,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
*/
|
||||
if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
png_app_warning(png_ptr,
|
||||
"profile matches sRGB but writing iCCP instead");
|
||||
"profile matches sRGB but writing iCCP instead");
|
||||
# endif /* WRITE_sRGB */
|
||||
|
||||
png_write_iCCP(png_ptr, info_ptr->iccp_name,
|
||||
info_ptr->iccp_profile);
|
||||
info_ptr->iccp_profile);
|
||||
}
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
else /* iCCP not written */
|
||||
@ -280,7 +280,7 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
else /* 1.7.0: flag multiple calls; previously ignored */
|
||||
png_app_error(png_ptr,
|
||||
"png_write_info_before_PLTE called more than once");
|
||||
"png_write_info_before_PLTE called more than once");
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
@ -322,15 +322,15 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
|
||||
{
|
||||
png_write_tRNS(png_ptr, info_ptr->trans_alpha,
|
||||
&(info_ptr->trans_color), info_ptr->num_trans,
|
||||
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
|
||||
&(info_ptr->trans_color), info_ptr->num_trans,
|
||||
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
|
||||
}
|
||||
# endif /* WRITE_tRNS */
|
||||
|
||||
# ifdef PNG_WRITE_bKGD_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
|
||||
png_write_bKGD(png_ptr, &(info_ptr->background),
|
||||
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
|
||||
PNG_COLOR_TYPE_FROM_FORMAT(info_ptr->format));
|
||||
# endif /* WRITE_bKGD */
|
||||
|
||||
# ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
@ -354,7 +354,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
# ifdef PNG_WRITE_sCAL_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
png_write_sCAL_s(png_ptr, info_ptr->scal_unit, info_ptr->scal_s_width,
|
||||
info_ptr->scal_s_height);
|
||||
info_ptr->scal_s_height);
|
||||
# endif /* WRITE_sCAL */
|
||||
|
||||
# ifdef PNG_WRITE_pHYs_SUPPORTED
|
||||
@ -570,10 +570,10 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
defined(PNG_WRITE_TRANSFORMS_SUPPORTED)
|
||||
static void
|
||||
write_row_buffered(png_structrp png_ptr,
|
||||
png_const_bytep row, unsigned int row_info_flags,
|
||||
void (*copy_fn)(png_const_structrp png_ptr, png_bytep row_buffer,
|
||||
png_const_bytep row, png_uint_32 x, unsigned int count, unsigned int p),
|
||||
unsigned int copy_parameter)
|
||||
png_const_bytep row, unsigned int row_info_flags,
|
||||
void (*copy_fn)(png_const_structrp png_ptr, png_bytep row_buffer,
|
||||
png_const_bytep row, png_uint_32 x, unsigned int count, unsigned int p),
|
||||
unsigned int copy_parameter)
|
||||
{
|
||||
unsigned int max_pixels = png_max_pixel_block(png_ptr);
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
@ -648,7 +648,7 @@ write_row_buffered(png_structrp png_ptr,
|
||||
* maxpixels says if this is the final block in the row.
|
||||
*/
|
||||
png_write_png_data(png_ptr, prev_pixels, pixel_buffer.buffer, x,
|
||||
max_pixels, row_info_flags);
|
||||
max_pixels, row_info_flags);
|
||||
}
|
||||
}
|
||||
#endif /* WRITE { INTERLACING || TRANSFORMS } */
|
||||
@ -656,19 +656,19 @@ write_row_buffered(png_structrp png_ptr,
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
static void
|
||||
copy_row(png_const_structrp png_ptr, png_bytep row_buffer,
|
||||
png_const_bytep row, png_uint_32 x, unsigned int count,
|
||||
unsigned int pixel_depth)
|
||||
png_const_bytep row, png_uint_32 x, unsigned int count,
|
||||
unsigned int pixel_depth)
|
||||
{
|
||||
/* Copy row[x..x+count] pixels to row_buffer. */
|
||||
png_copy_row(png_ptr, row_buffer, row, x, count, pixel_depth, 1/*clear*/,
|
||||
0/* x_in_dest; row[x]->row_buffer */);
|
||||
0/* x_in_dest; row[x]->row_buffer */);
|
||||
}
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
static void
|
||||
interlace_row_lbd(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
png_uint_32 x, unsigned int count, const unsigned int B)
|
||||
png_uint_32 x, unsigned int count, const unsigned int B)
|
||||
{
|
||||
/* Pick out the correct pixels for the interlace pass. The basic idea here
|
||||
* is to go through the row with a source pointer and a destination pointer
|
||||
@ -745,7 +745,7 @@ interlace_row_lbd(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
|
||||
static void
|
||||
interlace_row_byte(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
png_uint_32 x, unsigned int count, unsigned int cbytes)
|
||||
png_uint_32 x, unsigned int count, unsigned int cbytes)
|
||||
{
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
const unsigned int inc = PNG_PASS_COL_OFFSET(pass);
|
||||
@ -764,12 +764,12 @@ interlace_row_byte(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
static void
|
||||
write_row_core(png_structrp png_ptr, png_const_bytep row,
|
||||
unsigned int row_info_flags)
|
||||
unsigned int row_info_flags)
|
||||
{
|
||||
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transform_list != NULL)
|
||||
write_row_buffered(png_ptr, row, row_info_flags,
|
||||
copy_row, png_ptr->row_input_pixel_depth);
|
||||
copy_row, png_ptr->row_input_pixel_depth);
|
||||
|
||||
else
|
||||
# endif /* WRITE_TRANSFORMS */
|
||||
@ -859,12 +859,12 @@ interlace_row(png_structrp png_ptr, png_const_bytep row)
|
||||
/*FALL THROUGH*/
|
||||
case 1U: /* B will be 0 */
|
||||
write_row_buffered(png_ptr, row, row_info_flags,
|
||||
interlace_row_lbd, B);
|
||||
interlace_row_lbd, B);
|
||||
break;
|
||||
|
||||
default: /* Parameter is the pixel size in bytes */
|
||||
write_row_buffered(png_ptr, row, row_info_flags,
|
||||
interlace_row_byte, input_depth >> 3);
|
||||
interlace_row_byte, input_depth >> 3);
|
||||
break;
|
||||
}
|
||||
} /* pass < 6 */
|
||||
@ -895,7 +895,7 @@ interlace_row(png_structrp png_ptr, png_const_bytep row)
|
||||
*/
|
||||
static void
|
||||
png_write_rows_internal(png_structrp png_ptr, png_const_bytep *rows,
|
||||
png_uint_32 num_rows)
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
if (png_ptr != NULL && num_rows > 0U && rows != NULL)
|
||||
{
|
||||
@ -1011,9 +1011,9 @@ png_write_rows_internal(png_structrp png_ptr, png_const_bytep *rows,
|
||||
|
||||
else /* app does interlace */
|
||||
affirm(PNG_PASS_IN_IMAGE(png_ptr->width, png_ptr->height,
|
||||
png_ptr->pass) &&
|
||||
png_ptr->row_number <
|
||||
PNG_PASS_ROWS(png_ptr->height, png_ptr->pass));
|
||||
png_ptr->pass) &&
|
||||
png_ptr->row_number <
|
||||
PNG_PASS_ROWS(png_ptr->height, png_ptr->pass));
|
||||
}
|
||||
} /* png_ptr, rows, num_rows all valid */
|
||||
|
||||
@ -1042,7 +1042,7 @@ png_write_rows(png_structrp png_ptr, png_bytepp rows, png_uint_32 num_rows)
|
||||
|
||||
if (png_ptr != NULL)
|
||||
png_write_rows_internal(png_ptr, png_constcast(png_const_bytep*,rows),
|
||||
num_rows);
|
||||
num_rows);
|
||||
}
|
||||
|
||||
/* Write the image. You only need to call this function once, even
|
||||
@ -1202,7 +1202,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
|
||||
png_app_error(png_ptr,
|
||||
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
|
||||
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
|
||||
|
||||
/* Continue if ignored - this is the pre-1.6.10 behavior */
|
||||
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
||||
@ -1266,7 +1266,7 @@ static int
|
||||
png_image_write_init(png_imagep image)
|
||||
{
|
||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,
|
||||
png_safe_error, png_safe_warning);
|
||||
png_safe_error, png_safe_warning);
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -1275,7 +1275,7 @@ png_image_write_init(png_imagep image)
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_controlp control = png_voidcast(png_controlp,
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
png_malloc_warn(png_ptr, (sizeof *control)));
|
||||
|
||||
if (control != NULL)
|
||||
{
|
||||
@ -1326,12 +1326,12 @@ static int
|
||||
png_write_image_16bit(png_voidp argument)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
|
||||
png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
|
||||
display->first_row);
|
||||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
@ -1436,7 +1436,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
|
||||
static png_byte
|
||||
png_unpremultiply(png_const_structrp png_ptr, png_uint_32 component,
|
||||
png_uint_32 alpha, png_uint_32 reciprocal/*from the above macro*/)
|
||||
png_uint_32 alpha, png_uint_32 reciprocal/*from the above macro*/)
|
||||
{
|
||||
/* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0
|
||||
* is represented as some other value there is more likely to be a
|
||||
@ -1485,12 +1485,12 @@ static int
|
||||
png_write_image_8bit(png_voidp argument)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
|
||||
png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,
|
||||
display->first_row);
|
||||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
@ -1536,7 +1536,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
c = channels;
|
||||
do /* always at least one channel */
|
||||
*out_ptr++ = png_unpremultiply(png_ptr, *in_ptr++, alpha,
|
||||
reciprocal);
|
||||
reciprocal);
|
||||
while (--c > 0);
|
||||
|
||||
/* Skip to next component (skip the intervening alpha channel) */
|
||||
@ -1545,7 +1545,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
} /* while out_ptr < row_end */
|
||||
|
||||
png_write_row(png_ptr, png_voidcast(png_const_bytep,
|
||||
display->local_row));
|
||||
display->local_row));
|
||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
||||
} /* while y */
|
||||
}
|
||||
@ -1637,7 +1637,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
else /* Gray */
|
||||
palette[i].blue = palette[i].red = palette[i].green =
|
||||
PNG_sRGB_FROM_LINEAR(display->image->opaque->png_ptr,
|
||||
255 * *entry);
|
||||
255 * *entry);
|
||||
}
|
||||
|
||||
else /* alpha */
|
||||
@ -1661,20 +1661,20 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
if (channels >= 3) /* RGB */
|
||||
{
|
||||
palette[i].blue = png_unpremultiply(
|
||||
display->image->opaque->png_ptr, entry[afirst + (2 ^ bgr)],
|
||||
alpha, reciprocal);
|
||||
display->image->opaque->png_ptr, entry[afirst + (2 ^ bgr)],
|
||||
alpha, reciprocal);
|
||||
palette[i].green = png_unpremultiply(
|
||||
display->image->opaque->png_ptr, entry[afirst + 1], alpha,
|
||||
reciprocal);
|
||||
display->image->opaque->png_ptr, entry[afirst + 1], alpha,
|
||||
reciprocal);
|
||||
palette[i].red = png_unpremultiply(
|
||||
display->image->opaque->png_ptr, entry[afirst + bgr], alpha,
|
||||
reciprocal);
|
||||
display->image->opaque->png_ptr, entry[afirst + bgr], alpha,
|
||||
reciprocal);
|
||||
}
|
||||
|
||||
else /* gray */
|
||||
palette[i].blue = palette[i].red = palette[i].green =
|
||||
png_unpremultiply(display->image->opaque->png_ptr,
|
||||
entry[afirst], alpha, reciprocal);
|
||||
png_unpremultiply(display->image->opaque->png_ptr,
|
||||
entry[afirst], alpha, reciprocal);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1721,11 +1721,11 @@ png_image_set_PLTE(png_image_write_control *display)
|
||||
# endif
|
||||
|
||||
png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,
|
||||
entries);
|
||||
entries);
|
||||
|
||||
if (num_trans > 0)
|
||||
png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
|
||||
num_trans, NULL);
|
||||
num_trans, NULL);
|
||||
|
||||
image->colormap_entries = entries;
|
||||
}
|
||||
@ -1734,7 +1734,7 @@ static int
|
||||
png_image_write_main(png_voidp argument)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
argument);
|
||||
argument);
|
||||
png_imagep image = display->image;
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
@ -1802,24 +1802,24 @@ png_image_write_main(png_voidp argument)
|
||||
png_uint_32 entries = image->colormap_entries;
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
|
||||
entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
|
||||
PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),
|
||||
PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
png_image_set_PLTE(display);
|
||||
}
|
||||
|
||||
else
|
||||
png_error(image->opaque->png_ptr,
|
||||
"no color-map for color-mapped image");
|
||||
"no color-map for color-mapped image");
|
||||
}
|
||||
|
||||
else
|
||||
png_set_IHDR(png_ptr, info_ptr, image->width, image->height,
|
||||
write_16bit ? 16 : 8,
|
||||
((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
|
||||
((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
write_16bit ? 16 : 8,
|
||||
((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +
|
||||
((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
/* Counter-intuitively the data transformations must be called *after*
|
||||
* png_write_info, not before as in the read code, but the 'set' functions
|
||||
@ -1834,11 +1834,11 @@ png_image_write_main(png_voidp argument)
|
||||
|
||||
if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
/* color x y */
|
||||
/* white */ 31270, 32900,
|
||||
/* red */ 64000, 33000,
|
||||
/* green */ 30000, 60000,
|
||||
/* blue */ 15000, 6000
|
||||
/* color x y */
|
||||
/* white */ 31270, 32900,
|
||||
/* red */ 64000, 33000,
|
||||
/* green */ 30000, 60000,
|
||||
/* blue */ 15000, 6000
|
||||
);
|
||||
}
|
||||
|
||||
@ -1925,7 +1925,7 @@ png_image_write_main(png_voidp argument)
|
||||
(colormap == 0 && display->convert_to_8bit != 0))
|
||||
{
|
||||
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
int result;
|
||||
|
||||
display->local_row = row;
|
||||
@ -1965,10 +1965,10 @@ png_image_write_main(png_voidp argument)
|
||||
|
||||
static void (PNGCBAPI
|
||||
image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data,
|
||||
png_size_t size)
|
||||
png_size_t size)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
|
||||
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
|
||||
const png_alloc_size_t ob = display->output_bytes;
|
||||
|
||||
/* Check for overflow; this should never happen: */
|
||||
@ -1999,22 +1999,22 @@ static int
|
||||
png_image_write_memory(png_voidp argument)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
argument);
|
||||
argument);
|
||||
|
||||
/* The rest of the memory-specific init and write_main in an error protected
|
||||
* environment. This case needs to use callbacks for the write operations
|
||||
* since libpng has no built in support for writing to memory.
|
||||
*/
|
||||
png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/,
|
||||
image_memory_write, image_memory_flush);
|
||||
image_memory_write, image_memory_flush);
|
||||
|
||||
return png_image_write_main(display);
|
||||
}
|
||||
|
||||
int PNGAPI
|
||||
png_image_write_to_memory(png_imagep image, void *memory,
|
||||
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
|
||||
const void *buffer, ptrdiff_t row_stride, const void *colormap)
|
||||
png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit,
|
||||
const void *buffer, ptrdiff_t row_stride, const void *colormap)
|
||||
{
|
||||
/* Write the image to the given buffer, or count the bytes if it is NULL */
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
@ -2066,12 +2066,12 @@ png_image_write_to_memory(png_imagep image, void *memory,
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_memory: invalid argument");
|
||||
"png_image_write_to_memory: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_write_to_memory: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
else
|
||||
return 0;
|
||||
@ -2080,7 +2080,7 @@ png_image_write_to_memory(png_imagep image, void *memory,
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||
int PNGAPI
|
||||
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
const void *buffer, ptrdiff_t row_stride, const void *colormap)
|
||||
const void *buffer, ptrdiff_t row_stride, const void *colormap)
|
||||
{
|
||||
/* Write the image to the given (FILE*). */
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
@ -2111,12 +2111,12 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_stdio: invalid argument");
|
||||
"png_image_write_to_stdio: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
else
|
||||
return 0;
|
||||
@ -2124,8 +2124,8 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
|
||||
int PNGAPI
|
||||
png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
int convert_to_8bit, const void *buffer, ptrdiff_t row_stride,
|
||||
const void *colormap)
|
||||
int convert_to_8bit, const void *buffer, ptrdiff_t row_stride,
|
||||
const void *colormap)
|
||||
{
|
||||
/* Write the image to the named file. */
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
@ -2137,7 +2137,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
|
||||
row_stride, colormap) != 0)
|
||||
row_stride, colormap) != 0)
|
||||
{
|
||||
int error; /* from fflush/fclose */
|
||||
|
||||
@ -2178,12 +2178,12 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
||||
|
||||
else
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_file: invalid argument");
|
||||
"png_image_write_to_file: invalid argument");
|
||||
}
|
||||
|
||||
else if (image != NULL)
|
||||
return png_image_error(image,
|
||||
"png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
|
||||
"png_image_write_to_file: incorrect PNG_IMAGE_VERSION");
|
||||
|
||||
else
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
48
pngwutil.c
48
pngwutil.c
@ -59,7 +59,7 @@ png_write_sig(png_structrp png_ptr)
|
||||
|
||||
/* Write the rest of the 8 byte signature */
|
||||
png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
|
||||
(png_size_t)(8 - png_ptr->sig_bytes));
|
||||
(png_size_t)(8 - png_ptr->sig_bytes));
|
||||
|
||||
if (png_ptr->sig_bytes < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
@ -172,7 +172,7 @@ png_write_chunk_end(png_structrp png_ptr)
|
||||
*/
|
||||
static void
|
||||
png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
png_const_voidp data, png_size_t length)
|
||||
png_const_voidp data, png_size_t length)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
@ -189,10 +189,10 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
/* This is the API that calls the internal function above. */
|
||||
void PNGAPI
|
||||
png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
|
||||
png_const_voidp data, png_size_t length)
|
||||
png_const_voidp data, png_size_t length)
|
||||
{
|
||||
png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
|
||||
length);
|
||||
length);
|
||||
}
|
||||
|
||||
static png_alloc_size_t
|
||||
@ -314,7 +314,7 @@ typedef struct png_compression_buffer
|
||||
/* Deleting a compression buffer deletes the whole list: */
|
||||
static void
|
||||
png_free_compression_buffer(png_const_structrp png_ptr,
|
||||
png_compression_bufferp *listp)
|
||||
png_compression_bufferp *listp)
|
||||
{
|
||||
png_compression_bufferp list = *listp;
|
||||
|
||||
@ -338,7 +338,7 @@ png_free_compression_buffer(png_const_structrp png_ptr,
|
||||
*/
|
||||
static png_compression_bufferp
|
||||
png_get_compression_buffer(png_const_structrp png_ptr,
|
||||
png_compression_bufferp *end)
|
||||
png_compression_bufferp *end)
|
||||
{
|
||||
png_compression_bufferp next = *end;
|
||||
|
||||
@ -1714,7 +1714,7 @@ png_image_size(png_const_structrp png_ptr)
|
||||
/* Initialize the compressor for the appropriate type of compression. */
|
||||
static png_zlib_statep
|
||||
png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
png_alloc_size_t data_size)
|
||||
png_alloc_size_t data_size)
|
||||
{
|
||||
png_zlib_statep ps = get_zlib_state(png_ptr);
|
||||
|
||||
@ -1789,8 +1789,8 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
|
||||
else
|
||||
ret = deflateInit2(&ps->s.zs, pz_value(level, settings), Z_DEFLATED,
|
||||
pz_value(windowBits, settings), pz_value(memLevel, settings),
|
||||
pz_value(strategy, settings));
|
||||
pz_value(windowBits, settings), pz_value(memLevel, settings),
|
||||
pz_value(strategy, settings));
|
||||
|
||||
ps->pz_current = settings;
|
||||
|
||||
@ -1824,7 +1824,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
*/
|
||||
static int /* success */
|
||||
png_compress_chunk_data(png_structrp png_ptr, png_uint_32 chunk_name,
|
||||
png_uint_32 prefix_len, png_const_voidp input, png_alloc_size_t input_len)
|
||||
png_uint_32 prefix_len, png_const_voidp input, png_alloc_size_t input_len)
|
||||
{
|
||||
/* To find the length of the output it is necessary to first compress the
|
||||
* input. The result is buffered rather than using the two-pass algorithm
|
||||
@ -3234,7 +3234,7 @@ png_write_IDAT(png_structrp png_ptr, int flush)
|
||||
*/
|
||||
static int
|
||||
png_compress_IDAT_data(png_structrp png_ptr, png_zlib_statep ps,
|
||||
png_zlib_compressp pz, png_const_voidp input, uInt input_len, int flush)
|
||||
png_zlib_compressp pz, png_const_voidp input, uInt input_len, int flush)
|
||||
{
|
||||
/* Delay initialize the z_stream. */
|
||||
if (png_ptr->zowner != png_IDAT)
|
||||
@ -3278,7 +3278,7 @@ png_compress_IDAT_data(png_structrp png_ptr, png_zlib_statep ps,
|
||||
*/
|
||||
static void
|
||||
png_compress_IDAT(png_structrp png_ptr, png_const_voidp input, uInt input_len,
|
||||
int flush)
|
||||
int flush)
|
||||
{
|
||||
png_zlib_statep ps = png_ptr->zlib_state;
|
||||
int ret = png_compress_IDAT_data(png_ptr, ps, &ps->s, input, input_len,
|
||||
@ -4447,7 +4447,7 @@ select_filter(png_zlib_statep ps, png_const_bytep row,
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_write_png_rows(png_structrp png_ptr, png_const_bytep *rows,
|
||||
png_uint_32 num_rows)
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
const png_zlib_statep ps = png_ptr->zlib_state;
|
||||
const unsigned int bpp = png_ptr->row_output_pixel_depth;
|
||||
@ -4755,8 +4755,8 @@ write_png_data(png_structrp png_ptr, png_const_bytep prev_row,
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
|
||||
png_const_bytep unfiltered_row, png_uint_32 x,
|
||||
unsigned int width/*pixels*/, unsigned int row_info_flags)
|
||||
png_const_bytep unfiltered_row, png_uint_32 x,
|
||||
unsigned int width/*pixels*/, unsigned int row_info_flags)
|
||||
{
|
||||
const png_zlib_statep ps = png_ptr->zlib_state;
|
||||
|
||||
@ -4876,8 +4876,8 @@ png_write_start_IDAT(png_structrp png_ptr)
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
|
||||
png_const_bytep unfiltered_row, png_uint_32 x,
|
||||
unsigned int width/*pixels*/, unsigned int row_info_flags)
|
||||
png_const_bytep unfiltered_row, png_uint_32 x,
|
||||
unsigned int width/*pixels*/, unsigned int row_info_flags)
|
||||
{
|
||||
const unsigned int bpp = png_ptr->row_output_pixel_depth;
|
||||
int flush;
|
||||
@ -4905,7 +4905,7 @@ png_write_png_data(png_structrp png_ptr, png_bytep prev_pixels,
|
||||
|
||||
png_int_32 /* PRIVATE */
|
||||
png_write_setting(png_structrp png_ptr, png_uint_32 setting,
|
||||
png_uint_32 parameter, png_int_32 value)
|
||||
png_uint_32 parameter, png_int_32 value)
|
||||
{
|
||||
/* Caller checks the arguments for basic validity */
|
||||
int only_get = (setting & PNG_SF_GET) != 0U;
|
||||
@ -4930,24 +4930,24 @@ png_write_setting(png_structrp png_ptr, png_uint_32 setting,
|
||||
/* Settings in zlib_state: */
|
||||
case PNG_SW_COMPRESS_png_level:
|
||||
return compression_setting(png_ptr, parameter, png_level, value,
|
||||
only_get);
|
||||
only_get);
|
||||
|
||||
# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
case PNG_SW_COMPRESS_zlib_level:
|
||||
return compression_setting(png_ptr, parameter, level, value,
|
||||
only_get);
|
||||
only_get);
|
||||
|
||||
case PNG_SW_COMPRESS_windowBits:
|
||||
return compression_setting(png_ptr, parameter, windowBits, value,
|
||||
only_get);
|
||||
only_get);
|
||||
|
||||
case PNG_SW_COMPRESS_memLevel:
|
||||
return compression_setting(png_ptr, parameter, memLevel, value,
|
||||
only_get);
|
||||
only_get);
|
||||
|
||||
case PNG_SW_COMPRESS_strategy:
|
||||
return compression_setting(png_ptr, parameter, strategy, value,
|
||||
only_get);
|
||||
only_get);
|
||||
|
||||
case PNG_SW_COMPRESS_method:
|
||||
if (value != 8) /* Only supported method */
|
||||
@ -4964,7 +4964,7 @@ png_write_setting(png_structrp png_ptr, png_uint_32 setting,
|
||||
return set_filter(get_zlib_state(png_ptr), value);
|
||||
|
||||
else if (png_ptr->zlib_state != NULL &&
|
||||
png_ptr->zlib_state->filter_mask != 0U/*unset*/)
|
||||
png_ptr->zlib_state->filter_mask != 0U/*unset*/)
|
||||
return png_ptr->zlib_state->filter_mask;
|
||||
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user