summaryrefslogtreecommitdiff
path: root/pngwutil.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2009-08-13 18:04:26 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2009-08-13 18:05:36 -0500
commit3358a9880ba8080a51c23097388a18b2cd2c663e (patch)
treee58fd659c106ca8ef55a31ec54bac7f1da8293ee /pngwutil.c
parent3c9c3ea7aed64b470dc6e3e6b16ac4d0da58aab8 (diff)
downloadlibpng-3358a9880ba8080a51c23097388a18b2cd2c663e.tar.gz
[devel] Bump version to libpng-1.4.0beta75
Diffstat (limited to 'pngwutil.c')
-rw-r--r--pngwutil.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/pngwutil.c b/pngwutil.c
index 9c92e33b8..4a82fcf8e 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
- * Last changed in libpng 1.4.0 [August 8, 2009]
+ * Last changed in libpng 1.4.0 [August 13, 2009]
* Copyright (c) 1998-2009 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.)
@@ -424,6 +424,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_byte buf[13]; /* Buffer to store the IHDR info */
png_debug(1, "in png_write_IHDR");
+
/* Check that we have valid input data from the application info */
switch (color_type)
{
@@ -601,6 +602,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_byte buf[3];
png_debug(1, "in png_write_PLTE");
+
if ((
#if defined(PNG_MNG_FEATURES_SUPPORTED)
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
@@ -660,6 +662,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
#endif
+
png_debug(1, "in png_write_IDAT");
/* Optimize the CMF field in the zlib stream. */
@@ -714,7 +717,9 @@ png_write_IEND(png_structp png_ptr)
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IEND;
#endif
+
png_debug(1, "in png_write_IEND");
+
png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL,
(png_size_t)0);
png_ptr->mode |= PNG_HAVE_IEND;
@@ -733,6 +738,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
png_byte buf[4];
png_debug(1, "in png_write_gAMA");
+
/* file_gamma is saved in 1/100,000ths */
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
png_save_uint_32(buf, igamma);
@@ -749,6 +755,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
png_byte buf[4];
png_debug(1, "in png_write_gAMA");
+
/* file_gamma is saved in 1/100,000ths */
png_save_uint_32(buf, (png_uint_32)file_gamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
@@ -767,6 +774,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
png_byte buf[1];
png_debug(1, "in png_write_sRGB");
+
if (srgb_intent >= PNG_sRGB_INTENT_LAST)
png_warning(png_ptr,
"Invalid sRGB rendering intent specified");
@@ -875,6 +883,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
#endif
png_debug(1, "in png_write_sPLT");
+
if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0)
return;
@@ -948,6 +957,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
png_size_t size;
png_debug(1, "in png_write_sBIT");
+
/* Make sure we don't depend upon the order of PNG_COLOR_8 */
if (color_type & PNG_COLOR_MASK_COLOR)
{
@@ -1055,6 +1065,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_byte buf[32];
png_debug(1, "in png_write_cHRM");
+
/* Each value is saved in 1/100,000ths */
#if !defined(PNG_NO_CHECK_cHRM)
if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
@@ -1091,6 +1102,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
png_byte buf[6];
png_debug(1, "in png_write_tRNS");
+
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
@@ -1130,7 +1142,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
}
else
{
- png_warning(png_ptr, "Can't write tRNS in a PNG with an alpha channel");
+ png_warning(png_ptr, "Can't write tRNS with an alpha channel");
}
}
#endif
@@ -1146,6 +1158,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
png_byte buf[6];
png_debug(1, "in png_write_bKGD");
+
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (
@@ -1200,6 +1213,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
png_byte buf[3];
png_debug(1, "in png_write_hIST");
+
if (num_hist > (int)png_ptr->num_palette)
{
png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
@@ -1240,6 +1254,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
int kwarn=0;
png_debug(1, "in png_check_keyword");
+
*new_key = NULL;
if (key == NULL || (key_len = png_strlen(key)) == 0)
@@ -1362,6 +1377,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
png_charp new_key;
png_debug(1, "in png_write_tEXt");
+
if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
return;
@@ -1550,6 +1566,7 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
png_byte buf[9];
png_debug(1, "in png_write_oFFs");
+
if (unit_type >= PNG_OFFSET_LAST)
png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
@@ -1576,6 +1593,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
int i;
png_debug1(1, "in png_write_pCAL (%d parameters)", nparams);
+
if (type >= PNG_EQUATION_LAST)
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
@@ -1692,6 +1710,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
png_byte buf[9];
png_debug(1, "in png_write_pHYs");
+
if (unit_type >= PNG_RESOLUTION_LAST)
png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
@@ -1716,6 +1735,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
png_byte buf[7];
png_debug(1, "in png_write_tIME");
+
if (mod_time->month > 12 || mod_time->month < 1 ||
mod_time->day > 31 || mod_time->day < 1 ||
mod_time->hour > 23 || mod_time->second > 60)
@@ -1760,6 +1780,7 @@ png_write_start_row(png_structp png_ptr)
png_size_t buf_size;
png_debug(1, "in png_write_start_row");
+
buf_size = (png_size_t)(PNG_ROWBYTES(
png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1);
@@ -1865,6 +1886,7 @@ png_write_finish_row(png_structp png_ptr)
int ret;
png_debug(1, "in png_write_finish_row");
+
/* Next row */
png_ptr->row_number++;
@@ -1974,6 +1996,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
#endif
png_debug(1, "in png_do_write_interlace");
+
/* We don't have to do anything on the last pass (6) */
if (pass < 6)
{
@@ -2151,6 +2174,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
#endif
png_debug(1, "in png_write_find_filter");
+
/* Find out how many bytes offset each pixel is */
bpp = (row_info->pixel_depth + 7) >> 3;
@@ -2760,6 +2784,7 @@ void /* PRIVATE */
png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
{
png_debug(1, "in png_write_filtered_row");
+
png_debug1(2, "filter = %d", filtered_row[0]);
/* Set up the zlib input buffer */