Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibPNG/png.c view on Meta::CPAN
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
"unexpected NamedColor ICC profile class");
break;
default:
/* To allow for future enhancements to the profile accept unrecognized
* profile classes with a warning, these then hit the test below on the
* tag content to ensure they are backward compatible with one of the
* understood profiles.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
"unrecognized ICC profile class");
break;
}
/* For any profile other than a device link one the PCS must be encoded
* either in XYZ or Lab.
*/
temp = png_get_uint_32(profile+20);
switch (temp)
{
case 0x58595A20: /* 'XYZ ' */
case 0x4C616220: /* 'Lab ' */
break;
default:
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"unexpected ICC PCS encoding");
}
return 1;
}
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_uint_32 tag_count = png_get_uint_32(profile+128);
png_uint_32 itag;
png_const_bytep tag = profile+132; /* The first tag */
/* First scan all the tags in the table and add bits to the icc_info value
* (temporarily in 'tags').
*/
for (itag=0; itag < tag_count; ++itag, tag += 12)
{
png_uint_32 tag_id = png_get_uint_32(tag+0);
png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */
png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */
/* The ICC specification does not exclude zero length tags, therefore the
* start might actually be anywhere if there is no data, but this would be
* a clear abuse of the intent of the standard so the start is checked for
* being in range. All defined tag types have an 8 byte header - a 4 byte
* type signature then 0.
*/
if ((tag_start & 3) != 0)
{
/* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is
* only a warning here because libpng does not care about the
* alignment.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
"ICC profile tag start not a multiple of 4");
}
/* This is a hard error; potentially it can cause read outside the
* profile.
*/
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");
}
return 1; /* success, maybe with warnings */
}
#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
/* Information about the known ICC sRGB profiles */
static const struct
{
png_uint_32 adler, crc, length;
png_uint_32 md5[4];
png_byte have_md5;
png_byte is_broken;
png_uint_16 intent;
# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0)
# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\
{ adler, crc, length, md5, broke, intent },
} png_sRGB_checks[] =
{
/* This data comes from contrib/tools/checksum-icc run on downloads of
* all four ICC sRGB profiles from www.color.org.
*/
/* 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")
/* 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_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")
/* 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")
/* 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
* a warning is produced. The first two of these profiles have a 'cprt' tag
* which suggests that they were also made by Hewlett Packard.
*/
( run in 0.651 second using v1.01-cache-2.11-cpan-e93a5daba3e )