13 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 16 #define PNG_READ_SIG_MODE 0 17 #define PNG_READ_CHUNK_MODE 1 18 #define PNG_READ_IDAT_MODE 2 19 #define PNG_SKIP_MODE 3 20 #define PNG_READ_tEXt_MODE 4 21 #define PNG_READ_zTXt_MODE 5 22 #define PNG_READ_DONE_MODE 6 23 #define PNG_READ_iTXt_MODE 7 24 #define PNG_ERROR_MODE 8 30 if (png_ptr == NULL || info_ptr == NULL)
return;
33 while (png_ptr->buffer_size)
45 if (png_ptr == NULL)
return;
46 switch (png_ptr->process_mode)
63 #if defined(PNG_READ_tEXt_SUPPORTED) 70 #if defined(PNG_READ_zTXt_SUPPORTED) 77 #if defined(PNG_READ_iTXt_SUPPORTED) 80 png_push_read_iTXt(png_ptr, info_ptr);
91 png_ptr->buffer_size = 0;
120 if (num_checked < 4 &&
124 png_error(png_ptr,
"PNG file corrupted by ASCII conversion");
128 if (png_ptr->sig_bytes >= 8)
138 #ifdef PNG_USE_LOCAL_ARRAYS 143 #if defined(PNG_READ_bKGD_SUPPORTED) 146 #if defined(PNG_READ_cHRM_SUPPORTED) 149 #if defined(PNG_READ_gAMA_SUPPORTED) 152 #if defined(PNG_READ_hIST_SUPPORTED) 155 #if defined(PNG_READ_iCCP_SUPPORTED) 158 #if defined(PNG_READ_iTXt_SUPPORTED) 161 #if defined(PNG_READ_oFFs_SUPPORTED) 164 #if defined(PNG_READ_pCAL_SUPPORTED) 167 #if defined(PNG_READ_pHYs_SUPPORTED) 170 #if defined(PNG_READ_sBIT_SUPPORTED) 173 #if defined(PNG_READ_sCAL_SUPPORTED) 176 #if defined(PNG_READ_sRGB_SUPPORTED) 179 #if defined(PNG_READ_sPLT_SUPPORTED) 182 #if defined(PNG_READ_tEXt_SUPPORTED) 185 #if defined(PNG_READ_tIME_SUPPORTED) 188 #if defined(PNG_READ_tRNS_SUPPORTED) 191 #if defined(PNG_READ_zTXt_SUPPORTED) 201 if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
205 if (png_ptr->buffer_size < 8)
216 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
219 if (!
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
221 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
223 if (!
png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
225 if (png_ptr->push_length != 13)
226 png_error(png_ptr,
"Invalid IHDR length");
227 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
234 else if (!
png_memcmp(png_ptr->chunk_name, png_IEND, 4))
236 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
246 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 249 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
254 if (!
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
257 if (!
png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
259 else if (!
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
262 png_error(png_ptr,
"Missing IHDR before IDAT");
265 png_error(png_ptr,
"Missing PLTE before IDAT");
269 else if (!
png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
271 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
278 else if (!
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
285 png_error(png_ptr,
"Missing IHDR before IDAT");
288 png_error(png_ptr,
"Missing PLTE before IDAT");
292 if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
293 if (png_ptr->push_length == 0)
297 png_error(png_ptr,
"Too many IDAT's found");
300 png_ptr->idat_size = png_ptr->push_length;
304 png_ptr->zstream.avail_out = (
uInt)png_ptr->irowbytes;
305 png_ptr->zstream.next_out = png_ptr->row_buf;
308 #if defined(PNG_READ_gAMA_SUPPORTED) 309 else if (!
png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
311 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
319 #if defined(PNG_READ_sBIT_SUPPORTED) 320 else if (!
png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
322 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
330 #if defined(PNG_READ_cHRM_SUPPORTED) 331 else if (!
png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
333 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
341 #if defined(PNG_READ_sRGB_SUPPORTED) 342 else if (!
png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
344 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
352 #if defined(PNG_READ_iCCP_SUPPORTED) 353 else if (!
png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
355 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
363 #if defined(PNG_READ_sPLT_SUPPORTED) 364 else if (!
png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
366 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
374 #if defined(PNG_READ_tRNS_SUPPORTED) 375 else if (!
png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
377 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
385 #if defined(PNG_READ_bKGD_SUPPORTED) 386 else if (!
png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
388 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
396 #if defined(PNG_READ_hIST_SUPPORTED) 397 else if (!
png_memcmp(png_ptr->chunk_name, png_hIST, 4))
399 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
407 #if defined(PNG_READ_pHYs_SUPPORTED) 408 else if (!
png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
410 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
418 #if defined(PNG_READ_oFFs_SUPPORTED) 419 else if (!
png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
421 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
429 #if defined(PNG_READ_pCAL_SUPPORTED) 430 else if (!
png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
432 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
440 #if defined(PNG_READ_sCAL_SUPPORTED) 441 else if (!
png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
443 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
451 #if defined(PNG_READ_tIME_SUPPORTED) 452 else if (!
png_memcmp(png_ptr->chunk_name, png_tIME, 4))
454 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
462 #if defined(PNG_READ_tEXt_SUPPORTED) 463 else if (!
png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
465 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
473 #if defined(PNG_READ_zTXt_SUPPORTED) 474 else if (!
png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
476 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
484 #if defined(PNG_READ_iTXt_SUPPORTED) 485 else if (!
png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
487 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
492 png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
497 if (png_ptr->push_length + 4 > png_ptr->buffer_size)
505 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
512 png_ptr->skip_length = skip;
518 if (png_ptr->skip_length && png_ptr->save_buffer_size)
522 if (png_ptr->skip_length < (
png_uint_32)png_ptr->save_buffer_size)
525 save_size = png_ptr->save_buffer_size;
529 png_ptr->skip_length -= save_size;
530 png_ptr->buffer_size -= save_size;
531 png_ptr->save_buffer_size -= save_size;
532 png_ptr->save_buffer_ptr += save_size;
534 if (png_ptr->skip_length && png_ptr->current_buffer_size)
538 if (png_ptr->skip_length < (
png_uint_32)png_ptr->current_buffer_size)
541 save_size = png_ptr->current_buffer_size;
545 png_ptr->skip_length -= save_size;
546 png_ptr->buffer_size -= save_size;
547 png_ptr->current_buffer_size -= save_size;
548 png_ptr->current_buffer_ptr += save_size;
550 if (!png_ptr->skip_length)
552 if (png_ptr->buffer_size < 4)
568 if (png_ptr == NULL)
return;
570 if (png_ptr->save_buffer_size)
574 if (length < png_ptr->save_buffer_size)
577 save_size = png_ptr->save_buffer_size;
579 png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);
582 png_ptr->buffer_size -= save_size;
583 png_ptr->save_buffer_size -= save_size;
584 png_ptr->save_buffer_ptr += save_size;
586 if (length && png_ptr->current_buffer_size)
590 if (length < png_ptr->current_buffer_size)
593 save_size = png_ptr->current_buffer_size;
595 png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);
596 png_ptr->buffer_size -= save_size;
597 png_ptr->current_buffer_size -= save_size;
598 png_ptr->current_buffer_ptr += save_size;
605 if (png_ptr->save_buffer_size)
607 if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
613 istop = png_ptr->save_buffer_size;
614 for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
615 i < istop; i++, sp++, dp++)
621 if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
622 png_ptr->save_buffer_max)
628 (png_ptr->current_buffer_size + 256))
630 png_error(png_ptr,
"Potential overflow of save_buffer");
632 new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
633 old_buffer = png_ptr->save_buffer;
636 png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
638 png_ptr->save_buffer_max = new_max;
640 if (png_ptr->current_buffer_size)
642 png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
643 png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);
644 png_ptr->save_buffer_size += png_ptr->current_buffer_size;
645 png_ptr->current_buffer_size = 0;
647 png_ptr->save_buffer_ptr = png_ptr->save_buffer;
648 png_ptr->buffer_size = 0;
655 png_ptr->current_buffer =
buffer;
656 png_ptr->current_buffer_size = buffer_length;
657 png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;
658 png_ptr->current_buffer_ptr = png_ptr->current_buffer;
664 #ifdef PNG_USE_LOCAL_ARRAYS 667 if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
671 if (png_ptr->buffer_size < 8)
681 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
683 if (
png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
686 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
687 png_error(png_ptr,
"Not enough compressed data");
691 png_ptr->idat_size = png_ptr->push_length;
693 if (png_ptr->idat_size && png_ptr->save_buffer_size)
697 if (png_ptr->idat_size < (
png_uint_32)png_ptr->save_buffer_size)
702 png_error(png_ptr,
"save_size overflowed in pngpread");
705 save_size = png_ptr->save_buffer_size;
708 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
710 png_ptr->idat_size -= save_size;
711 png_ptr->buffer_size -= save_size;
712 png_ptr->save_buffer_size -= save_size;
713 png_ptr->save_buffer_ptr += save_size;
715 if (png_ptr->idat_size && png_ptr->current_buffer_size)
719 if (png_ptr->idat_size < (
png_uint_32)png_ptr->current_buffer_size)
724 png_error(png_ptr,
"save_size overflowed in pngpread");
727 save_size = png_ptr->current_buffer_size;
730 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
733 png_ptr->idat_size -= save_size;
734 png_ptr->buffer_size -= save_size;
735 png_ptr->current_buffer_size -= save_size;
736 png_ptr->current_buffer_ptr += save_size;
738 if (!png_ptr->idat_size)
740 if (png_ptr->buffer_size < 4)
747 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
758 if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length)
759 png_error(png_ptr,
"Extra compression data");
761 png_ptr->zstream.next_in =
buffer;
762 png_ptr->zstream.avail_in = (
uInt)buffer_length;
770 if (png_ptr->zstream.avail_in)
771 png_error(png_ptr,
"Extra compressed data");
772 if (!(png_ptr->zstream.avail_out))
778 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
784 png_error(png_ptr,
"Decompression Error");
786 if (!(png_ptr->zstream.avail_out))
790 png_ptr->interlaced && png_ptr->pass > 6) ||
791 (!png_ptr->interlaced &&
793 png_ptr->row_number == png_ptr->num_rows))
795 if (png_ptr->zstream.avail_in)
796 png_warning(png_ptr,
"Too much data in IDAT chunks");
797 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
801 png_ptr->zstream.avail_out = (
uInt)png_ptr->irowbytes;
802 png_ptr->zstream.next_out = png_ptr->row_buf;
812 png_ptr->row_info.color_type = png_ptr->color_type;
813 png_ptr->row_info.width = png_ptr->iwidth;
814 png_ptr->row_info.channels = png_ptr->channels;
815 png_ptr->row_info.bit_depth = png_ptr->bit_depth;
816 png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
818 png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
819 png_ptr->row_info.width);
822 png_ptr->row_buf + 1, png_ptr->prev_row + 1,
823 (
int)(png_ptr->row_buf[0]));
826 png_ptr->rowbytes + 1);
828 if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
831 #if defined(PNG_READ_INTERLACING_SUPPORTED) 833 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
835 if (png_ptr->pass < 6)
842 switch (png_ptr->pass)
847 for (i = 0; i < 8 && png_ptr->pass == 0; i++)
852 if (png_ptr->pass == 2)
854 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
860 if (png_ptr->pass == 4 && png_ptr->height <= 4)
862 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
868 if (png_ptr->pass == 6 && png_ptr->height <= 4)
878 for (i = 0; i < 8 && png_ptr->pass == 1; i++)
883 if (png_ptr->pass == 2)
885 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
896 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
901 for (i = 0; i < 4 && png_ptr->pass == 2; i++)
906 if (png_ptr->pass == 4)
908 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
919 for (i = 0; i < 4 && png_ptr->pass == 3; i++)
924 if (png_ptr->pass == 4)
926 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
937 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
942 for (i = 0; i < 2 && png_ptr->pass == 4; i++)
947 if (png_ptr->pass == 6)
957 for (i = 0; i < 2 && png_ptr->pass == 5; i++)
962 if (png_ptr->pass == 6)
973 if (png_ptr->pass != 6)
991 #ifdef PNG_USE_LOCAL_ARRAYS 1012 png_ptr->row_number++;
1013 if (png_ptr->row_number < png_ptr->num_rows)
1016 if (png_ptr->interlaced)
1018 png_ptr->row_number = 0;
1020 png_ptr->rowbytes + 1);
1024 if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
1025 (png_ptr->pass == 3 && png_ptr->width < 3) ||
1026 (png_ptr->pass == 5 && png_ptr->width < 2))
1029 if (png_ptr->pass > 7)
1031 if (png_ptr->pass >= 7)
1034 png_ptr->iwidth = (png_ptr->width +
1035 png_pass_inc[png_ptr->pass] - 1 -
1036 png_pass_start[png_ptr->pass]) /
1037 png_pass_inc[png_ptr->pass];
1039 png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
1040 png_ptr->iwidth) + 1;
1042 if (png_ptr->transformations & PNG_INTERLACE)
1045 png_ptr->num_rows = (png_ptr->height +
1046 png_pass_yinc[png_ptr->pass] - 1 -
1047 png_pass_ystart[png_ptr->pass]) /
1048 png_pass_yinc[png_ptr->pass];
1050 }
while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
1054 #if defined(PNG_READ_tEXt_SUPPORTED) 1061 png_error(png_ptr,
"Out of place tEXt");
1065 #ifdef PNG_MAX_MALLOC_64K 1066 png_ptr->skip_length = 0;
1070 png_warning(png_ptr,
"tEXt chunk too large to fit in memory");
1071 png_ptr->skip_length = length - (
png_uint_32)65535L;
1078 png_ptr->current_text[
length] =
'\0';
1079 png_ptr->current_text_ptr = png_ptr->current_text;
1080 png_ptr->current_text_size = (
png_size_t)length;
1081 png_ptr->current_text_left = (
png_size_t)length;
1088 if (png_ptr->buffer_size && png_ptr->current_text_left)
1092 if (png_ptr->buffer_size < png_ptr->current_text_left)
1093 text_size = png_ptr->buffer_size;
1095 text_size = png_ptr->current_text_left;
1097 png_ptr->current_text_left -= text_size;
1098 png_ptr->current_text_ptr += text_size;
1100 if (!(png_ptr->current_text_left))
1107 if (png_ptr->buffer_size < 4)
1115 #if defined(PNG_MAX_MALLOC_64K) 1116 if (png_ptr->skip_length)
1120 key = png_ptr->current_text;
1122 for (text = key; *text; text++)
1125 if (text < key + png_ptr->current_text_size)
1131 text_ptr->key = key;
1132 #ifdef PNG_iTXt_SUPPORTED 1133 text_ptr->lang = NULL;
1134 text_ptr->lang_key = NULL;
1136 text_ptr->text = text;
1142 png_ptr->current_text = NULL;
1145 png_warning(png_ptr,
"Insufficient memory to store text chunk.");
1150 #if defined(PNG_READ_zTXt_SUPPORTED) 1157 png_error(png_ptr,
"Out of place zTXt");
1161 #ifdef PNG_MAX_MALLOC_64K 1168 png_warning(png_ptr,
"zTXt chunk too large to fit in memory");
1176 png_ptr->current_text[
length] =
'\0';
1177 png_ptr->current_text_ptr = png_ptr->current_text;
1178 png_ptr->current_text_size = (
png_size_t)length;
1179 png_ptr->current_text_left = (
png_size_t)length;
1186 if (png_ptr->buffer_size && png_ptr->current_text_left)
1190 if (png_ptr->buffer_size < (
png_uint_32)png_ptr->current_text_left)
1191 text_size = png_ptr->buffer_size;
1193 text_size = png_ptr->current_text_left;
1195 png_ptr->current_text_left -= text_size;
1196 png_ptr->current_text_ptr += text_size;
1198 if (!(png_ptr->current_text_left))
1206 if (png_ptr->buffer_size < 4)
1214 key = png_ptr->current_text;
1216 for (text = key; *text; text++)
1220 if (text >= key + png_ptr->current_text_size)
1222 png_ptr->current_text = NULL;
1231 png_ptr->current_text = NULL;
1238 png_ptr->zstream.next_in = (
png_bytep )text;
1239 png_ptr->zstream.avail_in = (
uInt)(png_ptr->current_text_size -
1241 png_ptr->zstream.next_out = png_ptr->zbuf;
1242 png_ptr->zstream.avail_out = (
uInt)png_ptr->zbuf_size;
1244 key_size = text - key;
1249 while (png_ptr->zstream.avail_in)
1255 png_ptr->zstream.avail_in = 0;
1256 png_ptr->current_text = NULL;
1261 if (!(png_ptr->zstream.avail_out) || ret ==
Z_STREAM_END)
1267 - png_ptr->zstream.avail_out + key_size + 1));
1269 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
1271 text_size = key_size + png_ptr->zbuf_size -
1272 png_ptr->zstream.avail_out;
1273 *(text + text_size) =
'\0';
1282 - png_ptr->zstream.avail_out + 1));
1286 png_ptr->zbuf_size - png_ptr->zstream.avail_out);
1287 text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
1288 *(text + text_size) =
'\0';
1292 png_ptr->zstream.next_out = png_ptr->zbuf;
1293 png_ptr->zstream.avail_out = (
uInt)png_ptr->zbuf_size;
1306 png_ptr->zstream.avail_in = 0;
1310 png_ptr->current_text = NULL;
1316 png_ptr->current_text = NULL;
1324 text_ptr->key = key;
1325 #ifdef PNG_iTXt_SUPPORTED 1326 text_ptr->lang = NULL;
1327 text_ptr->lang_key = NULL;
1329 text_ptr->text = text;
1337 png_warning(png_ptr,
"Insufficient memory to store text chunk.");
1342 #if defined(PNG_READ_iTXt_SUPPORTED) 1349 png_error(png_ptr,
"Out of place iTXt");
1353 #ifdef PNG_MAX_MALLOC_64K 1354 png_ptr->skip_length = 0;
1358 png_warning(png_ptr,
"iTXt chunk too large to fit in memory");
1359 png_ptr->skip_length = length - (
png_uint_32)65535L;
1366 png_ptr->current_text[
length] =
'\0';
1367 png_ptr->current_text_ptr = png_ptr->current_text;
1368 png_ptr->current_text_size = (
png_size_t)length;
1369 png_ptr->current_text_left = (
png_size_t)length;
1377 if (png_ptr->buffer_size && png_ptr->current_text_left)
1381 if (png_ptr->buffer_size < png_ptr->current_text_left)
1382 text_size = png_ptr->buffer_size;
1384 text_size = png_ptr->current_text_left;
1386 png_ptr->current_text_left -= text_size;
1387 png_ptr->current_text_ptr += text_size;
1389 if (!(png_ptr->current_text_left))
1399 if (png_ptr->buffer_size < 4)
1407 #if defined(PNG_MAX_MALLOC_64K) 1408 if (png_ptr->skip_length)
1412 key = png_ptr->current_text;
1414 for (lang = key; *lang; lang++)
1417 if (lang < key + png_ptr->current_text_size - 3)
1420 comp_flag = *lang++;
1423 for (lang_key = lang; *lang_key; lang_key++)
1428 if (lang_key < key + png_ptr->current_text_size - 1)
1430 for (; *text; text++)
1434 if (text < key + png_ptr->current_text_size)
1439 text_ptr->compression = comp_flag + 2;
1440 text_ptr->key = key;
1441 text_ptr->lang = lang;
1442 text_ptr->lang_key = lang_key;
1443 text_ptr->text = text;
1444 text_ptr->text_length = 0;
1449 png_ptr->current_text = NULL;
1453 png_warning(png_ptr,
"Insufficient memory to store iTXt chunk.");
1468 if (!(png_ptr->chunk_name[0] & 0x20))
1470 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) 1474 && png_ptr->read_user_chunk_fn == NULL
1483 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) 1484 if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
1486 #ifdef PNG_MAX_MALLOC_64K 1489 png_warning(png_ptr,
"unknown chunk too large to fit in memory");
1497 png_ptr->unknown_chunk.name[
png_sizeof(png_ptr->unknown_chunk.name) - 1]
1500 png_ptr->unknown_chunk.size = (
png_size_t)length;
1502 png_ptr->unknown_chunk.data = NULL;
1509 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) 1510 if (png_ptr->read_user_chunk_fn != NULL)
1514 ret = (*(png_ptr->read_user_chunk_fn))
1515 (png_ptr, &png_ptr->unknown_chunk);
1520 if (!(png_ptr->chunk_name[0] & 0x20))
1525 &png_ptr->unknown_chunk, 1);
1531 png_free(png_ptr, png_ptr->unknown_chunk.data);
1532 png_ptr->unknown_chunk.data = NULL;
1543 if (png_ptr->info_fn != NULL)
1544 (*(png_ptr->info_fn))(png_ptr,
info_ptr);
1550 if (png_ptr->end_fn != NULL)
1551 (*(png_ptr->end_fn))(png_ptr,
info_ptr);
1557 if (png_ptr->row_fn != NULL)
1558 (*(png_ptr->row_fn))(png_ptr,
row, png_ptr->row_number,
1559 (
int)png_ptr->pass);
1566 #ifdef PNG_USE_LOCAL_ARRAYS 1568 {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
1570 if (png_ptr == NULL)
return;
1571 if (new_row != NULL)
1577 png_progressive_info_ptr
info_fn, png_progressive_row_ptr
row_fn,
1578 png_progressive_end_ptr
end_fn)
1580 if (png_ptr == NULL)
return;
1582 png_ptr->row_fn =
row_fn;
1583 png_ptr->end_fn =
end_fn;
1591 if (png_ptr == NULL)
return (NULL);
1592 return png_ptr->io_ptr;
void png_push_read_IDAT(png_structp png_ptr)
#define PNG_READ_INTERLACING_SUPPORTED
PNG_CONST int FARDATA png_pass_start[]
png_bytep png_bytep new_row
void png_push_have_row(png_structp png_ptr, png_bytep row)
void png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define PNG_READ_DONE_MODE
int ZEXPORT inflateReset(z_streamp strm)
void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)
png_infop png_textp * text_ptr
void png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
void png_push_have_end(png_structp png_ptr, png_infop info_ptr)
png_voidp progressive_ptr
void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
#define PNG_COLOR_TYPE_PALETTE
void png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
PNG_CONST int FARDATA png_pass_yinc[]
void png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t png_size_t num_to_check
void PNGAPI png_progressive_combine_row(png_structp png_ptr, png_bytep old_row, png_bytep new_row)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
png_voidp png_progressive_info_ptr png_progressive_row_ptr row_fn
void png_do_read_transformations(png_structp png_ptr)
int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
void png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
PNG_CONST int FARDATA png_pass_ystart[]
png_voidp png_progressive_info_ptr info_fn
void png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_bytep png_bytep png_size_t length
png_voidp PNGAPI png_get_progressive_ptr(png_structp png_ptr)
#define PNG_READ_IDAT_MODE
void png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
#define PNG_READ_zTXt_MODE
void png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
#define PNG_TEXT_COMPRESSION_zTXt
void png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_push_save_buffer(png_structp png_ptr)
#define PNG_TEXT_COMPRESSION_NONE
png_struct FAR * png_structp
#define PNG_HANDLE_CHUNK_ALWAYS
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
void png_push_crc_finish(png_structp png_ptr)
#define PNG_READ_iTXt_MODE
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)
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)
PNG_CONST int FARDATA png_pass_dsp_mask[]
void png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
#define PNG_READ_USER_CHUNKS_SUPPORTED
void png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)
void png_read_push_finish_row(png_structp png_ptr)
png_voidp png_progressive_info_ptr png_progressive_row_ptr png_progressive_end_ptr end_fn
void png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
#define PNG_READ_CHUNK_MODE
int png_crc_finish(png_structp png_ptr, png_uint_32 skip)
void PNGAPI png_chunk_error(png_structp png_ptr, png_const_charp error_message)
void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
int png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)
png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf)
void png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)
void png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define PNG_READ_tEXt_MODE
PNG_CONST int FARDATA png_pass_inc[]
void png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)
png_voidp PNGAPI png_memcpy_check(png_structp png_ptr, png_voidp s1, png_voidp s2, png_uint_32 length)
png_infop png_bytep png_size_t buffer_size
png_infop png_bytep buffer
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)
void png_process_some_data(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
void png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_voidp PNGAPI png_memset_check(png_structp png_ptr, png_voidp s1, int value, png_uint_32 length)
void png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_push_process_row(png_structp png_ptr)
int ZEXPORT inflate(z_streamp strm, int flush)
void png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void PNGAPI png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)
unsigned long png_uint_32
#define PNG_READ_SIG_MODE
void png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
void png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
void png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
void png_push_have_info(png_structp png_ptr, png_infop info_ptr)
void png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
void png_reset_crc(png_structp png_ptr)