summaryrefslogtreecommitdiff
path: root/pngset.c
diff options
context:
space:
mode:
Diffstat (limited to 'pngset.c')
-rw-r--r--pngset.c191
1 files changed, 75 insertions, 116 deletions
diff --git a/pngset.c b/pngset.c
index 4893671e5..ea77fef82 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
- * Last changed in libpng 1.2.30 [August 15, 2008]
+ * Last changed in libpng 1.2.34 [December 11, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -21,7 +21,7 @@
void PNGAPI
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
{
- png_debug1(1, "in %s storage function\n", "bKGD");
+ png_debug1(1, "in %s storage function", "bKGD");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -37,34 +37,9 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double white_x, double white_y, double red_x, double red_y,
double green_x, double green_y, double blue_x, double blue_y)
{
- png_debug1(1, "in %s storage function\n", "cHRM");
+ png_debug1(1, "in %s storage function", "cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
- if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
- blue_x || blue_y))
- {
- png_warning(png_ptr,
- "Ignoring attempt to set all-zero chromaticity values");
- return;
- }
- if (white_x < 0.0 || white_y < 0.0 ||
- red_x < 0.0 || red_y < 0.0 ||
- green_x < 0.0 || green_y < 0.0 ||
- blue_x < 0.0 || blue_y < 0.0)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set negative chromaticity value");
- return;
- }
- if (white_x > 21474.83 || white_y > 21474.83 ||
- red_x > 21474.83 || red_y > 21474.83 ||
- green_x > 21474.83 || green_y > 21474.83 ||
- blue_x > 21474.83 || blue_y > 21474.83)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set chromaticity value exceeding 21474.83");
- return;
- }
info_ptr->x_white = (float)white_x;
info_ptr->y_white = (float)white_y;
@@ -94,61 +69,38 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
png_fixed_point blue_x, png_fixed_point blue_y)
{
- png_debug1(1, "in %s storage function\n", "cHRM");
+ png_debug1(1, "in %s storage function", "cHRM fixed");
if (png_ptr == NULL || info_ptr == NULL)
return;
- if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
- blue_x || blue_y))
- {
- png_warning(png_ptr,
- "Ignoring attempt to set all-zero chromaticity values");
- return;
- }
- if (white_x < 0 || white_y < 0 ||
- red_x < 0 || red_y < 0 ||
- green_x < 0 || green_y < 0 ||
- blue_x < 0 || blue_y < 0)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set negative chromaticity value");
- return;
- }
- if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
- white_y > (png_fixed_point) PNG_UINT_31_MAX ||
- red_x > (png_fixed_point) PNG_UINT_31_MAX ||
- red_y > (png_fixed_point) PNG_UINT_31_MAX ||
- green_x > (png_fixed_point) PNG_UINT_31_MAX ||
- green_y > (png_fixed_point) PNG_UINT_31_MAX ||
- blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
- blue_y > (png_fixed_point) PNG_UINT_31_MAX )
+#if !defined(PNG_NO_CHECK_cHRM)
+ if (png_check_cHRM_fixed(png_ptr,
+ white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
+#endif
{
- png_warning(png_ptr,
- "Ignoring attempt to set chromaticity value exceeding 21474.83");
- return;
- }
- info_ptr->int_x_white = white_x;
- info_ptr->int_y_white = white_y;
- info_ptr->int_x_red = red_x;
- info_ptr->int_y_red = red_y;
- info_ptr->int_x_green = green_x;
- info_ptr->int_y_green = green_y;
- info_ptr->int_x_blue = blue_x;
- info_ptr->int_y_blue = blue_y;
+ info_ptr->int_x_white = white_x;
+ info_ptr->int_y_white = white_y;
+ info_ptr->int_x_red = red_x;
+ info_ptr->int_y_red = red_y;
+ info_ptr->int_x_green = green_x;
+ info_ptr->int_y_green = green_y;
+ info_ptr->int_x_blue = blue_x;
+ info_ptr->int_y_blue = blue_y;
#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->x_white = (float)(white_x/100000.);
- info_ptr->y_white = (float)(white_y/100000.);
- info_ptr->x_red = (float)( red_x/100000.);
- info_ptr->y_red = (float)( red_y/100000.);
- info_ptr->x_green = (float)(green_x/100000.);
- info_ptr->y_green = (float)(green_y/100000.);
- info_ptr->x_blue = (float)( blue_x/100000.);
- info_ptr->y_blue = (float)( blue_y/100000.);
-#endif
- info_ptr->valid |= PNG_INFO_cHRM;
+ info_ptr->x_white = (float)(white_x/100000.);
+ info_ptr->y_white = (float)(white_y/100000.);
+ info_ptr->x_red = (float)( red_x/100000.);
+ info_ptr->y_red = (float)( red_y/100000.);
+ info_ptr->x_green = (float)(green_x/100000.);
+ info_ptr->y_green = (float)(green_y/100000.);
+ info_ptr->x_blue = (float)( blue_x/100000.);
+ info_ptr->y_blue = (float)( blue_y/100000.);
+#endif
+ info_ptr->valid |= PNG_INFO_cHRM;
+ }
}
-#endif
-#endif
+#endif /* PNG_FIXED_POINT_SUPPORTED */
+#endif /* PNG_cHRM_SUPPORTED */
#if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -156,7 +108,7 @@ void PNGAPI
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{
double gamma;
- png_debug1(1, "in %s storage function\n", "gAMA");
+ png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -183,7 +135,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
{
png_fixed_point gamma;
- png_debug1(1, "in %s storage function\n", "gAMA");
+ png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -220,7 +172,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
{
int i;
- png_debug1(1, "in %s storage function\n", "hIST");
+ png_debug1(1, "in %s storage function", "hIST");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette == 0 || info_ptr->num_palette
@@ -263,7 +215,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type)
{
- png_debug1(1, "in %s storage function\n", "IHDR");
+ png_debug1(1, "in %s storage function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -370,7 +322,7 @@ void PNGAPI
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
png_int_32 offset_x, png_int_32 offset_y, int unit_type)
{
- png_debug1(1, "in %s storage function\n", "oFFs");
+ png_debug1(1, "in %s storage function", "oFFs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -390,12 +342,12 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 length;
int i;
- png_debug1(1, "in %s storage function\n", "pCAL");
+ png_debug1(1, "in %s storage function", "pCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
length = png_strlen(purpose) + 1;
- png_debug1(3, "allocating purpose for info (%lu bytes)\n",
+ png_debug1(3, "allocating purpose for info (%lu bytes)",
(unsigned long)length);
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_purpose == NULL)
@@ -405,14 +357,14 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
}
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
- png_debug(3, "storing X0, X1, type, and nparams in info\n");
+ png_debug(3, "storing X0, X1, type, and nparams in info");
info_ptr->pcal_X0 = X0;
info_ptr->pcal_X1 = X1;
info_ptr->pcal_type = (png_byte)type;
info_ptr->pcal_nparams = (png_byte)nparams;
length = png_strlen(units) + 1;
- png_debug1(3, "allocating units for info (%lu bytes)\n",
+ png_debug1(3, "allocating units for info (%lu bytes)",
(unsigned long)length);
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_units == NULL)
@@ -435,7 +387,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
for (i = 0; i < nparams; i++)
{
length = png_strlen(params[i]) + 1;
- png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i,
+ png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
(unsigned long)length);
info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->pcal_params[i] == NULL)
@@ -459,7 +411,7 @@ void PNGAPI
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
int unit, double width, double height)
{
- png_debug1(1, "in %s storage function\n", "sCAL");
+ png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -477,14 +429,14 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
{
png_uint_32 length;
- png_debug1(1, "in %s storage function\n", "sCAL");
+ png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
info_ptr->scal_unit = (png_byte)unit;
length = png_strlen(swidth) + 1;
- png_debug1(3, "allocating unit for info (%u bytes)\n",
+ png_debug1(3, "allocating unit for info (%u bytes)",
(unsigned int)length);
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->scal_s_width == NULL)
@@ -496,7 +448,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
length = png_strlen(sheight) + 1;
- png_debug1(3, "allocating unit for info (%u bytes)\n",
+ png_debug1(3, "allocating unit for info (%u bytes)",
(unsigned int)length);
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->scal_s_height == NULL)
@@ -522,7 +474,7 @@ void PNGAPI
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
{
- png_debug1(1, "in %s storage function\n", "pHYs");
+ png_debug1(1, "in %s storage function", "pHYs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -538,7 +490,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
png_colorp palette, int num_palette)
{
- png_debug1(1, "in %s storage function\n", "PLTE");
+ png_debug1(1, "in %s storage function", "PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -587,7 +539,7 @@ void PNGAPI
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit)
{
- png_debug1(1, "in %s storage function\n", "sBIT");
+ png_debug1(1, "in %s storage function", "sBIT");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -600,7 +552,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
void PNGAPI
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{
- png_debug1(1, "in %s storage function\n", "sRGB");
+ png_debug1(1, "in %s storage function", "sRGB");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -624,12 +576,10 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
int_green_y, int_blue_x, int_blue_y;
#endif
-#endif
- png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
+ png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -647,7 +597,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
#endif
#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FIXED_POINT_SUPPORTED
int_white_x = 31270L;
int_white_y = 32900L;
int_red_x = 64000L;
@@ -657,10 +606,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int_blue_x = 15000L;
int_blue_y = 6000L;
- png_set_cHRM_fixed(png_ptr, info_ptr,
- int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
- int_blue_x, int_blue_y);
-#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
white_x = (float).3127;
white_y = (float).3290;
@@ -670,11 +615,25 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
green_y = (float).60;
blue_x = (float).15;
blue_y = (float).06;
+#endif
- png_set_cHRM(png_ptr, info_ptr,
- white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
+#if !defined(PNG_NO_CHECK_cHRM)
+ if (png_check_cHRM_fixed(png_ptr,
+ int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
+ int_green_y, int_blue_x, int_blue_y))
#endif
+ {
+#ifdef PNG_FIXED_POINT_SUPPORTED
+ png_set_cHRM_fixed(png_ptr, info_ptr,
+ int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
+ int_green_y, int_blue_x, int_blue_y);
+#endif
+#ifdef PNG_FLOATING_POINT_SUPPORTED
+ png_set_cHRM(png_ptr, info_ptr,
+ white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
#endif
+ }
+#endif /* cHRM */
}
#endif
@@ -689,7 +648,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charp new_iccp_profile;
png_uint_32 length;
- png_debug1(1, "in %s storage function\n", "iCCP");
+ png_debug1(1, "in %s storage function", "iCCP");
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return;
@@ -743,7 +702,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
{
int i;
- png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
+ png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ?
"text" : (png_const_charp)png_ptr->chunk_name));
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
@@ -785,7 +744,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->free_me |= PNG_FREE_TEXT;
#endif
}
- png_debug1(3, "allocated %d entries for info_ptr->text\n",
+ png_debug1(3, "allocated %d entries for info_ptr->text",
info_ptr->max_text);
}
for (i = 0; i < num_text; i++)
@@ -845,7 +804,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
(key_len + text_length + lang_len + lang_key_len + 4));
if (textp->key == NULL)
return(1);
- png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
+ png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
(png_uint_32)
(key_len + lang_len + lang_key_len + text_length + 4),
(int)textp->key);
@@ -893,7 +852,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
#endif
}
info_ptr->num_text++;
- png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
+ png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
}
return(0);
}
@@ -903,7 +862,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
void PNGAPI
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{
- png_debug1(1, "in %s storage function\n", "tIME");
+ png_debug1(1, "in %s storage function", "tIME");
if (png_ptr == NULL || info_ptr == NULL ||
(png_ptr->mode & PNG_WROTE_tIME))
return;
@@ -918,7 +877,7 @@ void PNGAPI
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values)
{
- png_debug1(1, "in %s storage function\n", "tRNS");
+ png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1123,7 +1082,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{
/* This function is deprecated in favor of png_permit_mng_features()
and will be removed from libpng-1.3.0 */
- png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
+ png_debug(1, "in png_permit_empty_plte, DEPRECATED.");
if (png_ptr == NULL)
return;
png_ptr->mng_features_permitted = (png_byte)
@@ -1137,7 +1096,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
png_uint_32 PNGAPI
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
{
- png_debug(1, "in png_permit_mng_features\n");
+ png_debug(1, "in png_permit_mng_features");
if (png_ptr == NULL)
return (png_uint_32)0;
png_ptr->mng_features_permitted =
@@ -1198,7 +1157,7 @@ void PNGAPI
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
png_user_chunk_ptr read_user_chunk_fn)
{
- png_debug(1, "in png_set_read_user_chunk_fn\n");
+ png_debug(1, "in png_set_read_user_chunk_fn");
if (png_ptr == NULL)
return;
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
@@ -1210,7 +1169,7 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
void PNGAPI
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
{
- png_debug1(1, "in %s storage function\n", "rows");
+ png_debug1(1, "in %s storage function", "rows");
if (png_ptr == NULL || info_ptr == NULL)
return;