31#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
32#define GCC_STRICT_OVERFLOW 1
35#ifndef GCC_STRICT_OVERFLOW
36#define GCC_STRICT_OVERFLOW 0
45#ifdef PNG_READ_SUPPORTED
49 unsigned int nb = (
unsigned int)num_bytes;
60 png_error(
png_ptr,
"Too many bytes for PNG signature");
62 png_ptr->sig_bytes = (png_byte)nb;
76 png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
81 else if (num_to_check < 1)
87 if (
start + num_to_check > 8)
88 num_to_check = 8 -
start;
95#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
108 "Potential overflow in png_zalloc()");
161 if (need_crc != 0 &&
length > 0)
169 if (safe_length == 0)
170 safe_length = (
uInt)-1;
200 if (user_png_ver !=
NULL)
210 if (user_png_ver[
i] ==
'.')
212 }
while (found_dots < 2 && user_png_ver[
i] != 0 &&
221#ifdef PNG_WARNINGS_SUPPORTED
225 pos = png_safecat(
m, (
sizeof m),
pos,
226 "Application built with libpng-");
227 pos = png_safecat(
m, (
sizeof m),
pos, user_png_ver);
228 pos = png_safecat(
m, (
sizeof m),
pos,
" but running with ");
235#ifdef PNG_ERROR_NUMBERS_SUPPORTED
251 png_error_ptr error_fn, png_error_ptr warn_fn,
png_voidp mem_ptr,
252 png_malloc_ptr malloc_fn, png_free_ptr free_fn),
PNG_ALLOCATED)
255# ifdef PNG_SETJMP_SUPPORTED
263 memset(&create_struct, 0, (
sizeof create_struct));
266# ifdef PNG_USER_LIMITS_SUPPORTED
270# ifdef PNG_USER_CHUNK_CACHE_MAX
275# ifdef PNG_USER_CHUNK_MALLOC_MAX
286# ifdef PNG_USER_MEM_SUPPORTED
287 png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn);
299 png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn);
301# ifdef PNG_SETJMP_SUPPORTED
302 if (!
setjmp(create_jmp_buf))
305# ifdef PNG_SETJMP_SUPPORTED
311 create_struct.jmp_buf_ptr = &create_jmp_buf;
312 create_struct.jmp_buf_size = 0;
313 create_struct.longjmp_fn = longjmp;
317 if (png_user_version_check(&create_struct, user_png_ver) != 0)
320 png_malloc_warn(&create_struct, (
sizeof *
png_ptr)));
331# ifdef PNG_SETJMP_SUPPORTED
333 create_struct.jmp_buf_ptr =
NULL;
334 create_struct.jmp_buf_size = 0;
335 create_struct.longjmp_fn = 0;
358 png_debug(1,
"in png_create_info_struct");
390 png_debug(1,
"in png_destroy_info_struct");
395 if (info_ptr_ptr !=
NULL)
406 *info_ptr_ptr =
NULL;
424png_info_init_3,(
png_infopp ptr_ptr,
size_t png_info_struct_size),
434 if ((
sizeof (
png_info)) > png_info_struct_size)
467 png_error(
png_ptr,
"Unknown freer parameter in png_data_freer");
479#ifdef PNG_TEXT_SUPPORTED
505#ifdef PNG_tRNS_SUPPORTED
516#ifdef PNG_sCAL_SUPPORTED
528#ifdef PNG_pCAL_SUPPORTED
551#ifdef PNG_iCCP_SUPPORTED
563#ifdef PNG_sPLT_SUPPORTED
594#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
618#ifdef PNG_eXIf_SUPPORTED
622# ifdef PNG_READ_eXIf_SUPPORTED
638#ifdef PNG_hIST_SUPPORTED
657#ifdef PNG_INFO_IMAGE_SUPPORTED
675 mask &= ~PNG_FREE_MUL;
694#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
695# ifdef PNG_STDIO_SUPPORTED
714# ifdef PNG_SAVE_INT_32_SUPPORTED
732# ifdef PNG_TIME_RFC1123_SUPPORTED
739 static const char short_months[12][4] =
740 {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
741 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
746 if (ptime->
year > 9999 ||
748 ptime->
day == 0 || ptime->
day > 31 ||
757# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
758# define APPEND_NUMBER(format, value)\
759 APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))
760# define APPEND(ch) if (pos < 28) out[pos++] = (ch)
762 APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (
unsigned)ptime->
day);
764 APPEND_STRING(short_months[(ptime->
month - 1)]);
766 APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->
year);
768 APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (
unsigned)ptime->
hour);
770 APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (
unsigned)ptime->
minute);
772 APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (
unsigned)ptime->
second);
773 APPEND_STRING(
" +0000");
784# if PNG_LIBPNG_VER < 10700
796 if (png_convert_to_rfc1123_buffer(
png_ptr->time_buffer, ptime) == 0)
797 png_warning(
png_ptr,
"Ignoring invalid time value");
814#ifdef PNG_STRING_COPYRIGHT
815 return PNG_STRING_COPYRIGHT
820 "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
823 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
858# ifndef PNG_READ_SUPPORTED
867#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
882 png_debug(1,
"in png_do_build_grayscale_palette");
915 for (
i = 0,
v = 0;
i < num_palette;
i++,
v += color_inc)
924#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
935 p = p_end +
png_ptr->num_chunk_list*5;
945 if (
memcmp(chunk_name,
p, 4) == 0)
958#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
959 defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
963 png_byte chunk_string[5];
966 return png_handle_as_unknown(
png_ptr, chunk_string);
971#ifdef PNG_READ_SUPPORTED
992#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
1068#ifdef PNG_GAMMA_SUPPORTED
1084 if ((
colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
1086 png_gamma_significant(gtest) != 0))
1094 if ((
colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 ||
from == 2)
1096 png_chunk_report(
png_ptr,
"gamma value does not match sRGB",
1104 png_chunk_report(
png_ptr,
"gamma value does not match libpng estimate",
1130 if (gAMA < 16 || gAMA > 625000000)
1131 errmsg =
"gamma value out of range";
1133# ifdef PNG_READ_gAMA_SUPPORTED
1136 (
colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)
1141 else if ((
colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
1152 (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA);
1171 if ((
info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
1177# ifdef PNG_COLORSPACE_SUPPORTED
1187# ifdef PNG_COLORSPACE_SUPPORTED
1192 if ((
info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
1198 if ((
info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
1205 if ((
info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0)
1213#ifdef PNG_READ_SUPPORTED
1226#ifdef PNG_COLORSPACE_SUPPORTED
1233png_xy_from_XYZ(png_xy *xy,
const png_XYZ *XYZ)
1235 png_int_32
d, dwhite, whiteX, whiteY;
1237 d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z;
1238 if (png_muldiv(&xy->redx, XYZ->red_X,
PNG_FP_1,
d) == 0)
1240 if (png_muldiv(&xy->redy, XYZ->red_Y,
PNG_FP_1,
d) == 0)
1243 whiteX = XYZ->red_X;
1244 whiteY = XYZ->red_Y;
1246 d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z;
1247 if (png_muldiv(&xy->greenx, XYZ->green_X,
PNG_FP_1,
d) == 0)
1249 if (png_muldiv(&xy->greeny, XYZ->green_Y,
PNG_FP_1,
d) == 0)
1252 whiteX += XYZ->green_X;
1253 whiteY += XYZ->green_Y;
1255 d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z;
1256 if (png_muldiv(&xy->bluex, XYZ->blue_X,
PNG_FP_1,
d) == 0)
1258 if (png_muldiv(&xy->bluey, XYZ->blue_Y,
PNG_FP_1,
d) == 0)
1261 whiteX += XYZ->blue_X;
1262 whiteY += XYZ->blue_Y;
1267 if (png_muldiv(&xy->whitex, whiteX,
PNG_FP_1, dwhite) == 0)
1269 if (png_muldiv(&xy->whitey, whiteY,
PNG_FP_1, dwhite) == 0)
1276png_XYZ_from_xy(png_XYZ *XYZ,
const png_xy *xy)
1286 if (xy->redx < 0 || xy->redx >
PNG_FP_1)
return 1;
1287 if (xy->redy < 0 || xy->redy >
PNG_FP_1-xy->redx)
return 1;
1288 if (xy->greenx < 0 || xy->greenx >
PNG_FP_1)
return 1;
1289 if (xy->greeny < 0 || xy->greeny >
PNG_FP_1-xy->greenx)
return 1;
1290 if (xy->bluex < 0 || xy->bluex >
PNG_FP_1)
return 1;
1291 if (xy->bluey < 0 || xy->bluey >
PNG_FP_1-xy->bluex)
return 1;
1292 if (xy->whitex < 0 || xy->whitex >
PNG_FP_1)
return 1;
1293 if (xy->whitey < 5 || xy->whitey >
PNG_FP_1-xy->whitex)
return 1;
1474 if (png_muldiv(&
left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0)
1476 if (png_muldiv(&
right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0)
1481 if (png_muldiv(&
left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
1483 if (png_muldiv(&
right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
1491 if (png_muldiv(&red_inverse, xy->whitey, denominator,
left-
right) == 0 ||
1492 red_inverse <= xy->whitey )
1496 if (png_muldiv(&
left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
1498 if (png_muldiv(&
right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
1500 if (png_muldiv(&green_inverse, xy->whitey, denominator,
left-
right) == 0 ||
1501 green_inverse <= xy->whitey)
1507 blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) -
1508 png_reciprocal(green_inverse);
1509 if (blue_scale <= 0)
1514 if (png_muldiv(&XYZ->red_X, xy->redx,
PNG_FP_1, red_inverse) == 0)
1516 if (png_muldiv(&XYZ->red_Y, xy->redy,
PNG_FP_1, red_inverse) == 0)
1522 if (png_muldiv(&XYZ->green_X, xy->greenx,
PNG_FP_1, green_inverse) == 0)
1524 if (png_muldiv(&XYZ->green_Y, xy->greeny,
PNG_FP_1, green_inverse) == 0)
1526 if (png_muldiv(&XYZ->green_Z,
PNG_FP_1 - xy->greenx - xy->greeny,
PNG_FP_1,
1527 green_inverse) == 0)
1530 if (png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale,
PNG_FP_1) == 0)
1532 if (png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale,
PNG_FP_1) == 0)
1534 if (png_muldiv(&XYZ->blue_Z,
PNG_FP_1 - xy->bluex - xy->bluey, blue_scale,
1542png_XYZ_normalize(png_XYZ *XYZ)
1546 if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 ||
1547 XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 ||
1548 XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0)
1557 if (0x7fffffff - Y < XYZ->
green_X)
1560 if (0x7fffffff - Y < XYZ->
blue_X)
1566 if (png_muldiv(&XYZ->red_X, XYZ->red_X,
PNG_FP_1,
Y) == 0)
1568 if (png_muldiv(&XYZ->red_Y, XYZ->red_Y,
PNG_FP_1,
Y) == 0)
1570 if (png_muldiv(&XYZ->red_Z, XYZ->red_Z,
PNG_FP_1,
Y) == 0)
1573 if (png_muldiv(&XYZ->green_X, XYZ->green_X,
PNG_FP_1,
Y) == 0)
1575 if (png_muldiv(&XYZ->green_Y, XYZ->green_Y,
PNG_FP_1,
Y) == 0)
1577 if (png_muldiv(&XYZ->green_Z, XYZ->green_Z,
PNG_FP_1,
Y) == 0)
1580 if (png_muldiv(&XYZ->blue_X, XYZ->blue_X,
PNG_FP_1,
Y) == 0)
1582 if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y,
PNG_FP_1,
Y) == 0)
1584 if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z,
PNG_FP_1,
Y) == 0)
1592png_colorspace_endpoints_match(
const png_xy *xy1,
const png_xy *xy2,
int delta)
1618png_colorspace_check_xy(png_XYZ *XYZ,
const png_xy *xy)
1624 result = png_XYZ_from_xy(XYZ, xy);
1628 result = png_xy_from_XYZ(&xy_test, XYZ);
1632 if (png_colorspace_endpoints_match(xy, &xy_test,
1644png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ)
1649 result = png_XYZ_normalize(XYZ);
1653 result = png_xy_from_XYZ(xy, XYZ);
1658 return png_colorspace_check_xy(&XYZtemp, xy);
1662static const png_xy sRGB_xy =
1673 png_colorspacerp
colorspace,
const png_xy *xy,
const png_XYZ *XYZ,
1676 if ((
colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
1683 if (preferred < 2 &&
1684 (
colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
1689 if (png_colorspace_endpoints_match(xy, &
colorspace->end_points_xy,
1693 png_benign_error(
png_ptr,
"inconsistent chromaticities");
1704 colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS;
1709 if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0)
1710 colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB;
1714 PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
1721 png_colorspacerp
colorspace,
const png_xy *xy,
int preferred)
1731 switch (png_colorspace_check_xy(&XYZ, xy))
1742 png_benign_error(
png_ptr,
"invalid chromaticities");
1750 png_error(
png_ptr,
"internal error checking chromaticities");
1758 png_colorspacerp
colorspace,
const png_XYZ *XYZ_in,
int preferred)
1760 png_XYZ XYZ = *XYZ_in;
1763 switch (png_colorspace_check_XYZ(&xy, &XYZ))
1772 png_benign_error(
png_ptr,
"invalid end points");
1777 png_error(
png_ptr,
"internal error checking chromaticities");
1783#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED)
1789 if (
byte >= 32 &&
byte <= 126)
1799 name[1] = png_icc_tag_char(
tag >> 24);
1800 name[2] = png_icc_tag_char(
tag >> 16);
1801 name[3] = png_icc_tag_char(
tag >> 8);
1802 name[4] = png_icc_tag_char(
tag );
1809 return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) ||
1810 (it >= 97 && it <= 122);
1816 return is_ICC_signature_char(it >> 24) &&
1817 is_ICC_signature_char((it >> 16) & 0xff) &&
1818 is_ICC_signature_char((it >> 8) & 0xff) &&
1819 is_ICC_signature_char(it & 0xff);
1835 if (is_ICC_signature(
value) != 0)
1843# ifdef PNG_WARNINGS_SUPPORTED
1846 char number[PNG_NUMBER_BUFFER_SIZE];
1850 PNG_NUMBER_FORMAT_x,
value));
1870#ifdef PNG_sRGB_SUPPORTED
1887 static const png_XYZ sRGB_XYZ =
1891 35758, 71517, 11919,
1896 if ((
colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
1912 if ((
colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
1917 if ((
colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
1919 png_benign_error(
png_ptr,
"duplicate sRGB information ignored");
1926 if ((
colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
1927 !png_colorspace_endpoints_match(&sRGB_xy, &
colorspace->end_points_xy,
1929 png_chunk_report(
png_ptr,
"cHRM chunk does not match sRGB",
1939 colorspace->rendering_intent = (png_uint_16)intent;
1940 colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT;
1946 (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
1950 colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA;
1954 (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB);
1960#ifdef PNG_iCCP_SUPPORTED
1966static const png_byte D50_nCIEXYZ[12] =
1967 { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
1973 if (profile_length < 132)
1979#ifdef PNG_READ_iCCP_SUPPORTED
1993# ifdef PNG_SET_USER_LIMITS_SUPPORTED
1994 else if (
png_ptr->user_chunk_malloc_max > 0 &&
1995 png_ptr->user_chunk_malloc_max < profile_length)
1997 "exceeds application limits");
1998# elif PNG_USER_CHUNK_MALLOC_MAX > 0
2001 "exceeds libpng limits");
2006 "exceeds system limits");
2026 if (
temp != profile_length)
2028 "length does not match profile");
2031 if (
temp > 3 && (profile_length & 3))
2036 if (
temp > 357913930 ||
2037 profile_length < 132+12*
temp)
2039 "tag count too large");
2047 "invalid rendering intent");
2054 "intent outside defined range");
2069 if (
temp != 0x61637370)
2071 "invalid signature");
2082 "PCS illuminant is not D50");
2110 "RGB color space not permitted on grayscale PNG");
2116 "Gray color space not permitted on RGB PNG");
2121 "invalid ICC profile color space");
2146 "invalid embedded Abstract ICC profile");
2156 "unexpected DeviceLink ICC profile class");
2164 "unexpected NamedColor ICC profile class");
2174 "unrecognized ICC profile class");
2190 "unexpected ICC PCS encoding");
2208 for (itag=0; itag < tag_count; ++itag,
tag += 12)
2224 if (tag_start > profile_length || tag_length > profile_length - tag_start)
2226 "ICC profile tag outside profile");
2228 if ((tag_start & 3) != 0)
2235 "ICC profile tag start not a multiple of 4");
2242#ifdef PNG_sRGB_SUPPORTED
2243#if PNG_sRGB_PROFILE_CHECKS >= 0
2253# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0)
2254# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\
2255 { adler, crc, length, md5, broke, intent },
2257} png_sRGB_checks[] =
2263 PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
2264 PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
2265 "2009/03/27 21:36:31", 3048,
"sRGB_IEC61966-2-1_black_scaled.icc")
2268 PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
2269 PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
2270 "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
2272 PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
2273 PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
2274 "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
2277 PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
2278 PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
2279 "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
2286 PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
2287 PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
2288 "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
2297 PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
2298 PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1,
2299 "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB
v2 perceptual")
2301 PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
2302 PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1,
2303 "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB
v2 media-relative")
2320#if PNG_sRGB_PROFILE_CHECKS > 1
2325#ifdef PNG_SET_OPTION_SUPPORTED
2332 for (
i=0;
i < (
sizeof png_sRGB_checks) / (
sizeof png_sRGB_checks[0]); ++
i)
2343# if PNG_sRGB_PROFILE_CHECKS == 0
2344 if (png_sRGB_checks[
i].have_md5 != 0)
2345 return 1+png_sRGB_checks[
i].is_broken;
2366 if (adler == png_sRGB_checks[
i].adler)
2372# if PNG_sRGB_PROFILE_CHECKS > 1
2381 if (crc == png_sRGB_checks[
i].crc)
2384 if (png_sRGB_checks[
i].is_broken != 0)
2391 png_chunk_report(
png_ptr,
"known incorrect sRGB profile",
2399 else if (png_sRGB_checks[
i].have_md5 == 0)
2402 "out-of-date sRGB profile with no signature",
2406 return 1+png_sRGB_checks[
i].is_broken;
2410# if PNG_sRGB_PROFILE_CHECKS > 0
2416 "Not recognizing known sRGB profile that has been edited",
2434 if (png_compare_ICC_profile_with_sRGB(
png_ptr,
profile, adler) != 0)
2446 if ((
colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
2455# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
2467#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
2472 if (
png_ptr->rgb_to_gray_coefficients_set == 0 &&
2473 (
png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
2484 r >= 0 && png_muldiv(&
r,
r, 32768,
total) &&
r >= 0 &&
r <= 32768 &&
2485 g >= 0 && png_muldiv(&
g,
g, 32768,
total) &&
g >= 0 &&
g <= 32768 &&
2486 b >= 0 && png_muldiv(&
b,
b, 32768,
total) &&
b >= 0 &&
b <= 32768 &&
2498 else if (
r+
g+
b < 32768)
2503 if (
g >=
r &&
g >=
b)
2505 else if (
r >=
g &&
r >=
b)
2514 "internal error handling cHRM coefficients");
2518 png_ptr->rgb_to_gray_red_coeff = (png_uint_16)
r;
2519 png_ptr->rgb_to_gray_green_coeff = (png_uint_16)
g;
2528 png_error(
png_ptr,
"internal error handling cHRM->XYZ");
2538png_gt(
size_t a,
size_t b)
2543# define png_gt(a,b) ((a) > (b))
2549 int color_type,
int interlace_type,
int compression_type,
2557 png_warning(
png_ptr,
"Image width is zero in IHDR");
2563 png_warning(
png_ptr,
"Invalid image width in IHDR");
2567 if (png_gt(((
width + 7) & (~7U)),
2585 png_warning(
png_ptr,
"Image width is too large for this architecture");
2589#ifdef PNG_SET_USER_LIMITS_SUPPORTED
2595 png_warning(
png_ptr,
"Image width exceeds user limit in IHDR");
2601 png_warning(
png_ptr,
"Image height is zero in IHDR");
2607 png_warning(
png_ptr,
"Invalid image height in IHDR");
2611#ifdef PNG_SET_USER_LIMITS_SUPPORTED
2617 png_warning(
png_ptr,
"Image height exceeds user limit in IHDR");
2622 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
2623 bit_depth != 8 && bit_depth != 16)
2625 png_warning(
png_ptr,
"Invalid bit depth in IHDR");
2629 if (color_type < 0 || color_type == 1 ||
2630 color_type == 5 || color_type > 6)
2632 png_warning(
png_ptr,
"Invalid color type in IHDR");
2641 png_warning(
png_ptr,
"Invalid color type/bit depth combination in IHDR");
2647 png_warning(
png_ptr,
"Unknown interlace method in IHDR");
2653 png_warning(
png_ptr,
"Unknown compression method in IHDR");
2657#ifdef PNG_MNG_FEATURES_SUPPORTED
2668 png_ptr->mng_features_permitted != 0)
2669 png_warning(
png_ptr,
"MNG features are not allowed in a PNG datastream");
2679 png_warning(
png_ptr,
"Unknown filter method in IHDR");
2685 png_warning(
png_ptr,
"Invalid filter method in IHDR");
2693 png_warning(
png_ptr,
"Unknown filter method in IHDR");
2699 png_error(
png_ptr,
"Invalid IHDR data");
2702#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)
2708#define png_fp_add(state, flags) ((state) |= (flags))
2709#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))
2715 int state = *statep;
2716 size_t i = *whereami;
2724 case 43:
type = PNG_FP_SAW_SIGN;
break;
2725 case 45:
type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE;
break;
2726 case 46:
type = PNG_FP_SAW_DOT;
break;
2727 case 48:
type = PNG_FP_SAW_DIGIT;
break;
2728 case 49:
case 50:
case 51:
case 52:
2729 case 53:
case 54:
case 55:
case 56:
2730 case 57:
type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO;
break;
2732 case 101:
type = PNG_FP_SAW_E;
break;
2733 default:
goto PNG_FP_End;
2740 switch ((
state & PNG_FP_STATE) + (
type & PNG_FP_SAW_ANY))
2742 case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
2743 if ((
state & PNG_FP_SAW_ANY) != 0)
2749 case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
2751 if ((
state & PNG_FP_SAW_DOT) != 0)
2754 else if ((
state & PNG_FP_SAW_DIGIT) != 0)
2758 png_fp_set(
state, PNG_FP_FRACTION |
type);
2762 case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
2763 if ((
state & PNG_FP_SAW_DOT) != 0)
2764 png_fp_set(
state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
2766 png_fp_add(
state,
type | PNG_FP_WAS_VALID);
2770 case PNG_FP_INTEGER + PNG_FP_SAW_E:
2771 if ((
state & PNG_FP_SAW_DIGIT) == 0)
2774 png_fp_set(
state, PNG_FP_EXPONENT);
2784 case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:
2785 png_fp_add(
state,
type | PNG_FP_WAS_VALID);
2788 case PNG_FP_FRACTION + PNG_FP_SAW_E:
2793 if ((
state & PNG_FP_SAW_DIGIT) == 0)
2796 png_fp_set(
state, PNG_FP_EXPONENT);
2800 case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
2801 if ((
state & PNG_FP_SAW_ANY) != 0)
2804 png_fp_add(
state, PNG_FP_SAW_SIGN);
2811 case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:
2812 png_fp_add(
state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);
2819 default:
goto PNG_FP_End;
2833 return (
state & PNG_FP_SAW_DIGIT) != 0;
2842 size_t char_index=0;
2844 if (png_check_fp_number(
string,
size, &
state, &char_index) != 0 &&
2845 (char_index ==
size ||
string[char_index] == 0))
2852#ifdef PNG_sCAL_SUPPORTED
2853# ifdef PNG_FLOATING_POINT_SUPPORTED
2878 if (
power & 1)
d *= mult;
2884 if (recip != 0)
d = 1/
d;
2894#if GCC_STRICT_OVERFLOW
2895#pragma GCC diagnostic push
2900#pragma GCC diagnostic warning "-Wstrict-overflow=2"
2944 exp_b10 = (exp_b10 * 77) >> 8;
2947 base = png_pow10(exp_b10);
2952 double test = png_pow10(exp_b10+1);
2973 fp /= 10; ++exp_b10;
2983 unsigned int czero, clead, cdigits;
2989 if (exp_b10 < 0 && exp_b10 > -3)
3026 if (cdigits == 0) --clead;
3030 while (cdigits > 0 &&
d > 9)
3034 if (exp_b10 != (-1))
3039 ch = *--ascii; ++
size;
3057 if (exp_b10 == (-1))
3067 ++
size; exp_b10 = 1;
3088 if (cdigits == 0) ++clead;
3093 cdigits += czero - clead;
3102 if (exp_b10 != (-1))
3106 *ascii++ = 46; --
size;
3111 *ascii++ = 48; --czero;
3114 if (exp_b10 != (-1))
3118 *ascii++ = 46; --
size;
3123 *ascii++ = (
char)(48 + (
int)
d); ++cdigits;
3126 while (cdigits+czero < precision+clead && fp >
DBL_MIN);
3137 if (exp_b10 >= (-1) && exp_b10 <= 2)
3146 while (exp_b10-- > 0) *ascii++ = 48;
3164 *ascii++ = 69; --
size;
3171 unsigned int uexp_b10;
3175 *ascii++ = 45; --
size;
3176 uexp_b10 = 0
U-exp_b10;
3180 uexp_b10 = 0
U+exp_b10;
3184 while (uexp_b10 > 0)
3196 while (cdigits > 0) *ascii++ =
exponent[--cdigits];
3221 png_error(
png_ptr,
"ASCII conversion buffer too small");
3223#if GCC_STRICT_OVERFLOW
3224#pragma GCC diagnostic pop
3229# ifdef PNG_FIXED_POINT_SUPPORTED
3251 if (
num <= 0x80000000)
3259 unsigned int tmp =
num/10;
3303 png_error(
png_ptr,
"ASCII conversion buffer too small");
3308#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
3309 !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
3310 (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
3311 defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
3312 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
3313 (defined(PNG_sCAL_SUPPORTED) && \
3314 defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))
3318 double r =
floor(100000 * fp + .5);
3320 if (
r > 2147483647. ||
r < -2147483648.)
3323# ifndef PNG_ERROR_TEXT_SUPPORTED
3331#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
3332 defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
3339#if GCC_STRICT_OVERFLOW
3345#pragma GCC diagnostic push
3346#pragma GCC diagnostic warning "-Wstrict-overflow=2"
3355 if (
a == 0 ||
times == 0)
3362#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3369 if (r <= 2147483647. && r >= -2147483648.)
3380 negative = 1,
A = -
a;
3385 negative = !negative,
T = -
times;
3390 negative = !negative,
D = -
divisor;
3397 s16 = (
A >> 16) * (
T & 0xffff) +
3398 (
A & 0xffff) * (
T >> 16);
3402 s32 = (
A >> 16) * (
T >> 16) + (
s16 >> 16);
3403 s00 = (
A & 0xffff) * (
T & 0xffff);
3405 s16 = (
s16 & 0xffff) << 16;
3420 while (--bitshift >= 0)
3425 d32 =
D >> (32-bitshift), d00 =
D << bitshift;
3432 if (s00 < d00) --
s32;
3433 s32 -= d32, s00 -= d00,
result += 1<<bitshift;
3437 if (
s32 == d32 && s00 >= d00)
3438 s32 = 0, s00 -= d00,
result += 1<<bitshift;
3442 if (s00 >= (
D >> 1))
3449 if ((negative != 0 &&
result <= 0) ||
3450 (negative == 0 &&
result >= 0))
3462#if GCC_STRICT_OVERFLOW
3463#pragma GCC diagnostic pop
3467#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
3480 png_warning(
png_ptr,
"fixed point overflow ignored");
3485#ifdef PNG_GAMMA_SUPPORTED
3490#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3493 if (r <= 2147483647. && r >= -2147483648.)
3498 if (png_muldiv(&
res, 100000, 100000,
a) != 0)
3516#ifdef PNG_READ_GAMMA_SUPPORTED
3517#ifdef PNG_16BIT_SUPPORTED
3523#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3524 double r =
a * 1
E-5;
3528 if (r <= 2147483647. && r >= -2147483648.)
3533 if (png_muldiv(&
res,
a,
b, 100000) != 0)
3546#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3547 if (
a != 0 &&
b != 0)
3553 if (r <= 2147483647. && r >= -2147483648.)
3565 return png_reciprocal(
res);
3572#ifdef PNG_READ_GAMMA_SUPPORTED
3573#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED
3594 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,
3595 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,
3596 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,
3597 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U,
3598 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U,
3599 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U,
3600 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U,
3601 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U,
3602 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U,
3603 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U,
3604 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U,
3605 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U,
3606 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U,
3607 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U,
3608 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U,
3609 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U,
3610 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U,
3611 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U,
3612 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U,
3613 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,
3614 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,
3623 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054,
3624 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803,
3625 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068,
3626 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782,
3627 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887,
3628 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339,
3629 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098,
3630 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132,
3631 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415,
3632 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523,
3633 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495,
3639png_log8bit(
unsigned int x)
3641 unsigned int lg2 = 0;
3648 if ((
x &= 0xff) == 0)
3651 if ((
x & 0xf0) == 0)
3654 if ((
x & 0xc0) == 0)
3657 if ((
x & 0x80) == 0)
3661 return (png_int_32)((lg2 << 16) + ((png_8bit_l2[
x-128]+32768)>>16));
3694#ifdef PNG_16BIT_SUPPORTED
3698 unsigned int lg2 = 0;
3701 if ((
x &= 0xffff) == 0)
3704 if ((
x & 0xff00) == 0)
3707 if ((
x & 0xf000) == 0)
3710 if ((
x & 0xc000) == 0)
3713 if ((
x & 0x8000) == 0)
3720 lg2 += (png_8bit_l2[(
x>>8)-128]+8) >> 4;
3725 x = ((
x << 16) + (
x >> 9)) / (
x >> 8);
3737 lg2 += ((23591U * (65536U-
x)) + (1U << (16+6-12-1))) >> (16+6-12);
3740 lg2 -= ((23499U * (
x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);
3743 return (png_int_32)((lg2 + 2048) >> 12);
3765 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,
3766 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,
3767 2553802834U, 2445529972U, 2341847524U, 2242560872U
3772for (
i=11;
i>=0;--
i){
print i,
" ", (1 -
e(-(2^
i)/65536*
l(2))) * 2^(32-
i),
"\n"}
3773 11 44937.64284865548751208448
3774 10 45180.98734845585101160448
3775 9 45303.31936980687359311872
3776 8 45364.65110595323018870784
3777 7 45395.35850361789624614912
3778 6 45410.72259715102037508096
3779 5 45418.40724413220722311168
3780 4 45422.25021786898173001728
3781 3 45424.17186732298419044352
3782 2 45425.13273269940811464704
3783 1 45425.61317555035558641664
3784 0 45425.85339951654943850496
3790 if (
x > 0 &&
x <= 0xfffff)
3802 e -= (((
e >> 16) * 44938U) + 16U) >> 5;
3805 e -= (((
e >> 16) * 45181U) + 32U) >> 6;
3808 e -= (((
e >> 16) * 45303U) + 64U) >> 7;
3811 e -= (((
e >> 16) * 45365U) + 128U) >> 8;
3814 e -= (((
e >> 16) * 45395U) + 256U) >> 9;
3817 e -= (((
e >> 16) * 45410U) + 512U) >> 10;
3820 e -= (((
e >> 16) * 355U * (
x & 0x3fU)) + 256U) >> 9;
3829 return png_32bit_exp[0];
3846 return (png_byte)(((
x + 0x7fffffU) >> 24) & 0xff);
3849#ifdef PNG_16BIT_SUPPORTED
3858 return (png_uint_16)((
x + 32767U) >> 16);
3868# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3896 png_int_32 lg2 = png_log8bit(
value);
3899 if (png_muldiv(&
res, gamma_val, lg2,
PNG_FP_1) != 0)
3900 return png_exp8bit(
res);
3907 return (png_byte)(
value & 0xff);
3910#ifdef PNG_16BIT_SUPPORTED
3916# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3923 gamma_val*.00001)+.5);
3924 return (png_uint_16)
r;
3926 png_int_32 lg2 = png_log16bit(
value);
3929 if (png_muldiv(&
res, gamma_val, lg2,
PNG_FP_1) != 0)
3930 return png_exp16bit(
res);
3937 return (png_uint_16)
value;
3951 return png_gamma_8bit_correct(
value, gamma_val);
3953#ifdef PNG_16BIT_SUPPORTED
3955 return png_gamma_16bit_correct(
value, gamma_val);
3962#ifdef PNG_16BIT_SUPPORTED
3976 unsigned int num = 1U << (8U -
shift);
3977#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
3981 double fmax = 1.0 / (((png_int_32)1 << (16U -
shift)) - 1);
3983 unsigned int max = (1U << (16U -
shift)) - 1U;
3984 unsigned int max_by_2 = 1U << (15U -
shift);
3990 for (
i = 0;
i <
num;
i++)
3998 if (png_gamma_significant(gamma_val) != 0)
4009 for (
j = 0;
j < 256;
j++)
4012# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
4018 sub_table[
j] = (png_uint_16)
d;
4021 ig = (ig * 65535U + max_by_2)/
max;
4023 sub_table[
j] = png_gamma_16bit_correct(ig, gamma_val);
4032 for (
j = 0;
j < 256;
j++)
4037 ig = (ig * 65535U + max_by_2)/
max;
4039 sub_table[
j] = (png_uint_16)ig;
4052 unsigned int num = 1U << (8U -
shift);
4053 unsigned int max = (1U << (16U -
shift))-1U;
4064 for (
i = 0;
i <
num;
i++)
4066 256 * (
sizeof (png_uint_16)));
4085 for (
i = 0;
i < 255; ++
i)
4088 png_uint_16
out = (png_uint_16)(
i * 257U);
4091 png_uint_32 bound = png_gamma_16bit_correct(
out+128U, gamma_val);
4094 bound = (bound *
max + 32768U)/65535U + 1U;
4096 while (
last < bound)
4123 if (png_gamma_significant(gamma_val) != 0)
4124 for (
i=0;
i<256;
i++)
4125 table[
i] = png_gamma_8bit_correct(
i, gamma_val);
4128 for (
i=0;
i<256; ++
i)
4129 table[
i] = (png_byte)(
i & 0xff);
4141#ifdef PNG_16BIT_SUPPORTED
4145 int istop = (1 << (8 -
png_ptr->gamma_shift));
4146 for (
i = 0;
i < istop;
i++)
4155#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
4156 defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
4157 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
4163#ifdef PNG_16BIT_SUPPORTED
4167 int istop = (1 << (8 -
png_ptr->gamma_shift));
4168 for (
i = 0;
i < istop;
i++)
4178 int istop = (1 << (8 -
png_ptr->gamma_shift));
4179 for (
i = 0;
i < istop;
i++)
4198 png_debug(1,
"in png_build_gamma_table");
4208 png_warning(
png_ptr,
"gamma table being rebuilt");
4209 png_destroy_gamma_table(
png_ptr);
4216 png_reciprocal2(
png_ptr->colorspace.gamma,
4219#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
4220 defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
4221 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
4225 png_reciprocal(
png_ptr->colorspace.gamma));
4229 png_reciprocal(
png_ptr->screen_gamma) :
4234#ifdef PNG_16BIT_SUPPORTED
4237 png_byte
shift, sig_bit;
4241 sig_bit =
png_ptr->sig_bit.red;
4243 if (
png_ptr->sig_bit.green > sig_bit)
4244 sig_bit =
png_ptr->sig_bit.green;
4246 if (
png_ptr->sig_bit.blue > sig_bit)
4247 sig_bit =
png_ptr->sig_bit.blue;
4250 sig_bit =
png_ptr->sig_bit.gray;
4270 if (sig_bit > 0 && sig_bit < 16U)
4272 shift = (png_byte)((16U - sig_bit) & 0xff);
4299 png_ptr->screen_gamma > 0 ? png_product2(
png_ptr->colorspace.gamma,
4304 png_ptr->screen_gamma > 0 ? png_reciprocal2(
png_ptr->colorspace.gamma,
4307#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
4308 defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
4309 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
4313 png_reciprocal(
png_ptr->colorspace.gamma));
4320 png_ptr->screen_gamma > 0 ? png_reciprocal(
png_ptr->screen_gamma) :
4330#ifdef PNG_SET_OPTION_SUPPORTED
4351#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
4352 defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
4371#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
4373const png_uint_16 png_sRGB_table[256] =
4375 0,20,40,60,80,99,119,139,
4376 159,179,199,219,241,264,288,313,
4377 340,367,396,427,458,491,526,562,
4378 599,637,677,718,761,805,851,898,
4379 947,997,1048,1101,1156,1212,1270,1330,
4380 1391,1453,1517,1583,1651,1720,1790,1863,
4381 1937,2013,2090,2170,2250,2333,2418,2504,
4382 2592,2681,2773,2866,2961,3058,3157,3258,
4383 3360,3464,3570,3678,3788,3900,4014,4129,
4384 4247,4366,4488,4611,4736,4864,4993,5124,
4385 5257,5392,5530,5669,5810,5953,6099,6246,
4386 6395,6547,6700,6856,7014,7174,7335,7500,
4387 7666,7834,8004,8177,8352,8528,8708,8889,
4388 9072,9258,9445,9635,9828,10022,10219,10417,
4389 10619,10822,11028,11235,11446,11658,11873,12090,
4390 12309,12530,12754,12980,13209,13440,13673,13909,
4391 14146,14387,14629,14874,15122,15371,15623,15878,
4392 16135,16394,16656,16920,17187,17456,17727,18001,
4393 18277,18556,18837,19121,19407,19696,19987,20281,
4394 20577,20876,21177,21481,21787,22096,22407,22721,
4395 23038,23357,23678,24002,24329,24658,24990,25325,
4396 25662,26001,26344,26688,27036,27386,27739,28094,
4397 28452,28813,29176,29542,29911,30282,30656,31033,
4398 31412,31794,32179,32567,32957,33350,33745,34143,
4399 34544,34948,35355,35764,36176,36591,37008,37429,
4400 37852,38278,38706,39138,39572,40009,40449,40891,
4401 41337,41785,42236,42690,43147,43606,44069,44534,
4402 45002,45473,45947,46423,46903,47385,47871,48359,
4403 48850,49344,49841,50341,50844,51349,51858,52369,
4404 52884,53401,53921,54445,54971,55500,56032,56567,
4405 57105,57646,58190,58737,59287,59840,60396,60955,
4406 61517,62082,62650,63221,63795,64372,64952,65535
4413const png_uint_16 png_sRGB_base[512] =
4415 128,1782,3383,4644,5675,6564,7357,8074,
4416 8732,9346,9921,10463,10977,11466,11935,12384,
4417 12816,13233,13634,14024,14402,14769,15125,15473,
4418 15812,16142,16466,16781,17090,17393,17690,17981,
4419 18266,18546,18822,19093,19359,19621,19879,20133,
4420 20383,20630,20873,21113,21349,21583,21813,22041,
4421 22265,22487,22707,22923,23138,23350,23559,23767,
4422 23972,24175,24376,24575,24772,24967,25160,25352,
4423 25542,25730,25916,26101,26284,26465,26645,26823,
4424 27000,27176,27350,27523,27695,27865,28034,28201,
4425 28368,28533,28697,28860,29021,29182,29341,29500,
4426 29657,29813,29969,30123,30276,30429,30580,30730,
4427 30880,31028,31176,31323,31469,31614,31758,31902,
4428 32045,32186,32327,32468,32607,32746,32884,33021,
4429 33158,33294,33429,33564,33697,33831,33963,34095,
4430 34226,34357,34486,34616,34744,34873,35000,35127,
4431 35253,35379,35504,35629,35753,35876,35999,36122,
4432 36244,36365,36486,36606,36726,36845,36964,37083,
4433 37201,37318,37435,37551,37668,37783,37898,38013,
4434 38127,38241,38354,38467,38580,38692,38803,38915,
4435 39026,39136,39246,39356,39465,39574,39682,39790,
4436 39898,40005,40112,40219,40325,40431,40537,40642,
4437 40747,40851,40955,41059,41163,41266,41369,41471,
4438 41573,41675,41777,41878,41979,42079,42179,42279,
4439 42379,42478,42577,42676,42775,42873,42971,43068,
4440 43165,43262,43359,43456,43552,43648,43743,43839,
4441 43934,44028,44123,44217,44311,44405,44499,44592,
4442 44685,44778,44870,44962,45054,45146,45238,45329,
4443 45420,45511,45601,45692,45782,45872,45961,46051,
4444 46140,46229,46318,46406,46494,46583,46670,46758,
4445 46846,46933,47020,47107,47193,47280,47366,47452,
4446 47538,47623,47709,47794,47879,47964,48048,48133,
4447 48217,48301,48385,48468,48552,48635,48718,48801,
4448 48884,48966,49048,49131,49213,49294,49376,49458,
4449 49539,49620,49701,49782,49862,49943,50023,50103,
4450 50183,50263,50342,50422,50501,50580,50659,50738,
4451 50816,50895,50973,51051,51129,51207,51285,51362,
4452 51439,51517,51594,51671,51747,51824,51900,51977,
4453 52053,52129,52205,52280,52356,52432,52507,52582,
4454 52657,52732,52807,52881,52956,53030,53104,53178,
4455 53252,53326,53400,53473,53546,53620,53693,53766,
4456 53839,53911,53984,54056,54129,54201,54273,54345,
4457 54417,54489,54560,54632,54703,54774,54845,54916,
4458 54987,55058,55129,55199,55269,55340,55410,55480,
4459 55550,55620,55689,55759,55828,55898,55967,56036,
4460 56105,56174,56243,56311,56380,56448,56517,56585,
4461 56653,56721,56789,56857,56924,56992,57059,57127,
4462 57194,57261,57328,57395,57462,57529,57595,57662,
4463 57728,57795,57861,57927,57993,58059,58125,58191,
4464 58256,58322,58387,58453,58518,58583,58648,58713,
4465 58778,58843,58908,58972,59037,59101,59165,59230,
4466 59294,59358,59422,59486,59549,59613,59677,59740,
4467 59804,59867,59930,59993,60056,60119,60182,60245,
4468 60308,60370,60433,60495,60558,60620,60682,60744,
4469 60806,60868,60930,60992,61054,61115,61177,61238,
4470 61300,61361,61422,61483,61544,61605,61666,61727,
4471 61788,61848,61909,61969,62030,62090,62150,62211,
4472 62271,62331,62391,62450,62510,62570,62630,62689,
4473 62749,62808,62867,62927,62986,63045,63104,63163,
4474 63222,63281,63340,63398,63457,63515,63574,63632,
4475 63691,63749,63807,63865,63923,63981,64039,64097,
4476 64155,64212,64270,64328,64385,64443,64500,64557,
4477 64614,64672,64729,64786,64843,64900,64956,65013,
4478 65070,65126,65183,65239,65296,65352,65409,65465
4481const png_byte png_sRGB_delta[512] =
4483 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54,
4484 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36,
4485 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28,
4486 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24,
4487 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21,
4488 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,
4489 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,
4490 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,
4491 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,
4492 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,
4493 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,
4494 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,
4495 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
4496 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,
4497 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
4498 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
4499 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
4500 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
4501 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
4502 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
4503 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
4504 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
4505 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
4506 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
4507 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
4508 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
4509 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
4510 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
4511 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,
4512 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
4513 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
4514 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
4519#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
4520 defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
4522png_image_free_function(
png_voidp argument)
4535# ifdef PNG_STDIO_SUPPORTED
4536 if (
cp->owned_file != 0)
4544 cp->png_ptr->io_ptr =
NULL;
4557 png_free(
c.png_ptr,
cp);
4560 if (
c.for_write != 0)
4562# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
4563 png_destroy_write_struct(&
c.png_ptr, &
c.info_ptr);
4565 png_error(
c.png_ptr,
"simplified write not supported");
4570# ifdef PNG_SIMPLIFIED_READ_SUPPORTED
4571 png_destroy_read_struct(&
c.png_ptr, &
c.info_ptr,
NULL);
4573 png_error(
c.png_ptr,
"simplified read not supported");
4591 png_image_free_function(
image);
4602 png_image_free(
image);
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
static const char * onoff(int bool)
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
#define APPEND(From, Length)
EXPORT int errmsg(char *msg, va_alist)
void error_message(HWND hwnd, const char *msg)
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
#define crc32(crc, buf, len)
static int inflateReset(z_streamp strm)
static uLong adler32(uLong adler, const Bytef *buf, uInt len)
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
double pow(double x, double y)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum type
GLint GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum GLint GLint * precision
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat v2
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_ _CRTIMP double __cdecl frexp(_In_ double x, _Out_ int *y)
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static const int digits[]
struct task_struct * current
static const struct encodedFiletime times[]
static unsigned int number
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
static size_t double int ndigits
__forceinline bool __cdecl add(big_integer &x, uint32_t const value)
png_voidp PNGAPI png_get_io_ptr(png_const_structrp png_ptr)
png_const_charp PNGAPI png_get_copyright(png_const_structrp png_ptr)
png_libpng_version_1_6_39 Your_png_h_is_not_version_1_6_39
png_const_charp PNGAPI png_get_header_ver(png_const_structrp png_ptr)
png_const_charp PNGAPI png_get_libpng_ver(png_const_structrp png_ptr)
png_const_charp PNGAPI png_get_header_version(png_const_structrp png_ptr)
png_uint_32 PNGAPI png_access_version_number(void)
#define PNG_OPTION_INVALID
#define PNG_INTRAPIXEL_DIFFERENCING
struct png_control * png_controlp
char * png_libpng_version_1_6_39
#define PNG_FLAG_MNG_FILTER_64
png_const_structrp png_const_inforp double double double double * green_X
#define PNG_sRGB_INTENT_LAST
#define PNG_COLOR_MASK_COLOR
#define PNG_HEADER_VERSION_STRING
#define PNG_DESTROY_WILL_FREE_DATA
png_const_structrp png_const_inforp double double double double double double double * blue_X
#define PNG_FILTER_TYPE_BASE
#define png_get_uint_32(buf)
#define PNG_USER_WILL_FREE_DATA
#define PNG_INTERLACE_LAST
const png_struct *PNG_RESTRICT png_const_structrp
#define PNG_LIBPNG_VER_STRING
png_info *PNG_RESTRICT png_inforp
#define PNG_SKIP_sRGB_CHECK_PROFILE
#define PNG_COMPRESSION_TYPE_BASE
#define PNG_HANDLE_CHUNK_AS_DEFAULT
png_struct *PNG_RESTRICT png_structrp
png_const_structrp png_const_inforp info_ptr
#define PNG_FUNCTION(type, name, args, attributes)
png_int_32 png_fixed_point
const png_byte * png_const_bytep
png_uint_16 * png_uint_16p
png_fixed_point * png_fixed_point_p
const char * png_const_charp
png_uint_16 ** png_uint_16pp
#define PNG_STRING_NEWLINE
#define PNG_USER_HEIGHT_MAX
#define PNG_USER_CHUNK_MALLOC_MAX
#define PNG_USER_CHUNK_CACHE_MAX
#define PNG_USER_WIDTH_MAX
#define PNG_GAMMA_THRESHOLD_FIXED
#define PNG_SCALE_16_TO_8
#define PNG_OUT_OF_RANGE(value, ideal, delta)
#define PNG_UNEXPECTED_ZLIB_RETURN
#define PNG_UNUSED(param)
#define PNG_HAVE_PNG_SIGNATURE
#define PNG_CHUNK_WRITE_ERROR
#define png_fixed_error(s1, s2)
#define PNG_FLAG_CRC_ANCILLARY_USE
#define PNG_FLAG_CRC_ANCILLARY_NOWARN
#define PNG_FLAG_LIBRARY_MISMATCH
#define PNG_FLAG_CRC_ANCILLARY_MASK
#define PNG_CSTRING_FROM_CHUNK(s, c)
#define PNG_FLAG_CRC_CRITICAL_IGNORE
#define PNG_IS_READ_STRUCT
#define PNG_GAMMA_sRGB_INVERSE
#define PNG_CHUNK_ANCILLARY(c)
#define png_voidcast(type, value)
#define PNG_CHUNK_WARNING
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out