21 #ifdef PNG_USE_GLOBAL_ARRAYS 25 #ifdef PNG_READ_SUPPORTED 55 #ifdef PNG_READ_SUPPORTED 80 = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
91 #ifdef PNG_READ_SUPPORTED 95 if (png_ptr == NULL)
return;
98 png_error(png_ptr,
"Too many bytes for PNG signature.");
100 png_ptr->sig_bytes = (
png_byte)(num_bytes < 0 ? 0 : num_bytes);
114 png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
115 if (num_to_check > 8)
117 else if (num_to_check < 1)
123 if (start + num_to_check > 8)
124 num_to_check = 8 -
start;
126 return ((
int)(
png_memcmp(&sig[start], &png_signature[start], num_to_check)));
129 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 142 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 156 if (png_ptr == NULL)
return (NULL);
159 png_warning (p,
"Potential overflow in png_zalloc()");
164 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
168 #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) 216 if (png_ptr->chunk_name[0] & 0x20)
218 if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
219 (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
224 if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
229 png_ptr->crc =
crc32(png_ptr->crc, ptr, (
uInt)length);
243 png_debug(1,
"in png_create_info_struct\n");
244 if (png_ptr == NULL)
return (NULL);
245 #ifdef PNG_USER_MEM_SUPPORTED 247 png_ptr->malloc_fn, png_ptr->mem_ptr);
251 if (info_ptr != NULL)
266 if (png_ptr == NULL)
return;
268 png_debug(1,
"in png_destroy_info_struct\n");
269 if (info_ptr_ptr != NULL)
272 if (info_ptr != NULL)
276 #ifdef PNG_USER_MEM_SUPPORTED 282 *info_ptr_ptr = NULL;
290 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 305 if (info_ptr == NULL)
return;
320 #ifdef PNG_FREE_ME_SUPPORTED 326 if (png_ptr == NULL || info_ptr == NULL)
329 info_ptr->free_me |=
mask;
331 info_ptr->free_me &= ~mask;
334 "Unknown freer parameter in png_data_freer.");
343 if (png_ptr == NULL || info_ptr == NULL)
346 #if defined(PNG_TEXT_SUPPORTED) 348 #ifdef PNG_FREE_ME_SUPPORTED 351 if (mask & PNG_FREE_TEXT)
356 if (info_ptr->text && info_ptr->text[num].key)
358 png_free(png_ptr, info_ptr->text[num].key);
359 info_ptr->text[
num].key = NULL;
365 for (i = 0; i < info_ptr->num_text; i++)
368 info_ptr->text = NULL;
369 info_ptr->num_text=0;
374 #if defined(PNG_tRNS_SUPPORTED) 376 #ifdef PNG_FREE_ME_SUPPORTED 379 if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
383 info_ptr->trans = NULL;
385 #ifndef PNG_FREE_ME_SUPPORTED 386 png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
391 #if defined(PNG_sCAL_SUPPORTED) 393 #ifdef PNG_FREE_ME_SUPPORTED 396 if (mask & PNG_FREE_SCAL)
399 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) 400 png_free(png_ptr, info_ptr->scal_s_width);
401 png_free(png_ptr, info_ptr->scal_s_height);
402 info_ptr->scal_s_width = NULL;
403 info_ptr->scal_s_height = NULL;
409 #if defined(PNG_pCAL_SUPPORTED) 411 #ifdef PNG_FREE_ME_SUPPORTED 414 if (mask & PNG_FREE_PCAL)
417 png_free(png_ptr, info_ptr->pcal_purpose);
418 png_free(png_ptr, info_ptr->pcal_units);
419 info_ptr->pcal_purpose = NULL;
420 info_ptr->pcal_units = NULL;
421 if (info_ptr->pcal_params != NULL)
424 for (i = 0; i < (
int)info_ptr->pcal_nparams; i++)
426 png_free(png_ptr, info_ptr->pcal_params[i]);
427 info_ptr->pcal_params[
i]=NULL;
429 png_free(png_ptr, info_ptr->pcal_params);
430 info_ptr->pcal_params = NULL;
436 #if defined(PNG_iCCP_SUPPORTED) 438 #ifdef PNG_FREE_ME_SUPPORTED 441 if (mask & PNG_FREE_ICCP)
444 png_free(png_ptr, info_ptr->iccp_name);
445 png_free(png_ptr, info_ptr->iccp_profile);
446 info_ptr->iccp_name = NULL;
447 info_ptr->iccp_profile = NULL;
452 #if defined(PNG_sPLT_SUPPORTED) 454 #ifdef PNG_FREE_ME_SUPPORTED 457 if (mask & PNG_FREE_SPLT)
462 if (info_ptr->splt_palettes)
464 png_free(png_ptr, info_ptr->splt_palettes[num].name);
465 png_free(png_ptr, info_ptr->splt_palettes[num].entries);
466 info_ptr->splt_palettes[
num].name = NULL;
467 info_ptr->splt_palettes[
num].entries = NULL;
472 if (info_ptr->splt_palettes_num)
475 for (i = 0; i < (
int)info_ptr->splt_palettes_num; i++)
478 png_free(png_ptr, info_ptr->splt_palettes);
479 info_ptr->splt_palettes = NULL;
480 info_ptr->splt_palettes_num = 0;
487 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 488 if (png_ptr->unknown_chunk.data)
490 png_free(png_ptr, png_ptr->unknown_chunk.data);
491 png_ptr->unknown_chunk.data = NULL;
494 #ifdef PNG_FREE_ME_SUPPORTED 497 if (mask & PNG_FREE_UNKN)
502 if (info_ptr->unknown_chunks)
504 png_free(png_ptr, info_ptr->unknown_chunks[num].data);
505 info_ptr->unknown_chunks[
num].data = NULL;
512 if (info_ptr->unknown_chunks_num)
514 for (i = 0; i < (
int)info_ptr->unknown_chunks_num; i++)
517 png_free(png_ptr, info_ptr->unknown_chunks);
518 info_ptr->unknown_chunks = NULL;
519 info_ptr->unknown_chunks_num = 0;
525 #if defined(PNG_hIST_SUPPORTED) 527 #ifdef PNG_FREE_ME_SUPPORTED 530 if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
534 info_ptr->hist = NULL;
536 #ifndef PNG_FREE_ME_SUPPORTED 537 png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
543 #ifdef PNG_FREE_ME_SUPPORTED 546 if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
550 info_ptr->palette = NULL;
552 #ifndef PNG_FREE_ME_SUPPORTED 553 png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
555 info_ptr->num_palette = 0;
558 #if defined(PNG_INFO_IMAGE_SUPPORTED) 560 #ifdef PNG_FREE_ME_SUPPORTED 563 if (mask & PNG_FREE_ROWS)
566 if (info_ptr->row_pointers)
569 for (row = 0; row < (
int)info_ptr->height; row++)
571 png_free(png_ptr, info_ptr->row_pointers[row]);
572 info_ptr->row_pointers[
row]=NULL;
574 png_free(png_ptr, info_ptr->row_pointers);
575 info_ptr->row_pointers=NULL;
581 #ifdef PNG_FREE_ME_SUPPORTED 583 info_ptr->free_me &= ~mask;
600 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 601 if (png_ptr->num_chunk_list)
603 png_free(png_ptr, png_ptr->chunk_list);
604 png_ptr->chunk_list=NULL;
605 png_ptr->num_chunk_list = 0;
620 if (png_ptr == NULL)
return (NULL);
621 return (png_ptr->io_ptr);
624 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 625 #if !defined(PNG_NO_STDIO) 636 if (png_ptr == NULL)
return;
641 #if defined(PNG_TIME_RFC1123_SUPPORTED) 648 static PNG_CONST char short_months[12][4] =
649 {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
650 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
652 if (png_ptr == NULL)
return (NULL);
653 if (png_ptr->time_buffer == NULL)
659 #if defined(_WIN32_WCE) 661 wchar_t time_buf[29];
662 wsprintf(time_buf, TEXT(
"%d %S %d %02d:%02d:%02d +0000"),
663 ptime->day % 32, short_months[(ptime->month - 1) % 12],
664 ptime->year, ptime->hour % 24, ptime->minute % 60,
666 WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
670 #ifdef USE_FAR_KEYWORD 672 char near_time_buf[29];
673 png_snprintf6(near_time_buf, 29,
"%d %s %d %02d:%02d:%02d +0000",
674 ptime->day % 32, short_months[(ptime->month - 1) % 12],
675 ptime->year, ptime->hour % 24, ptime->minute % 60,
677 png_memcpy(png_ptr->time_buffer, near_time_buf,
681 png_snprintf6(png_ptr->time_buffer, 29,
"%d %s %d %02d:%02d:%02d +0000",
682 ptime->day % 32, short_months[(ptime->month - 1) % 12],
683 ptime->year, ptime->hour % 24, ptime->minute % 60,
687 return ((
png_charp)png_ptr->time_buffer);
697 return ((
png_charp)
"\n libpng version 1.2.32 - September 18, 2008\n\ 698 Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\ 699 Copyright (c) 1996-1997 Andreas Dilger\n\ 700 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
739 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 740 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 747 if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
749 p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
750 for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
752 return ((
int)*(p + 4));
775 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) 776 #if !defined(PNG_1_0_X) 787 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 792 png_convert_size(
size_t size)
PNG_CONST char png_libpng_ver[18]
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)
void PNGAPI png_info_init(png_infop info_ptr)
int ZEXPORT inflateReset(z_streamp strm)
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
png_structp version_1_2_32
PNG_CONST int FARDATA png_pass_yinc[]
#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)
void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes)
int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
PNG_CONST int FARDATA png_pass_ystart[]
png_bytep png_bytep png_size_t length
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)
#define PNG_USER_WILL_FREE_DATA
png_struct FAR * png_structp
void png_info_destroy(png_structp png_ptr, png_infop info_ptr)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, unsigned len)
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
void png_destroy_struct(png_voidp struct_ptr)
png_infop int png_uint_32 mask
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr)
PNG_CONST int FARDATA png_pass_dsp_mask[]
#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)
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)
png_charp PNGAPI png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#define PNG_HEADER_VERSION_STRING
png_size_t png_info_struct_size
void png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)
int PNGAPI png_mmx_support(void)
version_1_2_32 Your_png_h_is_not_version_1_2_32
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)
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)