mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from pngcrush-1.4.4.tar
This commit is contained in:
15
README.txt
15
README.txt
@@ -33,10 +33,11 @@ This is the copyright notice, disclaimer, and license:
|
||||
This is the output of "pngcrush" and "pngcrush -help":
|
||||
|
||||
|
||||
| pngcrush 1.4.1, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
|
||||
| pngcrush 1.4.4, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
| This is a free, open-source program. Permission is
|
||||
| granted to everyone to use pngcrush without fee.
|
||||
| This program was built with libpng version 1.0.6e,
|
||||
| This program was built with libpng version 1.0.6i,
|
||||
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
|
||||
| Copyright (C) 1996, 1997 Andreas Dilger,
|
||||
| Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,
|
||||
@@ -55,7 +56,7 @@ options:
|
||||
-e extension (used for creating output filename)
|
||||
-f user_filter [0-5]
|
||||
-force (Write a new output file even if larger than input)
|
||||
-g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
|
||||
-g gamma (float, e.g., 0.45455)
|
||||
-itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||
-l zlib_compression_level [0-9]
|
||||
-m method [0 through 200]
|
||||
@@ -64,7 +65,7 @@ options:
|
||||
-plte_len n (truncate PLTE)
|
||||
-q (quiet)
|
||||
-rem chunkname (or "alla" or "allb")
|
||||
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
||||
-replace_gamma gamma (float, e.g. 0.45455) even if gAMA is present.
|
||||
-res dpi
|
||||
-srgb [0, 1, 2, or 3]
|
||||
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||
@@ -75,8 +76,6 @@ options:
|
||||
-h (help)
|
||||
-p (pause)
|
||||
|
||||
|
||||
|
||||
options:
|
||||
-brute (Use brute-force, try 114 different methods [11-124])
|
||||
|
||||
@@ -126,7 +125,7 @@ options:
|
||||
if it is smaller than any generated file and no chunk
|
||||
additions, removals, or changes were requested.
|
||||
|
||||
-g gamma (float or fixed*100000, e.g., 0.45455 or 45455)
|
||||
-g gamma (float, e.g., 0.45455)
|
||||
|
||||
Value to insert in gAMA chunk, only if the input
|
||||
file has no gAMA chunk. To replace an existing
|
||||
@@ -182,7 +181,7 @@ options:
|
||||
all known ancillary chunks except for tRNS, and
|
||||
"-rem allb" removes all but tRNS and gAMA.
|
||||
|
||||
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
||||
-replace_gamma gamma (float, e.g. 0.45455) even if gAMA is present.
|
||||
|
||||
-res dpi
|
||||
|
||||
|
||||
38
png.c
38
png.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.6h - April 24, 2000
|
||||
* libpng version 1.0.6i - May 1, 2000
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
@@ -14,14 +14,14 @@
|
||||
#include "png.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_0_6h Your_png_h_is_not_version_1_0_6h;
|
||||
typedef version_1_0_6i Your_png_h_is_not_version_1_0_6i;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h. */
|
||||
|
||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||
char png_libpng_ver[12] = "1.0.6h";
|
||||
char png_libpng_ver[12] = "1.0.6i";
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
@@ -134,7 +134,7 @@ png_check_sig(png_bytep sig, int num)
|
||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||
}
|
||||
|
||||
/* Function to allocate memory for zlib. */
|
||||
/* Function to allocate memory for zlib and clear it to 0. */
|
||||
voidpf
|
||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||
{
|
||||
@@ -261,6 +261,7 @@ png_info_init(png_infop info_ptr)
|
||||
png_memset(info_ptr, 0, sizeof (png_info));
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
void
|
||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
@@ -276,6 +277,7 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
png_warning(png_ptr,
|
||||
"Unknown freer parameter in png_data_freer.");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
|
||||
@@ -286,7 +288,9 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
/* free text item num or (if num == -1) all text items */
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (mask & info_ptr->free_me & PNG_FREE_TEXT)
|
||||
#endif
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
@@ -314,7 +318,11 @@ if (mask & PNG_FREE_TRNS)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (info_ptr->free_me & PNG_FREE_TRNS)
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
|
||||
#endif
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
}
|
||||
@@ -362,7 +370,9 @@ if (mask & PNG_FREE_ICCP)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_iCCP)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (info_ptr->free_me & PNG_FREE_ICCP)
|
||||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->iccp_name);
|
||||
png_free(png_ptr, info_ptr->iccp_profile);
|
||||
@@ -427,7 +437,11 @@ if (mask & PNG_FREE_HIST)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_hIST)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (info_ptr->free_me & PNG_FREE_HIST)
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||
#endif
|
||||
png_free(png_ptr, info_ptr->hist);
|
||||
info_ptr->valid &= ~PNG_INFO_hIST;
|
||||
}
|
||||
@@ -439,7 +453,11 @@ if (mask & PNG_FREE_PLTE)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_PLTE)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (info_ptr->free_me & PNG_FREE_PLTE)
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
|
||||
#endif
|
||||
png_zfree(png_ptr, info_ptr->palette);
|
||||
info_ptr->valid &= ~(PNG_INFO_PLTE);
|
||||
info_ptr->num_palette = 0;
|
||||
@@ -450,7 +468,9 @@ if (mask & PNG_FREE_PLTE)
|
||||
/* free any image bits attached to the info structure */
|
||||
if (mask & PNG_FREE_ROWS)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (info_ptr->free_me & PNG_FREE_ROWS)
|
||||
#endif
|
||||
{
|
||||
int row;
|
||||
|
||||
@@ -460,8 +480,10 @@ if (mask & PNG_FREE_ROWS)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(num == -1)
|
||||
info_ptr->free_me &= ~mask;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is an internal routine to free any memory that the info struct is
|
||||
@@ -475,7 +497,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
@@ -561,7 +583,7 @@ png_charp
|
||||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||
return ("\n libpng version 1.0.6h - April 24, 2000\n\
|
||||
return ("\n libpng version 1.0.6i - May 1, 2000\n\
|
||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
|
||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n");
|
||||
@@ -579,8 +601,8 @@ png_get_libpng_ver(png_structp png_ptr)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||
return("1.0.6h");
|
||||
return("1.0.6h");
|
||||
return("1.0.6i");
|
||||
return("1.0.6i");
|
||||
}
|
||||
|
||||
png_charp
|
||||
|
||||
121
png.h
121
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.0.6h - April 24, 2000
|
||||
* libpng version 1.0.6i - May 1, 2000
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
@@ -9,7 +9,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.0.6h - April 24, 2000: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.0.6i - May 1, 2000: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -48,9 +48,11 @@
|
||||
* 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (not binary compatible)
|
||||
* 1.0.6 (+ 3 patches) 1.0.6 10006 2.1.0.6 (still binary incompat)
|
||||
* 1.0.6d-f 1.0.6d-f 10007 2.1.0.6d-f (still binary incompat)
|
||||
* 1.0.6g 1.0.6g 10007 2.1.0.6g (compatible with 1.0.5)
|
||||
* 1.0.6h 1.0.6h 10007 10.6h (compatible with 1.0.5)
|
||||
* 1.0.7 1.0.7 10007 10.7 (still compatible)
|
||||
* 1.0.6g 1.0.6g 10007 2.1.0.6g
|
||||
* 1.0.6h 1.0.6h 10007 10.6h
|
||||
* 1.0.6 (+ 4 patches) 1.0.6 10006 2.1.0.6ad (compatible with 1.0.0)
|
||||
* 1.0.6i 1.0.6i 10007 10.6i (can be compatible w/ 1.0.0)
|
||||
* 1.0.7 1.0.7 10007 10.7 (still can be compatible)
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -79,7 +81,7 @@
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* (libpng versions 0.89c, June 1996, through 0.96, May 1997)
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
* (libpng versions 0.97, January 1998, through 1.0.6h, April 24, 2000)
|
||||
* (libpng versions 0.97, January 1998, through 1.0.6i, May 1, 2000)
|
||||
*
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
@@ -154,13 +156,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* April 24, 2000
|
||||
* May 1, 2000
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.0.6h are Y2K compliant. It is my belief that earlier
|
||||
* upward through 1.0.6i are Y2K compliant. It is my belief that earlier
|
||||
* versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||
@@ -238,7 +240,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.6h"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.6i"
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
@@ -489,15 +491,13 @@ typedef struct png_info_struct
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
*/
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sRGB_SUPPORTED)
|
||||
/* GR-P, 0.96a */
|
||||
@@ -517,9 +517,6 @@ typedef struct png_info_struct
|
||||
int num_text; /* number of comments read/to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read/to write */
|
||||
int num_text_old; /* number of comments read/to write */
|
||||
png_textp text_old; /* array of comments read/to write, backward
|
||||
compatible with libpng-1.0.5 and earlier */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_tIME_SUPPORTED)
|
||||
@@ -595,7 +592,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_cHRM_SUPPORTED)
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
@@ -636,6 +633,16 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_byte pcal_nparams; /* number of parameters given in pcal_params */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
png_size_t unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_iCCP_SUPPORTED)
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
@@ -669,19 +676,13 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
png_size_t unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
|
||||
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
|
||||
png_bytepp row_pointers; /* the image bits */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
|
||||
png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
|
||||
#endif
|
||||
|
||||
@@ -696,8 +697,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_fixed_point int_y_blue;
|
||||
#endif
|
||||
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
} png_info;
|
||||
|
||||
typedef png_info FAR * png_infop;
|
||||
@@ -828,7 +827,8 @@ typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
typedef void (*png_user_transform_ptr) PNGARG((png_structp,
|
||||
png_row_infop, png_bytep));
|
||||
#endif
|
||||
@@ -885,11 +885,14 @@ struct png_struct_def
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
|
||||
/* These were added in libpng-1.0.2 */
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
png_voidp user_transform_ptr; /* user supplied struct for user transform */
|
||||
png_byte user_transform_depth; /* bit depth of user transformed pixels */
|
||||
png_byte user_transform_channels; /* channels in user transformed pixels */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
@@ -941,8 +944,12 @@ struct png_struct_def
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
png_byte filler; /* filler byte for pixel expansion */
|
||||
#else
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
@@ -1058,6 +1065,22 @@ struct png_struct_def
|
||||
png_free_ptr free_fn; /* function for freeing memory */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
png_voidp user_chunk_ptr;
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_byte rgb_to_gray_status;
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
@@ -1070,27 +1093,16 @@ struct png_struct_def
|
||||
png_byte empty_plte_permitted;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_fixed_point int_gamma;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
png_voidp user_chunk_ptr;
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
};
|
||||
|
||||
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
||||
and png.h are both at * version 1.0.6h
|
||||
and png.h are both at * version 1.0.6i
|
||||
*/
|
||||
typedef png_structp version_1_0_6h;
|
||||
typedef png_structp version_1_0_6i;
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
@@ -1574,18 +1586,21 @@ extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
|
||||
extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
|
||||
png_ptr, png_user_transform_ptr read_user_transform_fn));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
|
||||
png_ptr, png_user_transform_ptr write_user_transform_fn));
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
|
||||
png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
|
||||
int user_transform_channels));
|
||||
@@ -1634,18 +1649,17 @@ extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
|
||||
/* Free data that was allocated internally */
|
||||
extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 free_me, int num));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
/* Reassign responsibility for freeing existing data, whether allocated
|
||||
* by libpng or by the application */
|
||||
extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, int freer, png_uint_32 mask));
|
||||
#endif
|
||||
/* assignments for png_data_freer */
|
||||
#define PNG_DESTROY_WILL_FREE_DATA 1
|
||||
#define PNG_SET_WILL_FREE_DATA 1
|
||||
#define PNG_USER_WILL_FREE_DATA 2
|
||||
/* Flags for png_ptr->free_me and info_ptr->free_me */
|
||||
#define PNG_FREE_PLTE 0x0001
|
||||
#define PNG_FREE_TRNS 0x0002
|
||||
#define PNG_FREE_TEXT 0x0004
|
||||
#define PNG_FREE_HIST 0x0008
|
||||
#define PNG_FREE_ICCP 0x0010
|
||||
#define PNG_FREE_SPLT 0x0020
|
||||
@@ -1654,7 +1668,10 @@ extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
|
||||
#define PNG_FREE_SCAL 0x0100 /* not used any more */
|
||||
#define PNG_FREE_UNKN 0x0200
|
||||
#define PNG_FREE_LIST 0x0400
|
||||
#define PNG_FREE_ALL 0x07ff
|
||||
#define PNG_FREE_PLTE 0x1000
|
||||
#define PNG_FREE_TRNS 0x2000
|
||||
#define PNG_FREE_TEXT 0x4000
|
||||
#define PNG_FREE_ALL 0x3fff
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
|
||||
@@ -2034,6 +2051,7 @@ extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
|
||||
#endif
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||
/* The "params" pointer is currently not used and is for future expansion. */
|
||||
extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr,
|
||||
int transforms,
|
||||
@@ -2084,7 +2102,7 @@ extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)
|
||||
extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
||||
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.0.6h - April 24, 2000 (header)\n"
|
||||
" libpng version 1.0.6i - May 1, 2000 (header)\n"
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
/* With these routines we avoid an integer divide, which will be slower on
|
||||
@@ -2150,6 +2168,8 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
||||
#define PNG_WROTE_tIME 0x200
|
||||
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
|
||||
#define PNG_BACKGROUND_IS_GRAY 0x800
|
||||
#define PNG_CREATED_READ_STRUCT 0x1000
|
||||
#define PNG_CREATED_WRITE_STRUCT 0x2000
|
||||
|
||||
/* flags for the transformations the PNG library does on the image data */
|
||||
#define PNG_BGR 0x0001
|
||||
@@ -2200,8 +2220,11 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
|
||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
|
||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
||||
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x1000
|
||||
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x2000
|
||||
#define PNG_FLAG_FREE_PLTE 0x1000
|
||||
#define PNG_FLAG_FREE_TRNS 0x2000
|
||||
#define PNG_FLAG_FREE_HIST 0x4000
|
||||
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
|
||||
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
|
||||
|
||||
/* For use in png_set_keep_unknown, png_handle_as_unknown */
|
||||
#define HANDLE_CHUNK_AS_DEFAULT 0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
64
pngconf.h
64
pngconf.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -17,6 +17,38 @@
|
||||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
/* The following support, added at version 1.0.6, will be turned on by
|
||||
* default in version 2.0.0.
|
||||
* They have been turned off here in case you need binary compatibility
|
||||
* with old applications that require the length of png_struct and
|
||||
* png_info to remain at the old length.
|
||||
*/
|
||||
|
||||
#include "pngcrush.h" /* except for this line, this is libpng's pngconf.h */
|
||||
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
#define PNG_NO_FREE_ME
|
||||
#define PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
#define PNG_NO_WRITE_UNKNOWN_CHUNKS
|
||||
#define PNG_NO_READ_USER_CHUNKS
|
||||
#define PNG_NO_READ_iCCP
|
||||
#define PNG_NO_WRITE_iCCP
|
||||
#define PNG_NO_READ_sCAL
|
||||
#define PNG_NO_WRITE_sCAL
|
||||
#define PNG_NO_READ_sPLT
|
||||
#define PNG_NO_WRITE_sPLT
|
||||
#define PNG_NO_INFO_IMAGE
|
||||
#define PNG_NO_READ_RGB_TO_GRAY
|
||||
#define PNG_NO_READ_USER_TRANSFORM
|
||||
#define PNG_NO_WRITE_USER_TRANSFORM
|
||||
#define PNG_NO_USER_MEM
|
||||
#define PNG_NO_READ_EMPTY_PLTE
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FREE_ME
|
||||
#define PNG_FREE_ME_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* This is the size of the compression buffer, and thus the size of
|
||||
* an IDAT chunk. Make this whatever size you feel is best for your
|
||||
* machine. One of these will be allocated per png_struct. When this
|
||||
@@ -271,7 +303,9 @@
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FIXED_POINT_SUPPORTED
|
||||
/* Ignore attempt to turn off both floating and fixed point support */
|
||||
|
||||
#ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
@@ -389,6 +423,13 @@
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifndef PNG_NO_USER_TRANSFORM_PTR
|
||||
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||
encoders, but can cause trouble
|
||||
if left undefined */
|
||||
@@ -455,7 +496,9 @@
|
||||
/* very little testing */
|
||||
/*
|
||||
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
|
||||
#ifndef PNG_NO_USER_MEM
|
||||
#define PNG_USER_MEM_SUPPORTED
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* This is only for PowerPC big-endian and 680x0 systems */
|
||||
@@ -560,7 +603,15 @@
|
||||
# define PNG_READ_zTXt_SUPPORTED
|
||||
# define PNG_zTXt_SUPPORTED
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_USER_CHUNKS
|
||||
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#if !defined (PNG_NO_READ_USER_CHUNKS) && \
|
||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
# define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
# define PNG_USER_CHUNKS_SUPPORTED
|
||||
# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
@@ -570,13 +621,6 @@
|
||||
# undef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_NO_READ_OPT_PLTE
|
||||
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
|
||||
#endif /* optional PLTE chunk in RGB and RGBA images */
|
||||
|
||||
259
pngcrush.c
259
pngcrush.c
@@ -15,7 +15,7 @@
|
||||
* occasionally creating Linux executables.
|
||||
*/
|
||||
|
||||
#define PNGCRUSH_VERSION "1.4.3"
|
||||
#define PNGCRUSH_VERSION "1.4.4"
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE:
|
||||
@@ -46,6 +46,10 @@
|
||||
*/
|
||||
|
||||
/* Change log:
|
||||
*
|
||||
* Version 1.4.4 (built with libpng-1.0.6i and cexcept-0.6.3)
|
||||
*
|
||||
* Can be built on RISCOS platforms.
|
||||
*
|
||||
* Version 1.4.3 (built with libpng-1.0.6h and cexcept-0.6.3)
|
||||
*
|
||||
@@ -213,14 +217,23 @@
|
||||
# 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
|
||||
#if !defined(__TURBOC__) && !defined(_MSC_VER) && !defined(_MBCS)
|
||||
#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>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@@ -247,6 +260,26 @@
|
||||
|
||||
/* so we can load pngcrush with pre-1.0.6 versions of libpng */
|
||||
|
||||
/* for version 1.0.2 and earlier */
|
||||
#ifndef PNG_MAX_UINT
|
||||
#define PNG_MAX_UINT 2147483647L
|
||||
#endif
|
||||
|
||||
/* for version 0.89c and earlier */
|
||||
#ifndef PNG_TEXT_COMPRESSION_NONE
|
||||
#define PNG_TEXT_COMPRESSION_NONE -1
|
||||
#define PNG_TEXT_COMPRESSION_zTXt 0
|
||||
#endif
|
||||
#ifndef png_debug
|
||||
#define png_debug(l, m)
|
||||
#endif
|
||||
#ifndef png_debug1
|
||||
#define png_debug1(l, m, p1)
|
||||
#endif
|
||||
#ifndef png_debug2
|
||||
#define png_debug2(l, m, p1, p2)
|
||||
#endif
|
||||
|
||||
#if (PNG_LIBPNG_VER < 10006)
|
||||
/* These shorter macros weren't defined until version 1.0.6 */
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
@@ -279,16 +312,22 @@
|
||||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
#if CLOCKS_PER_SEC <= 100
|
||||
# define TIME_T long
|
||||
#else
|
||||
# define TIME_T float
|
||||
#endif
|
||||
|
||||
/* defined so I can write to a file on gui/windowing platforms */
|
||||
/* #define STDERR stderr */
|
||||
#define STDERR stdout /* for DOS */
|
||||
|
||||
/* input and output filenames */
|
||||
static PNG_CONST char *progname = "pngtest.png";
|
||||
static PNG_CONST char *inname = "pngtest.png";
|
||||
static PNG_CONST char *outname = "pngout.png";
|
||||
static PNG_CONST char *directory_name = "pngcrush.bak";
|
||||
static PNG_CONST char *extension = "_C.png";
|
||||
static PNG_CONST char *progname = "pngtest" DOT "png";
|
||||
static PNG_CONST char *inname = "pngtest" DOT "png";
|
||||
static PNG_CONST char *outname = "pngout" DOT "png";
|
||||
static PNG_CONST char *directory_name = "pngcrush" DOT "bak";
|
||||
static PNG_CONST char *extension = "_C" DOT "png";
|
||||
|
||||
static png_uint_32 measured_idat_length;
|
||||
static int all_chunks_are_safe=0;
|
||||
@@ -323,7 +362,11 @@ char *str_return;
|
||||
define_exception_type(const char *);
|
||||
extern struct exception_context the_exception_context[1];
|
||||
struct exception_context the_exception_context[1];
|
||||
#if (PNG_LIBPNG_VER > 96)
|
||||
png_const_charp msg;
|
||||
#else
|
||||
const char *msg;
|
||||
#endif
|
||||
|
||||
static png_uint_32 total_input_length = 0;
|
||||
static png_uint_32 total_output_length = 0;
|
||||
@@ -405,7 +448,7 @@ png_uint_32 png_measure_idat(png_structp png_ptr);
|
||||
static png_uint_32 idat_length[MAX_METHODSP1];
|
||||
static int filter_method, zlib_level;
|
||||
static png_bytep png_row_filters=NULL;
|
||||
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||
static TIME_T t_start, t_stop, t_decode, t_encode, t_misc;
|
||||
|
||||
static png_uint_32 max_idat_size = PNG_ZBUF_SIZE;
|
||||
int ia;
|
||||
@@ -419,6 +462,17 @@ int ia;
|
||||
* libpng.
|
||||
*/
|
||||
|
||||
#if (PNG_LIBPNG_VER < 95)
|
||||
png_uint_32
|
||||
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->rowbytes);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (PNG_LIBPNG_VER < 10007)
|
||||
/* This is binary incompatible with versions earlier than 0.99h because of the
|
||||
* introduction of png_user_transform stuff ahead of the zbuf_size member
|
||||
@@ -428,6 +482,14 @@ int ia;
|
||||
static png_uint_32
|
||||
png_get_compression_buffer_size(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr->zbuf_size != PNG_ZBUF_SIZE)
|
||||
{
|
||||
fprintf(STDERR, " png_ptr->zbuf_size = %d but PNG_ZBUF_SIZE is %d\n",
|
||||
png_ptr->zbuf_size, PNG_ZBUF_SIZE);
|
||||
fprintf(STDERR, " You may be using pngcrush with an incompatible version");
|
||||
fprintf(STDERR, " of libpng. pngcrush was compiled with version %s\n",
|
||||
PNG_LIBPNG_VER_STRING);
|
||||
}
|
||||
return(png_ptr->zbuf_size);
|
||||
}
|
||||
static void
|
||||
@@ -590,6 +652,61 @@ void png_crush_pause(void)
|
||||
/* stifle compiler warning */ return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __riscos
|
||||
#include <kernel.h>
|
||||
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
|
||||
}
|
||||
#else
|
||||
# define setfiletype(x)
|
||||
#endif
|
||||
|
||||
int keep_chunk(png_const_charp name, char *argv[]);
|
||||
|
||||
int keep_chunk(png_const_charp name, char *argv[])
|
||||
@@ -665,7 +782,7 @@ show_result(void)
|
||||
-(100.0 - (100.0*total_output_length)/total_input_length),
|
||||
total_output_length - total_input_length);
|
||||
}
|
||||
t_stop = (float)clock();
|
||||
t_stop = (TIME_T)clock();
|
||||
t_misc += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
fprintf(STDERR," CPU time used = %.3f seconds",
|
||||
@@ -723,15 +840,19 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
|
||||
}
|
||||
|
||||
t_start = (float)clock();
|
||||
t_start = (TIME_T)clock();
|
||||
|
||||
prog_string[0] = '\0';
|
||||
str_return = strcat(prog_string,argv[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
|
||||
}
|
||||
|
||||
for(i=0; i<MAX_METHODS; i++)
|
||||
@@ -1676,7 +1797,11 @@ main(int argc, char *argv[])
|
||||
while(*ip != '\0')
|
||||
{
|
||||
*op++ = *ip++;
|
||||
#ifdef __riscos
|
||||
if(*ip == '/')dot=op;
|
||||
#else
|
||||
if(*ip == '.')dot=op;
|
||||
#endif
|
||||
}
|
||||
*op = '\0';
|
||||
|
||||
@@ -1695,8 +1820,12 @@ main(int argc, char *argv[])
|
||||
|
||||
if(pngcrush_mode == DIRECTORY_MODE)
|
||||
{
|
||||
#ifdef __riscos
|
||||
if(fileexists(directory_name) & 2)
|
||||
#else
|
||||
struct stat stat_buf;
|
||||
if(stat(directory_name, &stat_buf) != 0)
|
||||
#endif
|
||||
{
|
||||
#if defined(_MBCS) || defined(WIN32) || defined(__WIN32__)
|
||||
if(_mkdir(directory_name) != 0)
|
||||
@@ -1715,11 +1844,16 @@ main(int argc, char *argv[])
|
||||
in_string[0] = '\0';
|
||||
str_return = strcat(in_string,inname);
|
||||
ip = op = in_string;
|
||||
#ifdef __riscos
|
||||
op = strrchr(in_string, '.');
|
||||
if (!op) op = in_string; else op++;
|
||||
#else
|
||||
while(*ip != '\0')
|
||||
{
|
||||
if(*ip == '\\' || *ip == '/')op=ip+1;
|
||||
ip++;
|
||||
}
|
||||
#endif
|
||||
|
||||
str_return = strcat(out_string,op);
|
||||
outname=out_string;
|
||||
@@ -1751,6 +1885,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if(idat_length[0] == 0) continue;
|
||||
|
||||
}
|
||||
else
|
||||
idat_length[0]=1;
|
||||
@@ -1787,7 +1922,9 @@ main(int argc, char *argv[])
|
||||
if(idat_length[best] == idat_length[0] && things_have_changed == 0
|
||||
&& best != final_method && nosave == 0)
|
||||
{
|
||||
#ifndef __riscos
|
||||
struct stat stat_in, stat_out;
|
||||
#endif
|
||||
/* just copy input to output */
|
||||
|
||||
P2("prepare to copy input to output\n");
|
||||
@@ -1810,10 +1947,14 @@ main(int argc, char *argv[])
|
||||
number_of_open_files++;
|
||||
P2("copying input to output...");
|
||||
|
||||
#ifndef __riscos
|
||||
stat(inname, &stat_in);
|
||||
stat(outname, &stat_out);
|
||||
if((stat_in.st_ino != stat_out.st_ino) ||
|
||||
(stat_in.st_size != stat_out.st_size))
|
||||
#else
|
||||
/* (brokenly) assume that they're different */
|
||||
#endif
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
@@ -1830,6 +1971,7 @@ main(int argc, char *argv[])
|
||||
png_crush_pause();
|
||||
FCLOSE(fpin);
|
||||
FCLOSE(fpout);
|
||||
setfiletype(outname);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1880,6 +2022,10 @@ main(int argc, char *argv[])
|
||||
number_of_open_files++;
|
||||
if(nosave == 0)
|
||||
{
|
||||
#ifndef __riscos
|
||||
/* Can't sensibly check this on RISC OS without opening a file for
|
||||
update or output
|
||||
*/
|
||||
struct stat stat_in, stat_out;
|
||||
stat(inname, &stat_in);
|
||||
stat(outname, &stat_out);
|
||||
@@ -1897,7 +2043,7 @@ main(int argc, char *argv[])
|
||||
FCLOSE(fpin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
if ((fpout = FOPEN(outname, "wb")) == NULL)
|
||||
{
|
||||
fprintf(STDERR, "Could not open output file %s\n", outname);
|
||||
@@ -1969,7 +2115,9 @@ main(int argc, char *argv[])
|
||||
/* We don't need to check CRC's because they were already checked
|
||||
in the png_measure_idat function */
|
||||
|
||||
#ifdef PNG_CRC_QUIET_USE
|
||||
png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
|
||||
#endif
|
||||
|
||||
#if (PNG_LIBPNG_VER >= 10000)
|
||||
/* reinitialize zbuf - compression buffer */
|
||||
@@ -2113,6 +2261,7 @@ main(int argc, char *argv[])
|
||||
png_debug(0, "Reading info struct\n");
|
||||
png_read_info(read_ptr, read_info_ptr);
|
||||
|
||||
#if (PNG_LIBPNG_VER > 90)
|
||||
png_debug(0, "Transferring info struct\n");
|
||||
{
|
||||
int interlace_type, compression_type, filter_type;
|
||||
@@ -2387,6 +2536,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) && defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
{
|
||||
int file_intent;
|
||||
@@ -2574,24 +2724,24 @@ main(int argc, char *argv[])
|
||||
trns_gray = trans_values->gray;
|
||||
if(output_color_type == 3)
|
||||
{
|
||||
if(verbose > 2)
|
||||
fprintf(STDERR," Filling trns_array\n");
|
||||
for (ia=0;ia<num_trans;ia++)
|
||||
trns_array[ia]=trans[ia];
|
||||
if(verbose > 2)
|
||||
fprintf(STDERR," Extending trns_array\n");
|
||||
for ( ; ia<256; ia++)
|
||||
trns_array[ia]=255;
|
||||
if(verbose > 2)
|
||||
fprintf(STDERR," Done filling trns_array\n");
|
||||
for (ia=0; ia<256; ia++)
|
||||
{
|
||||
if(trns_array[ia] != 255)
|
||||
last_nonmax=ia;
|
||||
}
|
||||
num_trans = last_nonmax+1;
|
||||
if(num_trans == 0 && verbose > 0)
|
||||
if(first_trial && verbose > 0)
|
||||
{
|
||||
if(last_nonmax < 0)
|
||||
fprintf(STDERR," Deleting all-opaque tRNS chunk.\n");
|
||||
else if(last_nonmax+1 < num_trans)
|
||||
fprintf(STDERR,
|
||||
" Truncating trailing opaque entries from tRNS chunk.\n");
|
||||
}
|
||||
num_trans = last_nonmax+1;
|
||||
}
|
||||
if(verbose > 1)
|
||||
fprintf(STDERR," png_set_tRNS, num_trans=%d\n",num_trans);
|
||||
@@ -2700,6 +2850,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_sPLT_SUPPORTED)
|
||||
{
|
||||
png_sPLT_tp entries;
|
||||
@@ -2821,6 +2972,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) && defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
{
|
||||
png_timep mod_time;
|
||||
@@ -2832,9 +2984,11 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_LIBPNG_VER > 90 */
|
||||
|
||||
png_read_transform_info(read_ptr, read_info_ptr);
|
||||
|
||||
|
||||
if(nosave == 0)
|
||||
{
|
||||
png_set_compression_level(write_ptr, zlib_level);
|
||||
@@ -2874,6 +3028,7 @@ main(int argc, char *argv[])
|
||||
P2("wrote info structure.\n");
|
||||
png_crush_pause();
|
||||
|
||||
#if (PNG_LIBPNG_VER > 90)
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if(output_bit_depth < input_bit_depth)
|
||||
{
|
||||
@@ -2887,6 +3042,7 @@ main(int argc, char *argv[])
|
||||
png_set_packing(write_ptr);
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_LIBPNG_VER > 90 */
|
||||
} /* no save */
|
||||
|
||||
#define LARGE_PNGCRUSH
|
||||
@@ -2940,7 +3096,7 @@ main(int argc, char *argv[])
|
||||
if(nosave == 0)
|
||||
png_set_interlace_handling(write_ptr);
|
||||
|
||||
t_stop = (float)clock();
|
||||
t_stop = (TIME_T)clock();
|
||||
t_misc += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
for (pass = 0; pass < num_pass; pass++)
|
||||
@@ -2951,11 +3107,11 @@ main(int argc, char *argv[])
|
||||
png_read_row(read_ptr, row_buf, (png_bytep)NULL);
|
||||
if(nosave == 0)
|
||||
{
|
||||
t_stop = (float)clock();
|
||||
t_stop = (TIME_T)clock();
|
||||
t_decode += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
png_write_row(write_ptr, row_buf);
|
||||
t_stop = (float)clock();
|
||||
t_stop = (TIME_T)clock();
|
||||
t_encode += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
}
|
||||
@@ -2964,7 +3120,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
if(nosave)
|
||||
{
|
||||
t_stop = (float)clock();
|
||||
t_stop = (TIME_T)clock();
|
||||
t_decode += (t_stop - t_start);
|
||||
t_start = t_stop;
|
||||
}
|
||||
@@ -3000,6 +3156,7 @@ main(int argc, char *argv[])
|
||||
png_debug(0, "Reading and writing end_info data\n");
|
||||
png_read_end(read_ptr, end_info_ptr);
|
||||
|
||||
#if (PNG_LIBPNG_VER > 90)
|
||||
#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) || \
|
||||
(defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
|
||||
{
|
||||
@@ -3136,6 +3293,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_LIBPNG_VER > 90 */
|
||||
|
||||
if(nosave == 0)
|
||||
png_write_end(write_ptr, write_end_info_ptr);
|
||||
@@ -3163,7 +3321,10 @@ main(int argc, char *argv[])
|
||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||
if(nosave == 0)
|
||||
{
|
||||
FCLOSE(fpout);
|
||||
setfiletype(outname);
|
||||
}
|
||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||
FCLOSE(fpin);
|
||||
if(verbose > 1)
|
||||
@@ -3175,7 +3336,10 @@ main(int argc, char *argv[])
|
||||
write_ptr=NULL;
|
||||
FCLOSE(fpin);
|
||||
if(nosave == 0)
|
||||
{
|
||||
FCLOSE(fpout);
|
||||
setfiletype(outname);
|
||||
}
|
||||
|
||||
if(nosave != 0)
|
||||
break;
|
||||
@@ -3217,20 +3381,25 @@ main(int argc, char *argv[])
|
||||
if (nosave == 0 && fpout)
|
||||
{
|
||||
FCLOSE(fpout);
|
||||
setfiletype(outname);
|
||||
}
|
||||
|
||||
if(verbose > 0 && nosave == 0)
|
||||
{
|
||||
png_uint_32 input_length, output_length;
|
||||
|
||||
#ifdef __riscos
|
||||
input_length = (unsigned long)filesize(inname);
|
||||
output_length = (unsigned long)filesize(outname);
|
||||
#else
|
||||
struct stat stat_buf;
|
||||
|
||||
stat(inname, &stat_buf);
|
||||
input_length = (unsigned long)stat_buf.st_size;
|
||||
total_input_length += input_length;
|
||||
stat(outname, &stat_buf);
|
||||
output_length = (unsigned long)stat_buf.st_size;
|
||||
total_output_length += output_length;
|
||||
#endif
|
||||
total_input_length += input_length + output_length;
|
||||
if(input_length == output_length)
|
||||
fprintf(STDERR,
|
||||
" Best %s method = %d for %s (no change)\n\n",
|
||||
@@ -3264,7 +3433,11 @@ main(int argc, char *argv[])
|
||||
png_uint_32
|
||||
measure_idats(FILE *fpin)
|
||||
{
|
||||
#if (PNG_LIBPNG_VER > 96)
|
||||
png_const_charp msg;
|
||||
#else
|
||||
const char *msg;
|
||||
#endif
|
||||
P2("measure_idats:\n");
|
||||
png_debug(0, "Allocating read structure\n");
|
||||
Try
|
||||
@@ -3305,14 +3478,14 @@ png_measure_idat(png_structp png_ptr)
|
||||
png_debug(1, "in png_read_info\n");
|
||||
|
||||
{
|
||||
png_byte png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
png_byte png_sign[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
png_read_data(png_ptr, png_sig, 8);
|
||||
png_read_data(png_ptr, png_sign, 8);
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
|
||||
if (png_sig_cmp(png_sig, 0, 8))
|
||||
if (png_sig_cmp(png_sign, 0, 8))
|
||||
{
|
||||
if (png_sig_cmp(png_sig, 0, 4))
|
||||
if (png_sig_cmp(png_sign, 0, 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
@@ -3339,18 +3512,6 @@ png_measure_idat(png_structp png_ptr)
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, chunk_name, 4);
|
||||
|
||||
#ifdef PNG_UINT_IDAT
|
||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IHDR)
|
||||
#else
|
||||
if (!png_memcmp(chunk_name, png_IHDR, 4))
|
||||
#endif
|
||||
{
|
||||
/* get the color type */
|
||||
png_crc_read(png_ptr, buffer, 13);
|
||||
length-=13;
|
||||
input_color_type=buffer[9];
|
||||
}
|
||||
|
||||
#ifdef PNG_UINT_IDAT
|
||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IDAT)
|
||||
#else
|
||||
@@ -3363,8 +3524,22 @@ png_measure_idat(png_structp png_ptr)
|
||||
chunk_name[4]='\0';
|
||||
printf( "Reading %s chunk, length = %ld.\n", chunk_name, length);
|
||||
}
|
||||
|
||||
#ifdef PNG_UINT_IDAT
|
||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IHDR)
|
||||
#else
|
||||
if (!png_memcmp(chunk_name, png_IHDR, 4))
|
||||
#endif
|
||||
{
|
||||
/* get the color type */
|
||||
png_crc_read(png_ptr, buffer, 13);
|
||||
length-=13;
|
||||
input_color_type=buffer[9];
|
||||
}
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
||||
|
||||
#ifdef PNG_UINT_IEND
|
||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IEND)
|
||||
#else
|
||||
@@ -3373,7 +3548,7 @@ png_measure_idat(png_structp png_ptr)
|
||||
return sum_idat_length;
|
||||
}
|
||||
}
|
||||
#else /* PNG_LIBPNG_VER < 96 */
|
||||
#else /* !PNG_LIBPNG_VER > 95 */
|
||||
main()
|
||||
{
|
||||
printf("Sorry, but pngcrush needs libpng version 0.96 or later\n");
|
||||
|
||||
13
pngcrush.h
13
pngcrush.h
@@ -6,6 +6,8 @@
|
||||
#ifndef PNGCRUSH_H
|
||||
#define PNGCRUSH_H
|
||||
|
||||
#define PNG_NO_LEGACY_SUPPORTED
|
||||
|
||||
#define PNG_SETJMP_NOT_SUPPORTED
|
||||
|
||||
#if PNG_LIBPNG_VER > 10006
|
||||
@@ -36,22 +38,28 @@
|
||||
#define PNG_NO_WRITE_TRANSFORMS
|
||||
#define PNG_NO_PROGRESSIVE_READ
|
||||
#define PNG_NO_WRITE_WEIGHTED_FILTER
|
||||
#define PNG_NO_READ_COMPOSITED_NODIV
|
||||
|
||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
|
||||
#if (PNG_LIBPNG_VER > 10002)
|
||||
/* versions 0.96 through 1.0.2 have a stub png_rgb_to_gray() with the
|
||||
* wrong number of parameters */
|
||||
# define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
# define PNG_READ_BACKGROUND_SUPPORTED
|
||||
# define PNG_READ_GAMMA_SUPPORTED
|
||||
#else
|
||||
# if (PNG_LIBPNG_VER < 10007)
|
||||
# define PNG_NO_READ_RGB_TO_GRAY
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(PNG_ZBUF_SIZE) && (PNG_LIBPNG_VER > 97)
|
||||
# define PNG_ZBUF_SIZE 524288 /* increases the IDAT size */
|
||||
#endif
|
||||
@@ -66,6 +74,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* We are not supporting legacy code so we don't need the reserved space */
|
||||
|
||||
/* This allows png_default_error() to return, when it is called after our
|
||||
own exception handling, which only returns after "Too many IDAT's",
|
||||
that we want to handle as a warning instead of an error. */
|
||||
#define PNG_ABORT()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
|
||||
* for Intel's performance analysis of the MMX vs. non-MMX code.
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998, Intel Corporation
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
|
||||
4
pngget.c
4
pngget.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -434,6 +434,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32
|
||||
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
png_fixed_point *int_file_gamma)
|
||||
@@ -448,6 +449,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
png_uint_32
|
||||
|
||||
2
pngmem.c
2
pngmem.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -1336,12 +1336,14 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
/* to quiet compiler warnings about unused info_ptr */
|
||||
|
||||
51
pngread.c
51
pngread.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -108,6 +108,8 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
png_set_read_fn(png_ptr, NULL, NULL);
|
||||
|
||||
png_ptr->mode |= PNG_CREATED_READ_STRUCT;
|
||||
|
||||
return (png_ptr);
|
||||
}
|
||||
|
||||
@@ -136,6 +138,15 @@ png_read_init(png_structp png_ptr)
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
#ifndef PNG_LEGACY_SUPPORTED
|
||||
if(!(png_ptr->mode & PNG_CREATED_READ_STRUCT))
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
png_error(png_ptr,
|
||||
"Read struct not properly created; use a legacy-supporting libpng.");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
@@ -641,7 +652,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
* not called png_set_interlace_handling(), the display_row buffer will
|
||||
* be ignored, so pass NULL to it.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6h.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6i.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -690,7 +701,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
* only call this function once. If you desire to have an image for
|
||||
* each pass of a interlaced image, use png_read_rows() instead.
|
||||
*
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6h.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6i.
|
||||
*/
|
||||
void
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
@@ -1013,19 +1024,37 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_from_1);
|
||||
png_free(png_ptr, png_ptr->gamma_to_1);
|
||||
#endif
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
#if defined(PNG_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->free_me &= ~PNG_FREE_TRNS;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if (png_ptr->free_me & PNG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->free_me &= ~PNG_FREE_HIST;
|
||||
#else
|
||||
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
|
||||
png_free(png_ptr, png_ptr->hist);
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
@@ -1218,15 +1247,29 @@ void png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||
|
||||
/* -------------- image transformations end here ------------------- */
|
||||
|
||||
if(info_ptr->row_pointers)
|
||||
{
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(info_ptr->free_me & PNG_FREE_ROWS)
|
||||
{
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
png_free(png_ptr, info_ptr->row_pointers[row]);
|
||||
png_free(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->row_pointers = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(info_ptr->row_pointers == NULL)
|
||||
{
|
||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||
info_ptr->height * sizeof(png_bytep));
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||
}
|
||||
#endif
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
info_ptr->row_pointers[row] = png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr));
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, info_ptr->row_pointers);
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
|
||||
2
pngrio.c
2
pngrio.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
||||
18
pngrtran.c
18
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -645,14 +645,23 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void
|
||||
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
#endif
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
if(read_user_transform_fn)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transforms");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1079,7 +1088,8 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->channels++;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if(png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if(info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
@@ -1307,10 +1317,12 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if(png_ptr->user_transform_depth)
|
||||
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
|
||||
if(png_ptr->user_transform_channels)
|
||||
png_ptr->row_info.channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
png_ptr->row_info.channels);
|
||||
png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
|
||||
|
||||
34
pngrutil.c
34
pngrutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -446,8 +446,12 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||
png_ptr->free_me |= PNG_FREE_PLTE;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_PLTE;
|
||||
#endif
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
@@ -849,8 +853,19 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
igamma=(int)info_ptr->int_gamma;
|
||||
#else
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
igamma=info_ptr->gamma * 100000.;
|
||||
igamma=(int)(info_ptr->gamma * 100000.);
|
||||
# endif
|
||||
#endif
|
||||
#if 0 && defined(PNG_cHRM_SUPPORTED) && !defined(PNG_FIXED_POINT_SUPPORTED)
|
||||
/* We need to define these here because they aren't in png.h */
|
||||
png_fixed_point int_x_white;
|
||||
png_fixed_point int_y_white;
|
||||
png_fixed_point int_x_red;
|
||||
png_fixed_point int_y_red;
|
||||
png_fixed_point int_x_green;
|
||||
png_fixed_point int_y_green;
|
||||
png_fixed_point int_x_blue;
|
||||
png_fixed_point int_y_blue;
|
||||
#endif
|
||||
if(igamma < 45000L || igamma > 46000L)
|
||||
{
|
||||
@@ -870,6 +885,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif /* PNG_READ_gAMA_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
if (info_ptr->valid & PNG_INFO_cHRM)
|
||||
if (abs(info_ptr->int_x_white - 31270L) > 1000 ||
|
||||
abs(info_ptr->int_y_white - 32900L) > 1000 ||
|
||||
@@ -883,6 +899,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect cHRM value when sRGB is also present");
|
||||
}
|
||||
#endif /* PNG_FIXED_POINT_SUPPORTED */
|
||||
#endif /* PNG_READ_cHRM_SUPPORTED */
|
||||
|
||||
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
|
||||
@@ -1157,8 +1174,12 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
png_ptr->free_me |= PNG_FREE_TRNS;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
png_set_tRNS(png_ptr, info_ptr, png_ptr->trans, png_ptr->num_trans,
|
||||
&(png_ptr->trans_values));
|
||||
}
|
||||
@@ -1304,8 +1325,12 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
|
||||
png_ptr->free_me |= PNG_FREE_HIST;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_HIST;
|
||||
#endif
|
||||
png_set_hIST(png_ptr, info_ptr, png_ptr->hist);
|
||||
}
|
||||
#endif
|
||||
@@ -1924,12 +1949,14 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
HANDLE_CHUNK_ALWAYS
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
}
|
||||
|
||||
@@ -2831,7 +2858,8 @@ png_read_start_row(png_structp png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
|
||||
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if(png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
int user_pixel_depth=png_ptr->user_transform_depth*
|
||||
|
||||
15
pngset.c
15
pngset.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -123,7 +123,9 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->gamma = (float)(int_gamma/100000.);
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = int_gamma;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
@@ -441,7 +443,9 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
/* Compression is always zero but is here so the API and info structure
|
||||
* does not have to change if we introduce multiple compression types */
|
||||
info_ptr->iccp_compression = (png_byte)compression_type;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_ICCP;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_iCCP;
|
||||
}
|
||||
#endif
|
||||
@@ -574,7 +578,9 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||
|
||||
info_ptr->text[info_ptr->num_text]= *textp;
|
||||
info_ptr->num_text++;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
#endif
|
||||
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
||||
}
|
||||
}
|
||||
@@ -652,7 +658,9 @@ png_set_sPLT(png_structp png_ptr,
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->splt_palettes_num += nentries;
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
@@ -691,7 +699,9 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||
|
||||
info_ptr->unknown_chunks = np;
|
||||
info_ptr->unknown_chunks_num += num_unknowns;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_UNKN;
|
||||
#endif
|
||||
}
|
||||
void
|
||||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
@@ -749,7 +759,9 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||
*p=(png_byte)keep;
|
||||
png_ptr->num_chunk_list=old_num_chunks+num_chunks;
|
||||
png_ptr->chunk_list=new_list;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->free_me |= PNG_FREE_LIST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -780,7 +792,6 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
||||
{
|
||||
|
||||
19
pngtrans.c
19
pngtrans.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -571,16 +571,24 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_LEGACY_SUPPORTED)
|
||||
void
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info\n");
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
#else
|
||||
if(user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transform info");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function returns a pointer to the user_transform_ptr associated with
|
||||
* the user transform functions. The application should free any memory
|
||||
@@ -590,6 +598,11 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
png_voidp
|
||||
png_get_user_transform_ptr(png_structp png_ptr)
|
||||
{
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
}
|
||||
#else
|
||||
if(png_ptr)
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998, Intel Corporation
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
|
||||
2
pngwio.c
2
pngwio.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
||||
15
pngwrite.c
15
pngwrite.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -480,6 +480,8 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
1, NULL, NULL);
|
||||
#endif
|
||||
|
||||
png_ptr->mode |= PNG_CREATED_WRITE_STRUCT;
|
||||
|
||||
return ((png_structp)png_ptr);
|
||||
}
|
||||
|
||||
@@ -505,6 +507,15 @@ png_write_init(png_structp png_ptr)
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
|
||||
#endif
|
||||
|
||||
#ifndef PNG_LEGACY_SUPPORTED
|
||||
if(!(png_ptr->mode & PNG_CREATED_WRITE_STRUCT))
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
png_error(png_ptr,
|
||||
"Write struct not properly created; use a legacy-supporting libpng.");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize zbuf - compression buffer */
|
||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||
@@ -804,11 +815,13 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)info_ptr, free_fn);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
|
||||
14
pngwutil.c
14
pngwutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.6h - April 24, 2000
|
||||
* libpng 1.0.6i - May 1, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
@@ -167,7 +167,7 @@ png_text_compress(png_structp png_ptr,
|
||||
{
|
||||
comp->input = text;
|
||||
comp->input_len = text_len;
|
||||
return(text_len);
|
||||
return((int)text_len);
|
||||
}
|
||||
|
||||
if (compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
@@ -314,7 +314,7 @@ png_text_compress(png_structp png_ptr,
|
||||
if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
|
||||
text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;
|
||||
|
||||
return(text_len);
|
||||
return((int)text_len);
|
||||
}
|
||||
|
||||
/* ship the compressed text out via chunk writes */
|
||||
@@ -647,7 +647,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
profile_len = 0;
|
||||
|
||||
if (profile_len)
|
||||
profile_len = png_text_compress(png_ptr, profile, profile_len,
|
||||
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
||||
PNG_TEXT_COMPRESSION_zTXt, &comp);
|
||||
|
||||
/* make sure we include the NULL after the name and the compression type */
|
||||
@@ -1204,7 +1204,8 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
||||
png_free(png_ptr, new_key);
|
||||
|
||||
/* compute the compressed data; do it now for the length */
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp);
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression,
|
||||
&comp);
|
||||
|
||||
/* write start of chunk */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
|
||||
@@ -1256,7 +1257,8 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
||||
text_len = 0;
|
||||
|
||||
/* compute the compressed data; do it now for the length */
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression-2, &comp);
|
||||
text_len = png_text_compress(png_ptr, text, text_len, compression-2,
|
||||
&comp);
|
||||
|
||||
/* make sure we include the compression flag, the compression byte,
|
||||
* and the NULs after the key, lang, and lang_key parts */
|
||||
|
||||
Reference in New Issue
Block a user