📄 changelog.txt
字号:
break;
}
ppinfo = &pinfo->next;
}
}
/* Finally free the data. */
png_free_default(png_ptr, ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
/* END of code to test memory allocation/deallocation */
void png_crush_pause(void)
{
if (pauses > 0) {
char keystroke;
fprintf(STDERR, "Press [ENTER] key to continue.\n");
keystroke = (char) getc(stdin);
keystroke = keystroke; /* stifle compiler warning */
}
}
void png_skip_chunk(png_structp png_ptr)
{
png_byte buff[4];
int i;
unsigned long length;
/* read the length field */
png_default_read_data(png_ptr, buff, 4);
length=buff[3]+(buff[2]<<8)+(buff[1]<<16)+(buff[0]<<24);
/* read the chunk name */
png_default_read_data(png_ptr, buff, 4);
printf("Skipping %c%c%c%c chunk.\n",buff[0],buff[1],
buff[2],buff[3]);
/* skip the data */
for (i=0; i<length; i++)
png_default_read_data(png_ptr, buff, 1);
/* skip the CRC */
png_default_read_data(png_ptr, buff, 4);
}
#ifndef __riscos
# define setfiletype(x)
#else /* defined(__riscos) */
# include <kernel.h>
/* The riscos/acorn support was contributed by Darren Salt. */
static int fileexists(const char *name)
{
# ifdef __acorn
int ret;
return _swix(8, 3 | 1 << 31, 17, name, &ret) ? 0 : ret;
# else
_kernel_swi_regs r;
r.r[0] = 17;
r.r[1] = (int) name;
return _kernel_swi(8, &r, &r) ? 0 : r.r[0];
# endif
}
static int filesize(const char *name)
{
# ifdef __acorn
int ret;
return _swix(8, 3 | 1 << 27, 17, name, &ret) ? 0 : ret;
# else
_kernel_swi_regs r;
r.r[0] = 17;
r.r[1] = (int) name;
return _kernel_swi(8, &r, &r) ? 0 : r.r[4];
# endif
}
static int mkdir(const char *name, int ignored)
{
# ifdef __acorn
_swi(8, 0x13, 8, name, 0);
return 0;
# else
_kernel_swi_regs r;
r.r[0] = 8;
r.r[1] = (int) name;
r.r[4] = r.r[3] = r.r[2] = 0;
return (int) _kernel_swi(8 | 1 << 31, &r, &r);
# endif
}
static void setfiletype(const char *name)
{
# ifdef __acorn
_swi(8, 7, 18, name, 0xB60);
# else
_kernel_swi_regs r;
r.r[0] = 18;
r.r[1] = (int) name;
r.r[2] = 0xB60;
_kernel_swi(8 | 1 << 31, &r, &r);
# endif
}
#endif /* ?defined(__riscos) */
/* GRR: basically boolean; first arg is chunk name-string (e.g., "tIME" or
* "alla"); second is always full argv[] command line
* - remove_chunks is argv index of *last* -rem arg on command line
* (would be more efficient to build table at time of cmdline processing!)
* (i.e., build removal_list with names or unique IDs or whatever--skip
* excessive string-processing on every single one)
* - reprocesses command line _every_ time called, looking for -rem opts...
* - just like keep_chunk() except that latter sets things_have_changed
* variable and debug stmts say "Removed chunk" (but caller actually does
* so, by choosing not to copy chunk to new file)
* - for any given chunk name, "name" must either match exact command-line
* arg (e.g., -rem fOOb), OR it must match one of the official PNG chunk
* names explicitly listed below AND command-line arg either used all-
* lowercase form or one of "all[ab]" options
*/
int keep_unknown_chunk(png_const_charp name, char *argv[])
{
int i;
if (remove_chunks == 0)
return 1; /* no -rem options, so always keeping */
for (i = 1; i <= remove_chunks; i++) {
if (!strncmp(argv[i], "-rem", 4)) {
int allb = 0;
i++;
if (!strncmp(argv[i], "all", 3)) {
allb++; /* all but gamma, but not doing gamma here */
}
if (!strncmp(argv[i], name, 4) /* exact chunk-name match in args */
/* ...or exact match for one of known set, plus args included
* either "alla", "allb", or all-lowercase form of "name" */
|| (!strncmp(name, "cHRM", 4)
&& (!strncmp(argv[i], "chrm", 4) || allb))
|| (!strncmp(name, "dSIG", 4)
&& (!strncmp(argv[i], "dsig", 4) || allb))
|| (!strncmp(name, "gIFg", 4)
&& (!strncmp(argv[i], "gifg", 4) || allb))
|| (!strncmp(name, "gIFt", 4)
&& (!strncmp(argv[i], "gift", 4) || allb))
|| (!strncmp(name, "gIFx", 4)
&& (!strncmp(argv[i], "gifx", 4) || allb))
|| (!strncmp(name, "hIST", 4)
&& (!strncmp(argv[i], "hist", 4) || allb))
|| (!strncmp(name, "iCCP", 4)
&& (!strncmp(argv[i], "iccp", 4) || allb))
|| (!strncmp(name, "pCAL", 4)
&& (!strncmp(argv[i], "pcal", 4) || allb))
|| (!strncmp(name, "sCAL", 4)
&& (!strncmp(argv[i], "scal", 4) || allb))
|| (!strncmp(name, "sPLT", 4)
&& (!strncmp(argv[i], "splt", 4) || allb))
|| (!strncmp(name, "tIME", 4)
&& (!strncmp(argv[i], "time", 4) || allb)))
{
return 0;
}
}
}
return 1;
}
int keep_chunk(png_const_charp name, char *argv[])
{
int i;
if (verbose > 2 && first_trial)
fprintf(STDERR, " Read the %s chunk.\n", name);
if (remove_chunks == 0)
return 1;
if (verbose > 1 && first_trial)
fprintf(STDERR, " Check for removal of the %s chunk.\n", name);
for (i = 1; i <= remove_chunks; i++) {
if (!strncmp(argv[i], "-rem", 4)) {
int alla = 0;
int allb = 0;
int allt = 0;
i++;
if (!strncmp(argv[i], "all", 3)) {
allt++; /* all forms of text chunk are ancillary */
allb++; /* all ancillaries but gamma... */
if (!strncmp(argv[i], "alla", 4))
alla++; /* ...no, all ancillaries, period */
} else if (!strncmp(argv[i], "text", 4))
allt++; /* all forms of text chunk */
if (!strncmp(argv[i], name, 4) /* exact chunk-name match in args
* ...or exact match for one of known set, plus args included
* either "alla", "allb", or all-lowercase form of "name": */
|| (!strncmp(name, "PLTE", 4)
&& (!strncmp(argv[i], "plte", 4) ))
|| (!strncmp(name, "bKGD", 4)
&& (!strncmp(argv[i], "bkgd", 4) || allb))
|| (!strncmp(name, "cHRM", 4)
&& (!strncmp(argv[i], "chrm", 4) || allb))
|| (!strncmp(name, "dSIG", 4)
&& (!strncmp(argv[i], "dsig", 4) || allb))
|| (!strncmp(name, "gAMA", 4)
&& (!strncmp(argv[i], "gama", 4) || alla))
|| (!strncmp(name, "gIFg", 4)
&& (!strncmp(argv[i], "gifg", 4) || allb))
|| (!strncmp(name, "gIFt", 4)
&& (!strncmp(argv[i], "gift", 4) || allb))
|| (!strncmp(name, "gIFx", 4)
&& (!strncmp(argv[i], "gifx", 4) || allb))
|| (!strncmp(name, "hIST", 4)
&& (!strncmp(argv[i], "hist", 4) || allb))
|| (!strncmp(name, "iCCP", 4)
&& (!strncmp(argv[i], "iccp", 4) || allb))
|| (!strncmp(name, "iTXt", 4)
&& (!strncmp(argv[i], "itxt", 4) || allt))
|| (!strncmp(name, "oFFs", 4)
&& (!strncmp(argv[i], "offs", 4) || allb))
|| (!strncmp(name, "pHYs", 4)
&& (!strncmp(argv[i], "phys", 4) || allb))
|| (!strncmp(name, "pCAL", 4)
&& (!strncmp(argv[i], "pcal", 4) || allb))
|| (!strncmp(name, "sBIT", 4)
&& (!strncmp(argv[i], "sbit", 4) || allb))
|| (!strncmp(name, "sCAL", 4)
&& (!strncmp(argv[i], "scal", 4) || allb))
|| (!strncmp(name, "sRGB", 4)
&& (!strncmp(argv[i], "srgb", 4) || allb))
|| (!strncmp(name, "sTER", 4)
&& (!strncmp(argv[i], "ster", 4) || allb))
|| (!strncmp(name, "sPLT", 4)
&& (!strncmp(argv[i], "splt", 4) || allb))
|| (!strncmp(name, "tEXt", 4)
&& ( allt))
|| (!strncmp(name, "tIME", 4)
&& (!strncmp(argv[i], "time", 4) || allb))
|| (!strncmp(name, "tRNS", 4)
&& (!strncmp(argv[i], "trns", 4) ))
|| (!strncmp(name, "zTXt", 4)
&& (!strncmp(argv[i], "ztxt", 4) || allt)) )
{
things_have_changed = 1;
/* (caller actually does the removal--by failing to create
* copy) */
if (verbose > 0 && first_trial)
fprintf(STDERR, " Removed the %s chunk.\n", name);
return 0;
}
}
}
if (verbose > 1 && first_trial)
fprintf(STDERR, " Preserving the %s chunk.\n", name);
return 1;
}
void show_result(void)
{
if (total_output_length) {
if (total_input_length == total_output_length)
fprintf(STDERR, " Overall result: no change\n");
else if (total_input_length > total_output_length)
fprintf(STDERR,
" Overall result: %4.2f%% reduction, %lu bytes\n",
(100.0 -
(100.0 * total_output_length) / total_input_length),
(unsigned long)(total_input_length-total_output_length));
else
fprintf(STDERR,
" Overall result: %4.2f%% increase, %lu bytes\n",
-(100.0 -
(100.0 * total_output_length) / total_input_length),
(unsigned long)(total_output_length - total_input_length));
}
t_stop = (TIME_T) clock();
t_misc += (t_stop - t_start);
if (t_stop < t_start) {
t_misc += PNG_UINT_31_MAX;
if (t_stop < 0)
t_misc += PNG_UINT_31_MAX;
}
t_start = t_stop;
fprintf(STDERR, " CPU time used = %.3f seconds",
(t_misc + t_decode + t_encode) / (float) CLOCKS_PER_SEC);
fprintf(STDERR, " (decoding %.3f,\n",
t_decode / (float) CLOCKS_PER_SEC);
fprintf(STDERR, " encoding %.3f,",
t_encode / (float) CLOCKS_PER_SEC);
fprintf(STDERR, " other %.3f seconds)\n\n",
t_misc / (float) CLOCKS_PER_SEC);
#ifdef PNG_USER_MEM_SUPPORTED
if (current_allocation) {
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
current_allocation);
while (pinfo != NULL) {
fprintf(STDERR, " %8lu bytes at %lux\n", (unsigned long)pinfo->size,
(unsigned long) pinfo->pointer);
free(pinfo->pointer);
pinfo = pinfo->next;
}
}
#endif
}
int main(int argc, char *argv[])
{
png_uint_32 y;
int bit_depth, color_type;
int num_pass, pass;
int num_methods;
int try_method[MAX_METHODSP1];
int fm[MAX_METHODSP1];
int lv[MAX_METHODSP1];
int zs[MAX_METHODSP1];
int lev, strat, filt;
#ifdef PNG_gAMA_SUPPORTED
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point file_gamma = 0;
#else
double file_gamma = 0.;
#endif
#endif
char *cp;
int i;
row_buf = (png_bytep) NULL;
number_of_open_files = 0;
#ifdef PNGCRUSH_COUNT_COLORS
reduce_to_gray = 0;
it_is_opaque = 0;
#else
do_color_count = 0;
do_color_count = do_color_count; /* silence compiler warning */
#endif
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) {
fprintf(STDERR,
"Warning: versions are different between png.h and png.c\n");
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
}
t_start = (TIME_T) clock();
strncpy(prog_string, argv[0], STR_BUF_SIZE);
prog_string[STR_BUF_SIZE-1] = '\0';
progname = prog_string;
for (i = 0, cp = prog_string; *cp != '\0'; i++, cp++) {
#ifdef __riscos
if (*cp == '.' || *cp == ':')
progname = ++cp;
#else
if (*cp == '\\' || *cp == '/')
progname = ++cp;
if (*cp == '.')
*cp = '\0';
#endif
}
/*
* Definition of methods ("canonical list" is methods 11 and up)
*/
for (i = 0; i < MAX_METHODS; i++) {
try_method[i] = 1;
fm[i] = 5; lv[i] = 9; zs[i] = 1; /* default: method 124 */
}
fm[1] = 0; lv[1] = 4; zs[1] = 0; /* method 1 == method 53 */
fm[2] = 1; lv[2] = 4; zs[2] = 0; /* method 2 == method 54 */
lv[3] = 4; /* method 3 == method 64 */
fm[4] = 0; /* method 4 == method 119 */
fm[5] = 1; zs[5] = 0; /* method 5 == method 114 */
zs[6] = 0; /* method 6 == method 118 */
fm[7] = 0; zs[7] = 0; /* method 7 == method 113 */
fm[8] = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -