19 #ifdef PNG_READ_SUPPORTED 21 #define png_strtod(p,a,b) strtod(a,b) 29 png_error(png_ptr,
"PNG unsigned integer out of range");
34 #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) 40 #define PNG_FIXED_ERROR (-1) 52 png_warning(png_ptr,
"PNG fixed point integer out of range");
58 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED 90 if ((uval & 0x80000000L) == 0)
93 uval = (uval ^ 0xffffffffL) + 1;
107 ((
unsigned int)(*buf) << 8) +
108 ((
unsigned int)(*(buf + 1)));
122 if (png_ptr->sig_bytes >= 8)
125 num_checked = png_ptr->sig_bytes;
126 num_to_check = 8 - num_checked;
128 #ifdef PNG_IO_STATE_SUPPORTED 133 png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
134 png_ptr->sig_bytes = 8;
136 if (
png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
138 if (num_checked < 4 &&
139 png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
140 png_error(png_ptr,
"Not a PNG file");
142 png_error(png_ptr,
"PNG file corrupted by ASCII conversion");
157 #ifdef PNG_IO_STATE_SUPPORTED 170 png_debug2(0,
"Reading %s chunk, length = %u",
171 png_ptr->chunk_name, length);
180 #ifdef PNG_IO_STATE_SUPPORTED 209 for (i = (
png_size_t)skip; i > istop; i -= istop)
211 png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
221 if (((png_ptr->chunk_name[0] & 0x20) &&
223 (!(png_ptr->chunk_name[0] & 0x20) &&
251 if (png_ptr->chunk_name[0] & 0x20)
264 #ifdef PNG_IO_STATE_SUPPORTED 274 return ((
int)(crc != png_ptr->crc));
281 #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ 282 defined(PNG_READ_iCCP_SUPPORTED) 298 png_ptr->zstream.next_in =
data;
300 png_ptr->zstream.avail_in = 0;
313 if (png_ptr->zstream.avail_in == 0 && size > 0)
318 png_ptr->zstream.avail_in = (
uInt)size;
332 png_ptr->zstream.next_out = png_ptr->zbuf;
333 png_ptr->zstream.avail_out = png_ptr->zbuf_size;
336 avail = png_ptr->zbuf_size - png_ptr->zstream.avail_out;
345 if (output != 0 && output_size > count)
352 png_memcpy(output + count, png_ptr->zbuf, copy);
363 png_ptr->zstream.avail_in = 0;
375 #ifdef PNG_CONSOLE_IO_SUPPORTED 378 if (png_ptr->zstream.msg != 0)
379 msg = png_ptr->zstream.msg;
383 #ifdef PNG_CONSOLE_IO_SUPPORTED 387 msg =
"Buffer error in compressed datastream in %s chunk";
391 msg =
"Data error in compressed datastream in %s chunk";
395 msg =
"Incomplete compressed datastream in %s chunk";
399 png_snprintf(umsg,
sizeof umsg, msg, png_ptr->chunk_name);
402 msg =
"Damaged compressed datastream in chunk other than IDAT";
429 if (prefix_size > chunklength)
438 png_size_t expanded_size = png_inflate(png_ptr,
439 (
png_bytep)(png_ptr->chunkdata + prefix_size),
440 chunklength - prefix_size,
447 #ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED 448 if (png_ptr->user_chunk_malloc_max &&
449 (prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1))
451 # ifdef PNG_USER_CHUNK_MALLOC_MAX 456 png_warning(png_ptr,
"Exceeded size limit while expanding chunk");
463 #if defined(PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED) || \ 464 defined(PNG_USER_CHUNK_MALLOC_MAX) 465 else if (expanded_size > 0)
467 if (expanded_size > 0)
472 png_charp text = png_malloc_warn(png_ptr,
473 prefix_size + expanded_size + 1);
477 png_memcpy(text, png_ptr->chunkdata, prefix_size);
478 new_size = png_inflate(png_ptr,
479 (
png_bytep)(png_ptr->chunkdata + prefix_size),
480 chunklength - prefix_size,
481 (
png_bytep)(text + prefix_size), expanded_size);
482 text[prefix_size + expanded_size] = 0;
484 if (new_size == expanded_size)
486 png_free(png_ptr, png_ptr->chunkdata);
487 png_ptr->chunkdata = text;
488 *newlength = prefix_size + expanded_size;
497 png_warning(png_ptr,
"Not enough memory to decompress chunk");
503 #ifdef PNG_STDIO_SUPPORTED 507 "Unknown zTXt compression type %d", comp_type);
510 png_warning(png_ptr,
"Unknown zTXt compression type");
521 png_charp text = png_malloc_warn(png_ptr, prefix_size + 1);
526 png_memcpy(text, png_ptr->chunkdata, prefix_size);
528 png_free(png_ptr, png_ptr->chunkdata);
529 png_ptr->chunkdata = text;
532 *(png_ptr->chunkdata + prefix_size) = 0x00;
537 *newlength = prefix_size;
547 int bit_depth, color_type, compression_type, filter_type;
553 png_error(png_ptr,
"Out of place IHDR");
557 png_error(png_ptr,
"Invalid IHDR chunk");
568 compression_type = buf[10];
569 filter_type = buf[11];
570 interlace_type = buf[12];
573 png_ptr->width = width;
574 png_ptr->height = height;
575 png_ptr->bit_depth = (
png_byte)bit_depth;
576 png_ptr->interlaced = (
png_byte)interlace_type;
577 png_ptr->color_type = (
png_byte)color_type;
578 #ifdef PNG_MNG_FEATURES_SUPPORTED 579 png_ptr->filter_type = (
png_byte)filter_type;
581 png_ptr->compression_type = (
png_byte)compression_type;
584 switch (png_ptr->color_type)
589 png_ptr->channels = 1;
593 png_ptr->channels = 3;
597 png_ptr->channels = 2;
601 png_ptr->channels = 4;
606 png_ptr->pixel_depth = (
png_byte)(png_ptr->bit_depth *
608 png_ptr->rowbytes =
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
609 png_debug1(3,
"bit_depth = %d", png_ptr->bit_depth);
610 png_debug1(3,
"channels = %d", png_ptr->channels);
611 png_debug1(3,
"rowbytes = %lu", (
unsigned long)png_ptr->rowbytes);
612 png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
613 color_type, interlace_type, compression_type, filter_type);
622 #ifdef PNG_POINTER_INDEXING_SUPPORTED 629 png_error(png_ptr,
"Missing IHDR before PLTE");
639 png_error(png_ptr,
"Duplicate PLTE chunk");
646 "Ignoring PLTE chunk in grayscale PNG");
651 #ifndef PNG_READ_OPT_PLTE_SUPPORTED 670 png_error(png_ptr,
"Invalid palette chunk");
674 num = (int)length / 3;
676 #ifdef PNG_POINTER_INDEXING_SUPPORTED 677 for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
682 pal_ptr->red = buf[0];
683 pal_ptr->green = buf[1];
684 pal_ptr->blue = buf[2];
687 for (i = 0; i < num; i++)
693 palette[i].
red = buf[0];
694 palette[i].
green = buf[1];
695 palette[i].
blue = buf[2];
704 #ifndef PNG_READ_OPT_PLTE_SUPPORTED 711 #ifndef PNG_READ_OPT_PLTE_SUPPORTED 743 #ifdef PNG_READ_tRNS_SUPPORTED 750 png_warning(png_ptr,
"Truncating incorrect tRNS chunk length");
756 png_warning(png_ptr,
"Truncating incorrect info tRNS chunk length");
772 png_error(png_ptr,
"No image in file");
779 png_warning(png_ptr,
"Incorrect IEND chunk length");
787 #ifdef PNG_READ_gAMA_SUPPORTED 797 png_error(png_ptr,
"Missing IHDR before gAMA");
823 png_warning(png_ptr,
"Incorrect gAMA chunk length");
833 igamma = png_get_fixed_point(NULL, buf);
839 "Ignoring gAMA chunk with out of range gamma");
844 # ifdef PNG_READ_sRGB_SUPPORTED 850 "Ignoring incorrect gAMA value when sRGB is also present");
852 # ifdef PNG_CONSOLE_IO_SUPPORTED 853 fprintf(stderr,
"gamma = (%d/100000)", (
int)igamma);
860 # ifdef PNG_READ_GAMMA_SUPPORTED 862 png_ptr->gamma = igamma;
869 #ifdef PNG_READ_sBIT_SUPPORTED 878 buf[0] = buf[1] = buf[2] = buf[3] = 0;
881 png_error(png_ptr,
"Missing IHDR before sBIT");
909 if (length != truelen || length > 4)
911 png_warning(png_ptr,
"Incorrect sBIT chunk length");
923 png_ptr->sig_bit.red = buf[0];
924 png_ptr->sig_bit.green = buf[1];
925 png_ptr->sig_bit.blue = buf[2];
926 png_ptr->sig_bit.alpha = buf[3];
931 png_ptr->sig_bit.gray = buf[0];
932 png_ptr->sig_bit.red = buf[0];
933 png_ptr->sig_bit.green = buf[0];
934 png_ptr->sig_bit.blue = buf[0];
935 png_ptr->sig_bit.alpha = buf[1];
942 #ifdef PNG_READ_cHRM_SUPPORTED 947 png_fixed_point x_white, y_white, x_red, y_red, x_green, y_green, x_blue,
953 png_error(png_ptr,
"Missing IHDR before cHRM");
979 png_warning(png_ptr,
"Incorrect cHRM chunk length");
989 x_white = png_get_fixed_point(NULL, buf);
990 y_white = png_get_fixed_point(NULL, buf + 4);
991 x_red = png_get_fixed_point(NULL, buf + 8);
992 y_red = png_get_fixed_point(NULL, buf + 12);
993 x_green = png_get_fixed_point(NULL, buf + 16);
994 y_green = png_get_fixed_point(NULL, buf + 20);
995 x_blue = png_get_fixed_point(NULL, buf + 24);
996 y_blue = png_get_fixed_point(NULL, buf + 28);
1007 png_warning(png_ptr,
"Ignoring cHRM chunk with negative chromaticities");
1011 #ifdef PNG_READ_sRGB_SUPPORTED 1012 if ((info_ptr != NULL) && (info_ptr->valid &
PNG_INFO_sRGB))
1024 "Ignoring incorrect cHRM value when sRGB is also present");
1026 #ifdef PNG_CONSOLE_IO_SUPPORTED 1027 fprintf(stderr,
"wx=%d, wy=%d, rx=%d, ry=%d\n",
1028 x_white, y_white, x_red, y_red);
1030 fprintf(stderr,
"gx=%d, gy=%d, bx=%d, by=%d\n",
1031 x_green, y_green, x_blue, y_blue);
1039 x_green, y_green, x_blue, y_blue);
1043 #ifdef PNG_READ_sRGB_SUPPORTED 1053 png_error(png_ptr,
"Missing IHDR before sRGB");
1075 png_warning(png_ptr,
"Incorrect sRGB chunk length");
1094 #if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) 1100 "Ignoring incorrect gAMA value when sRGB is also present");
1101 #ifdef PNG_CONSOLE_IO_SUPPORTED 1102 fprintf(stderr,
"incorrect gamma=(%d/100000)\n", info_ptr->gamma);
1108 #ifdef PNG_READ_cHRM_SUPPORTED 1120 "Ignoring incorrect cHRM value when sRGB is also present");
1128 #ifdef PNG_READ_iCCP_SUPPORTED 1139 png_size_t slength, prefix_length, data_length;
1144 png_error(png_ptr,
"Missing IHDR before iCCP");
1164 #ifdef PNG_MAX_MALLOC_64K 1167 png_warning(png_ptr,
"iCCP chunk too large to fit in memory");
1173 png_free(png_ptr, png_ptr->chunkdata);
1174 png_ptr->chunkdata = (
png_charp)png_malloc(png_ptr, length + 1);
1180 png_free(png_ptr, png_ptr->chunkdata);
1181 png_ptr->chunkdata = NULL;
1185 png_ptr->chunkdata[slength] = 0x00;
1187 for (profile = png_ptr->chunkdata; *profile; profile++)
1195 if (profile >= png_ptr->chunkdata + slength - 1)
1197 png_free(png_ptr, png_ptr->chunkdata);
1198 png_ptr->chunkdata = NULL;
1204 compression_type = *profile++;
1206 if (compression_type)
1208 png_warning(png_ptr,
"Ignoring nonzero compression type in iCCP chunk");
1209 compression_type = 0x00;
1213 prefix_length = profile - png_ptr->chunkdata;
1215 slength, prefix_length, &data_length);
1217 profile_length = data_length - prefix_length;
1219 if (prefix_length > data_length || profile_length < 4)
1221 png_free(png_ptr, png_ptr->chunkdata);
1222 png_ptr->chunkdata = NULL;
1223 png_warning(png_ptr,
"Profile size field missing from iCCP chunk");
1228 pC = (
png_bytep)(png_ptr->chunkdata + prefix_length);
1229 profile_size = ((*(pC )) << 24) |
1230 ((*(pC + 1)) << 16) |
1231 ((*(pC + 2)) << 8) |
1237 if (profile_size < profile_length)
1238 profile_length = profile_size;
1241 if (profile_size > profile_length)
1243 png_free(png_ptr, png_ptr->chunkdata);
1244 png_ptr->chunkdata = NULL;
1245 #ifdef PNG_STDIO_SUPPORTED 1250 "Ignoring iCCP chunk with declared size = %u " 1251 "and actual length = %u",
1252 (
unsigned int) profile_size,
1253 (
unsigned int) profile_length);
1258 "Ignoring iCCP chunk with uncompressed size mismatch");
1264 compression_type, (
png_bytep)png_ptr->chunkdata + prefix_length,
1266 png_free(png_ptr, png_ptr->chunkdata);
1267 png_ptr->chunkdata = NULL;
1271 #ifdef PNG_READ_sPLT_SUPPORTED 1278 #ifdef PNG_POINTER_INDEXING_SUPPORTED 1290 #ifdef PNG_USER_LIMITS_SUPPORTED 1292 if (png_ptr->user_chunk_cache_max != 0)
1294 if (png_ptr->user_chunk_cache_max == 1)
1300 if (--png_ptr->user_chunk_cache_max == 1)
1302 png_warning(png_ptr,
"No space in chunk cache for sPLT");
1310 png_error(png_ptr,
"Missing IHDR before sPLT");
1319 #ifdef PNG_MAX_MALLOC_64K 1322 png_warning(png_ptr,
"sPLT chunk too large to fit in memory");
1328 png_free(png_ptr, png_ptr->chunkdata);
1329 png_ptr->chunkdata = (
png_charp)png_malloc(png_ptr, length + 1);
1340 png_free(png_ptr, png_ptr->chunkdata);
1341 png_ptr->chunkdata = NULL;
1345 png_ptr->chunkdata[slength] = 0x00;
1347 for (entry_start = (
png_bytep)png_ptr->chunkdata; *entry_start;
1354 if (entry_start > (
png_bytep)png_ptr->chunkdata + slength - 2)
1356 png_free(png_ptr, png_ptr->chunkdata);
1357 png_ptr->chunkdata = NULL;
1362 new_palette.
depth = *entry_start++;
1363 entry_size = (new_palette.
depth == 8 ? 6 : 10);
1368 data_length = length - (
png_uint_32)(entry_start -
1372 if (data_length % entry_size)
1374 png_free(png_ptr, png_ptr->chunkdata);
1375 png_ptr->chunkdata = NULL;
1376 png_warning(png_ptr,
"sPLT chunk has bad length");
1394 if (new_palette.
entries == NULL)
1396 png_warning(png_ptr,
"sPLT chunk requires too much memory");
1400 #ifdef PNG_POINTER_INDEXING_SUPPORTED 1401 for (i = 0; i < new_palette.
nentries; i++)
1405 if (new_palette.
depth == 8)
1407 pp->red = *entry_start++;
1408 pp->green = *entry_start++;
1409 pp->blue = *entry_start++;
1410 pp->alpha = *entry_start++;
1426 for (i = 0; i < new_palette.
nentries; i++)
1429 if (new_palette.
depth == 8)
1431 pp[i].red = *entry_start++;
1432 pp[i].green = *entry_start++;
1433 pp[i].blue = *entry_start++;
1434 pp[i].alpha = *entry_start++;
1450 new_palette.
name = png_ptr->chunkdata;
1454 png_free(png_ptr, png_ptr->chunkdata);
1455 png_ptr->chunkdata = NULL;
1460 #ifdef PNG_READ_tRNS_SUPPORTED 1469 png_error(png_ptr,
"Missing IHDR before tRNS");
1478 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_tRNS))
1491 png_warning(png_ptr,
"Incorrect tRNS chunk length");
1497 png_ptr->num_trans = 1;
1507 png_warning(png_ptr,
"Incorrect tRNS chunk length");
1513 png_ptr->num_trans = 1;
1530 png_warning(png_ptr,
"Incorrect tRNS chunk length");
1548 png_warning(png_ptr,
"tRNS chunk not allowed with alpha channel");
1555 png_ptr->num_trans = 0;
1559 png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
1560 &(png_ptr->trans_color));
1564 #ifdef PNG_READ_bKGD_SUPPORTED 1574 png_error(png_ptr,
"Missing IHDR before bKGD");
1591 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_bKGD))
1607 if (length != truelen)
1609 png_warning(png_ptr,
"Incorrect bKGD chunk length");
1626 png_ptr->background.index = buf[0];
1628 if (info_ptr && info_ptr->num_palette)
1630 if (buf[0] >= info_ptr->num_palette)
1632 png_warning(png_ptr,
"Incorrect bKGD chunk index value");
1636 png_ptr->background.red =
1639 png_ptr->background.green =
1642 png_ptr->background.blue =
1649 png_ptr->background.red =
1650 png_ptr->background.green =
1651 png_ptr->background.blue =
1662 png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background));
1666 #ifdef PNG_READ_hIST_SUPPORTED 1670 unsigned int num, i;
1676 png_error(png_ptr,
"Missing IHDR before hIST");
1692 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_hIST))
1701 if (num != (
unsigned int)png_ptr->num_palette || num >
1704 png_warning(png_ptr,
"Incorrect hIST chunk length");
1709 for (i = 0; i < num; i++)
1724 #ifdef PNG_READ_pHYs_SUPPORTED 1735 png_error(png_ptr,
"Missing IHDR before pHYs");
1744 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_pHYs))
1753 png_warning(png_ptr,
"Incorrect pHYs chunk length");
1766 png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
1770 #ifdef PNG_READ_oFFs_SUPPORTED 1781 png_error(png_ptr,
"Missing IHDR before oFFs");
1790 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_oFFs))
1799 png_warning(png_ptr,
"Incorrect oFFs chunk length");
1812 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);
1816 #ifdef PNG_READ_pCAL_SUPPORTED 1831 png_error(png_ptr,
"Missing IHDR before pCAL");
1840 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_pCAL))
1847 png_debug1(2,
"Allocating and reading pCAL chunk data (%u bytes)",
1849 png_free(png_ptr, png_ptr->chunkdata);
1850 png_ptr->chunkdata = (
png_charp)png_malloc_warn(png_ptr, length + 1);
1852 if (png_ptr->chunkdata == NULL)
1854 png_warning(png_ptr,
"No memory for pCAL purpose");
1863 png_free(png_ptr, png_ptr->chunkdata);
1864 png_ptr->chunkdata = NULL;
1868 png_ptr->chunkdata[slength] = 0x00;
1870 png_debug(3,
"Finding end of pCAL purpose string");
1871 for (buf = png_ptr->chunkdata; *buf; buf++)
1874 endptr = png_ptr->chunkdata + slength;
1879 if (endptr <= buf + 12)
1882 png_free(png_ptr, png_ptr->chunkdata);
1883 png_ptr->chunkdata = NULL;
1887 png_debug(3,
"Reading pCAL X0, X1, type, nparams, and units");
1894 png_debug(3,
"Checking pCAL equation type and number of parameters");
1903 png_warning(png_ptr,
"Invalid pCAL parameters for equation type");
1904 png_free(png_ptr, png_ptr->chunkdata);
1905 png_ptr->chunkdata = NULL;
1911 png_warning(png_ptr,
"Unrecognized equation type for pCAL chunk");
1914 for (buf = units; *buf; buf++)
1917 png_debug(3,
"Allocating pCAL parameters array");
1919 params = (
png_charpp)png_malloc_warn(png_ptr,
1924 png_free(png_ptr, png_ptr->chunkdata);
1925 png_ptr->chunkdata = NULL;
1926 png_warning(png_ptr,
"No memory for pCAL params");
1931 for (i = 0; i < (int)nparams; i++)
1935 png_debug1(3,
"Reading pCAL parameter %d", i);
1937 for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
1944 png_free(png_ptr, png_ptr->chunkdata);
1945 png_ptr->chunkdata = NULL;
1951 png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams,
1954 png_free(png_ptr, png_ptr->chunkdata);
1955 png_ptr->chunkdata = NULL;
1960 #ifdef PNG_READ_sCAL_SUPPORTED 1971 png_error(png_ptr,
"Missing IHDR before sCAL");
1980 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_sCAL))
1987 png_debug1(2,
"Allocating and reading sCAL chunk data (%u bytes)",
1990 png_ptr->chunkdata = (
png_charp)png_malloc_warn(png_ptr, length + 1);
1992 if (png_ptr->chunkdata == NULL)
1994 png_warning(png_ptr,
"Out of memory while processing sCAL chunk");
2001 png_ptr->chunkdata[slength] = 0x00;
2005 png_free(png_ptr, png_ptr->chunkdata);
2006 png_ptr->chunkdata = NULL;
2011 if (png_ptr->chunkdata[0] != 1 && png_ptr->chunkdata[0] != 2)
2013 png_warning(png_ptr,
"Invalid sCAL ignored: invalid unit");
2014 png_free(png_ptr, png_ptr->chunkdata);
2015 png_ptr->chunkdata = NULL;
2025 if (png_ptr->chunkdata[1] == 45 ||
2027 i >= slength || png_ptr->chunkdata[i++] != 0)
2028 png_warning(png_ptr,
"Invalid sCAL chunk ignored: bad width format");
2034 if (png_ptr->chunkdata[i] == 45 ||
2037 png_warning(png_ptr,
"Invalid sCAL chunk ignored: bad height format");
2042 png_ptr->chunkdata+1, png_ptr->chunkdata+heighti);
2046 png_free(png_ptr, png_ptr->chunkdata);
2047 png_ptr->chunkdata = NULL;
2051 #ifdef PNG_READ_tIME_SUPPORTED 2061 png_error(png_ptr,
"Out of place tIME chunk");
2063 else if (info_ptr != NULL && (info_ptr->valid &
PNG_INFO_tIME))
2075 png_warning(png_ptr,
"Incorrect tIME chunk length");
2085 mod_time.
second = buf[6];
2086 mod_time.
minute = buf[5];
2087 mod_time.
hour = buf[4];
2088 mod_time.
day = buf[3];
2089 mod_time.
month = buf[2];
2096 #ifdef PNG_READ_tEXt_SUPPORTED 2110 #ifdef PNG_USER_LIMITS_SUPPORTED 2111 if (png_ptr->user_chunk_cache_max != 0)
2113 if (png_ptr->user_chunk_cache_max == 1)
2119 if (--png_ptr->user_chunk_cache_max == 1)
2121 png_warning(png_ptr,
"No space in chunk cache for tEXt");
2129 png_error(png_ptr,
"Missing IHDR before tEXt");
2134 #ifdef PNG_MAX_MALLOC_64K 2137 png_warning(png_ptr,
"tEXt chunk too large to fit in memory");
2143 png_free(png_ptr, png_ptr->chunkdata);
2145 png_ptr->chunkdata = (
png_charp)png_malloc_warn(png_ptr, length + 1);
2147 if (png_ptr->chunkdata == NULL)
2149 png_warning(png_ptr,
"No memory to process text chunk");
2158 png_free(png_ptr, png_ptr->chunkdata);
2159 png_ptr->chunkdata = NULL;
2163 key = png_ptr->chunkdata;
2165 key[slength] = 0x00;
2167 for (text = key; *text; text++)
2170 if (text != key + slength)
2173 text_ptr = (
png_textp)png_malloc_warn(png_ptr,
2176 if (text_ptr == NULL)
2178 png_warning(png_ptr,
"Not enough memory to process text chunk");
2179 png_free(png_ptr, png_ptr->chunkdata);
2180 png_ptr->chunkdata = NULL;
2185 text_ptr->key = key;
2186 text_ptr->lang = NULL;
2187 text_ptr->lang_key = NULL;
2188 text_ptr->itxt_length = 0;
2189 text_ptr->text = text;
2194 png_free(png_ptr, png_ptr->chunkdata);
2195 png_ptr->chunkdata = NULL;
2199 png_warning(png_ptr,
"Insufficient memory to process text chunk");
2203 #ifdef PNG_READ_zTXt_SUPPORTED 2216 #ifdef PNG_USER_LIMITS_SUPPORTED 2217 if (png_ptr->user_chunk_cache_max != 0)
2219 if (png_ptr->user_chunk_cache_max == 1)
2225 if (--png_ptr->user_chunk_cache_max == 1)
2227 png_warning(png_ptr,
"No space in chunk cache for zTXt");
2235 png_error(png_ptr,
"Missing IHDR before zTXt");
2240 #ifdef PNG_MAX_MALLOC_64K 2246 png_warning(png_ptr,
"zTXt chunk too large to fit in memory");
2252 png_free(png_ptr, png_ptr->chunkdata);
2253 png_ptr->chunkdata = (
png_charp)png_malloc_warn(png_ptr, length + 1);
2255 if (png_ptr->chunkdata == NULL)
2257 png_warning(png_ptr,
"Out of memory processing zTXt chunk");
2266 png_free(png_ptr, png_ptr->chunkdata);
2267 png_ptr->chunkdata = NULL;
2271 png_ptr->chunkdata[slength] = 0x00;
2273 for (text = png_ptr->chunkdata; *text; text++)
2277 if (text >= png_ptr->chunkdata + slength - 2)
2280 png_free(png_ptr, png_ptr->chunkdata);
2281 png_ptr->chunkdata = NULL;
2287 comp_type = *(++text);
2291 png_warning(png_ptr,
"Unknown compression type in zTXt chunk");
2298 prefix_len = text - png_ptr->chunkdata;
2303 text_ptr = (
png_textp)png_malloc_warn(png_ptr,
2306 if (text_ptr == NULL)
2308 png_warning(png_ptr,
"Not enough memory to process zTXt chunk");
2309 png_free(png_ptr, png_ptr->chunkdata);
2310 png_ptr->chunkdata = NULL;
2314 text_ptr->compression = comp_type;
2315 text_ptr->key = png_ptr->chunkdata;
2316 text_ptr->lang = NULL;
2317 text_ptr->lang_key = NULL;
2318 text_ptr->itxt_length = 0;
2319 text_ptr->text = png_ptr->chunkdata + prefix_len;
2320 text_ptr->text_length = data_len;
2325 png_free(png_ptr, png_ptr->chunkdata);
2326 png_ptr->chunkdata = NULL;
2329 png_error(png_ptr,
"Insufficient memory to store zTXt chunk");
2333 #ifdef PNG_READ_iTXt_SUPPORTED 2347 #ifdef PNG_USER_LIMITS_SUPPORTED 2348 if (png_ptr->user_chunk_cache_max != 0)
2350 if (png_ptr->user_chunk_cache_max == 1)
2356 if (--png_ptr->user_chunk_cache_max == 1)
2358 png_warning(png_ptr,
"No space in chunk cache for iTXt");
2366 png_error(png_ptr,
"Missing IHDR before iTXt");
2371 #ifdef PNG_MAX_MALLOC_64K 2377 png_warning(png_ptr,
"iTXt chunk too large to fit in memory");
2383 png_free(png_ptr, png_ptr->chunkdata);
2384 png_ptr->chunkdata = (
png_charp)png_malloc_warn(png_ptr, length + 1);
2386 if (png_ptr->chunkdata == NULL)
2388 png_warning(png_ptr,
"No memory to process iTXt chunk");
2397 png_free(png_ptr, png_ptr->chunkdata);
2398 png_ptr->chunkdata = NULL;
2402 png_ptr->chunkdata[slength] = 0x00;
2404 for (lang = png_ptr->chunkdata; *lang; lang++)
2414 if (lang >= png_ptr->chunkdata + slength - 3)
2417 png_free(png_ptr, png_ptr->chunkdata);
2418 png_ptr->chunkdata = NULL;
2424 comp_flag = *lang++;
2425 comp_type = *lang++;
2428 for (lang_key = lang; *lang_key; lang_key++)
2433 if (lang_key >= png_ptr->chunkdata + slength)
2436 png_free(png_ptr, png_ptr->chunkdata);
2437 png_ptr->chunkdata = NULL;
2441 for (text = lang_key; *text; text++)
2446 if (text >= png_ptr->chunkdata + slength)
2449 png_free(png_ptr, png_ptr->chunkdata);
2450 png_ptr->chunkdata = NULL;
2454 prefix_len = text - png_ptr->chunkdata;
2456 key=png_ptr->chunkdata;
2460 (
size_t)length, prefix_len, &data_len);
2463 data_len =
png_strlen(png_ptr->chunkdata + prefix_len);
2465 text_ptr = (
png_textp)png_malloc_warn(png_ptr,
2468 if (text_ptr == NULL)
2470 png_warning(png_ptr,
"Not enough memory to process iTXt chunk");
2471 png_free(png_ptr, png_ptr->chunkdata);
2472 png_ptr->chunkdata = NULL;
2476 text_ptr->compression = (int)comp_flag + 1;
2477 text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key);
2478 text_ptr->lang = png_ptr->chunkdata + (lang - key);
2479 text_ptr->itxt_length = data_len;
2480 text_ptr->text_length = 0;
2481 text_ptr->key = png_ptr->chunkdata;
2482 text_ptr->text = png_ptr->chunkdata + prefix_len;
2487 png_free(png_ptr, png_ptr->chunkdata);
2488 png_ptr->chunkdata = NULL;
2491 png_error(png_ptr,
"Insufficient memory to store iTXt chunk");
2508 #ifdef PNG_USER_LIMITS_SUPPORTED 2509 if (png_ptr->user_chunk_cache_max != 0)
2511 if (png_ptr->user_chunk_cache_max == 1)
2517 if (--png_ptr->user_chunk_cache_max == 1)
2519 png_warning(png_ptr,
"No space in chunk cache for unknown chunk");
2530 if (
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
2534 if (!(png_ptr->chunk_name[0] & 0x20))
2536 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 2540 && png_ptr->read_user_chunk_fn == NULL
2544 png_chunk_error(png_ptr,
"unknown critical chunk");
2547 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 2550 || (png_ptr->read_user_chunk_fn != NULL)
2554 #ifdef PNG_MAX_MALLOC_64K 2557 png_warning(png_ptr,
"unknown chunk too large to fit in memory");
2567 png_ptr->unknown_chunk.name[
png_sizeof(png_ptr->unknown_chunk.name)-1]
2570 png_ptr->unknown_chunk.size = (
png_size_t)length;
2573 png_ptr->unknown_chunk.data = NULL;
2577 png_ptr->unknown_chunk.data = (
png_bytep)png_malloc(png_ptr, length);
2581 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED 2582 if (png_ptr->read_user_chunk_fn != NULL)
2587 ret = (*(png_ptr->read_user_chunk_fn))
2588 (png_ptr, &png_ptr->unknown_chunk);
2591 png_chunk_error(png_ptr,
"error in user chunk");
2595 if (!(png_ptr->chunk_name[0] & 0x20))
2597 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 2601 png_chunk_error(png_ptr,
"unknown critical chunk");
2605 &png_ptr->unknown_chunk, 1);
2613 png_free(png_ptr, png_ptr->unknown_chunk.data);
2614 png_ptr->unknown_chunk.data = NULL;
2623 #ifndef PNG_READ_USER_CHUNKS_SUPPORTED 2635 #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) 2640 png_debug(1,
"in png_check_chunk_name");
2644 png_chunk_error(png_ptr,
"invalid chunk type");
2668 PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width));
2673 switch (png_ptr->row_info.pixel_depth)
2679 int s_inc, s_start, s_end;
2685 #ifdef PNG_READ_PACKSWAP_SUPPORTED 2703 for (i = 0; i < row_width; i++)
2709 value = (*sp >> shift) & 0x01;
2710 *dp &= (
png_byte)((0x7f7f >> (7 - shift)) & 0xff);
2737 int s_start, s_end, s_inc;
2744 #ifdef PNG_READ_PACKSWAP_SUPPORTED 2762 for (i = 0; i < row_width; i++)
2766 value = (*sp >> shift) & 0x03;
2767 *dp &= (
png_byte)((0x3f3f >> (6 - shift)) & 0xff);
2794 int s_start, s_end, s_inc;
2801 #ifdef PNG_READ_PACKSWAP_SUPPORTED 2818 for (i = 0; i < row_width; i++)
2822 value = (*sp >> shift) & 0xf;
2823 *dp &= (
png_byte)((0xf0f >> (4 - shift)) & 0xff);
2850 png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
2855 for (i = 0; i < row_width; i++)
2877 #ifdef PNG_READ_INTERLACING_SUPPORTED 2883 int pass = png_ptr->pass;
2884 png_uint_32 transformations = png_ptr->transformations;
2887 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
2889 png_debug(1,
"in png_do_read_interlace");
2890 if (row != NULL && row_info != NULL)
2894 final_width = row_info->width * png_pass_inc[pass];
2896 switch (row_info->pixel_depth)
2903 int s_start, s_end, s_inc;
2904 int jstop = png_pass_inc[pass];
2909 #ifdef PNG_READ_PACKSWAP_SUPPORTED 2912 sshift = (int)((row_info->width + 7) & 0x07);
2913 dshift = (int)((final_width + 7) & 0x07);
2922 sshift = 7 - (int)((row_info->width + 7) & 0x07);
2923 dshift = 7 - (int)((final_width + 7) & 0x07);
2929 for (i = 0; i < row_info->width; i++)
2931 v = (
png_byte)((*sp >> sshift) & 0x01);
2932 for (j = 0; j < jstop; j++)
2934 *dp &= (
png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
2937 if (dshift == s_end)
2947 if (sshift == s_end)
2964 int s_start, s_end, s_inc;
2965 int jstop = png_pass_inc[pass];
2968 #ifdef PNG_READ_PACKSWAP_SUPPORTED 2971 sshift = (int)(((row_info->width + 3) & 0x03) << 1);
2972 dshift = (int)(((final_width + 3) & 0x03) << 1);
2981 sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
2982 dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
2988 for (i = 0; i < row_info->width; i++)
2993 v = (
png_byte)((*sp >> sshift) & 0x03);
2994 for (j = 0; j < jstop; j++)
2996 *dp &= (
png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
2999 if (dshift == s_end)
3009 if (sshift == s_end)
3026 int s_start, s_end, s_inc;
3028 int jstop = png_pass_inc[pass];
3030 #ifdef PNG_READ_PACKSWAP_SUPPORTED 3033 sshift = (int)(((row_info->width + 1) & 0x01) << 2);
3034 dshift = (int)(((final_width + 1) & 0x01) << 2);
3043 sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
3044 dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
3050 for (i = 0; i < row_info->width; i++)
3055 for (j = 0; j < jstop; j++)
3057 *dp &= (
png_byte)((0xf0f >> (4 - dshift)) & 0xff);
3060 if (dshift == s_end)
3070 if (sshift == s_end)
3083 png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
3090 int jstop = png_pass_inc[pass];
3093 for (i = 0; i < row_info->width; i++)
3100 for (j = 0; j < jstop; j++)
3111 row_info->width = final_width;
3112 row_info->rowbytes =
PNG_ROWBYTES(row_info->pixel_depth, final_width);
3114 #ifndef PNG_READ_PACKSWAP_SUPPORTED 3125 png_debug2(2,
"row = %u, filter = %d", png_ptr->row_number, filter);
3135 unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
3139 for (i = bpp; i < istop; i++)
3141 *rp = (
png_byte)(((
int)(*rp) + (int)(*lp++)) & 0xff);
3153 for (i = 0; i < istop; i++)
3155 *rp = (
png_byte)(((
int)(*rp) + (int)(*pp++)) & 0xff);
3166 unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
3169 for (i = 0; i < bpp; i++)
3172 ((int)(*pp++) / 2 )) & 0xff);
3177 for (i = 0; i < istop; i++)
3180 (int)(*pp++ + *lp++) / 2 ) & 0xff);
3193 unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
3196 for (i = 0; i < bpp; i++)
3198 *rp = (
png_byte)(((
int)(*rp) + (int)(*pp++)) & 0xff);
3202 for (i = 0; i < istop; i++)
3204 int a,
b, c, pa, pb, pc, p;
3218 pa = p < 0 ? -p : p;
3219 pb = pc < 0 ? -pc : pc;
3220 pc = (p + pc) < 0 ? -(p + pc) : p + pc;
3234 p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
3236 *rp = (
png_byte)(((
int)(*rp) + p) & 0xff);
3242 png_error(png_ptr,
"Ignoring bad adaptive filter type");
3248 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED 3252 #ifdef PNG_READ_INTERLACING_SUPPORTED 3256 PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
3259 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
3262 PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
3265 PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
3269 png_ptr->row_number++;
3270 if (png_ptr->row_number < png_ptr->num_rows)
3273 #ifdef PNG_READ_INTERLACING_SUPPORTED 3274 if (png_ptr->interlaced)
3276 png_ptr->row_number = 0;
3278 png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
3284 if (png_ptr->pass >= 7)
3287 png_ptr->iwidth = (png_ptr->width +
3288 png_pass_inc[png_ptr->pass] - 1 -
3289 png_pass_start[png_ptr->pass]) /
3290 png_pass_inc[png_ptr->pass];
3294 png_ptr->num_rows = (png_ptr->height +
3295 png_pass_yinc[png_ptr->pass] - 1 -
3296 png_pass_ystart[png_ptr->pass]) /
3297 png_pass_yinc[png_ptr->pass];
3303 }
while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0);
3305 if (png_ptr->pass < 7)
3316 png_ptr->zstream.next_out = (
Byte *)&extra;
3317 png_ptr->zstream.avail_out = (
uInt)1;
3321 if (!(png_ptr->zstream.avail_in))
3323 while (!png_ptr->idat_size)
3327 if (
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
3328 png_error(png_ptr,
"Not enough image data");
3331 png_ptr->zstream.avail_in = (
uInt)png_ptr->zbuf_size;
3332 png_ptr->zstream.next_in = png_ptr->zbuf;
3334 if (png_ptr->zbuf_size > png_ptr->idat_size)
3335 png_ptr->zstream.avail_in = (
uInt)png_ptr->idat_size;
3337 png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);
3338 png_ptr->idat_size -= png_ptr->zstream.avail_in;
3345 if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in ||
3355 png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
3356 "Decompression Error");
3358 if (!(png_ptr->zstream.avail_out))
3367 png_ptr->zstream.avail_out = 0;
3370 if (png_ptr->idat_size || png_ptr->zstream.avail_in)
3382 #ifdef PNG_READ_INTERLACING_SUPPORTED 3386 PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
3389 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
3392 PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
3395 PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
3398 int max_pixel_depth;
3402 png_ptr->zstream.avail_in = 0;
3404 #ifdef PNG_READ_INTERLACING_SUPPORTED 3405 if (png_ptr->interlaced)
3408 png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
3409 png_pass_ystart[0]) / png_pass_yinc[0];
3412 png_ptr->num_rows = png_ptr->height;
3414 png_ptr->iwidth = (png_ptr->width +
3415 png_pass_inc[png_ptr->pass] - 1 -
3416 png_pass_start[png_ptr->pass]) /
3417 png_pass_inc[png_ptr->pass];
3423 png_ptr->num_rows = png_ptr->height;
3424 png_ptr->iwidth = png_ptr->width;
3427 max_pixel_depth = png_ptr->pixel_depth;
3429 #ifdef PNG_READ_PACK_SUPPORTED 3430 if ((png_ptr->transformations &
PNG_PACK) && png_ptr->bit_depth < 8)
3431 max_pixel_depth = 8;
3434 #ifdef PNG_READ_EXPAND_SUPPORTED 3439 if (png_ptr->num_trans)
3440 max_pixel_depth = 32;
3443 max_pixel_depth = 24;
3448 if (max_pixel_depth < 8)
3449 max_pixel_depth = 8;
3451 if (png_ptr->num_trans)
3452 max_pixel_depth *= 2;
3457 if (png_ptr->num_trans)
3459 max_pixel_depth *= 4;
3460 max_pixel_depth /= 3;
3466 #ifdef PNG_READ_FILLER_SUPPORTED 3470 max_pixel_depth = 32;
3474 if (max_pixel_depth <= 8)
3475 max_pixel_depth = 16;
3478 max_pixel_depth = 32;
3483 if (max_pixel_depth <= 32)
3484 max_pixel_depth = 32;
3487 max_pixel_depth = 64;
3492 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 3497 (png_ptr->num_trans && (png_ptr->transformations &
PNG_EXPAND)) ||
3504 if (max_pixel_depth <= 16)
3505 max_pixel_depth = 32;
3508 max_pixel_depth = 64;
3513 if (max_pixel_depth <= 8)
3516 max_pixel_depth = 32;
3519 max_pixel_depth = 24;
3523 max_pixel_depth = 64;
3526 max_pixel_depth = 48;
3531 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ 3532 defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 3535 int user_pixel_depth = png_ptr->user_transform_depth*
3536 png_ptr->user_transform_channels;
3538 if (user_pixel_depth > max_pixel_depth)
3539 max_pixel_depth=user_pixel_depth;
3546 row_bytes = ((png_ptr->width + 7) & ~((
png_uint_32)7));
3551 1 + ((max_pixel_depth + 7) >> 3);
3553 #ifdef PNG_MAX_MALLOC_64K 3555 png_error(png_ptr,
"This image requires a row greater than 64KB");
3558 if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
3560 png_free(png_ptr, png_ptr->big_row_buf);
3562 if (png_ptr->interlaced)
3563 png_ptr->big_row_buf = (
png_bytep)png_calloc(png_ptr,
3567 png_ptr->big_row_buf = (
png_bytep)png_malloc(png_ptr,
3570 png_ptr->old_big_row_buf_size = row_bytes + 48;
3572 #ifdef PNG_ALIGNED_MEMORY_SUPPORTED 3576 png_ptr->row_buf = png_ptr->big_row_buf + 32 -
3579 png_ptr->old_big_row_buf_size = row_bytes + 48;
3582 png_ptr->row_buf = png_ptr->big_row_buf + 32;
3584 png_ptr->old_big_row_buf_size = row_bytes + 48;
3587 #ifdef PNG_MAX_MALLOC_64K 3588 if (png_ptr->rowbytes > 65535)
3589 png_error(png_ptr,
"This image requires a row greater than 64KB");
3593 png_error(png_ptr,
"Row has too many bytes to allocate in memory");
3595 if (png_ptr->rowbytes + 1 > png_ptr->old_prev_row_size)
3597 png_free(png_ptr, png_ptr->prev_row);
3599 png_ptr->prev_row = (
png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
3601 png_ptr->old_prev_row_size = png_ptr->rowbytes + 1;
3604 png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
3606 png_debug1(3,
"width = %u,", png_ptr->width);
3607 png_debug1(3,
"height = %u,", png_ptr->height);
3608 png_debug1(3,
"iwidth = %u,", png_ptr->iwidth);
3609 png_debug1(3,
"num_rows = %u,", png_ptr->num_rows);
3610 png_debug1(3,
"rowbytes = %lu,", (
unsigned long)png_ptr->rowbytes);
3612 (
unsigned long)
PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);
#define PNG_FILTER_VALUE_AVG
#define png_get_uint_16(buf)
void PNGAPI png_set_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
void PNGAPI png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)
#define PNG_USER_CHUNK_MALLOC_MAX
#define PNG_READ_USER_CHUNKS_SUPPORTED
void png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int ZEXPORT inflateReset(z_streamp strm)
#define png_get_uint_32(buf)
void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)
#define PNG_UNUSED(param)
#define PNG_MAX_PALETTE_LENGTH
void PNGAPI png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_EQUATION_LINEAR
#define PNG_COLOR_TYPE_PALETTE
void png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define PNG_FILTER_VALUE_PAETH
void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
#define PNG_IO_CHUNK_DATA
void PNGFAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point file_gamma)
#define PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS
void png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
void png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter)
void png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define PNG_sRGB_INTENT_LAST
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_uint_32(PNGAPI png_get_uint_32)(png_const_bytep buf)
void PNGAPI png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
void png_read_finish_row(png_structp png_ptr)
void png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t png_alloc_size_t
#define PNG_FLAG_ROW_INIT
void png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_init_read_transformations(png_structp png_ptr)
void PNGAPI png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, int srgb_intent)
#define PNG_TEXT_COMPRESSION_zTXt
#define PNG_FLAG_CRC_ANCILLARY_USE
void png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_const_color_16p background)
void png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
unsigned long png_uint_32
#define PNG_TEXT_COMPRESSION_NONE
#define PNG_READ_sRGB_SUPPORTED
void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit)
png_struct FAR * png_structp
void png_read_start_row(png_structp png_ptr)
#define PNG_HANDLE_CHUNK_ALWAYS
void PNGAPI png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_const_colorp palette, int num_palette)
#define PNG_COLOR_MASK_COLOR
void PNGAPI png_set_sPLT(png_structp png_ptr, png_infop info_ptr, png_const_sPLT_tp entries, int nentries)
void png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int png_check_fp_number(png_const_charp string, png_size_t size, int *statep, png_size_tp whereami)
#define PNG_FLAG_CRC_CRITICAL_IGNORE
unsigned short png_uint_16
void png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_do_read_interlace(png_structp png_ptr)
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_FILTER_VALUE_SUB
#define PNG_COLOR_TYPE_GRAY
#define PNG_FLAG_CRC_CRITICAL_USE
png_sPLT_entry FAR * png_sPLT_entryp
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
void png_combine_row(png_structp png_ptr, png_bytep row, int mask)
#define PNG_EQUATION_ARBITRARY
int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_const_bytep chunk_name)
PNG_CONST png_byte FAR * png_const_bytep
#define png_debug1(l, m, p1)
#define PNG_FLAG_CRC_ANCILLARY_NOWARN
void png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void PNGFAPI png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, 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)
#define PNG_EQUATION_LAST
#define PNG_FLAG_ZLIB_FINISHED
void png_read_sig(png_structp png_ptr, png_infop info_ptr)
int png_crc_finish(png_structp png_ptr, png_uint_32 skip)
#define PNG_READ_FILLER_SUPPORTED
#define PNG_FILTER_VALUE_UP
#define png_get_int_32(buf)
png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
int png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr, int num_text)
void PNGAPI png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)
void png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_int_32(PNGAPI png_get_int_32)(png_const_bytep buf)
#define PNG_OUT_OF_RANGE(value, ideal, delta)
png_row_info FAR * png_row_infop
#define PNG_COMPRESSION_TYPE_BASE
void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
void png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_int_32 png_fixed_point
#define PNG_EQUATION_HYPERBOLIC
char FAR *FAR * png_charpp
void png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define PNG_FILTER_VALUE_NONE
void png_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length)
void png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int png_crc_error(png_structp png_ptr)
#define PNG_USER_TRANSFORM
void png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int ZEXPORT inflate(z_streamp strm, int flush)
#define PNG_EQUATION_BASE_E
void png_decompress_chunk(png_structp png_ptr, int comp_type, png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength)
void png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_16(PNGAPI png_get_uint_16)(png_const_bytep buf)
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)
#define PNG_FLAG_CRC_ANCILLARY_MASK
void png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void PNGAPI png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
#define PNG_ROWBYTES(pixel_bits, width)
void PNGAPI png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)
#define PNG_HAVE_PNG_SIGNATURE
void png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int PNGAPI png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
void png_reset_crc(png_structp png_ptr)
png_uint_32 png_read_chunk_header(png_structp png_ptr)
#define png_debug2(l, m, p1, p2)
png_color FAR * png_colorp
void png_check_chunk_name(png_structp png_ptr, png_const_bytep chunk_name)