📄 changelog.txt
字号:
specify the filter, level, and strategy, instead of just the first 10.
Version 1.2.1 (built with libpng-1.0.5f): Fixed -srgb parameter so it
really does take an argument, and so it continues to use "0" if an
integer does not follow the -srgb.
Added "-plte_len n" argument for truncating the PLTE. Be sure not to
truncate it to less than the greatest index actually appearing in IDAT.
Version 1.2.0: Removed registration requirement. Added open source
license. Redefined TOO_FAR=32k in deflate.c.
Changes prior to going "open source":
Version 1.1.8: built with libpng-1.0.5a. Runs OK with pngvcrd.c.
Version 1.1.7: added ability to add tEXt/zTXt chunks. Fixed bug with
closing a file that wasn't opened when using "pngcrush -n". Fixed
bug with tEXt/zTXt chunks after IDAT not being copied.
Added alpha to the displayed palette table. Rebuilt with libpng-1.0.5.
Version 1.1.6: fixed bug with one file left open after each image is
processed
Version 1.1.5: Shorten or remove tRNS chunks that are all opaque or have
opaque entries at the end. Added timing report.
Version 1.1.4: added ability to restrict brute_force to one or more filter
types, compression levels, or compression strategies.
#endif /* end of changelog */
#include "png.h"
/* internal libpng macros */
#ifdef PNG_LIBPNG_VER
#define PNGCRUSH_LIBPNG_VER PNG_LIBPNG_VER
#else
/* This must agree with PNG_LIBPNG_VER; you have to define it manually
here if you are using libpng-1.0.6h or earlier */
#define PNGCRUSH_LIBPNG_VER 10007
#endif
/* Changed in version 0.99 */
#if PNGCRUSH_LIBPNG_VER < 99
#undef PNG_CONST
#ifndef PNG_NO_CONST
# define PNG_CONST const
#else
# define PNG_CONST
#endif
#endif
#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
#define PNG_dSIG const png_byte png_dSIG[5] = {100, 83, 73, 71, '\0'}
#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
/* GRR 20050220: added these, which apparently aren't defined anywhere else */
#ifndef PNG_UINT_IHDR
# define PNG_UINT_IHDR (((png_uint_32) 73<<24) | \
((png_uint_32) 72<<16) | \
((png_uint_32) 68<< 8) | \
((png_uint_32) 82 ))
#endif
#ifndef PNG_UINT_IDAT
# define PNG_UINT_IDAT (((png_uint_32) 73<<24) | \
((png_uint_32) 68<<16) | \
((png_uint_32) 65<< 8) | \
((png_uint_32) 84 ))
#endif
#ifndef PNG_UINT_IEND
# define PNG_UINT_IEND (((png_uint_32) 73<<24) | \
((png_uint_32) 69<<16) | \
((png_uint_32) 78<< 8) | \
((png_uint_32) 68 ))
#endif
#ifndef PNG_UINT_PLTE
# define PNG_UINT_PLTE (((png_uint_32) 80<<24) | \
((png_uint_32) 76<<16) | \
((png_uint_32) 84<< 8) | \
((png_uint_32) 69 ))
#endif
#ifndef PNG_UINT_bKGD
# define PNG_UINT_bKGD (((png_uint_32) 98<<24) | \
((png_uint_32) 75<<16) | \
((png_uint_32) 71<< 8) | \
((png_uint_32) 68 ))
#endif
/* glennrp added CgBI at pngcrush-1.6.16 */
#ifndef PNG_UINT_CgBI
# define PNG_UINT_CgBI (((png_uint_32) 67<<24) | \
((png_uint_32) 103<<16) | \
((png_uint_32) 66<< 8) | \
((png_uint_32) 73 ))
#endif
#ifndef PNG_UINT_cHRM
# define PNG_UINT_cHRM (((png_uint_32) 99<<24) | \
((png_uint_32) 72<<16) | \
((png_uint_32) 82<< 8) | \
((png_uint_32) 77 ))
#endif
#ifndef PNG_UINT_dSIG
# define PNG_UINT_dSIG (((png_uint_32) 100<<24) | \
((png_uint_32) 83<<16) | \
((png_uint_32) 73<< 8) | \
((png_uint_32) 71 ))
#endif
#ifndef PNG_UINT_gAMA
# define PNG_UINT_gAMA (((png_uint_32) 103<<24) | \
((png_uint_32) 65<<16) | \
((png_uint_32) 77<< 8) | \
((png_uint_32) 65 ))
#endif
#ifndef PNG_UINT_hIST
# define PNG_UINT_hIST (((png_uint_32) 104<<24) | \
((png_uint_32) 73<<16) | \
((png_uint_32) 83<< 8) | \
((png_uint_32) 84 ))
#endif
#ifndef PNG_UINT_iCCP
# define PNG_UINT_iCCP (((png_uint_32) 105<<24) | \
((png_uint_32) 67<<16) | \
((png_uint_32) 67<< 8) | \
((png_uint_32) 80 ))
#endif
#ifndef PNG_UINT_iTXt
# define PNG_UINT_iTXt (((png_uint_32) 105<<24) | \
((png_uint_32) 84<<16) | \
((png_uint_32) 88<< 8) | \
((png_uint_32) 116 ))
#endif
#ifndef PNG_UINT_oFFs
# define PNG_UINT_oFFs (((png_uint_32) 111<<24) | \
((png_uint_32) 70<<16) | \
((png_uint_32) 70<< 8) | \
((png_uint_32) 115 ))
#endif
#ifndef PNG_UINT_pCAL
# define PNG_UINT_pCAL (((png_uint_32) 112<<24) | \
((png_uint_32) 67<<16) | \
((png_uint_32) 65<< 8) | \
((png_uint_32) 76 ))
#endif
#ifndef PNG_UINT_pHYs
# define PNG_UINT_pHYs (((png_uint_32) 112<<24) | \
((png_uint_32) 72<<16) | \
((png_uint_32) 89<< 8) | \
((png_uint_32) 115 ))
#endif
#ifndef PNG_UINT_sBIT
# define PNG_UINT_sBIT (((png_uint_32) 115<<24) | \
((png_uint_32) 66<<16) | \
((png_uint_32) 73<< 8) | \
((png_uint_32) 84 ))
#endif
#ifndef PNG_UINT_sCAL
# define PNG_UINT_sCAL (((png_uint_32) 115<<24) | \
((png_uint_32) 67<<16) | \
((png_uint_32) 65<< 8) | \
((png_uint_32) 76 ))
#endif
#ifndef PNG_UINT_sPLT
# define PNG_UINT_sPLT (((png_uint_32) 115<<24) | \
((png_uint_32) 80<<16) | \
((png_uint_32) 76<< 8) | \
((png_uint_32) 84 ))
#endif
#ifndef PNG_UINT_sTER
# define PNG_UINT_sTER (((png_uint_32) 115<<24) | \
((png_uint_32) 84<<16) | \
((png_uint_32) 69<< 8) | \
((png_uint_32) 82 ))
#endif
#ifndef PNG_UINT_sRGB
# define PNG_UINT_sRGB (((png_uint_32) 115<<24) | \
((png_uint_32) 82<<16) | \
((png_uint_32) 71<< 8) | \
((png_uint_32) 66 ))
#endif
#ifndef PNG_UINT_tEXt
# define PNG_UINT_tEXt (((png_uint_32) 116<<24) | \
((png_uint_32) 69<<16) | \
((png_uint_32) 88<< 8) | \
((png_uint_32) 116 ))
#endif
#ifndef PNG_UINT_tIME
# define PNG_UINT_tIME (((png_uint_32) 116<<24) | \
((png_uint_32) 73<<16) | \
((png_uint_32) 77<< 8) | \
((png_uint_32) 69 ))
#endif
#ifndef PNG_UINT_tRNS
# define PNG_UINT_tRNS (((png_uint_32) 116<<24) | \
((png_uint_32) 82<<16) | \
((png_uint_32) 78<< 8) | \
((png_uint_32) 83 ))
#endif
#ifndef PNG_UINT_zTXt
# define PNG_UINT_zTXt (((png_uint_32) 122<<24) | \
((png_uint_32) 84<<16) | \
((png_uint_32) 88<< 8) | \
((png_uint_32) 116 ))
#endif
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN)
#define PNG_PACK 0x0004
#define PNG_DITHER 0x0040
#define PNG_BACKGROUND 0x0080
#define PNG_16_TO_8 0x0400
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000
#define PNG_GRAY_TO_RGB 0x4000
#define PNG_FILLER 0x8000L
#define PNG_USER_TRANSFORM 0x100000L
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
/* we don't need some of the extra libpng transformations
* so they are ifdef'ed out in pngcrush.h, which is included by
* pngcrush's local copy of libpng's pngconf.h which is included
* by png.h */
/* defined so I can write to a file on gui/windowing platforms */
/* #define STDERR stderr */
#define STDERR stdout /* for DOS */
#ifndef PNGCRUSH_LIBPNG_VER
# define PNGCRUSH_LIBPNG_VER PNG_LIBPNG_VER
#endif
#ifdef PNG_MNG_FEATURES_SUPPORTED
# define PNGCRUSH_LOCO
#endif
#ifndef PNG_UINT_31_MAX
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
#endif
/* These macros were renamed in libpng-1.2.6 */
#ifndef PNG_HANDLE_CHUNK_ALWAYS
#define PNG_HANDLE_CHUNK_ALWAYS HANDLE_CHUNK_ALWAYS
#define PNG_HANDLE_CHUNK_NEVER HANDLE_CHUNK_NEVER
#define PNG_HANDLE_CHUNK_IF_SAFE HANDLE_CHUNK_IF_SAFE
#endif
#if defined(__DJGPP__)
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
# endif
# define SLASH "\\"
# define DOT "."
#else
# ifdef __riscos
# define SLASH "."
# define DOT "/"
# else
# define SLASH "/"
# define DOT "."
# endif
#endif
#ifndef GAS_VERSION
# define GAS_VERSION "2.9.5(?)" /* used only in help/usage screen */
#endif
#if !defined(__TURBOC__) && !defined(_MSC_VER) && !defined(_MBCS) && \
!defined(__riscos)
# include <unistd.h>
#endif
#ifndef __riscos
# include <sys/types.h>
# include <sys/stat.h>
# include <utime.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#if defined(_MBCS) || defined(WIN32) || defined(__WIN32__)
# include <direct.h>
#endif
#define DEFAULT_MODE 0
#define DIRECTORY_MODE 1
#define EXTENSION_MODE 2
#define DIREX_MODE 3
#define FOPEN(file, how) fopen(file, how)
#define FCLOSE(file) {fclose(file); file=NULL;--number_of_open_files;};
#define P0 if(first_trial && verbose > 0)printf
#define P1 if(verbose > 1)printf
#define P2 if(verbose > 2)printf
#define STRNGIFY_STAGE1(x) #x
#define STRNGIFY(x) STRNGIFY_STAGE1(x)
#define STR_BUF_SIZE 256
#define MAX_IDAT_SIZE 524288L
#define MAX_METHODS 200
#define MAX_METHODSP1 (MAX_METHODS+1)
#define DEFAULT_METHODS 10
#define FAKE_PAUSE_STRING "P"
#ifdef Z_RLE
# define NUM_STRATEGIES 4
#else
# define NUM_STRATEGIES 3
#endif
#ifdef __TURBOC__
# include <mem.h>
#endif
#ifndef CLOCKS_PER_SEC
# define CLOCKS_PER_SEC 1000
#endif
#ifdef __STDC__
# define TIME_T clock_t
#else
# if CLOCKS_PER_SEC <= 100
# define TIME_T long
# else
# define TIME_T float
# endif
#endif
struct options_help {
int verbosity; /* if verbose >= this value, then print line */
const char *textline; /* static string with newline chopped off */
};
/* input and output filenames */
static PNG_CONST char *progname;
static PNG_CONST char *inname = "pngtest" DOT "png";
static PNG_CONST char *outname = "pngout" DOT "png";
static PNG_CONST char *mngname = "mngout" DOT "mng";
static PNG_CONST char *directory_name = "pngcrush" DOT "bak";
static PNG_CONST char *extension = "_C" DOT "png";
static png_uint_32 width, height;
static png_uint_32 measured_idat_length;
static int found_gAMA = 0;
static int found_cHRM = 0;
static int found_CgBI = 0;
static int found_any_chunk = 0;
static int image_is_immutable = 0;
static int pngcrush_must_exit = 0;
static int all_chunks_are_safe = 0;
static int number_of_open_files;
static int do_pplt = 0;
#ifdef PNGCRUSH_MULTIPLE_ROWS
static png_uint_32 max_rows_at_a_time = 1;
static png_uint_32 rows_at_a_time;
#endif
char pplt_string[1024];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -