33 #if defined(_WIN32_WCE) 35 __error__ (
f|w)printf functions are not supported on old WindowsCE.;
39 # define READFILE(file, data, length, check) \ 40 if (ReadFile(file, data, length, &check, NULL)) check = 0 41 # define WRITEFILE(file, data, length, check)) \ 42 if (WriteFile(file, data, length, &check, NULL)) check = 0 43 # define FCLOSE(file) CloseHandle(file) 47 # define READFILE(file, data, length, check) \ 48 check=(png_size_t)fread(data, (png_size_t)1, length, file) 49 # define WRITEFILE(file, data, length, check) \ 50 check=(png_size_t)fwrite(data, (png_size_t)1, length, file) 51 # define FCLOSE(file) fclose(file) 54 #if defined(PNG_NO_STDIO) 55 # if defined(_WIN32_WCE) 68 # define SINGLE_ROWBUF_ALLOC 75 #ifdef PNG_NO_FLOATING_POINT_SUPPORTED 80 static float t_start, t_stop, t_decode, t_encode, t_misc;
84 #if defined(PNG_TIME_RFC1123_SUPPORTED) 85 #define PNG_tIME_STRING_LENGTH 29 100 #define STDERR stdout 109 # define png_jmpbuf(png_ptr) png_ptr->jmpbuf 129 if (status_pass != pass)
131 fprintf(stdout,
"\n Pass %d: ", pass);
136 if (status_dots == 0)
138 fprintf(stdout,
"\n ");
141 fprintf(stdout,
"r");
155 if (png_ptr == NULL || row_number >
PNG_UINT_31_MAX || pass > 7)
return;
156 fprintf(stdout,
"w");
160 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 176 if (png_ptr != NULL && row_info != NULL)
177 ++filters_used[*(data - 1)];
181 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 199 if (png_ptr == NULL)
return;
213 if (row_info->color_type == 0 || row_info->color_type == 3)
217 for (n = 0, nstop=row_info->width; n<nstop; n++)
219 if (row_info->bit_depth == 1)
221 if (((*dp << pos++ ) & 0x80) == 0) zero_samples++;
228 if (row_info->bit_depth == 2)
230 if (((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++;
237 if (row_info->bit_depth == 4)
239 if (((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++;
246 if (row_info->bit_depth == 8)
247 if (*dp++ == 0) zero_samples++;
248 if (row_info->bit_depth == 16)
250 if ((*dp | *(dp+1)) == 0) zero_samples++;
259 int color_channels = row_info->channels;
260 if (row_info->color_type > 3)color_channels--;
262 for (n = 0, nstop=row_info->width; n<nstop; n++)
264 for (channel = 0; channel < color_channels; channel++)
266 if (row_info->bit_depth == 8)
267 if (*dp++ == 0) zero_samples++;
268 if (row_info->bit_depth == 16)
270 if ((*dp | *(dp+1)) == 0) zero_samples++;
274 if (row_info->color_type > 3)
277 if (row_info->bit_depth == 16)dp++;
286 #if defined(PNG_NO_STDIO) 295 #ifndef USE_FAR_KEYWORD 304 READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check);
317 #define NEAR_BUF_SIZE 1024 318 #define MIN(a,b) (a <= b ? a : b) 332 READFILE(io_ptr, n_data, length, check);
342 read =
MIN(NEAR_BUF_SIZE, remaining);
352 while (remaining != 0);
361 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 365 #if !defined(_WIN32_WCE) 378 #ifndef USE_FAR_KEYWORD 384 WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check);
396 #define NEAR_BUF_SIZE 1024 397 #define MIN(a,b) (a <= b ? a : b) 411 WRITEFILE(io_ptr, near_data, length, check);
421 written =
MIN(NEAR_BUF_SIZE, remaining);
429 remaining -= written;
431 while (remaining != 0);
449 if (png_ptr != NULL && png_ptr->error_ptr != NULL)
450 name = png_ptr->error_ptr;
451 fprintf(
STDERR,
"%s: libpng warning: %s\n", name, message);
462 pngtest_warning(png_ptr, message);
470 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 480 typedef struct memory_information
484 struct memory_information FAR *next;
485 } memory_information;
486 typedef memory_information
FAR *memory_infop;
488 static memory_infop pinformation = NULL;
489 static int current_allocation = 0;
490 static int maximum_allocation = 0;
491 static int total_allocation = 0;
492 static int num_allocations = 0;
516 current_allocation +=
size;
517 total_allocation +=
size;
519 if (current_allocation > maximum_allocation)
520 maximum_allocation = current_allocation;
525 (png_free_ptr)png_debug_free);
526 if (size != 0 && pinfo->pointer == NULL)
528 current_allocation -=
size;
529 total_allocation -=
size;
531 "out of memory in pngtest->png_debug_malloc.");
533 pinfo->next = pinformation;
534 pinformation = pinfo;
536 png_memset(pinfo->pointer, 0xdd, pinfo->size);
538 printf(
"png_malloc %lu bytes at %x\n", (
unsigned long)size,
549 fprintf(
STDERR,
"NULL pointer to png_debug_free.\n");
553 fprintf(
STDERR,
"WARNING: freeing NULL pointer\n");
560 memory_infop
FAR *ppinfo = &pinformation;
563 memory_infop pinfo = *ppinfo;
564 if (pinfo->pointer == ptr)
566 *ppinfo = pinfo->next;
567 current_allocation -= pinfo->size;
568 if (current_allocation < 0)
569 fprintf(
STDERR,
"Duplicate free of memory\n");
577 if (pinfo->next == NULL)
579 fprintf(
STDERR,
"Pointer %x not found\n", (
unsigned int)ptr);
582 ppinfo = &pinfo->next;
588 printf(
"Freeing %x\n", ptr);
597 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 629 if (chunk->name[0] == 115 && chunk->name[1] == 84 &&
630 chunk->name[2] == 69 && chunk->name[3] == 82)
633 if (chunk->size != 1)
635 if (chunk->data[0] != 0 && chunk->data[0] != 1)
638 user_chunk_data[0]=chunk->data[0]+1;
641 if (chunk->name[0] != 118 || chunk->name[1] != 112 ||
642 chunk->name[2] != 65 || chunk->name[3] != 103)
647 if (chunk->size != 9)
666 static png_FILE_p fpin;
667 static png_FILE_p fpout;
670 #ifdef PNG_WRITE_SUPPORTED 684 #ifdef PNG_SETJMP_SUPPORTED 685 #ifdef USE_FAR_KEYWORD 690 #if defined(_WIN32_WCE) 691 TCHAR
path[MAX_PATH];
693 char inbuf[256], outbuf[256];
697 #if defined(_WIN32_WCE) 698 MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
699 if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
701 if ((fpin = fopen(inname,
"rb")) == NULL)
704 fprintf(
STDERR,
"Could not find input file %s\n", inname);
708 #if defined(_WIN32_WCE) 709 MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
710 if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE)
712 if ((fpout = fopen(outname,
"wb")) == NULL)
715 fprintf(
STDERR,
"Could not open output file %s\n", outname);
720 png_debug(0,
"Allocating read and write structures\n");
721 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 725 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
731 #if defined(PNG_NO_STDIO) 736 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 737 user_chunk_data[0] = 0;
738 user_chunk_data[1] = 0;
739 user_chunk_data[2] = 0;
740 user_chunk_data[3] = 0;
745 #ifdef PNG_WRITE_SUPPORTED 746 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 750 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
756 #if defined(PNG_NO_STDIO) 761 png_debug(0,
"Allocating read_info, write_info and end_info structures\n");
764 #ifdef PNG_WRITE_SUPPORTED 769 #ifdef PNG_SETJMP_SUPPORTED 770 png_debug(0,
"Setting jmpbuf for read struct\n");
771 #ifdef USE_FAR_KEYWORD 777 fprintf(
STDERR,
"%s -> %s: libpng read error\n", inname, outname);
781 #ifdef PNG_WRITE_SUPPORTED 789 #ifdef USE_FAR_KEYWORD 793 #ifdef PNG_WRITE_SUPPORTED 794 png_debug(0,
"Setting jmpbuf for write struct\n");
795 #ifdef USE_FAR_KEYWORD 801 fprintf(
STDERR,
"%s -> %s: libpng write error\n", inname, outname);
804 #ifdef PNG_WRITE_SUPPORTED 811 #ifdef USE_FAR_KEYWORD 817 png_debug(0,
"Initializing input and output streams\n");
818 #if !defined(PNG_NO_STDIO) 820 # ifdef PNG_WRITE_SUPPORTED 825 # ifdef PNG_WRITE_SUPPORTED 834 if (status_dots_requested == 1)
836 #ifdef PNG_WRITE_SUPPORTED 843 #ifdef PNG_WRITE_SUPPORTED 849 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 852 for (i = 0; i<256; i++)
857 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 862 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) 863 # ifndef PNG_HANDLE_CHUNK_ALWAYS 864 # define PNG_HANDLE_CHUNK_ALWAYS 3 869 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 870 # ifndef PNG_HANDLE_CHUNK_IF_SAFE 871 # define PNG_HANDLE_CHUNK_IF_SAFE 2 880 png_debug(0,
"Transferring info struct\n");
884 if (
png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,
885 &color_type, &interlace_type, &compression_type, &filter_type))
887 png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
889 color_type, interlace_type, compression_type, filter_type);
895 #if defined(PNG_FIXED_POINT_SUPPORTED) 896 #if defined(PNG_cHRM_SUPPORTED) 901 &red_y, &green_x, &green_y, &blue_x, &blue_y))
904 red_y, green_x, green_y, blue_x, blue_y);
908 #if defined(PNG_gAMA_SUPPORTED) 919 #if defined(PNG_FLOATING_POINT_SUPPORTED) 920 #if defined(PNG_cHRM_SUPPORTED) 924 if (
png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
925 &red_y, &green_x, &green_y, &blue_x, &blue_y))
927 png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
928 red_y, green_x, green_y, blue_x, blue_y);
932 #if defined(PNG_gAMA_SUPPORTED) 944 #if defined(PNG_iCCP_SUPPORTED) 951 if (
png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
954 png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
959 #if defined(PNG_sRGB_SUPPORTED) 973 if (
png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
975 png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
978 #if defined(PNG_bKGD_SUPPORTED) 988 #if defined(PNG_hIST_SUPPORTED) 998 #if defined(PNG_oFFs_SUPPORTED) 1003 if (
png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
1006 png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
1010 #if defined(PNG_pCAL_SUPPORTED) 1017 if (
png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
1018 &nparams, &units, ¶ms))
1020 png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
1021 nparams, units, params);
1025 #if defined(PNG_pHYs_SUPPORTED) 1030 if (
png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
1032 png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
1036 #if defined(PNG_sBIT_SUPPORTED) 1046 #if defined(PNG_sCAL_SUPPORTED) 1047 #ifdef PNG_FLOATING_POINT_SUPPORTED 1050 double scal_width, scal_height;
1052 if (
png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
1055 png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
1059 #ifdef PNG_FIXED_POINT_SUPPORTED 1064 if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
1067 png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height);
1073 #if defined(PNG_TEXT_SUPPORTED) 1078 if (
png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
1080 png_debug1(0,
"Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
1081 png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
1085 #if defined(PNG_tIME_SUPPORTED) 1092 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1099 tIME_string[
png_sizeof(tIME_string) - 1] =
'\0';
1100 tIME_chunk_present++;
1105 #if defined(PNG_tRNS_SUPPORTED) 1111 if (
png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
1114 int sample_max = (1 << read_info_ptr->bit_depth);
1117 (
int)trans_values->gray > sample_max) ||
1119 ((
int)trans_values->red > sample_max ||
1120 (
int)trans_values->green > sample_max ||
1121 (
int)trans_values->blue > sample_max))))
1122 png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
1127 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 1140 for (i = 0; i < (
png_size_t)num_unknowns; i++)
1147 #ifdef PNG_WRITE_SUPPORTED 1148 png_debug(0,
"\nWriting info struct\n");
1155 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 1156 if (user_chunk_data[0] != 0)
1158 png_byte png_sTER[5] = {115, 84, 69, 82,
'\0'};
1164 fprintf(
STDERR,
"stereo mode = %lu\n",
1165 (
unsigned long)(user_chunk_data[0] - 1));
1166 ster_chunk_data[0]=(
unsigned char)(user_chunk_data[0] - 1);
1169 if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
1171 png_byte png_vpAg[5] = {118, 112, 65, 103,
'\0'};
1177 fprintf(
STDERR,
"vpAg = %lu x %lu, units=%lu\n",
1178 (
unsigned long)user_chunk_data[1],
1179 (
unsigned long)user_chunk_data[2],
1180 (
unsigned long)user_chunk_data[3]);
1183 vpag_chunk_data[8] = (
unsigned char)(user_chunk_data[3] & 0xff);
1190 #ifdef SINGLE_ROWBUF_ALLOC 1191 png_debug(0,
"\nAllocating row buffer...");
1194 png_debug1(0,
"0x%08lx\n\n", (
unsigned long)row_buf);
1198 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ 1199 defined(PNG_WRITE_INTERLACING_SUPPORTED) 1201 # ifdef PNG_WRITE_SUPPORTED 1208 #ifdef PNGTEST_TIMING 1209 t_stop = (float)clock();
1210 t_misc += (t_stop - t_start);
1213 for (pass = 0; pass < num_pass; pass++)
1215 png_debug1(0,
"Writing row data for pass %d\n", pass);
1216 for (y = 0; y <
height; y++)
1218 #ifndef SINGLE_ROWBUF_ALLOC 1219 png_debug2(0,
"\nAllocating row buffer (pass %d, y = %ld)...", pass, y);
1222 png_debug2(0,
"0x%08lx (%ld bytes)\n", (
unsigned long)row_buf,
1227 #ifdef PNG_WRITE_SUPPORTED 1228 #ifdef PNGTEST_TIMING 1229 t_stop = (float)clock();
1230 t_decode += (t_stop - t_start);
1234 #ifdef PNGTEST_TIMING 1235 t_stop = (float)clock();
1236 t_encode += (t_stop - t_start);
1241 #ifndef SINGLE_ROWBUF_ALLOC 1242 png_debug2(0,
"Freeing row buffer (pass %d, y = %ld)\n\n", pass, y);
1249 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) 1252 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 1256 png_debug(0,
"Reading and writing end_info data\n");
1259 #if defined(PNG_TEXT_SUPPORTED) 1264 if (
png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
1266 png_debug1(0,
"Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
1267 png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
1271 #if defined(PNG_tIME_SUPPORTED) 1278 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1285 tIME_string[
png_sizeof(tIME_string) - 1] =
'\0';
1286 tIME_chunk_present++;
1291 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 1305 for (i = 0; i < (
png_size_t)num_unknowns; i++)
1311 #ifdef PNG_WRITE_SUPPORTED 1315 #ifdef PNG_EASY_ACCESS_SUPPORTED 1321 fprintf(
STDERR,
"Image width = %lu, height = %lu\n",
1322 (
unsigned long)iwidth, (
unsigned long)iheight);
1326 png_debug(0,
"Destroying data structs\n");
1327 #ifdef SINGLE_ROWBUF_ALLOC 1328 png_debug(1,
"destroying row_buf for read_ptr\n");
1332 png_debug(1,
"destroying read_ptr, read_info_ptr, end_info_ptr\n");
1334 #ifdef PNG_WRITE_SUPPORTED 1335 png_debug(1,
"destroying write_end_info_ptr\n");
1337 png_debug(1,
"destroying write_ptr, write_info_ptr\n");
1340 png_debug(0,
"Destruction complete.\n");
1345 png_debug(0,
"Opening files for comparison\n");
1346 #if defined(_WIN32_WCE) 1347 MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
1348 if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
1350 if ((fpin = fopen(inname,
"rb")) == NULL)
1353 fprintf(
STDERR,
"Could not find file %s\n", inname);
1357 #if defined(_WIN32_WCE) 1358 MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
1359 if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
1361 if ((fpout = fopen(outname,
"rb")) == NULL)
1364 fprintf(
STDERR,
"Could not find file %s\n", outname);
1374 READFILE(fpout, outbuf, 1, num_out);
1376 if (num_in != num_out)
1378 fprintf(
STDERR,
"\nFiles %s and %s are of a different size\n",
1380 if (wrote_question == 0)
1383 " Was %s written with the same maximum IDAT chunk size (%d bytes),",
1386 "\n filtering heuristic (libpng default), compression");
1388 " level (zlib default),\n and zlib version (%s)?\n\n",
1402 fprintf(
STDERR,
"\nFiles %s and %s are different\n", inname, outname);
1403 if (wrote_question == 0)
1406 " Was %s written with the same maximum IDAT chunk size (%d bytes),",
1409 "\n filtering heuristic (libpng default), compression");
1411 " level (zlib default),\n and zlib version (%s)?\n\n",
1446 fprintf(
STDERR,
" library (%lu):%s",
1452 fprintf(
STDERR,
" sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
1459 #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) 1460 fprintf(
STDERR,
" NOTE: Zlib compiled for max 64k, libpng not\n");
1463 #if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) 1464 fprintf(
STDERR,
" NOTE: libpng compiled for max 64k, zlib not\n");
1470 "Warning: versions are different between png.h and png.c\n");
1478 if (strcmp(argv[1],
"-m") == 0)
1481 status_dots_requested = 0;
1483 else if (strcmp(argv[1],
"-mv") == 0 ||
1484 strcmp(argv[1],
"-vm") == 0 )
1488 status_dots_requested = 1;
1490 else if (strcmp(argv[1],
"-v") == 0)
1493 status_dots_requested = 1;
1499 status_dots_requested = 0;
1503 if (!multiple && argc == 3 + verbose)
1506 if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))
1509 "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
1512 " reads/writes one PNG file (without -m) or multiple files (-m)\n");
1514 " with -m %s is used as a temporary file\n", outname);
1521 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1522 int allocation_now = current_allocation;
1524 for (i=2; i<argc; ++
i)
1526 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1530 fprintf(
STDERR,
"Testing %s:", argv[i]);
1534 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1535 fprintf(
STDERR,
"\n PASS (%lu zero samples)\n",
1536 (
unsigned long)zero_samples);
1538 fprintf(
STDERR,
" PASS\n");
1540 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1541 for (k = 0; k<256; k++)
1542 if (filters_used[k])
1543 fprintf(
STDERR,
" Filter %d was used %lu times\n",
1544 k, (
unsigned long)filters_used[k]);
1546 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1547 if (tIME_chunk_present != 0)
1548 fprintf(
STDERR,
" tIME = %s\n", tIME_string);
1549 tIME_chunk_present = 0;
1554 fprintf(
STDERR,
" FAIL\n");
1557 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1558 if (allocation_now != current_allocation)
1559 fprintf(
STDERR,
"MEMORY ERROR: %d bytes lost\n",
1560 current_allocation - allocation_now);
1561 if (current_allocation != 0)
1563 memory_infop pinfo = pinformation;
1565 fprintf(
STDERR,
"MEMORY ERROR: %d bytes still allocated\n",
1566 current_allocation);
1567 while (pinfo != NULL)
1569 fprintf(
STDERR,
" %lu bytes at %x\n",
1570 (
unsigned long)pinfo->size,
1571 (
unsigned int) pinfo->pointer);
1572 pinfo = pinfo->next;
1577 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1578 fprintf(
STDERR,
" Current memory allocation: %10d bytes\n",
1579 current_allocation);
1580 fprintf(
STDERR,
" Maximum memory allocation: %10d bytes\n",
1581 maximum_allocation);
1582 fprintf(
STDERR,
" Total memory allocation: %10d bytes\n",
1584 fprintf(
STDERR,
" Number of allocations: %10d\n",
1591 for (i = 0; i<3; ++
i)
1594 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1595 int allocation_now = current_allocation;
1597 if (i == 1) status_dots_requested = 1;
1598 else if (verbose == 0)status_dots_requested = 0;
1599 if (i == 0 || verbose == 1 || ierror != 0)
1600 fprintf(
STDERR,
"Testing %s:", inname);
1604 if (verbose == 1 || i == 2)
1606 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1609 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 1610 fprintf(
STDERR,
"\n PASS (%lu zero samples)\n",
1611 (
unsigned long)zero_samples);
1613 fprintf(
STDERR,
" PASS\n");
1615 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1616 for (k = 0; k<256; k++)
1617 if (filters_used[k])
1618 fprintf(
STDERR,
" Filter %d was used %lu times\n",
1620 (
unsigned long)filters_used[k]);
1622 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1623 if (tIME_chunk_present != 0)
1624 fprintf(
STDERR,
" tIME = %s\n", tIME_string);
1630 if (verbose == 0 && i != 2)
1631 fprintf(
STDERR,
"Testing %s:", inname);
1632 fprintf(
STDERR,
" FAIL\n");
1635 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1636 if (allocation_now != current_allocation)
1637 fprintf(
STDERR,
"MEMORY ERROR: %d bytes lost\n",
1638 current_allocation - allocation_now);
1639 if (current_allocation != 0)
1641 memory_infop pinfo = pinformation;
1643 fprintf(
STDERR,
"MEMORY ERROR: %d bytes still allocated\n",
1644 current_allocation);
1645 while (pinfo != NULL)
1647 fprintf(
STDERR,
" %lu bytes at %x\n",
1648 (
unsigned long)pinfo->size, (
unsigned int)pinfo->pointer);
1649 pinfo = pinfo->next;
1654 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1655 fprintf(
STDERR,
" Current memory allocation: %10d bytes\n",
1656 current_allocation);
1657 fprintf(
STDERR,
" Maximum memory allocation: %10d bytes\n",
1658 maximum_allocation);
1659 fprintf(
STDERR,
" Total memory allocation: %10d bytes\n",
1661 fprintf(
STDERR,
" Number of allocations: %10d\n",
1666 #ifdef PNGTEST_TIMING 1667 t_stop = (float)clock();
1668 t_misc += (t_stop - t_start);
1670 fprintf(
STDERR,
" CPU time used = %.3f seconds",
1671 (t_misc+t_decode+t_encode)/(
float)CLOCKS_PER_SEC);
1672 fprintf(
STDERR,
" (decoding %.3f,\n",
1673 t_decode/(
float)CLOCKS_PER_SEC);
1674 fprintf(
STDERR,
" encoding %.3f ,",
1675 t_encode/(
float)CLOCKS_PER_SEC);
1676 fprintf(
STDERR,
" other %.3f seconds)\n\n",
1677 t_misc/(
float)CLOCKS_PER_SEC);
1681 fprintf(
STDERR,
"libpng passes test\n");
1683 fprintf(
STDERR,
"libpng FAILS test\n");
1684 return (
int)(ierror != 0);
void PNGAPI png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_charp name, int compression_type, png_charp profile, png_uint_32 proflen)
png_infop png_charpp int png_charpp profile
png_uint_32 PNGAPI png_get_image_width(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_write_chunk(png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length)
png_infop png_charpp int png_charpp png_uint_32 * proflen
static int wrote_question
#define png_write_status_ptr_NULL
PNG_CONST char png_libpng_ver[18]
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)
png_infop png_uint_32 * res_x
png_infop png_charp png_int_32 png_int_32 int int png_charp * units
png_unknown_chunk FAR * png_unknown_chunkp
png_uint_32 PNGAPI png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values)
void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
void PNGAPI 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)
png_uint_32 PNGAPI png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
void PNGAPI png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
png_uint_32 PNGAPI png_get_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_cHRM(png_structp png_ptr, png_infop info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)
png_uint_32 PNGAPI png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
png_infop png_charp png_int_32 png_int_32 int * type
png_infop png_uint_32 png_uint_32 * res_y
png_uint_32 PNGAPI png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp unknowns)
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
png_infop double double double double double double double double * blue_y
void PNGAPI png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
png_infop png_textp * text_ptr
png_colorp int num_palette
png_infop double double double double double double double * blue_x
#define png_error_ptr_NULL
#define PNG_INTERLACE_NONE
static png_uint_32 zero_samples
png_color_16 FAR * png_color_16p
void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
#define PNG_COLOR_TYPE_RGB
png_structp version_1_2_32
void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
void PNGAPI png_write_rows(png_structp png_ptr, png_bytepp row, png_uint_32 num_rows)
png_infop png_color_16p * background
png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
png_infop png_charp png_int_32 png_int_32 * X1
void PNGAPI png_read_rows(png_structp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)
png_infop png_charpp name
#define PNG_LIBPNG_VER_STRING
void count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
#define PNG_WRITE_FLUSH_SUPPORTED
void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
png_infop png_charp png_int_32 png_int_32 int int png_charp png_charpp * params
png_infop png_int_32 png_int_32 * offset_y
png_infop png_unknown_chunkp int num_unknowns
#define MIN(a, b)
Returns the min value between a and b.
png_infop png_int_32 * offset_x
PNG_CONST char FAR * png_const_charp
static PNG_CONST char * inname
void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
void PNGAPI png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, double height)
png_bytep png_bytep png_size_t length
void PNGAPI png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, int chunk, int location)
png_infop double double double double * red_y
#define CVT_PTR_NOCHECK(ptr)
void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
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_infop png_bytep * trans
void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit)
void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
#define PNG_WRITE_INTERLACING_SUPPORTED
static int status_dots_requested
png_infop png_charp png_int_32 * X0
png_infop png_uint_32 * width
png_uint_32 PNGAPI png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point *int_file_gamma)
png_uint_32 PNGAPI png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text)
png_uint_32 PNGAPI png_get_sCAL(png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height)
png_infop png_bytep int png_color_16p * trans_values
void count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
png_byte FAR *FAR * png_bytepp
png_infop png_charpp int * compression_type
static png_uint_32 user_chunk_data[4]
void PNGAPI png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr write_user_transform_fn)
png_infop png_uint_16p * hist
png_uint_32 PNGAPI png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#define png_read_status_ptr_NULL
png_struct FAR * png_structp
void PNGAPI png_write_info(png_structp png_ptr, png_infop info_ptr)
#define PNG_HANDLE_CHUNK_ALWAYS
void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr)
png_uint_32 PNGAPI png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette)
void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message)
#define READFILE(file, data, length, check)
png_uint_32 PNGAPI png_get_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)
png_infop png_uint_32 png_uint_32 * height
png_uint_32 PNGAPI png_get_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)
int main(int argc, char *argv[])
void PNGAPI png_set_cHRM(png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)
void PNGAPI png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
png_infop png_bytep int * num_trans
#define PNG_COLOR_TYPE_GRAY
void PNGAPI png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
png_uint_16 FAR * png_uint_16p
png_structp PNGAPI png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette)
static PNG_CONST char * outname
#define png_debug1(l, m, p1)
#define png_jmpbuf(png_ptr)
void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr)
png_infop int int location
void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)
void PNGAPI png_save_uint_32(png_bytep buf, png_uint_32 i)
png_infop png_uint_32 png_uint_32 int * bit_depth
#define PNG_HANDLE_CHUNK_IF_SAFE
png_uint_32 PNGAPI png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, png_charpp profile, png_uint_32 *proflen)
static png_uint_32 filters_used[256]
png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf)
png_uint_32 PNGAPI png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)
png_infop png_textp int * num_text
png_structp PNGAPI png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname))
png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
png_infop png_charp * purpose
void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr)
png_charp PNGAPI png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
#define PNG_HEADER_VERSION_STRING
png_infop png_uint_32 png_uint_32 int int * color_type
png_infop double double double double double double * green_y
png_infop double double * white_y
version_1_2_32 your_png_h_is_not_version_1_2_32
png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background)
png_infop png_charp png_int_32 png_int_32 int int * nparams
void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_color_8 FAR * png_color_8p
int PNGAPI png_set_interlace_handling(png_structp png_ptr)
png_int_32 png_fixed_point
png_infop double double double * red_x
char FAR *FAR * png_charpp
#define WRITEFILE(file, data, length, check)
static char tIME_string[PNG_tIME_STRING_LENGTH]
png_structp PNGAPI png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
png_infop png_int_32 png_int_32 int * unit_type
void PNGAPI png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)
void PNGAPI png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)
png_uint_32 PNGAPI png_get_image_height(png_structp png_ptr, png_infop info_ptr)
static int read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values)
void PNGAPI png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn)
png_infop double double double double double * green_x
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)
unsigned long png_uint_32
png_row_info FAR * png_row_infop
png_charp PNGAPI png_get_header_version(png_structp png_ptr)
png_uint_32 PNGAPI png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
png_charp PNGAPI png_get_copyright(png_structp png_ptr)
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
#define png_debug2(l, m, p1, p2)
png_uint_32 PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
png_voidp PNGAPI png_get_user_chunk_ptr(png_structp png_ptr)
png_infop double * white_x
static int tIME_chunk_present
png_infop png_timep * mod_time
#define PNG_tIME_STRING_LENGTH
void PNGAPI png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)
png_uint_32 PNGAPI png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp)
void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
void PNGAPI png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
void PNGAPI png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
png_infop png_unknown_chunkp unknowns
void PNGAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point int_gamma)
png_infop png_color_8p * sig_bit
png_uint_32 PNGAPI png_access_version_number(void)
png_color FAR * png_colorp