summaryrefslogtreecommitdiff
path: root/pngrutil.c
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2012-10-25 19:30:02 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2012-10-25 19:30:02 -0500
commitf8dfd123e2b337f0ce3c484bbcfec10c4c8daddc (patch)
tree104fc10e92f7852a2c5131a308b1449d88997828 /pngrutil.c
parente6b710cb3fc573688c2150f9b777156f5d053518 (diff)
downloadlibpng-f8dfd123e2b337f0ce3c484bbcfec10c4c8daddc.tar.gz
[libpng16] Changed ICC profile support to allow use of an external color
management system (CMS). In practice it is not possible to obtain cHRM information reliably using just the end-point tags because they do not exist in the vast majority of profiles. Instead it is necessary to run the endpoints through the ICC colorimetric intent transform (as described in the v4 spec). Since this is likely to be too much code inside libpng for too little gain (it implies a fairly complete CMS implementation) the code has been changed to allow an external CMS to be used. This code is temporarily disabled until a suitable set of test cases using one or more external CMS implementations have been implemented.
Diffstat (limited to 'pngrutil.c')
-rw-r--r--pngrutil.c56
1 files changed, 5 insertions, 51 deletions
diff --git a/pngrutil.c b/pngrutil.c
index 83a580497..b76b8dd8a 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1087,31 +1087,7 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
igamma = png_get_fixed_point(NULL, buf);
- /* The gAMA value is unsigned (and is a power law correction, so 0 is
- * meaningless.)
- */
- if (igamma <= 0)
- {
- png_chunk_benign_error(png_ptr, "out of range");
- return;
- }
-
- /* If a colorspace error has already been output skip this chunk */
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
- return;
-
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA)
- {
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
-
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_gAMA;
- (void)png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma,
- 1/*prefer gAMA values*/);
+ png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma);
png_colorspace_sync(png_ptr, info_ptr);
}
#endif
@@ -1285,13 +1261,6 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_crc_finish(png_ptr, 0))
return;
- /* Check for bad intent */
- if (intent >= PNG_sRGB_INTENT_LAST)
- {
- png_chunk_benign_error(png_ptr, "Unknown sRGB intent");
- return;
- }
-
/* If a colorspace error has already been output skip this chunk */
if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
return;
@@ -1307,16 +1276,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
return;
}
- /* Do not override gAMA or cHRM from the PNG file; just check they match.
- * This is because we write a cHRM which corresponds to D65, however there is
- * an issue with CMMs that assume a D50 environment that requires adaptation
- * of the white point. This way at least it is possible to supply an
- * adapated value (so long as it is within the tolerance limits for a match
- * against the D65 chromaticities.)
- *
- * TODO: get expert opinions on this issue
- */
- (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent, 0);
+ png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
png_colorspace_sync(png_ptr, info_ptr);
}
#endif /* PNG_READ_sRGB_SUPPORTED */
@@ -1475,8 +1435,6 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
/* But otherwise allow extra data: */
else if (size == 0)
{
- int ok;
-
if (length > 0)
{
/* This can be handled completely, so
@@ -1493,12 +1451,12 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
* checks for a known sRGB profile. The
* result is 0 on error.
*/
- ok = png_icc_set_gAMA_and_cHRM(png_ptr,
+ png_icc_set_gAMA_and_cHRM(png_ptr,
&png_ptr->colorspace, keyword, profile,
png_ptr->zstream.adler);
/* Steal the profile for info_ptr. */
- if (ok && info_ptr != NULL)
+ if (info_ptr != NULL)
{
png_free_data(png_ptr, info_ptr,
PNG_FREE_ICCP, 0);
@@ -1534,15 +1492,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (info_ptr != NULL)
png_colorspace_sync(png_ptr, info_ptr);
- if (errmsg == NULL && ok)
+ if (errmsg == NULL)
{
png_ptr->zowner = 0;
return;
}
-
- /* else png_icc_set_gAMA_and_cHRM has
- * already output an error.
- */
}
else if (size > 0)