34 #define PNG_PEDANTIC_WARNINGS 39 __error__ (
f|
w)printf functions are not supported on old WindowsCE.;
43 # define READFILE(file, data, length, check) \ 44 if (ReadFile(file, data, length, &check, NULL)) check = 0 45 # define WRITEFILE(file, data, length, check)) \ 46 if (WriteFile(file, data, length, &check, NULL)) check = 0 47 # define FCLOSE(file) CloseHandle(file) 51 # define READFILE(file, data, length, check) \ 52 check=(png_size_t)fread(data, (png_size_t)1, length, file) 53 # define WRITEFILE(file, data, length, check) \ 54 check=(png_size_t)fwrite(data, (png_size_t)1, length, file) 55 # define FCLOSE(file) fclose(file) 58 #ifndef PNG_STDIO_SUPPORTED 72 # define SINGLE_ROWBUF_ALLOC 79 #ifndef PNG_FLOATING_POINT_SUPPORTED 84 static float t_start, t_stop, t_decode, t_encode, t_misc;
88 #ifdef PNG_TIME_RFC1123_SUPPORTED 89 #define PNG_tIME_STRING_LENGTH 29 90 static int tIME_chunk_present = 0;
94 static int verbose = 0;
104 #define STDERR stdout 113 # define png_jmpbuf(png_ptr) png_ptr->jmpbuf 117 static int status_pass = 1;
118 static int status_dots_requested = 0;
119 static int status_dots = 1;
134 if (status_pass != pass)
136 fprintf(stdout,
"\n Pass %d: ", pass);
141 if (status_dots == 0)
143 fprintf(stdout,
"\n ");
146 fprintf(stdout,
"r");
162 fprintf(stdout,
"w");
166 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 183 if (png_ptr !=
NULL && row_info !=
NULL)
184 ++filters_used[*(data - 1)];
188 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED 207 if (png_ptr ==
NULL)
return;
220 if (row_info->color_type == 0 || row_info->color_type == 3)
224 for (n = 0, nstop=row_info->width; n<nstop; n++)
226 if (row_info->bit_depth == 1)
228 if (((*dp << pos++ ) & 0x80) == 0)
236 if (row_info->bit_depth == 2)
238 if (((*dp << (pos+=2)) & 0xc0) == 0)
246 if (row_info->bit_depth == 4)
248 if (((*dp << (pos+=4)) & 0xf0) == 0)
256 if (row_info->bit_depth == 8)
259 if (row_info->bit_depth == 16)
261 if ((*dp | *(dp+1)) == 0)
271 int color_channels = row_info->channels;
272 if (row_info->color_type > 3)color_channels--;
274 for (n = 0, nstop=row_info->width; n<nstop; n++)
276 for (channel = 0; channel < color_channels; channel++)
278 if (row_info->bit_depth == 8)
281 if (row_info->bit_depth == 16)
283 if ((*dp | *(dp+1)) == 0)
288 if (row_info->color_type > 3)
291 if (row_info->bit_depth == 16)
299 static int wrote_question = 0;
301 #ifndef PNG_STDIO_SUPPORTED 311 #ifndef USE_FAR_KEYWORD 338 #define NEAR_BUF_SIZE 1024 339 #define MIN(a,b) (a <= b ? a : b) 353 READFILE(io_ptr, n_data, length, check);
363 read =
MIN(NEAR_BUF_SIZE, remaining);
373 while (remaining != 0);
380 #ifdef PNG_WRITE_FLUSH_SUPPORTED 394 #ifndef USE_FAR_KEYWORD 412 #define NEAR_BUF_SIZE 1024 413 #define MIN(a,b) (a <= b ? a : b) 427 WRITEFILE(io_ptr, near_data, length, check);
437 written =
MIN(NEAR_BUF_SIZE, remaining);
445 remaining -= written;
447 while (remaining != 0);
468 fprintf(
STDERR,
"%s: libpng warning: %s\n", name, message);
470 fprintf(
STDERR,
"%s: libpng warning: %s\n", test, message);
481 pngtest_warning(png_ptr, message);
490 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 501 typedef struct memory_information
505 struct memory_information FAR *next;
506 } memory_information;
507 typedef memory_information
FAR *memory_infop;
509 static memory_infop pinformation =
NULL;
510 static int current_allocation = 0;
511 static int maximum_allocation = 0;
512 static int total_allocation = 0;
513 static int num_allocations = 0;
538 current_allocation +=
size;
539 total_allocation +=
size;
541 if (current_allocation > maximum_allocation)
542 maximum_allocation = current_allocation;
547 (png_free_ptr)png_debug_free);
548 if (size != 0 && pinfo->pointer ==
NULL)
550 current_allocation -=
size;
551 total_allocation -=
size;
553 "out of memory in pngtest->png_debug_malloc.");
555 pinfo->next = pinformation;
556 pinformation = pinfo;
558 png_memset(pinfo->pointer, 0xdd, pinfo->size);
560 printf(
"png_malloc %lu bytes at %p\n", (
unsigned long)size,
571 fprintf(
STDERR,
"NULL pointer to png_debug_free.\n");
575 fprintf(
STDERR,
"WARNING: freeing NULL pointer\n");
581 if (pinformation !=
NULL)
583 memory_infop
FAR *ppinfo = &pinformation;
586 memory_infop pinfo = *ppinfo;
587 if (pinfo->pointer == ptr)
589 *ppinfo = pinfo->next;
590 current_allocation -= pinfo->size;
591 if (current_allocation < 0)
592 fprintf(
STDERR,
"Duplicate free of memory\n");
600 if (pinfo->next ==
NULL)
602 fprintf(
STDERR,
"Pointer %p not found\n", ptr);
605 ppinfo = &pinfo->next;
611 printf(
"Freeing %p\n", ptr);
620 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 633 static int read_user_chunk_callback(
png_struct *png_ptr,
652 if (chunk->name[0] == 115 && chunk->name[1] == 84 &&
653 chunk->name[2] == 69 && chunk->name[3] == 82)
656 if (chunk->size != 1)
658 if (chunk->data[0] != 0 && chunk->data[0] != 1)
661 my_user_chunk_data[0]=chunk->data[0]+1;
665 if (chunk->name[0] != 118 || chunk->name[1] != 112 ||
666 chunk->name[2] != 65 || chunk->name[3] != 103)
671 if (chunk->size != 9)
694 #ifdef PNG_WRITE_SUPPORTED 708 #ifdef PNG_SETJMP_SUPPORTED 709 #ifdef USE_FAR_KEYWORD 715 TCHAR
path[MAX_PATH];
722 MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
723 if ((fpin = CreateFile(path, GENERIC_READ, 0,
NULL, OPEN_EXISTING, 0,
726 if ((fpin = fopen(inname,
"rb")) ==
NULL)
729 fprintf(
STDERR,
"Could not find input file %s\n", inname);
734 MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
735 if ((fpout = CreateFile(path, GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS,
738 if ((fpout = fopen(outname,
"wb")) ==
NULL)
741 fprintf(
STDERR,
"Could not open output file %s\n", outname);
746 png_debug(0,
"Allocating read and write structures");
747 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 751 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
757 #ifndef PNG_STDIO_SUPPORTED 762 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 763 user_chunk_data[0] = 0;
764 user_chunk_data[1] = 0;
765 user_chunk_data[2] = 0;
766 user_chunk_data[3] = 0;
768 read_user_chunk_callback);
771 #ifdef PNG_WRITE_SUPPORTED 772 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 776 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
782 #ifndef PNG_STDIO_SUPPORTED 787 png_debug(0,
"Allocating read_info, write_info and end_info structures");
790 #ifdef PNG_WRITE_SUPPORTED 795 #ifdef PNG_SETJMP_SUPPORTED 796 png_debug(0,
"Setting jmpbuf for read struct");
797 #ifdef USE_FAR_KEYWORD 803 fprintf(
STDERR,
"%s -> %s: libpng read error\n", inname, outname);
807 #ifdef PNG_WRITE_SUPPORTED 815 #ifdef USE_FAR_KEYWORD 819 #ifdef PNG_WRITE_SUPPORTED 820 png_debug(0,
"Setting jmpbuf for write struct");
821 #ifdef USE_FAR_KEYWORD 827 fprintf(
STDERR,
"%s -> %s: libpng write error\n", inname, outname);
830 #ifdef PNG_WRITE_SUPPORTED 837 #ifdef USE_FAR_KEYWORD 843 png_debug(0,
"Initializing input and output streams");
844 #ifdef PNG_STDIO_SUPPORTED 846 # ifdef PNG_WRITE_SUPPORTED 851 # ifdef PNG_WRITE_SUPPORTED 860 if (status_dots_requested == 1)
862 #ifdef PNG_WRITE_SUPPORTED 869 #ifdef PNG_WRITE_SUPPORTED 875 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 878 for (i = 0; i<256; i++)
883 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED 888 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 889 # ifndef PNG_HANDLE_CHUNK_ALWAYS 890 # define PNG_HANDLE_CHUNK_ALWAYS 3 895 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 896 # ifndef PNG_HANDLE_CHUNK_IF_SAFE 897 # define PNG_HANDLE_CHUNK_IF_SAFE 2 906 png_debug(0,
"Transferring info struct");
910 if (
png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,
911 &color_type, &interlace_type, &compression_type, &filter_type))
913 png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
915 color_type, interlace_type, compression_type, filter_type);
921 #ifdef PNG_FIXED_POINT_SUPPORTED 922 #ifdef PNG_cHRM_SUPPORTED 927 &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))
930 red_y, green_x, green_y, blue_x, blue_y);
934 #ifdef PNG_gAMA_SUPPORTED 943 #ifdef PNG_FLOATING_POINT_SUPPORTED 944 #ifdef PNG_cHRM_SUPPORTED 948 if (
png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
949 &red_y, &green_x, &green_y, &blue_x, &blue_y))
951 png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
952 red_y, green_x, green_y, blue_x, blue_y);
956 #ifdef PNG_gAMA_SUPPORTED 966 #ifdef PNG_iCCP_SUPPORTED 973 if (
png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
976 png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
981 #ifdef PNG_sRGB_SUPPORTED 993 if (
png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
994 png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
996 #ifdef PNG_bKGD_SUPPORTED 1000 if (
png_get_bKGD(read_ptr, read_info_ptr, &background))
1006 #ifdef PNG_hIST_SUPPORTED 1014 #ifdef PNG_oFFs_SUPPORTED 1019 if (
png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
1022 png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
1026 #ifdef PNG_pCAL_SUPPORTED 1033 if (
png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
1034 &nparams, &units, ¶ms))
1036 png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
1037 nparams, units, params);
1041 #ifdef PNG_pHYs_SUPPORTED 1046 if (
png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
1047 png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
1050 #ifdef PNG_sBIT_SUPPORTED 1058 #ifdef PNG_sCAL_SUPPORTED 1059 #ifdef PNG_FLOATING_POINT_SUPPORTED 1062 double scal_width, scal_height;
1064 if (
png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
1067 png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
1071 #ifdef PNG_FIXED_POINT_SUPPORTED 1076 if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
1079 png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
1086 #ifdef PNG_TEXT_SUPPORTED 1091 if (
png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
1093 png_debug1(0,
"Handling %d iTXt/tEXt/zTXt chunks", num_text);
1094 png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
1098 #ifdef PNG_tIME_SUPPORTED 1105 #ifdef PNG_TIME_RFC1123_SUPPORTED 1113 tIME_string[
png_sizeof(tIME_string) - 1] =
'\0';
1114 tIME_chunk_present++;
1119 #ifdef PNG_tRNS_SUPPORTED 1125 if (
png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
1131 (
int)trans_values->gray > sample_max) ||
1133 ((
int)trans_values->red > sample_max ||
1134 (
int)trans_values->green > sample_max ||
1135 (
int)trans_values->blue > sample_max))))
1136 png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
1141 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1155 for (i = 0; i < (
png_size_t)num_unknowns; i++)
1162 #ifdef PNG_WRITE_SUPPORTED 1170 #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED 1171 if (user_chunk_data[0] != 0)
1173 png_byte png_sTER[5] = {115, 84, 69, 82,
'\0'};
1179 fprintf(
STDERR,
"\n stereo mode = %lu\n",
1180 (
unsigned long)(user_chunk_data[0] - 1));
1181 ster_chunk_data[0]=(
unsigned char)(user_chunk_data[0] - 1);
1184 if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
1186 png_byte png_vpAg[5] = {118, 112, 65, 103,
'\0'};
1192 fprintf(
STDERR,
" vpAg = %lu x %lu, units = %lu\n",
1193 (
unsigned long)user_chunk_data[1],
1194 (
unsigned long)user_chunk_data[2],
1195 (
unsigned long)user_chunk_data[3]);
1198 vpag_chunk_data[8] = (
unsigned char)(user_chunk_data[3] & 0xff);
1205 #ifdef SINGLE_ROWBUF_ALLOC 1206 png_debug(0,
"Allocating row buffer...");
1209 png_debug1(0,
"0x%08lx", (
unsigned long)row_buf);
1213 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ 1214 defined(PNG_WRITE_INTERLACING_SUPPORTED) 1216 # ifdef PNG_WRITE_SUPPORTED 1223 #ifdef PNGTEST_TIMING 1224 t_stop = (float)clock();
1225 t_misc += (t_stop - t_start);
1228 for (pass = 0; pass < num_pass; pass++)
1230 png_debug1(0,
"Writing row data for pass %d", pass);
1231 for (y = 0; y <
height; y++)
1233 #ifndef SINGLE_ROWBUF_ALLOC 1234 png_debug2(0,
"Allocating row buffer (pass %d, y = %lu)...", pass, y);
1237 png_debug2(0,
"0x%08lx (%ld bytes)", (
unsigned long)row_buf,
1242 #ifdef PNG_WRITE_SUPPORTED 1243 #ifdef PNGTEST_TIMING 1244 t_stop = (float)clock();
1245 t_decode += (t_stop - t_start);
1249 #ifdef PNGTEST_TIMING 1250 t_stop = (float)clock();
1251 t_encode += (t_stop - t_start);
1256 #ifndef SINGLE_ROWBUF_ALLOC 1257 png_debug2(0,
"Freeing row buffer (pass %d, y = %lu)", pass, y);
1264 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 1267 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1271 png_debug(0,
"Reading and writing end_info data");
1274 #ifdef PNG_TEXT_SUPPORTED 1279 if (
png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
1281 png_debug1(0,
"Handling %d iTXt/tEXt/zTXt chunks", num_text);
1282 png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
1286 #ifdef PNG_tIME_SUPPORTED 1293 #ifdef PNG_TIME_RFC1123_SUPPORTED 1300 tIME_string[
png_sizeof(tIME_string) - 1] =
'\0';
1301 tIME_chunk_present++;
1306 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1321 for (i = 0; i < (
png_size_t)num_unknowns; i++)
1327 #ifdef PNG_WRITE_SUPPORTED 1331 #ifdef PNG_EASY_ACCESS_SUPPORTED 1337 fprintf(
STDERR,
"\n Image width = %lu, height = %lu\n",
1338 (
unsigned long)iwidth, (
unsigned long)iheight);
1342 png_debug(0,
"Destroying data structs");
1343 #ifdef SINGLE_ROWBUF_ALLOC 1344 png_debug(1,
"destroying row_buf for read_ptr");
1348 png_debug(1,
"destroying read_ptr, read_info_ptr, end_info_ptr");
1350 #ifdef PNG_WRITE_SUPPORTED 1351 png_debug(1,
"destroying write_end_info_ptr");
1353 png_debug(1,
"destroying write_ptr, write_info_ptr");
1361 png_debug(0,
"Opening files for comparison");
1363 MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
1364 if ((fpin = CreateFile(path, GENERIC_READ, 0,
NULL, OPEN_EXISTING,
1367 if ((fpin = fopen(inname,
"rb")) ==
NULL)
1370 fprintf(
STDERR,
"Could not find file %s\n", inname);
1375 MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
1376 if ((fpout = CreateFile(path, GENERIC_READ, 0,
NULL, OPEN_EXISTING,
1379 if ((fpout = fopen(outname,
"rb")) ==
NULL)
1382 fprintf(
STDERR,
"Could not find file %s\n", outname);
1392 READFILE(fpout, outbuf, 1, num_out);
1394 if (num_in != num_out)
1396 fprintf(
STDERR,
"\nFiles %s and %s are of a different size\n",
1398 if (wrote_question == 0)
1401 " Was %s written with the same maximum IDAT chunk size (%d bytes),",
1404 "\n filtering heuristic (libpng default), compression");
1406 " level (zlib default),\n and zlib version (%s)?\n\n",
1420 fprintf(
STDERR,
"\nFiles %s and %s are different\n", inname, outname);
1421 if (wrote_question == 0)
1424 " Was %s written with the same maximum IDAT chunk size (%d bytes),",
1427 "\n filtering heuristic (libpng default), compression");
1429 " level (zlib default),\n and zlib version (%s)?\n\n",
1447 static PNG_CONST char *inname =
"pngtest/png";
1448 static PNG_CONST char *outname =
"pngout/png";
1450 static PNG_CONST char *inname =
"pngtest.png";
1451 static PNG_CONST char *outname =
"pngout.png";
1466 fprintf(
STDERR,
" library (%lu):%s",
1472 fprintf(
STDERR,
" sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
1480 #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) 1481 fprintf(
STDERR,
" NOTE: Zlib compiled for max 64k, libpng not\n");
1484 #if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) 1485 fprintf(
STDERR,
" NOTE: libpng compiled for max 64k, zlib not\n");
1491 "Warning: versions are different between png.h and png.c\n");
1499 if (strcmp(argv[1],
"-m") == 0)
1502 status_dots_requested = 0;
1504 else if (strcmp(argv[1],
"-mv") == 0 ||
1505 strcmp(argv[1],
"-vm") == 0 )
1509 status_dots_requested = 1;
1511 else if (strcmp(argv[1],
"-v") == 0)
1514 status_dots_requested = 1;
1520 status_dots_requested = 0;
1524 if (!multiple && argc == 3 + verbose)
1525 outname = argv[2 + verbose];
1527 if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))
1530 "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
1533 " reads/writes one PNG file (without -m) or multiple files (-m)\n");
1535 " with -m %s is used as a temporary file\n", outname);
1542 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1543 int allocation_now = current_allocation;
1545 for (i=2; i<argc; ++
i)
1548 fprintf(
STDERR,
"\n Testing %s:", argv[i]);
1552 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 1555 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED 1556 fprintf(
STDERR,
"\n PASS (%lu zero samples)\n",
1557 (
unsigned long)zero_samples);
1559 fprintf(
STDERR,
" PASS\n");
1561 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 1562 for (k = 0; k<256; k++)
1563 if (filters_used[k])
1564 fprintf(
STDERR,
" Filter %d was used %lu times\n",
1565 k, (
unsigned long)filters_used[k]);
1567 #ifdef PNG_TIME_RFC1123_SUPPORTED 1568 if (tIME_chunk_present != 0)
1569 fprintf(
STDERR,
" tIME = %s\n", tIME_string);
1570 tIME_chunk_present = 0;
1575 fprintf(
STDERR,
" FAIL\n");
1578 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1579 if (allocation_now != current_allocation)
1580 fprintf(
STDERR,
"MEMORY ERROR: %d bytes lost\n",
1581 current_allocation - allocation_now);
1582 if (current_allocation != 0)
1584 memory_infop pinfo = pinformation;
1586 fprintf(
STDERR,
"MEMORY ERROR: %d bytes still allocated\n",
1587 current_allocation);
1588 while (pinfo !=
NULL)
1590 fprintf(
STDERR,
" %lu bytes at %p\n",
1591 (
unsigned long)pinfo->size,
1593 pinfo = pinfo->next;
1598 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1599 fprintf(
STDERR,
" Current memory allocation: %10d bytes\n",
1600 current_allocation);
1601 fprintf(
STDERR,
" Maximum memory allocation: %10d bytes\n",
1602 maximum_allocation);
1603 fprintf(
STDERR,
" Total memory allocation: %10d bytes\n",
1605 fprintf(
STDERR,
" Number of allocations: %10d\n",
1612 for (i = 0; i<3; ++
i)
1615 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1616 int allocation_now = current_allocation;
1618 if (i == 1) status_dots_requested = 1;
1619 else if (verbose == 0)status_dots_requested = 0;
1620 if (i == 0 || verbose == 1 || ierror != 0)
1621 fprintf(
STDERR,
"\n Testing %s:", inname);
1625 if (verbose == 1 || i == 2)
1627 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 1630 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED 1631 fprintf(
STDERR,
"\n PASS (%lu zero samples)\n",
1632 (
unsigned long)zero_samples);
1634 fprintf(
STDERR,
" PASS\n");
1636 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 1637 for (k = 0; k<256; k++)
1638 if (filters_used[k])
1639 fprintf(
STDERR,
" Filter %d was used %lu times\n",
1640 k, (
unsigned long)filters_used[k]);
1642 #ifdef PNG_TIME_RFC1123_SUPPORTED 1643 if (tIME_chunk_present != 0)
1644 fprintf(
STDERR,
" tIME = %s\n", tIME_string);
1650 if (verbose == 0 && i != 2)
1651 fprintf(
STDERR,
"\n Testing %s:", inname);
1652 fprintf(
STDERR,
" FAIL\n");
1655 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1656 if (allocation_now != current_allocation)
1657 fprintf(
STDERR,
"MEMORY ERROR: %d bytes lost\n",
1658 current_allocation - allocation_now);
1659 if (current_allocation != 0)
1661 memory_infop pinfo = pinformation;
1663 fprintf(
STDERR,
"MEMORY ERROR: %d bytes still allocated\n",
1664 current_allocation);
1665 while (pinfo !=
NULL)
1667 fprintf(
STDERR,
" %lu bytes at %p\n",
1668 (
unsigned long)pinfo->size, pinfo->pointer);
1669 pinfo = pinfo->next;
1674 #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG 1675 fprintf(
STDERR,
" Current memory allocation: %10d bytes\n",
1676 current_allocation);
1677 fprintf(
STDERR,
" Maximum memory allocation: %10d bytes\n",
1678 maximum_allocation);
1679 fprintf(
STDERR,
" Total memory allocation: %10d bytes\n",
1681 fprintf(
STDERR,
" Number of allocations: %10d\n",
1686 #ifdef PNGTEST_TIMING 1687 t_stop = (float)clock();
1688 t_misc += (t_stop - t_start);
1690 fprintf(
STDERR,
" CPU time used = %.3f seconds",
1691 (t_misc+t_decode+t_encode)/(
float)CLOCKS_PER_SEC);
1692 fprintf(
STDERR,
" (decoding %.3f,\n",
1693 t_decode/(
float)CLOCKS_PER_SEC);
1694 fprintf(
STDERR,
" encoding %.3f ,",
1695 t_encode/(
float)CLOCKS_PER_SEC);
1696 fprintf(
STDERR,
" other %.3f seconds)\n\n",
1697 t_misc/(
float)CLOCKS_PER_SEC);
1701 fprintf(
STDERR,
" libpng passes test\n");
1703 fprintf(
STDERR,
" libpng FAILS test\n");
1706 fprintf(
STDERR,
" Default limits:\n");
1707 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 1708 fprintf(
STDERR,
" width_max = %lu\n",
1710 fprintf(
STDERR,
" height_max = %lu\n",
1713 fprintf(
STDERR,
" width_max = %lu\n",
1715 fprintf(
STDERR,
" height_max = %lu\n",
1719 fprintf(
STDERR,
" cache_max = unlimited\n");
1721 fprintf(
STDERR,
" cache_max = %lu\n",
1724 fprintf(
STDERR,
" malloc_max = unlimited\n");
1726 fprintf(
STDERR,
" malloc_max = %lu\n",
1730 return (
int)(ierror != 0);
GLenum GLuint GLenum GLsizei length
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)
#define png_jmpbuf(png_ptr)
GLint GLint GLsizei GLsizei height
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
#define png_write_status_ptr_NULL
PNG_CONST char png_libpng_ver[18]
#define PNG_USER_WIDTH_MAX
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_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)
unsigned char outbuf[SIZE]
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_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
int read(int fd, char *buf, int nbytes)
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
GLint GLint GLint GLint GLint GLint y
GLsizei const GLvoid * pointer
#define PNG_INTERLACE_NONE
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_voidp PNGAPI png_get_error_ptr(png_structp png_ptr)
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
#define PNG_UNUSED(param)
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)
#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
#define PNG_USER_CHUNK_CACHE_MAX
void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
GLint GLint GLsizei width
png_structp version_1_2_56
png_infop png_int_32 png_int_32 * offset_y
png_infop png_unknown_chunkp int num_unknowns
png_infop png_int_32 * offset_x
PNG_CONST char FAR * png_const_charp
#define PNG_USER_HEIGHT_MAX
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)
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)
GLenum GLuint GLenum GLsizei const GLchar * buf
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)
#define INVALID_HANDLE_VALUE
void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
#define PNG_WRITE_INTERLACING_SUPPORTED
png_infop png_charp png_int_32 * X0
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
png_uint_32 PNGAPI png_get_user_height_max(png_structp png_ptr)
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
#define PNG_USER_CHUNK_MALLOC_MAX
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
GLsizei const GLchar ** path
png_struct FAR * png_structp
void PNGAPI png_write_info(png_structp png_ptr, png_infop info_ptr)
#define PNG_HANDLE_CHUNK_ALWAYS
#define png_error(s1, s2)
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)
#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_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[])
GLsizei GLsizei GLenum GLenum const GLvoid * data
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
unsigned char inbuf[SIZE]
#define PNG_COLOR_TYPE_GRAY
png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr)
void PNGAPI png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
version_1_2_56 your_png_h_is_not_version_1_2_56
png_uint_32 PNGAPI png_get_user_width_max(png_structp png_ptr)
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)
#define png_debug1(l, m, p1)
void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr)
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)
#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)
GLuint const GLchar * name
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)
GLenum const GLfloat * params
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
GLubyte GLubyte GLubyte GLubyte w
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)
GLenum GLuint GLenum GLsizei const GLchar * message
#define PNG_HEADER_VERSION_STRING
png_infop double double double double double double * green_y
png_infop double double * white_y
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)
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)
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
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