16 #define PNG_NO_PEDANTIC_WARNINGS 26 #ifdef PNG_USE_GLOBAL_ARRAYS 30 #ifdef PNG_READ_SUPPORTED 60 #ifdef PNG_READ_SUPPORTED 82 {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
86 = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
97 #ifdef PNG_READ_SUPPORTED 107 png_error(png_ptr,
"Too many bytes for PNG signature.");
109 png_ptr->sig_bytes = (
png_byte)(num_bytes < 0 ? 0 : num_bytes);
123 png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
124 if (num_to_check > 8)
126 else if (num_to_check < 1)
132 if (start + num_to_check > 8)
133 num_to_check = 8 -
start;
135 return ((
int)(
png_memcmp(&sig[start], &png_signature[start], num_to_check)));
138 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 151 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 173 png_warning (p,
"Potential overflow in png_zalloc()");
178 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
182 #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) 230 if (png_ptr->chunk_name[0] & 0x20)
232 if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
233 (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
238 if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
243 png_ptr->crc =
crc32(png_ptr->crc, ptr, (
uInt)length);
257 png_debug(1,
"in png_create_info_struct");
262 #ifdef PNG_USER_MEM_SUPPORTED 264 png_ptr->malloc_fn, png_ptr->mem_ptr);
268 if (info_ptr !=
NULL)
284 png_debug(1,
"in png_destroy_info_struct");
289 if (info_ptr_ptr !=
NULL)
292 if (info_ptr !=
NULL)
296 #ifdef PNG_USER_MEM_SUPPORTED 302 *info_ptr_ptr =
NULL;
310 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 327 if (info_ptr ==
NULL)
335 if (info_ptr ==
NULL)
343 #ifdef PNG_FREE_ME_SUPPORTED 350 if (png_ptr ==
NULL || info_ptr ==
NULL)
354 info_ptr->free_me |=
mask;
356 info_ptr->free_me &= ~mask;
359 "Unknown freer parameter in png_data_freer.");
369 if (png_ptr ==
NULL || info_ptr ==
NULL)
372 #ifdef PNG_TEXT_SUPPORTED 374 #ifdef PNG_FREE_ME_SUPPORTED 377 if (mask & PNG_FREE_TEXT)
382 if (info_ptr->text && info_ptr->text[num].key)
384 png_free(png_ptr, info_ptr->text[num].key);
385 info_ptr->text[
num].key =
NULL;
391 for (i = 0; i < info_ptr->num_text; i++)
394 info_ptr->text =
NULL;
395 info_ptr->num_text=0;
400 #ifdef PNG_tRNS_SUPPORTED 402 #ifdef PNG_FREE_ME_SUPPORTED 405 if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
409 info_ptr->trans =
NULL;
411 #ifndef PNG_FREE_ME_SUPPORTED 412 png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
417 #ifdef PNG_sCAL_SUPPORTED 419 #ifdef PNG_FREE_ME_SUPPORTED 422 if (mask & PNG_FREE_SCAL)
425 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) 426 png_free(png_ptr, info_ptr->scal_s_width);
427 png_free(png_ptr, info_ptr->scal_s_height);
428 info_ptr->scal_s_width =
NULL;
429 info_ptr->scal_s_height =
NULL;
435 #ifdef PNG_pCAL_SUPPORTED 437 #ifdef PNG_FREE_ME_SUPPORTED 440 if (mask & PNG_FREE_PCAL)
443 png_free(png_ptr, info_ptr->pcal_purpose);
444 png_free(png_ptr, info_ptr->pcal_units);
445 info_ptr->pcal_purpose =
NULL;
446 info_ptr->pcal_units =
NULL;
447 if (info_ptr->pcal_params !=
NULL)
450 for (i = 0; i < (
int)info_ptr->pcal_nparams; i++)
452 png_free(png_ptr, info_ptr->pcal_params[i]);
453 info_ptr->pcal_params[
i] =
NULL;
455 png_free(png_ptr, info_ptr->pcal_params);
456 info_ptr->pcal_params =
NULL;
462 #ifdef PNG_iCCP_SUPPORTED 464 #ifdef PNG_FREE_ME_SUPPORTED 467 if (mask & PNG_FREE_ICCP)
470 png_free(png_ptr, info_ptr->iccp_name);
471 png_free(png_ptr, info_ptr->iccp_profile);
472 info_ptr->iccp_name =
NULL;
473 info_ptr->iccp_profile =
NULL;
478 #ifdef PNG_sPLT_SUPPORTED 480 #ifdef PNG_FREE_ME_SUPPORTED 483 if (mask & PNG_FREE_SPLT)
488 if (info_ptr->splt_palettes)
490 png_free(png_ptr, info_ptr->splt_palettes[num].name);
491 png_free(png_ptr, info_ptr->splt_palettes[num].entries);
492 info_ptr->splt_palettes[
num].name =
NULL;
493 info_ptr->splt_palettes[
num].entries =
NULL;
498 if (info_ptr->splt_palettes_num)
501 for (i = 0; i < (
int)info_ptr->splt_palettes_num; i++)
504 png_free(png_ptr, info_ptr->splt_palettes);
505 info_ptr->splt_palettes =
NULL;
506 info_ptr->splt_palettes_num = 0;
513 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 514 if (png_ptr->unknown_chunk.data)
516 png_free(png_ptr, png_ptr->unknown_chunk.data);
517 png_ptr->unknown_chunk.data =
NULL;
520 #ifdef PNG_FREE_ME_SUPPORTED 523 if (mask & PNG_FREE_UNKN)
528 if (info_ptr->unknown_chunks)
530 png_free(png_ptr, info_ptr->unknown_chunks[num].data);
531 info_ptr->unknown_chunks[
num].data =
NULL;
538 if (info_ptr->unknown_chunks_num)
540 for (i = 0; i < (
int)info_ptr->unknown_chunks_num; i++)
543 png_free(png_ptr, info_ptr->unknown_chunks);
544 info_ptr->unknown_chunks =
NULL;
545 info_ptr->unknown_chunks_num = 0;
551 #ifdef PNG_hIST_SUPPORTED 553 #ifdef PNG_FREE_ME_SUPPORTED 556 if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
560 info_ptr->hist =
NULL;
562 #ifndef PNG_FREE_ME_SUPPORTED 563 png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
569 #ifdef PNG_FREE_ME_SUPPORTED 572 if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
576 info_ptr->palette =
NULL;
578 #ifndef PNG_FREE_ME_SUPPORTED 579 png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
581 info_ptr->num_palette = 0;
584 #ifdef PNG_INFO_IMAGE_SUPPORTED 586 #ifdef PNG_FREE_ME_SUPPORTED 589 if (mask & PNG_FREE_ROWS)
592 if (info_ptr->row_pointers)
595 for (row = 0; row < (
int)info_ptr->height; row++)
597 png_free(png_ptr, info_ptr->row_pointers[row]);
598 info_ptr->row_pointers[
row] =
NULL;
600 png_free(png_ptr, info_ptr->row_pointers);
601 info_ptr->row_pointers =
NULL;
607 #ifdef PNG_FREE_ME_SUPPORTED 609 info_ptr->free_me &= ~mask;
626 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 627 if (png_ptr->num_chunk_list)
629 png_free(png_ptr, png_ptr->chunk_list);
630 png_ptr->chunk_list =
NULL;
631 png_ptr->num_chunk_list = 0;
648 return (png_ptr->io_ptr);
651 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 652 #ifdef PNG_STDIO_SUPPORTED 671 #ifdef PNG_TIME_RFC1123_SUPPORTED 678 static PNG_CONST char short_months[12][4] =
679 {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
680 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
685 if (png_ptr->time_buffer ==
NULL)
693 wchar_t time_buf[29];
694 wsprintf(time_buf, TEXT(
"%d %S %d %02d:%02d:%02d +0000"),
695 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
696 ptime->year, ptime->hour % 24, ptime->minute % 60,
698 WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer,
702 #ifdef USE_FAR_KEYWORD 704 char near_time_buf[29];
705 png_snprintf6(near_time_buf, 29,
"%d %s %d %02d:%02d:%02d +0000",
706 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
707 ptime->year, ptime->hour % 24, ptime->minute % 60,
709 png_memcpy(png_ptr->time_buffer, near_time_buf,
713 png_snprintf6(png_ptr->time_buffer, 29,
"%d %s %d %02d:%02d:%02d +0000",
714 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
715 ptime->year, ptime->hour % 24, ptime->minute % 60,
719 return ((
png_charp)png_ptr->time_buffer);
729 #ifdef PNG_STRING_COPYRIGHT 730 return PNG_STRING_COPYRIGHT
735 "Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson" \
738 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
741 return ((
png_charp)
"libpng version 1.2.56 - December 17, 2015\ 742 Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson\ 743 Copyright (c) 1996-1997 Andreas Dilger\ 744 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
789 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 790 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 797 if (png_ptr ==
NULL || chunk_name ==
NULL || png_ptr->num_chunk_list<=0)
799 p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
800 for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
802 return ((
int)*(p + 4));
826 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) 838 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 843 png_convert_size(
size_t size)
852 #ifdef PNG_cHRM_SUPPORTED 853 #ifdef PNG_CHECK_cHRM_SUPPORTED 872 unsigned long *lo_product)
877 a = (v1 >> 16) & 0xffff;
879 c = (v2 >> 16) & 0xffff;
884 y = ((lo >> 16) & 0xffff) +
x;
886 lo = (lo & 0xffff) | ((y & 0xffff) << 16);
887 hi = (y >> 16) & 0xffff;
891 *hi_product = (
unsigned long)hi;
892 *lo_product = (
unsigned long)lo;
902 unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
904 png_debug(1,
"in function png_check_cHRM_fixed");
909 if (white_x < 0 || white_y <= 0 ||
910 red_x < 0 || red_y < 0 ||
911 green_x < 0 || green_y < 0 ||
912 blue_x < 0 || blue_y < 0)
915 "Ignoring attempt to set negative chromaticity value");
928 "Ignoring attempt to set chromaticity value exceeding 21474.83");
931 if (white_x > 100000L - white_y)
936 if (red_x > 100000L - red_y)
941 if (green_x > 100000L - green_y)
946 if (blue_x > 100000L - blue_y)
955 if (xy_hi == yx_hi && xy_lo == yx_lo)
958 "Ignoring attempt to set cHRM RGB triangle with zero area");
978 png_warning(png_ptr,
"Image width is zero in IHDR");
984 png_warning(png_ptr,
"Image height is zero in IHDR");
988 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 994 png_warning(png_ptr,
"Image width exceeds user limit in IHDR");
998 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 1004 png_warning(png_ptr,
"Image height exceeds user limit in IHDR");
1010 png_warning(png_ptr,
"Invalid image width in IHDR");
1016 png_warning(png_ptr,
"Invalid image height in IHDR");
1021 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
1022 bit_depth != 8 && bit_depth != 16)
1024 png_warning(png_ptr,
"Invalid bit depth in IHDR");
1028 if (color_type < 0 || color_type == 1 ||
1029 color_type == 5 || color_type > 6)
1031 png_warning(png_ptr,
"Invalid color type in IHDR");
1040 png_warning(png_ptr,
"Invalid color type/bit depth combination in IHDR");
1046 png_warning(png_ptr,
"Unknown interlace method in IHDR");
1052 png_warning(png_ptr,
"Unknown compression method in IHDR");
1056 #ifdef PNG_MNG_FEATURES_SUPPORTED 1066 if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) &&
1067 png_ptr->mng_features_permitted)
1068 png_warning(png_ptr,
"MNG features are not allowed in a PNG datastream");
1074 ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
1078 png_warning(png_ptr,
"Unknown filter method in IHDR");
1082 if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE)
1084 png_warning(png_ptr,
"Invalid filter method in IHDR");
1092 png_warning(png_ptr,
"Unknown filter method in IHDR");
1098 png_error(png_ptr,
"Invalid IHDR data");
GLenum GLuint GLenum GLsizei length
GLint GLint GLsizei GLsizei height
PNG_CONST char png_libpng_ver[18]
#define PNG_INTERLACE_LAST
#define PNG_USER_WIDTH_MAX
PNG_CONST int FARDATA png_pass_start[]
void png_zfree(voidpf png_ptr, voidpf ptr)
void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
png_voidp png_create_struct(int type)
GLboolean GLboolean GLboolean GLboolean a
void PNGAPI png_info_init(png_infop info_ptr)
GLfloat GLfloat GLfloat v2
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
png_infop double double double double double double double double * blue_y
png_infop double double double double double double double * blue_x
GLint GLint GLint GLint GLint GLint y
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
PNG_CONST int FARDATA png_pass_yinc[]
#define PNG_UNUSED(param)
#define PNG_LIBPNG_VER_STRING
png_size_t png_size_t num_to_check
int PNGAPI png_check_sig(png_bytep sig, int num)
png_charp PNGAPI png_get_libpng_ver(png_structp png_ptr)
GLint GLint GLsizei width
png_structp version_1_2_56
void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes)
GLint GLint GLint GLint GLint x
#define PNG_COLOR_TYPE_RGB_ALPHA
int ZEXPORT inflateReset(z_streamp strm)
int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
PNG_CONST int FARDATA png_pass_ystart[]
#define PNG_USER_HEIGHT_MAX
GLboolean GLboolean GLboolean b
png_infop double double double double * red_y
void PNGAPI png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
voidpf png_zalloc(voidpf png_ptr, uInt items, uInt size)
void png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
GLenum GLenum GLvoid * row
png_infop png_charpp int * compression_type
#define PNG_USER_WILL_FREE_DATA
void png_check_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
png_struct FAR * png_structp
#define png_error(s1, s2)
void png_info_destroy(png_structp png_ptr, png_infop info_ptr)
void png_destroy_struct(png_voidp struct_ptr)
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
int png_check_cHRM_fixed(png_structp png_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)
png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr)
PNG_CONST int FARDATA png_pass_dsp_mask[]
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
#define PNG_READ_SUPPORTED
int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
#define PNG_DESTROY_WILL_FREE_DATA
png_charp PNGAPI png_get_header_ver(png_structp png_ptr)
#define PNG_FLAG_MNG_FILTER_64
#define PNG_FILTER_TYPE_BASE
PNG_CONST int FARDATA png_pass_inc[]
PNG_CONST png_byte FARDATA png_sig[8]
png_voidp png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
PNG_CONST int FARDATA png_pass_mask[]
void PNGAPI png_data_freer(png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)
void png_64bit_product(long v1, long v2, unsigned long *hi_product, unsigned long *lo_product)
#define PNG_COMPRESSION_TYPE_BASE
png_charp PNGAPI png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#define PNG_HEADER_VERSION_STRING
png_infop double double double double double double * green_y
png_infop double double * white_y
png_size_t png_info_struct_size
png_int_32 png_fixed_point
png_infop double double double * red_x
void png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)
version_1_2_56 Your_png_h_is_not_version_1_2_56
int PNGAPI png_mmx_support(void)
#define PNG_INTRAPIXEL_DIFFERENCING
png_infop double double double double double * green_x
unsigned long png_uint_32
png_charp PNGAPI png_get_header_version(png_structp png_ptr)
png_charp PNGAPI png_get_copyright(png_structp png_ptr)
png_info FAR *FAR * png_infopp
int PNGAPI png_reset_zstream(png_structp png_ptr)
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
#define PNG_STRING_NEWLINE
png_infop double * white_x
void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
void png_reset_crc(png_structp png_ptr)
png_uint_32 PNGAPI png_access_version_number(void)