mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from pngcrush-1.5.3.tar
This commit is contained in:
45
README.txt
45
README.txt
@@ -40,13 +40,12 @@ case of any discrepancy, the copy in pngcrush.c shall prevail):
|
|||||||
|
|
||||||
This is the output of "pngcrush" and "pngcrush -help":
|
This is the output of "pngcrush" and "pngcrush -help":
|
||||||
|
|
||||||
|
| pngcrush 1.5.3, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
| pngcrush 1.5.2, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson
|
|
||||||
| This is a free, open-source program. Permission is
|
| This is a free, open-source program. Permission is
|
||||||
| irrevocably granted to everyone to use this version
|
| irrevocably granted to everyone to use this version
|
||||||
| of pngcrush without payment of any fee.
|
| of pngcrush without payment of any fee.
|
||||||
| This program was built with libpng version 1.0.9beta2,
|
| This program was built with libpng version 1.0.9beta5,
|
||||||
| and is running with libpng version 1.0.9beta2 - November 19, 2000 (header)
|
| and is running with libpng version 1.0.9beta5 - December 14, 2000 (header)
|
||||||
| Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,
|
| Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,
|
||||||
| Copyright (C) 1996, 1997 Andreas Dilger,
|
| Copyright (C) 1996, 1997 Andreas Dilger,
|
||||||
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
|
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
|
||||||
@@ -83,6 +82,7 @@ options:
|
|||||||
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
||||||
-res dpi
|
-res dpi
|
||||||
-srgb [0, 1, 2, or 3]
|
-srgb [0, 1, 2, or 3]
|
||||||
|
-loco ("loco crush" truecolor PNGs)
|
||||||
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||||
-trns index red green blue gray
|
-trns index red green blue gray
|
||||||
-v (display more detailed information)
|
-v (display more detailed information)
|
||||||
@@ -229,6 +229,15 @@ options (Note: any option can be spelled out for clarity, e.g.,
|
|||||||
|
|
||||||
Value of 'rendering intent' for sRGB chunk.
|
Value of 'rendering intent' for sRGB chunk.
|
||||||
|
|
||||||
|
-loco ("loco crush" truecolor PNGs)
|
||||||
|
|
||||||
|
Make the file more compressible by performing a
|
||||||
|
lossless reversible color transformation.
|
||||||
|
The resulting file is a MNG, not a PNG, and should
|
||||||
|
be given the ".mng" file extension. The
|
||||||
|
"loco" option has no effect on grayscale or
|
||||||
|
indexed-color PNG files.
|
||||||
|
|
||||||
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||||
|
|
||||||
tEXt chunk to insert. keyword < 80 chars,
|
tEXt chunk to insert. keyword < 80 chars,
|
||||||
@@ -285,3 +294,31 @@ options (Note: any option can be spelled out for clarity, e.g.,
|
|||||||
screen scrolls out of sight.
|
screen scrolls out of sight.
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu)
|
||||||
|
|
||||||
|
|
||||||
|
DISCLAIMER: The pngcrush computer program is supplied "AS IS".
|
||||||
|
The Author disclaims all warranties, expressed or implied, including,
|
||||||
|
without limitation, the warranties of merchantability and of fitness
|
||||||
|
for any purpose. The Author assumes no liability for direct, indirect,
|
||||||
|
incidental, special, exemplary, or consequential damages, which may
|
||||||
|
result from the use of the computer program, even if advised of the
|
||||||
|
possibility of such damage. There is no warranty against interference
|
||||||
|
with your enjoyment of the computer program or against infringement.
|
||||||
|
There is no warranty that my efforts or the computer program will
|
||||||
|
fulfill any of your particular purposes or needs. This computer
|
||||||
|
program is provided with all faults, and the entire risk of satisfactory
|
||||||
|
quality, performance, accuracy, and effort is with the user.
|
||||||
|
|
||||||
|
LICENSE: Permission is hereby irrevocably granted to everyone to use,
|
||||||
|
copy, modify, and distribute this computer program, or portions hereof,
|
||||||
|
purpose, without payment of any fee, subject to the following
|
||||||
|
restrictions:
|
||||||
|
|
||||||
|
1. The origin of this binary or source code must not be misrepresented.
|
||||||
|
|
||||||
|
2. Altered versions must be plainly marked as such and must not be
|
||||||
|
misrepresented as being the original binary or source.
|
||||||
|
|
||||||
|
3. The Copyright notice, disclaimer, and license may not be removed
|
||||||
|
or altered from any source, binary, or altered source distribution.
|
||||||
|
|||||||
@@ -232,9 +232,10 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|||||||
}
|
}
|
||||||
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
|
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
|
||||||
|
|
||||||
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
|
||||||
#ifdef FASTEST
|
#ifdef FASTEST
|
||||||
level = 1;
|
level = 1;
|
||||||
|
#else
|
||||||
|
if (level == Z_DEFAULT_COMPRESSION) level = 6;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (windowBits < 0) { /* undocumented feature: suppress zlib header */
|
if (windowBits < 0) { /* undocumented feature: suppress zlib header */
|
||||||
|
|||||||
14
png.c
14
png.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* libpng version 1.0.9beta2 - November 19, 2000
|
* libpng version 1.0.9beta5 - December 14, 2000
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@@ -13,14 +13,14 @@
|
|||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef version_1_0_9beta2 Your_png_h_is_not_version_1_0_9beta2;
|
typedef version_1_0_9beta5 Your_png_h_is_not_version_1_0_9beta5;
|
||||||
|
|
||||||
/* Version information for C files. This had better match the version
|
/* Version information for C files. This had better match the version
|
||||||
* string defined in png.h. */
|
* string defined in png.h. */
|
||||||
|
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||||
const char png_libpng_ver[18] = "1.0.9beta2";
|
const char png_libpng_ver[18] = "1.0.9beta5";
|
||||||
|
|
||||||
/* png_sig was changed to a function in version 1.0.5c */
|
/* png_sig was changed to a function in version 1.0.5c */
|
||||||
/* Place to hold the signature string for a PNG file. */
|
/* Place to hold the signature string for a PNG file. */
|
||||||
@@ -526,7 +526,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_debug(1, "in png_info_destroy\n");
|
png_debug(1, "in png_info_destroy\n");
|
||||||
|
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
if (png_ptr->num_chunk_list)
|
if (png_ptr->num_chunk_list)
|
||||||
{
|
{
|
||||||
@@ -626,7 +626,7 @@ png_charp PNGAPI
|
|||||||
png_get_copyright(png_structp png_ptr)
|
png_get_copyright(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
|
||||||
return ((png_charp) "\n libpng version 1.0.9beta2 - November 19, 2000\n\
|
return ((png_charp) "\n libpng version 1.0.9beta5 - December 14, 2000\n\
|
||||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson\n\
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson\n\
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
Copyright (c) 1996, 1997 Andreas Dilger\n\
|
||||||
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||||
@@ -644,8 +644,8 @@ png_get_libpng_ver(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
/* Version of *.c files used when building libpng */
|
/* Version of *.c files used when building libpng */
|
||||||
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
||||||
return((png_charp) "1.0.9beta2");
|
return((png_charp) "1.0.9beta5");
|
||||||
return((png_charp) "1.0.9beta2");
|
return((png_charp) "1.0.9beta5");
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
|
|||||||
52
png.h
52
png.h
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.0.9beta2 - November 19, 2000
|
* libpng version 1.0.9beta5 - December 14, 2000
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* 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.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.0.9beta2 - November 19, 2000: Glenn
|
* libpng versions 0.97, January 1998, through 1.0.9beta5 - December 14, 2000: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
* 1.0.8beta1-4 10008 2.1.0.8beta1-4
|
* 1.0.8beta1-4 10008 2.1.0.8beta1-4
|
||||||
* 1.0.8rc1 10008 2.1.0.8rc1
|
* 1.0.8rc1 10008 2.1.0.8rc1
|
||||||
* 1.0.8 10008 2.1.0.8
|
* 1.0.8 10008 2.1.0.8
|
||||||
* 1.0.9beta1-2 10009 2.1.0.9
|
* 1.0.9beta1-5 10009 2.1.0.9beta1-5
|
||||||
*
|
*
|
||||||
* Henceforth the source version will match the shared-library major
|
* Henceforth the source version will match the shared-library major
|
||||||
* and minor numbers; the shared-library major version number will be
|
* and minor numbers; the shared-library major version number will be
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
* If you modify libpng you may insert additional notices immediately following
|
* If you modify libpng you may insert additional notices immediately following
|
||||||
* this sentence.
|
* this sentence.
|
||||||
*
|
*
|
||||||
* libpng versions 1.0.7, July 1, 2000, through 1.0.9beta2, November 19, 2000, are
|
* libpng versions 1.0.7, July 1, 2000, through 1.0.9beta5, December 14, 2000, are
|
||||||
* Copyright (c) 2000 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2000 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.0.6
|
* distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
* with the following individuals added to the list of Contributing Authors
|
* with the following individuals added to the list of Contributing Authors
|
||||||
@@ -190,13 +190,13 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* November 19, 2000
|
* December 14, 2000
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.0.9beta2 are Y2K compliant. It is my belief that earlier
|
* upward through 1.0.9beta5 are Y2K compliant. It is my belief that earlier
|
||||||
* versions were also Y2K compliant.
|
* versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.0.9beta2"
|
#define PNG_LIBPNG_VER_STRING "1.0.9beta5"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 2
|
#define PNG_LIBPNG_VER_SONUM 2
|
||||||
|
|
||||||
@@ -262,8 +262,16 @@
|
|||||||
#define PNG_LIBPNG_VER_RELEASE 9
|
#define PNG_LIBPNG_VER_RELEASE 9
|
||||||
/* This should match the numeric part of the final component of
|
/* This should match the numeric part of the final component of
|
||||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
|
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
|
||||||
#define PNG_LIBPNG_VER_BUILD 2
|
|
||||||
#define PNG_LIBPNG_BUILD_TYPE beta /* alpha, beta, rc, stable, patched */
|
#define PNG_LIBPNG_VER_BUILD 5
|
||||||
|
|
||||||
|
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||||
|
#define PNG_LIBPNG_BUILD_BETA 2
|
||||||
|
#define PNG_LIBPNG_BUILD_RC 3
|
||||||
|
#define PNG_LIBPNG_BUILD_STABLE 4
|
||||||
|
#define PNG_LIBPNG_BUILD_TYPEMASK 7
|
||||||
|
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */
|
||||||
|
#define PNG_LIBPNG_BUILD_TYPE 2
|
||||||
|
|
||||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||||
* We must not include leading zeros.
|
* We must not include leading zeros.
|
||||||
@@ -695,6 +703,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|||||||
/* iCCP chunk data. */
|
/* iCCP chunk data. */
|
||||||
png_charp iccp_name; /* profile name */
|
png_charp iccp_name; /* profile name */
|
||||||
png_charp iccp_profile; /* International Color Consortium profile data */
|
png_charp iccp_profile; /* International Color Consortium profile data */
|
||||||
|
/* Note to maintainer: should be png_bytep */
|
||||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||||
png_byte iccp_compression; /* Always zero */
|
png_byte iccp_compression; /* Always zero */
|
||||||
#endif
|
#endif
|
||||||
@@ -775,6 +784,7 @@ typedef png_info FAR * FAR * png_infopp;
|
|||||||
|
|
||||||
/* This is for filter type. PNG 1.0-1.2 only define the single type. */
|
/* This is for filter type. PNG 1.0-1.2 only define the single type. */
|
||||||
#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
|
#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
|
||||||
|
#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
|
||||||
#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
|
#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
|
||||||
|
|
||||||
/* These are for the interlacing type. These values should NOT be changed. */
|
/* These are for the interlacing type. These values should NOT be changed. */
|
||||||
@@ -909,8 +919,10 @@ typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
|
|||||||
#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
|
#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
|
||||||
|
|
||||||
/* Flags for MNG supported features */
|
/* Flags for MNG supported features */
|
||||||
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
|
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
|
||||||
#define PNG_ALL_MNG_FEATURES 0x01
|
#define PNG_MODE_EMBEDDED_IN_MNG 0x02
|
||||||
|
#define PNG_FLAG_MNG_FILTER_64 0x04
|
||||||
|
#define PNG_ALL_MNG_FEATURES 0x07
|
||||||
|
|
||||||
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
|
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
|
||||||
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
|
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
|
||||||
@@ -1156,12 +1168,14 @@ struct png_struct_def
|
|||||||
png_fixed_point int_gamma;
|
png_fixed_point int_gamma;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
png_byte filter_type;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
||||||
and png.h are both at * version 1.0.9beta2
|
and png.h are both at * version 1.0.9beta5
|
||||||
*/
|
*/
|
||||||
typedef png_structp version_1_0_9beta2;
|
typedef png_structp version_1_0_9beta5;
|
||||||
|
|
||||||
typedef png_struct FAR * FAR * png_structpp;
|
typedef png_struct FAR * FAR * png_structpp;
|
||||||
|
|
||||||
@@ -2013,12 +2027,14 @@ extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
|
|||||||
extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
|
||||||
png_infop info_ptr, png_charpp name, int *compression_type,
|
png_infop info_ptr, png_charpp name, int *compression_type,
|
||||||
png_charpp profile, png_uint_32 *proflen));
|
png_charpp profile, png_uint_32 *proflen));
|
||||||
|
/* Note to maintainer: profile should be png_bytepp */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_iCCP_SUPPORTED)
|
#if defined(PNG_iCCP_SUPPORTED)
|
||||||
extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
|
||||||
png_infop info_ptr, png_charp name, int compression_type,
|
png_infop info_ptr, png_charp name, int compression_type,
|
||||||
png_charp profile, png_uint_32 proflen));
|
png_charp profile, png_uint_32 proflen));
|
||||||
|
/* Note to maintainer: profile should be png_bytep */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
@@ -2200,7 +2216,7 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.0.9beta2 - November 19, 2000 (header)\n"
|
" libpng version 1.0.9beta5 - December 14, 2000 (header)\n"
|
||||||
|
|
||||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||||
/* With these routines we avoid an integer divide, which will be slower on
|
/* With these routines we avoid an integer divide, which will be slower on
|
||||||
@@ -2584,6 +2600,7 @@ PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
|
|||||||
PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
|
PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
|
||||||
png_charp name, int compression_type,
|
png_charp name, int compression_type,
|
||||||
png_charp profile, int proflen));
|
png_charp profile, int proflen));
|
||||||
|
/* Note to maintainer: profile should be png_bytep */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
#if defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||||
@@ -2986,6 +3003,13 @@ PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
|
|||||||
|
|
||||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
|
||||||
|
png_bytep row));
|
||||||
|
PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
|
||||||
|
png_bytep row));
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_INTERNAL */
|
#endif /* PNG_INTERNAL */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
|
|||||||
18
pngconf.h
18
pngconf.h
@@ -1,6 +1,6 @@
|
|||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
#define PNG_ZBUF_SIZE 8192
|
#define PNG_ZBUF_SIZE 8192
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||||
#define PNG_FLOATING_POINT_SUPPORTED
|
#define PNG_FLOATING_POINT_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
* 'Normal' png-on-win32 defines/defaults:
|
* 'Normal' png-on-win32 defines/defaults:
|
||||||
* PNG_BUILD_DLL -- building dll
|
* PNG_BUILD_DLL -- building dll
|
||||||
* PNG_USE_DLL -- building an application, linking to dll
|
* PNG_USE_DLL -- building an application, linking to dll
|
||||||
* (no define) -- building static library, or building an
|
* (no define) -- building static library, or building an
|
||||||
* application and linking to the static lib
|
* application and linking to the static lib
|
||||||
* 'Cygwin' defines/defaults:
|
* 'Cygwin' defines/defaults:
|
||||||
* PNG_BUILD_DLL -- building the dll
|
* PNG_BUILD_DLL -- building the dll
|
||||||
@@ -1017,11 +1017,11 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
* It is equivalent to Microsoft predefined macro _DLL which is
|
* It is equivalent to Microsoft predefined macro _DLL which is
|
||||||
* automatically defined when you compile using the share
|
* automatically defined when you compile using the share
|
||||||
* version of the CRT (C Run-Time library)
|
* version of the CRT (C Run-Time library)
|
||||||
*
|
*
|
||||||
* The cygwin mods make this behavior a little different:
|
* The cygwin mods make this behavior a little different:
|
||||||
* Define PNG_BUILD_DLL if you are building a dll for use with cygwin
|
* Define PNG_BUILD_DLL if you are building a dll for use with cygwin
|
||||||
* Define PNG_STATIC if you are building a static library for use with cygwin,
|
* Define PNG_STATIC if you are building a static library for use with cygwin,
|
||||||
* -or- if you are building an application that you want to link to the
|
* -or- if you are building an application that you want to link to the
|
||||||
* static library.
|
* static library.
|
||||||
* PNG_USE_DLL is defined by default (no user action needed) unless one of
|
* PNG_USE_DLL is defined by default (no user action needed) unless one of
|
||||||
* the other flags is defined.
|
* the other flags is defined.
|
||||||
@@ -1053,7 +1053,7 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
# define PNG_USE_LOCAL_ARRAYS
|
# define PNG_USE_LOCAL_ARRAYS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Do not use global arrays (helps with building DLL's)
|
/* Do not use global arrays (helps with building DLL's)
|
||||||
* They are no longer used in libpng itself, since version 1.0.5c,
|
* They are no longer used in libpng itself, since version 1.0.5c,
|
||||||
* but might be required for some pre-1.0.5c applications.
|
* but might be required for some pre-1.0.5c applications.
|
||||||
@@ -1073,8 +1073,8 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
# ifndef PNG_NO_MODULEDEF
|
# ifndef PNG_NO_MODULEDEF
|
||||||
# define PNG_NO_MODULEDEF
|
# define PNG_NO_MODULEDEF
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
|
#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
|
||||||
# define PNG_IMPEXP
|
# define PNG_IMPEXP
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
252
pngcrush.c
252
pngcrush.c
@@ -23,7 +23,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNGCRUSH_VERSION "1.5.2"
|
#define PNGCRUSH_VERSION "1.5.3"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +64,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Change log:
|
/* Change log:
|
||||||
|
*
|
||||||
|
* Version 1.5.3 (built with libpng-1.0.9beta5)
|
||||||
|
*
|
||||||
|
* Added "-loco" option (writes MNG files with filter_method 64)
|
||||||
|
*
|
||||||
|
* "-dir" and "-ext" options are no longer mutually exclusive, e.g.:
|
||||||
|
* pngcrush -loco -dir Crushed -ext .mng *.png
|
||||||
*
|
*
|
||||||
* Version 1.5.2 (built with libpng-1.0.9beta1)
|
* Version 1.5.2 (built with libpng-1.0.9beta1)
|
||||||
*
|
*
|
||||||
@@ -77,6 +84,11 @@
|
|||||||
*
|
*
|
||||||
* Added missing "png_ptr" argument to png_error() call
|
* Added missing "png_ptr" argument to png_error() call
|
||||||
*
|
*
|
||||||
|
* Added "-loco" option, to enable the LOCO color transformation
|
||||||
|
* (R->R-G, G, B->B-G) while writing a MNG with filter_method 64. Undo
|
||||||
|
* the transformation and write the regular PNG filter_method (0) if the
|
||||||
|
* MNG filter_method 64 is detected.
|
||||||
|
*
|
||||||
* Revised the "-help" output slightly and improved the "-version" output.
|
* Revised the "-help" output slightly and improved the "-version" output.
|
||||||
*
|
*
|
||||||
* The "-already[_crushed]" option is now ignored if the "-force" option
|
* The "-already[_crushed]" option is now ignored if the "-force" option
|
||||||
@@ -298,6 +310,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* To do:
|
/* To do:
|
||||||
|
*
|
||||||
|
* Add a "pcRu" ancillary chunk that keeps track of the best method,
|
||||||
|
* methods already tried, and whether "loco crushing" was effective.
|
||||||
|
*
|
||||||
|
* Try both transformed and untransformed colors when "-loco" is used.
|
||||||
*
|
*
|
||||||
* Check for unused alpha channel and ok-to-reduce-depth.
|
* Check for unused alpha channel and ok-to-reduce-depth.
|
||||||
* Take care that sBIT and bKGD data aren't lost when reducing images
|
* Take care that sBIT and bKGD data aren't lost when reducing images
|
||||||
@@ -362,6 +379,10 @@ main()
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
# define PNGCRUSH_LOCO
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__DJGPP__)
|
#if defined(__DJGPP__)
|
||||||
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
|
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
|
||||||
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
|
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
|
||||||
@@ -396,6 +417,7 @@ main()
|
|||||||
#define DEFAULT_MODE 0
|
#define DEFAULT_MODE 0
|
||||||
#define DIRECTORY_MODE 1
|
#define DIRECTORY_MODE 1
|
||||||
#define EXTENSION_MODE 2
|
#define EXTENSION_MODE 2
|
||||||
|
#define DIREX_MODE 3
|
||||||
#define FOPEN(file, how) fopen(file, how)
|
#define FOPEN(file, how) fopen(file, how)
|
||||||
#define FCLOSE(file) {fclose(file); file=NULL;--number_of_open_files;};
|
#define FCLOSE(file) {fclose(file); file=NULL;--number_of_open_files;};
|
||||||
#define P1 if(verbose > 1)printf
|
#define P1 if(verbose > 1)printf
|
||||||
@@ -499,9 +521,6 @@ char text_keyword[800];
|
|||||||
char text_lang[800];
|
char text_lang[800];
|
||||||
char text_lang_key[800];
|
char text_lang_key[800];
|
||||||
#endif
|
#endif
|
||||||
#if (PNG_LIBPNG_VER < 10009)
|
|
||||||
#undef PNG_iCCP_SUPPORTED
|
|
||||||
#endif
|
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
int iccp_length = 0;
|
int iccp_length = 0;
|
||||||
char *iccp_text;
|
char *iccp_text;
|
||||||
@@ -606,6 +625,11 @@ static png_infop end_info_ptr;
|
|||||||
static png_infop write_end_info_ptr;
|
static png_infop write_end_info_ptr;
|
||||||
static FILE *fpin, *fpout;
|
static FILE *fpin, *fpout;
|
||||||
png_uint_32 measure_idats(FILE *fpin);
|
png_uint_32 measure_idats(FILE *fpin);
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
static int do_loco=0;
|
||||||
|
#endif
|
||||||
|
static int input_format=0; /* 0: PNG 1: MNG */
|
||||||
|
static int output_format=0;
|
||||||
static int do_color_count;
|
static int do_color_count;
|
||||||
static int reduction_ok=0;
|
static int reduction_ok=0;
|
||||||
#ifdef PNGCRUSH_COUNT_COLORS
|
#ifdef PNGCRUSH_COUNT_COLORS
|
||||||
@@ -621,11 +645,7 @@ static int filter_type, zlib_level;
|
|||||||
static png_bytep png_row_filters=NULL;
|
static png_bytep png_row_filters=NULL;
|
||||||
static TIME_T t_start, t_stop, t_decode, t_encode, t_misc;
|
static TIME_T t_start, t_stop, t_decode, t_encode, t_misc;
|
||||||
|
|
||||||
#if (PNG_LIBPNG_VER >= 10000)
|
|
||||||
static png_uint_32 max_idat_size = 524288;
|
|
||||||
#else
|
|
||||||
static png_uint_32 max_idat_size = PNG_ZBUF_SIZE;
|
static png_uint_32 max_idat_size = PNG_ZBUF_SIZE;
|
||||||
#endif
|
|
||||||
static png_uint_32 crushed_idat_size = 0x3ffffffL;
|
static png_uint_32 crushed_idat_size = 0x3ffffffL;
|
||||||
static int already_crushed = 0;
|
static int already_crushed = 0;
|
||||||
int ia;
|
int ia;
|
||||||
@@ -1152,7 +1172,10 @@ main(int argc, char *argv[])
|
|||||||
else if(!strncmp(argv[i],"-d",2))
|
else if(!strncmp(argv[i],"-d",2))
|
||||||
{
|
{
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
pngcrush_mode=DIRECTORY_MODE;
|
if(pngcrush_mode==EXTENSION_MODE)
|
||||||
|
pngcrush_mode=DIREX_MODE;
|
||||||
|
else
|
||||||
|
pngcrush_mode=DIRECTORY_MODE;
|
||||||
directory_name= argv[names++];
|
directory_name= argv[names++];
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i],"-exit",5))
|
else if(!strncmp(argv[i],"-exit",5))
|
||||||
@@ -1160,7 +1183,10 @@ main(int argc, char *argv[])
|
|||||||
else if(!strncmp(argv[i],"-e",2))
|
else if(!strncmp(argv[i],"-e",2))
|
||||||
{
|
{
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
pngcrush_mode=EXTENSION_MODE;
|
if(pngcrush_mode==DIRECTORY_MODE)
|
||||||
|
pngcrush_mode=DIREX_MODE;
|
||||||
|
else
|
||||||
|
pngcrush_mode=EXTENSION_MODE;
|
||||||
extension= argv[names++];
|
extension= argv[names++];
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i],"-force",6))
|
else if(!strncmp(argv[i],"-force",6))
|
||||||
@@ -1204,6 +1230,10 @@ main(int argc, char *argv[])
|
|||||||
brute_force_filter++;
|
brute_force_filter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
else if(!strncmp(argv[i],"-loco",5))
|
||||||
|
do_loco=1;
|
||||||
|
#endif
|
||||||
else if(!strncmp(argv[i],"-l",2))
|
else if(!strncmp(argv[i],"-l",2))
|
||||||
{
|
{
|
||||||
int lev, strat, filt;
|
int lev, strat, filt;
|
||||||
@@ -1281,9 +1311,9 @@ main(int argc, char *argv[])
|
|||||||
help++;
|
help++;
|
||||||
verbose++;
|
verbose++;
|
||||||
}
|
}
|
||||||
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
else if(!strncmp(argv[i],"-iccp",5))
|
else if(!strncmp(argv[i],"-iccp",5))
|
||||||
{
|
{
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
|
||||||
FILE *iccp_fn;
|
FILE *iccp_fn;
|
||||||
if(iccp_length)
|
if(iccp_length)
|
||||||
free(iccp_text);
|
free(iccp_text);
|
||||||
@@ -1299,8 +1329,7 @@ main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ic;
|
int ic;
|
||||||
iccp_text=malloc(iccp_length+1);
|
iccp_text=malloc(iccp_length);
|
||||||
iccp_text[iccp_length]=(char)0x00;
|
|
||||||
for (ic=0; ic<iccp_length; ic++)
|
for (ic=0; ic<iccp_length; ic++)
|
||||||
{
|
{
|
||||||
png_size_t num_in;
|
png_size_t num_in;
|
||||||
@@ -1310,17 +1339,16 @@ main(int argc, char *argv[])
|
|||||||
iccp_text[ic]=buffer[0];
|
iccp_text[ic]=buffer[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
names+=3;
|
|
||||||
i+=3;
|
|
||||||
fprintf(STDERR, "libpng-1.0.9 or later is required to support iCCP.\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if(!strncmp(argv[i],"-max",4))
|
else if(!strncmp(argv[i],"-max",4))
|
||||||
{
|
{
|
||||||
names++;
|
names++;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
max_idat_size = (png_uint_32)atoi(argv[i]);
|
max_idat_size = (png_uint_32)atoi(argv[i]);
|
||||||
|
#if 0
|
||||||
|
if (max_idat_size > PNG_ZBUF_SIZE) max_idat_size=PNG_ZBUF_SIZE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if(!strncmp(argv[i],"-m",2))
|
else if(!strncmp(argv[i],"-m",2))
|
||||||
{
|
{
|
||||||
@@ -1987,6 +2015,25 @@ main(int argc, char *argv[])
|
|||||||
if(verbose > 1)
|
if(verbose > 1)
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
"\n Value of 'rendering intent' for sRGB chunk.\n\n");
|
"\n Value of 'rendering intent' for sRGB chunk.\n\n");
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
fprintf(STDERR,
|
||||||
|
" -loco (\"loco crush\" truecolor PNGs)\n");
|
||||||
|
if(verbose > 1)
|
||||||
|
{
|
||||||
|
fprintf(STDERR,
|
||||||
|
"\n Make the file more compressible by performing a\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" lossless reversible color transformation.\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" The resulting file is a MNG, not a PNG, and should\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" be given the \".mng\" file extension. The\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" \"loco\" option has no effect on grayscale or\n");
|
||||||
|
fprintf(STDERR,
|
||||||
|
" indexed-color PNG files.\n\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" -text b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
|
" -text b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
|
||||||
if(verbose > 1)
|
if(verbose > 1)
|
||||||
@@ -2159,38 +2206,7 @@ main(int argc, char *argv[])
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pngcrush_mode == EXTENSION_MODE)
|
if(pngcrush_mode == DIRECTORY_MODE || pngcrush_mode == DIREX_MODE)
|
||||||
{
|
|
||||||
ip=in_string;
|
|
||||||
in_string[0]='\0';
|
|
||||||
str_return = strcat(in_string,inname);
|
|
||||||
ip = in_string;
|
|
||||||
op = dot = out_string;
|
|
||||||
while(*ip != '\0')
|
|
||||||
{
|
|
||||||
*op++ = *ip++;
|
|
||||||
#ifdef __riscos
|
|
||||||
if(*ip == '/')dot=op;
|
|
||||||
#else
|
|
||||||
if(*ip == '.')dot=op;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
*op = '\0';
|
|
||||||
|
|
||||||
if(dot != out_string)
|
|
||||||
*dot = '\0';
|
|
||||||
|
|
||||||
in_extension[0]='\0';
|
|
||||||
if(dot != out_string)
|
|
||||||
{
|
|
||||||
str_return = strcat(in_extension,++dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
str_return = strcat(out_string,extension);
|
|
||||||
outname=out_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pngcrush_mode == DIRECTORY_MODE)
|
|
||||||
{
|
{
|
||||||
#ifdef __riscos
|
#ifdef __riscos
|
||||||
if(fileexists(directory_name) & 2)
|
if(fileexists(directory_name) & 2)
|
||||||
@@ -2231,6 +2247,40 @@ main(int argc, char *argv[])
|
|||||||
outname=out_string;
|
outname=out_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pngcrush_mode == EXTENSION_MODE || pngcrush_mode == DIREX_MODE)
|
||||||
|
{
|
||||||
|
ip=in_string;
|
||||||
|
in_string[0]='\0';
|
||||||
|
if(pngcrush_mode == EXTENSION_MODE)
|
||||||
|
str_return = strcat(in_string,inname);
|
||||||
|
else
|
||||||
|
str_return = strcat(in_string,outname);
|
||||||
|
ip = in_string;
|
||||||
|
op = dot = out_string;
|
||||||
|
while(*ip != '\0')
|
||||||
|
{
|
||||||
|
*op++ = *ip++;
|
||||||
|
#ifdef __riscos
|
||||||
|
if(*ip == '/')dot=op;
|
||||||
|
#else
|
||||||
|
if(*ip == '.')dot=op;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
*op = '\0';
|
||||||
|
|
||||||
|
if(dot != out_string)
|
||||||
|
*dot = '\0';
|
||||||
|
|
||||||
|
in_extension[0]='\0';
|
||||||
|
if(dot != out_string)
|
||||||
|
{
|
||||||
|
str_return = strcat(in_extension,++dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
str_return = strcat(out_string,extension);
|
||||||
|
outname=out_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(nosave < 2)
|
if(nosave < 2)
|
||||||
{
|
{
|
||||||
@@ -2478,7 +2528,7 @@ main(int argc, char *argv[])
|
|||||||
struct stat stat_in, stat_out;
|
struct stat stat_in, stat_out;
|
||||||
if ((stat(inname, &stat_in) == 0) &&
|
if ((stat(inname, &stat_in) == 0) &&
|
||||||
(stat(outname, &stat_out) == 0) &&
|
(stat(outname, &stat_out) == 0) &&
|
||||||
#ifdef _MSC_VER /* maybe others? */
|
#if defined(_MSC_VER) || defined(__MINGW32__) /* maybe others? */
|
||||||
/* MSVC++6.0 will erroneously return 0 for both files, so we
|
/* MSVC++6.0 will erroneously return 0 for both files, so we
|
||||||
simply check the size instead. It is possible that we will
|
simply check the size instead. It is possible that we will
|
||||||
erroneously reject the attempt when inputsize and outputsize
|
erroneously reject the attempt when inputsize and outputsize
|
||||||
@@ -2729,11 +2779,25 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
png_debug(0, "Reading info struct\n");
|
png_debug(0, "Reading info struct\n");
|
||||||
{
|
{
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
png_byte mng_signature[8] = {138, 77, 78, 71, 13, 10, 26, 10};
|
||||||
|
#endif
|
||||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
|
|
||||||
png_read_data(read_ptr, png_signature, 8);
|
png_read_data(read_ptr, png_signature, 8);
|
||||||
png_set_sig_bytes(read_ptr, 8);
|
png_set_sig_bytes(read_ptr, 8);
|
||||||
|
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
if (!(int)(png_memcmp(mng_signature, png_signature, 8)))
|
||||||
|
{
|
||||||
|
png_byte buffer[40];
|
||||||
|
/* Skip the MHDR */
|
||||||
|
png_permit_mng_features (read_ptr, PNG_FLAG_MNG_FILTER_64);
|
||||||
|
png_read_data(read_ptr, buffer, 40);
|
||||||
|
input_format=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (png_sig_cmp(png_signature, 0, 8))
|
if (png_sig_cmp(png_signature, 0, 8))
|
||||||
{
|
{
|
||||||
if (png_sig_cmp(png_signature, 0, 4))
|
if (png_sig_cmp(png_signature, 0, 4))
|
||||||
@@ -2906,6 +2970,22 @@ main(int argc, char *argv[])
|
|||||||
if(verbose > 1)
|
if(verbose > 1)
|
||||||
fprintf(STDERR, " Setting IHDR\n");
|
fprintf(STDERR, " Setting IHDR\n");
|
||||||
|
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
output_format=0;
|
||||||
|
if(do_loco)
|
||||||
|
{
|
||||||
|
if(output_color_type == 2 || output_color_type == 6)
|
||||||
|
{
|
||||||
|
output_format=1;
|
||||||
|
filter_method = 64;
|
||||||
|
png_permit_mng_features (write_ptr, PNG_FLAG_MNG_FILTER_64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
filter_method=0;
|
||||||
|
if(input_format != output_format)
|
||||||
|
things_have_changed = 1;
|
||||||
|
#endif
|
||||||
png_set_IHDR(write_ptr, write_info_ptr, width, height,
|
png_set_IHDR(write_ptr, write_info_ptr, width, height,
|
||||||
output_bit_depth, output_color_type, output_interlace_method,
|
output_bit_depth, output_color_type, output_interlace_method,
|
||||||
compression_method, filter_method);
|
compression_method, filter_method);
|
||||||
@@ -3561,6 +3641,39 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
if(do_loco)
|
||||||
|
{
|
||||||
|
png_byte buffer[30];
|
||||||
|
const png_byte png_MHDR[5] = { 77, 72, 68, 82, '\0'};
|
||||||
|
png_byte mng_signature[8] = {138, 77, 78, 71, 13, 10, 26, 10};
|
||||||
|
/* write the MNG 8 byte signature */
|
||||||
|
if(outname[strlen(outname)-3] == 'p')
|
||||||
|
png_warning(read_ptr, " Writing a MNG file with a .png extension");
|
||||||
|
png_write_data(write_ptr, &mng_signature[0], (png_size_t)8);
|
||||||
|
png_set_sig_bytes(write_ptr, 8);
|
||||||
|
|
||||||
|
/* Write a MHDR chunk */
|
||||||
|
|
||||||
|
buffer[0]=(png_byte)((width>>24) & 0xff);
|
||||||
|
buffer[1]=(png_byte)((width>>16) & 0xff);
|
||||||
|
buffer[2]=(png_byte)((width>> 8) & 0xff);
|
||||||
|
buffer[3]=(png_byte)((width ) & 0xff);
|
||||||
|
buffer[4]=(png_byte)((height>>24) & 0xff);
|
||||||
|
buffer[5]=(png_byte)((height>>16) & 0xff);
|
||||||
|
buffer[6]=(png_byte)((height>> 8) & 0xff);
|
||||||
|
buffer[7]=(png_byte)((height ) & 0xff);
|
||||||
|
for (i=8; i<27; i++)
|
||||||
|
buffer[i]=0x00;
|
||||||
|
buffer[15]=1; /* frame count */
|
||||||
|
buffer[19]=2; /* layer count */
|
||||||
|
if(output_color_type == 6)
|
||||||
|
buffer[27]=0x09; /* simplicity profile: MNG-VLC with transparency */
|
||||||
|
else
|
||||||
|
buffer[27]=0x01; /* simplicity profile: MNG-VLC */
|
||||||
|
png_write_chunk(write_ptr, (png_bytep)png_MHDR, buffer, (png_size_t)28);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
P2("writing info structure.\n");
|
P2("writing info structure.\n");
|
||||||
png_crush_pause();
|
png_crush_pause();
|
||||||
png_debug(0, "\nWriting info struct\n");
|
png_debug(0, "\nWriting info struct\n");
|
||||||
@@ -3888,6 +4001,14 @@ main(int argc, char *argv[])
|
|||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
if(nosave == 0)
|
if(nosave == 0)
|
||||||
{
|
{
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
if(do_loco)
|
||||||
|
{
|
||||||
|
const png_byte png_MEND[5] = { 77, 69, 78, 68, '\0'};
|
||||||
|
/* write the MNG MEND chunk */
|
||||||
|
png_write_chunk(write_ptr, (png_bytep)png_MEND, NULL, (png_size_t)0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
}
|
}
|
||||||
@@ -4076,10 +4197,23 @@ png_measure_idat(png_structp png_ptr)
|
|||||||
|
|
||||||
{
|
{
|
||||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
png_byte mng_signature[8] = {138, 77, 78, 71, 13, 10, 26, 10};
|
||||||
|
#endif
|
||||||
|
|
||||||
png_read_data(png_ptr, png_signature, 8);
|
png_read_data(png_ptr, png_signature, 8);
|
||||||
png_set_sig_bytes(png_ptr, 8);
|
png_set_sig_bytes(png_ptr, 8);
|
||||||
|
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
if (!(int)(png_memcmp(mng_signature, png_signature, 8)))
|
||||||
|
{
|
||||||
|
png_byte buffer[40];
|
||||||
|
/* skip the MHDR */
|
||||||
|
png_read_data(read_ptr, buffer, 40);
|
||||||
|
input_format=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (png_sig_cmp(png_signature, 0, 8))
|
if (png_sig_cmp(png_signature, 0, 8))
|
||||||
{
|
{
|
||||||
if (png_sig_cmp(png_signature, 0, 4))
|
if (png_sig_cmp(png_signature, 0, 4))
|
||||||
@@ -4280,11 +4414,25 @@ count_colors(FILE *fpin)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
png_byte mng_signature[8] = {138, 77, 78, 71, 13, 10, 26, 10};
|
||||||
|
#endif
|
||||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
|
|
||||||
png_read_data(read_ptr, png_signature, 8);
|
png_read_data(read_ptr, png_signature, 8);
|
||||||
png_set_sig_bytes(read_ptr, 8);
|
png_set_sig_bytes(read_ptr, 8);
|
||||||
|
|
||||||
|
#if defined(PNGCRUSH_LOCO)
|
||||||
|
if (!(int)(png_memcmp(mng_signature, png_signature, 8)))
|
||||||
|
{
|
||||||
|
png_byte buffer[40];
|
||||||
|
/* skip the MHDR */
|
||||||
|
png_read_data(read_ptr, buffer, 40);
|
||||||
|
png_permit_mng_features (read_ptr, PNG_FLAG_MNG_FILTER_64);
|
||||||
|
input_format=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (png_sig_cmp(png_signature, 0, 8))
|
if (png_sig_cmp(png_signature, 0, 8))
|
||||||
{
|
{
|
||||||
if (png_sig_cmp(png_signature, 0, 4))
|
if (png_sig_cmp(png_signature, 0, 4))
|
||||||
@@ -4454,7 +4602,6 @@ count_colors(FILE *fpin)
|
|||||||
reduce_to_gray=0;
|
reduce_to_gray=0;
|
||||||
if(it_is_opaque && (*(rp+3)) != 255)
|
if(it_is_opaque && (*(rp+3)) != 255)
|
||||||
it_is_opaque=0;
|
it_is_opaque=0;
|
||||||
|
|
||||||
if (result > 1)
|
if (result > 1)
|
||||||
continue;
|
continue;
|
||||||
#ifdef USE_HASHCODE
|
#ifdef USE_HASHCODE
|
||||||
@@ -4672,7 +4819,6 @@ count_colors(FILE *fpin)
|
|||||||
}
|
}
|
||||||
P2 ("Finished checking alphas, result=%d\n",result);
|
P2 ("Finished checking alphas, result=%d\n",result);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret=result;
|
ret=result;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
# define PNG_USER_MEM_SUPPORTED
|
# define PNG_USER_MEM_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MNG_EXTENSIONS_SUPPORTED /* extra filter types */
|
#define PNG_MNG_FEATURES_SUPPORTED /* extra filter types */
|
||||||
|
|
||||||
#ifndef PNG_NO_LEGACY_SUPPORTED
|
#ifndef PNG_NO_LEGACY_SUPPORTED
|
||||||
# define PNG_NO_LEGACY_SUPPORTED
|
# define PNG_NO_LEGACY_SUPPORTED
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -99,7 +99,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_error(png_structp png_ptr, png_const_charp message)
|
png_chunk_error(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
char msg[16+64];
|
char msg[18+64];
|
||||||
png_format_buffer(png_ptr, msg, message);
|
png_format_buffer(png_ptr, msg, message);
|
||||||
png_error(png_ptr, msg);
|
png_error(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
50
pnggccrd.c
50
pnggccrd.c
@@ -6,7 +6,7 @@
|
|||||||
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
|
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
|
||||||
* for Intel's performance analysis of the MMX vs. non-MMX code.
|
* for Intel's performance analysis of the MMX vs. non-MMX code.
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998, Intel Corporation
|
* Copyright (c) 1998, Intel Corporation
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
* correctly (but 48-bit RGB just fine)
|
* correctly (but 48-bit RGB just fine)
|
||||||
*
|
*
|
||||||
* 20000916:
|
* 20000916:
|
||||||
* - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors:
|
* - fixed bug in png_read_filter_row_mmx_avg(), bpp == 2 case; three errors:
|
||||||
* - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;"
|
* - "_ShiftBpp.use = 24;" should have been "_ShiftBpp.use = 16;"
|
||||||
* - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;"
|
* - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;"
|
||||||
* - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2"
|
* - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2"
|
||||||
@@ -240,22 +240,22 @@ static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
|
|||||||
# define _unmask unmask
|
# define _unmask unmask
|
||||||
# define _const4 const4
|
# define _const4 const4
|
||||||
# define _const6 const6
|
# define _const6 const6
|
||||||
# define _mask8_0 mask8_0
|
# define _mask8_0 mask8_0
|
||||||
# define _mask16_1 mask16_1
|
# define _mask16_1 mask16_1
|
||||||
# define _mask16_0 mask16_0
|
# define _mask16_0 mask16_0
|
||||||
# define _mask24_2 mask24_2
|
# define _mask24_2 mask24_2
|
||||||
# define _mask24_1 mask24_1
|
# define _mask24_1 mask24_1
|
||||||
# define _mask24_0 mask24_0
|
# define _mask24_0 mask24_0
|
||||||
# define _mask32_3 mask32_3
|
# define _mask32_3 mask32_3
|
||||||
# define _mask32_2 mask32_2
|
# define _mask32_2 mask32_2
|
||||||
# define _mask32_1 mask32_1
|
# define _mask32_1 mask32_1
|
||||||
# define _mask32_0 mask32_0
|
# define _mask32_0 mask32_0
|
||||||
# define _mask48_5 mask48_5
|
# define _mask48_5 mask48_5
|
||||||
# define _mask48_4 mask48_4
|
# define _mask48_4 mask48_4
|
||||||
# define _mask48_3 mask48_3
|
# define _mask48_3 mask48_3
|
||||||
# define _mask48_2 mask48_2
|
# define _mask48_2 mask48_2
|
||||||
# define _mask48_1 mask48_1
|
# define _mask48_1 mask48_1
|
||||||
# define _mask48_0 mask48_0
|
# define _mask48_0 mask48_0
|
||||||
# define _FullLength FullLength
|
# define _FullLength FullLength
|
||||||
# define _MMXLength MMXLength
|
# define _MMXLength MMXLength
|
||||||
# define _dif dif
|
# define _dif dif
|
||||||
@@ -642,7 +642,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
png_memcpy(dstptr, srcptr, rep_bytes);
|
png_memcpy(dstptr, srcptr, rep_bytes);
|
||||||
srcptr += stride;
|
srcptr += stride;
|
||||||
dstptr += stride;
|
dstptr += stride;
|
||||||
}
|
}
|
||||||
} /* end of else */
|
} /* end of else */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -774,7 +774,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
png_memcpy(dstptr, srcptr, rep_bytes);
|
png_memcpy(dstptr, srcptr, rep_bytes);
|
||||||
srcptr += stride;
|
srcptr += stride;
|
||||||
dstptr += stride;
|
dstptr += stride;
|
||||||
}
|
}
|
||||||
} /* end of else */
|
} /* end of else */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -921,7 +921,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
png_memcpy(dstptr, srcptr, rep_bytes);
|
png_memcpy(dstptr, srcptr, rep_bytes);
|
||||||
srcptr += stride;
|
srcptr += stride;
|
||||||
dstptr += stride;
|
dstptr += stride;
|
||||||
}
|
}
|
||||||
} /* end of else */
|
} /* end of else */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1246,7 +1246,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
png_memcpy(dstptr, srcptr, rep_bytes);
|
png_memcpy(dstptr, srcptr, rep_bytes);
|
||||||
srcptr += stride;
|
srcptr += stride;
|
||||||
dstptr += stride;
|
dstptr += stride;
|
||||||
}
|
}
|
||||||
} /* end of else */
|
} /* end of else */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1273,7 +1273,7 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
png_memcpy(dstptr, srcptr, rep_bytes);
|
png_memcpy(dstptr, srcptr, rep_bytes);
|
||||||
srcptr += stride;
|
srcptr += stride;
|
||||||
dstptr += stride;
|
dstptr += stride;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} // end 64 bpp
|
} // end 64 bpp
|
||||||
|
|
||||||
@@ -2095,7 +2095,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
: "=c" (dummy_value_c), // output regs (dummy)
|
: "=c" (dummy_value_c), // output regs (dummy)
|
||||||
"=S" (dummy_value_S),
|
"=S" (dummy_value_S),
|
||||||
"=D" (dummy_value_D)
|
"=D" (dummy_value_D)
|
||||||
|
|
||||||
: "1" (sptr), // esi // input regs
|
: "1" (sptr), // esi // input regs
|
||||||
"2" (dp), // edi
|
"2" (dp), // edi
|
||||||
"0" (width_mmx) // ecx
|
"0" (width_mmx) // ecx
|
||||||
@@ -2153,7 +2153,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
: "=c" (dummy_value_c), // output regs (dummy)
|
: "=c" (dummy_value_c), // output regs (dummy)
|
||||||
"=S" (dummy_value_S),
|
"=S" (dummy_value_S),
|
||||||
"=D" (dummy_value_D)
|
"=D" (dummy_value_D)
|
||||||
|
|
||||||
: "1" (sptr), // esi // input regs
|
: "1" (sptr), // esi // input regs
|
||||||
"2" (dp), // edi
|
"2" (dp), // edi
|
||||||
"0" (width_mmx) // ecx
|
"0" (width_mmx) // ecx
|
||||||
|
|||||||
2
pngget.c
2
pngget.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
2
pngmem.c
2
pngmem.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
17
pngread.c
17
pngread.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -103,7 +103,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
removed from version 2.0.0 and beyond because the previous test
|
removed from version 2.0.0 and beyond because the previous test
|
||||||
would have already rejected it. */
|
would have already rejected it. */
|
||||||
|
|
||||||
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
||||||
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
||||||
{
|
{
|
||||||
png_error(png_ptr,
|
png_error(png_ptr,
|
||||||
@@ -646,6 +646,15 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
|
|
||||||
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
|
||||||
png_ptr->rowbytes + 1);
|
png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||||
|
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||||
|
{
|
||||||
|
/* Intrapixel differencing */
|
||||||
|
png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (png_ptr->transformations)
|
if (png_ptr->transformations)
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
@@ -701,7 +710,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
|
* not called png_set_interlace_handling(), the display_row buffer will
|
||||||
* be ignored, so pass NULL to it.
|
* be ignored, so pass NULL to it.
|
||||||
*
|
*
|
||||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta2
|
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
@@ -750,7 +759,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||||||
* only call this function once. If you desire to have an image for
|
* only call this function once. If you desire to have an image for
|
||||||
* each pass of a interlaced image, use png_read_rows() instead.
|
* each pass of a interlaced image, use png_read_rows() instead.
|
||||||
*
|
*
|
||||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta2
|
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta5
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
|
|||||||
2
pngrio.c
2
pngrio.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
62
pngrtran.c
62
pngrtran.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 15, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -4053,3 +4053,63 @@ png_build_gamma_table(png_structp png_ptr)
|
|||||||
/* To do: install integer version of png_build_gamma_table here */
|
/* To do: install integer version of png_build_gamma_table here */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
/* undoes intrapixel differencing */
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_read_intrapixel\n");
|
||||||
|
if (
|
||||||
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
|
row != NULL && row_info != NULL &&
|
||||||
|
#endif
|
||||||
|
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||||
|
{
|
||||||
|
int bytes_per_pixel;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
png_bytep rp;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
|
bytes_per_pixel = 3;
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
bytes_per_pixel = 4;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
|
{
|
||||||
|
*(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff);
|
||||||
|
*(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (row_info->bit_depth == 16)
|
||||||
|
{
|
||||||
|
png_bytep rp;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
|
bytes_per_pixel = 6;
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
bytes_per_pixel = 8;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
|
{
|
||||||
|
png_uint_32 s0=*(rp )<<8 | *(rp+1);
|
||||||
|
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
|
||||||
|
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
|
||||||
|
png_uint_32 red=(65536+s0+s1)&0xffff;
|
||||||
|
png_uint_32 blue=(65536+s2+s1)&0xffff;
|
||||||
|
*(rp ) = (png_byte)((red>>8)&0xff);
|
||||||
|
*(rp+1) = (png_byte)(red&0xff);
|
||||||
|
*(rp+4) = (png_byte)((blue>>8)&0xff);
|
||||||
|
*(rp+5) = (png_byte)(blue&0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||||
|
|||||||
12
pngrutil.c
12
pngrutil.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -353,7 +353,14 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
|
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
|
||||||
png_error(png_ptr, "Unknown compression method in IHDR");
|
png_error(png_ptr, "Unknown compression method in IHDR");
|
||||||
|
|
||||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
if(
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||||
|
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
|
||||||
|
(color_type == PNG_COLOR_TYPE_RGB ||
|
||||||
|
color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
|
||||||
|
#endif
|
||||||
|
filter_type != PNG_FILTER_TYPE_BASE)
|
||||||
png_error(png_ptr, "Unknown filter method in IHDR");
|
png_error(png_ptr, "Unknown filter method in IHDR");
|
||||||
|
|
||||||
/* set internal variables */
|
/* set internal variables */
|
||||||
@@ -362,6 +369,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||||
png_ptr->interlaced = (png_byte)interlace_type;
|
png_ptr->interlaced = (png_byte)interlace_type;
|
||||||
png_ptr->color_type = (png_byte)color_type;
|
png_ptr->color_type = (png_byte)color_type;
|
||||||
|
png_ptr->filter_type = (png_byte)filter_type;
|
||||||
|
|
||||||
/* find number of channels */
|
/* find number of channels */
|
||||||
switch (png_ptr->color_type)
|
switch (png_ptr->color_type)
|
||||||
|
|||||||
4
pngset.c
4
pngset.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -730,7 +730,7 @@ void PNGAPI
|
|||||||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||||
int chunk, int location)
|
int chunk, int location)
|
||||||
{
|
{
|
||||||
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||||
(int)info_ptr->unknown_chunks_num)
|
(int)info_ptr->unknown_chunks_num)
|
||||||
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
|
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -606,3 +606,4 @@ png_get_user_transform_ptr(png_structp png_ptr)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998, Intel Corporation
|
* Copyright (c) 1998, Intel Corporation
|
||||||
|
|||||||
2
pngwio.c
2
pngwio.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
17
pngwrite.c
17
pngwrite.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -375,7 +375,11 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
/* write end of PNG file */
|
/* write end of PNG file */
|
||||||
png_write_IEND(png_ptr);
|
png_write_IEND(png_ptr);
|
||||||
|
#if 0
|
||||||
|
/* This flush, added in libpng-1.0.8, causes some applications to crash
|
||||||
|
because they do not set png_ptr->output_flush_fn */
|
||||||
png_flush(png_ptr);
|
png_flush(png_ptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||||
@@ -488,7 +492,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
removed from version 2.0.0 and beyond because the previous test
|
removed from version 2.0.0 and beyond because the previous test
|
||||||
would have already rejected it. */
|
would have already rejected it. */
|
||||||
|
|
||||||
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
|
||||||
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
|
||||||
{
|
{
|
||||||
png_error(png_ptr,
|
png_error(png_ptr,
|
||||||
@@ -769,6 +773,15 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
|||||||
if (png_ptr->transformations)
|
if (png_ptr->transformations)
|
||||||
png_do_write_transformations(png_ptr);
|
png_do_write_transformations(png_ptr);
|
||||||
|
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||||
|
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||||
|
{
|
||||||
|
/* Intrapixel differencing */
|
||||||
|
png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Find a filter if necessary, filter the row and write it out. */
|
/* Find a filter if necessary, filter the row and write it out. */
|
||||||
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
png_write_find_filter(png_ptr, &(png_ptr->row_info));
|
||||||
|
|
||||||
|
|||||||
63
pngwtran.c
63
pngwtran.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 15, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -498,3 +498,64 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
/* undoes intrapixel differencing */
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
||||||
|
{
|
||||||
|
png_debug(1, "in png_do_write_intrapixel\n");
|
||||||
|
if (
|
||||||
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
|
row != NULL && row_info != NULL &&
|
||||||
|
#endif
|
||||||
|
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||||
|
{
|
||||||
|
int bytes_per_pixel;
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
if (row_info->bit_depth == 8)
|
||||||
|
{
|
||||||
|
png_bytep rp;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
|
bytes_per_pixel = 3;
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
bytes_per_pixel = 4;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
|
{
|
||||||
|
*(rp) = (png_byte)((*rp - *(rp+1))&0xff);
|
||||||
|
*(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (row_info->bit_depth == 16)
|
||||||
|
{
|
||||||
|
png_bytep rp;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||||
|
bytes_per_pixel = 6;
|
||||||
|
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
|
bytes_per_pixel = 8;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
|
{
|
||||||
|
png_uint_32 s0=*(rp )<<8 | *(rp+1);
|
||||||
|
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
|
||||||
|
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
|
||||||
|
png_uint_32 red=(s0-s1)&0xffff;
|
||||||
|
png_uint_32 blue=(s2-s1)&0xffff;
|
||||||
|
*(rp ) = (png_byte)((red>>8)&0xff);
|
||||||
|
*(rp+1) = (png_byte)(red&0xff);
|
||||||
|
*(rp+4) = (png_byte)((blue>>8)&0xff);
|
||||||
|
*(rp+5) = (png_byte)(blue&0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||||
|
|||||||
28
pngwutil.c
28
pngwutil.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwutil.c - utilities to write a PNG file
|
/* pngwutil.c - utilities to write a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.0.9beta2 - November 19, 2000
|
* libpng 1.0.9beta5 - December 14, 2000
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -419,7 +419,12 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
compression_type = PNG_COMPRESSION_TYPE_BASE;
|
compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
if (
|
||||||
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
|
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||||
|
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
|
||||||
|
#endif
|
||||||
|
filter_type != PNG_FILTER_TYPE_BASE)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Invalid filter type specified");
|
png_warning(png_ptr, "Invalid filter type specified");
|
||||||
filter_type = PNG_FILTER_TYPE_BASE;
|
filter_type = PNG_FILTER_TYPE_BASE;
|
||||||
@@ -440,6 +445,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||||
png_ptr->color_type = (png_byte)color_type;
|
png_ptr->color_type = (png_byte)color_type;
|
||||||
png_ptr->interlaced = (png_byte)interlace_type;
|
png_ptr->interlaced = (png_byte)interlace_type;
|
||||||
|
png_ptr->filter_type = (png_byte)filter_type;
|
||||||
png_ptr->width = width;
|
png_ptr->width = width;
|
||||||
png_ptr->height = height;
|
png_ptr->height = height;
|
||||||
|
|
||||||
@@ -1072,13 +1078,14 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
png_size_t key_len;
|
png_size_t key_len;
|
||||||
png_charp kp, dp;
|
png_charp kp, dp;
|
||||||
int kflag;
|
int kflag;
|
||||||
|
int kwarn=0;
|
||||||
|
|
||||||
png_debug(1, "in png_check_keyword\n");
|
png_debug(1, "in png_check_keyword\n");
|
||||||
*new_key = NULL;
|
*new_key = NULL;
|
||||||
|
|
||||||
if (key == NULL || (key_len = png_strlen(key)) == 0)
|
if (key == NULL || (key_len = png_strlen(key)) == 0)
|
||||||
{
|
{
|
||||||
png_chunk_warning(png_ptr, "zero length keyword");
|
png_warning(png_ptr, "zero length keyword");
|
||||||
return ((png_size_t)0);
|
return ((png_size_t)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1095,9 +1102,9 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
char msg[40];
|
char msg[40];
|
||||||
|
|
||||||
sprintf(msg, "invalid keyword character 0x%02X", *kp);
|
sprintf(msg, "invalid keyword character 0x%02X", *kp);
|
||||||
png_chunk_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#else
|
#else
|
||||||
png_chunk_warning(png_ptr, "invalid character in keyword");
|
png_warning(png_ptr, "invalid character in keyword");
|
||||||
#endif
|
#endif
|
||||||
*dp = ' ';
|
*dp = ' ';
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1119,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
kp = *new_key + key_len - 1;
|
kp = *new_key + key_len - 1;
|
||||||
if (*kp == ' ')
|
if (*kp == ' ')
|
||||||
{
|
{
|
||||||
png_chunk_warning(png_ptr, "trailing spaces removed from keyword");
|
png_warning(png_ptr, "trailing spaces removed from keyword");
|
||||||
|
|
||||||
while (*kp == ' ')
|
while (*kp == ' ')
|
||||||
{
|
{
|
||||||
@@ -1125,7 +1132,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
kp = *new_key;
|
kp = *new_key;
|
||||||
if (*kp == ' ')
|
if (*kp == ' ')
|
||||||
{
|
{
|
||||||
png_chunk_warning(png_ptr, "leading spaces removed from keyword");
|
png_warning(png_ptr, "leading spaces removed from keyword");
|
||||||
|
|
||||||
while (*kp == ' ')
|
while (*kp == ' ')
|
||||||
{
|
{
|
||||||
@@ -1147,6 +1154,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
else if (*kp == ' ')
|
else if (*kp == ' ')
|
||||||
{
|
{
|
||||||
key_len--;
|
key_len--;
|
||||||
|
kwarn=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1155,17 +1163,19 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*dp = '\0';
|
*dp = '\0';
|
||||||
|
if(kwarn)
|
||||||
|
png_warning(png_ptr, "extra interior spaces removed from keyword");
|
||||||
|
|
||||||
if (key_len == 0)
|
if (key_len == 0)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, *new_key);
|
png_free(png_ptr, *new_key);
|
||||||
*new_key=NULL;
|
*new_key=NULL;
|
||||||
png_chunk_warning(png_ptr, "Zero length keyword");
|
png_warning(png_ptr, "Zero length keyword");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_len > 79)
|
if (key_len > 79)
|
||||||
{
|
{
|
||||||
png_chunk_warning(png_ptr, "keyword length must be 1 - 79 characters");
|
png_warning(png_ptr, "keyword length must be 1 - 79 characters");
|
||||||
new_key[79] = '\0';
|
new_key[79] = '\0';
|
||||||
key_len = 79;
|
key_len = 79;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user