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.1.tar
This commit is contained in:
@@ -35,7 +35,7 @@ EXES = $(PNGCRUSH)$(E)
|
||||
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O): png.h pngconf.h zlib.h pngcrush.h
|
||||
.c$(O): png.h pngconf.h zlib.h pngcrush.h cexcept.h
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ all: $(EXES)
|
||||
$(PNGCRUSH)$(E): $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
$(PNGCRUSH)$(O): $(PNGCRUSH).c png.h pngconf.h zlib.h pngcrush.h
|
||||
$(PNGCRUSH)$(O): $(PNGCRUSH).c png.h pngconf.h zlib.h pngcrush.h cexcept.h
|
||||
|
||||
# maintenance ---------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ all: $(EXES)
|
||||
$(PNGCRUSH)$(E): $(OBJS)
|
||||
$(LD) $(LDFLAGS) -out:$@ $(OBJS) $(LIBS)
|
||||
|
||||
$(PNGCRUSH)$(O): $(PNGCRUSH).c png.h pngconf.h zlib.h pngcrush.h
|
||||
$(PNGCRUSH)$(O): $(PNGCRUSH).c png.h pngconf.h zlib.h pngcrush.h cexcept.h
|
||||
|
||||
# maintenance ---------------------------------------------------------------
|
||||
|
||||
|
||||
36
README.txt
36
README.txt
@@ -5,7 +5,10 @@ This is the copyright notice, disclaimer, and license:
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE:
|
||||
*
|
||||
* Copyright (c) 1998, 1999, Glenn Randers-Pehrson
|
||||
* If you have modified this source, you may insert additional notices
|
||||
* immediately after this sentence.
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu)
|
||||
*
|
||||
* The pngcrush program is supplied "AS IS". The Author disclaims all
|
||||
* warranties, expressed or implied, including, without limitation, the
|
||||
@@ -14,8 +17,8 @@ This is the copyright notice, disclaimer, and license:
|
||||
* exemplary, or consequential damages, which may result from the use of
|
||||
* the pngcrush program, even if advised of the possibility of such damage.
|
||||
*
|
||||
* Permission is hereby granted to use, copy, modify, and distribute this
|
||||
* source code, or portions hereof, for any purpose, without fee, subject
|
||||
* Permission is hereby granted to anyone to use, copy, modify, and distribute
|
||||
* this source code, or portions hereof, for any purpose, without fee, subject
|
||||
* to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this source code must not be misrepresented.
|
||||
@@ -30,15 +33,14 @@ This is the copyright notice, disclaimer, and license:
|
||||
This is the output of "pngcrush" and "pngcrush -help":
|
||||
|
||||
|
||||
|
||||
| pngcrush 1.3.5, Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson
|
||||
| pngcrush 1.4.1, 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.1.0a,
|
||||
| This program was built with libpng version 1.0.6e,
|
||||
| Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,
|
||||
| Copyright (C) 1996, 1997 Andreas Dilger,
|
||||
| Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,
|
||||
| and zlib version 1.1.3, Copyright (c) 1998,
|
||||
| and zlib version 1.1.3, Copyright (C) 1998,
|
||||
| Jean-loup Gailly and Mark Adler.
|
||||
|
||||
|
||||
@@ -57,12 +59,12 @@ options:
|
||||
-itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||
-l zlib_compression_level [0-9]
|
||||
-m method [0 through 200]
|
||||
-max maximum_IDAT_size [1 through 524288]
|
||||
-max maximum_IDAT_size [1 through 8192]
|
||||
-n (no save; does not do compression or write output PNG)
|
||||
-plte_len n (truncate PLTE)
|
||||
-q (quiet)
|
||||
-rem chunkname (or "alla" or "allb")
|
||||
-replace_gamma gamma_value (float) even when file has a gAMA chunk.
|
||||
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
||||
-res dpi
|
||||
-srgb [0, 1, 2, or 3]
|
||||
-text b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||
@@ -74,9 +76,6 @@ options:
|
||||
-p (pause)
|
||||
|
||||
|
||||
usage: pngcrush [options] infile.png outfile.png
|
||||
pngcrush -e ext [other options] files.png ...
|
||||
pngcrush -d dir [other options] files.png ...
|
||||
|
||||
options:
|
||||
-brute (Use brute-force, try 114 different methods [11-124])
|
||||
@@ -93,6 +92,7 @@ options:
|
||||
fewer colors present in the input file. Color types
|
||||
4 and 6 are padded with an opaque alpha channel if
|
||||
the input file does not have alpha information.
|
||||
You can use 0 or 4 to convert color to grayscale.
|
||||
Use 0 or 2 to delete an unwanted alpha channel.
|
||||
Default is to use same color type as the input file.
|
||||
|
||||
@@ -134,7 +134,7 @@ options:
|
||||
|
||||
-itxt b[efore_IDAT]|a[fter_IDAT] "keyword" "text"
|
||||
|
||||
Compressed iTXt chunk to insert (see -text).
|
||||
Uncompressed iTXt chunk to insert (see -text).
|
||||
|
||||
-l zlib_compression_level [0-9]
|
||||
|
||||
@@ -152,7 +152,7 @@ options:
|
||||
1, 4, and 7 use no filtering; methods 11 and up use
|
||||
specified filter, compression level, and strategy.
|
||||
|
||||
-max maximum_IDAT_size [1 through 524288]
|
||||
-max maximum_IDAT_size [1 through 8192]
|
||||
|
||||
-n (no save; does not do compression or write output PNG)
|
||||
|
||||
@@ -175,14 +175,14 @@ options:
|
||||
different chunks, repeat: -rem tEXt -rem pHYs.
|
||||
Known chunks (those in the PNG 1.1 spec or extensions
|
||||
document) can be named with all lower-case letters,
|
||||
so "-rem bkgd" is equivalent to "-rem bKGD".
|
||||
so "-rem bkgd" is equivalent to "-rem bKGD". But
|
||||
note: "-rem text" removes all forms of text chunks;
|
||||
Exact case is required to remove unknown chunks.
|
||||
"-rem text" also removes zTXt. If you like to do
|
||||
surgery with a chain-saw, "-rem alla" removes
|
||||
To do surgery with a chain-saw, "-rem alla" removes
|
||||
all known ancillary chunks except for tRNS, and
|
||||
"-rem allb" removes all but tRNS and gAMA.
|
||||
|
||||
-replace_gamma gamma_value (float) even when file has a gAMA chunk.
|
||||
-replace_gamma gamma (float or fixed*100000) even if gAMA is present.
|
||||
|
||||
-res dpi
|
||||
|
||||
|
||||
77
cexcept.h
Normal file
77
cexcept.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*===
|
||||
cexcept.h 0.6.0 (2000-Apr-07-Fri)
|
||||
Adam M. Costello <amc@cs.berkeley.edu>
|
||||
|
||||
An interface for exception-handling in ANSI C, developed jointly with
|
||||
Cosmin Truta <cosmin@cs.toronto.edu>.
|
||||
|
||||
Copyright (c) 2000 Adam M. Costello and Cosmin Truta. Everyone
|
||||
is hereby granted permission to do whatever they like with this
|
||||
file, provided that if they modify it they take reasonable steps to
|
||||
avoid confusing or misleading people about the authors, version,
|
||||
and terms of use of the derived file. The copyright holders make
|
||||
no guarantees about the correctness of this file, and are not
|
||||
responsible for any damage resulting from its use.
|
||||
|
||||
Comments have been stripped from this copy; if you are interested in cexcept
|
||||
you should look at the most recent version, which this probably isn't.
|
||||
|
||||
For recent versions of cexcept.h with documentation and examples, go to
|
||||
http://www.cs.berkeley.edu/~amc/cexcept/ or http://cexcept.sourceforge.net/
|
||||
|
||||
===*/
|
||||
|
||||
|
||||
#ifndef CEXCEPT_H
|
||||
#define CEXCEPT_H
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define define_exception_type(etype) \
|
||||
struct exception__state { \
|
||||
etype *exception; \
|
||||
jmp_buf env; \
|
||||
}
|
||||
|
||||
struct exception_context { \
|
||||
struct exception__state *last; \
|
||||
int caught; \
|
||||
};
|
||||
|
||||
#define init_exception_context(ec) ((void)((ec)->last = 0))
|
||||
|
||||
#define Catch(e) exception__catch(&(e))
|
||||
#define Catch_anonymous exception__catch(0)
|
||||
|
||||
#define Try \
|
||||
{ \
|
||||
struct exception__state *exception__p, exception__s; \
|
||||
int exception__i; \
|
||||
exception__p = the_exception_context->last; \
|
||||
the_exception_context->last = &exception__s; \
|
||||
for (exception__i = 0; ; exception__i = 1) \
|
||||
if (exception__i) { \
|
||||
if (setjmp(exception__s.env) == 0) { \
|
||||
if (&exception__s)
|
||||
|
||||
#define exception__catch(e_addr) \
|
||||
else { } \
|
||||
the_exception_context->caught = 0; \
|
||||
} \
|
||||
else the_exception_context->caught = 1; \
|
||||
the_exception_context->last = exception__p; \
|
||||
break; \
|
||||
} \
|
||||
else exception__s.exception = e_addr; \
|
||||
} \
|
||||
if (!the_exception_context->caught) { } \
|
||||
else
|
||||
|
||||
#define Throw \
|
||||
for (;; longjmp(the_exception_context->last->env, 1)) \
|
||||
if (the_exception_context->last->exception) \
|
||||
*the_exception_context->last->exception =
|
||||
|
||||
|
||||
#endif /* CEXCEPT_H */
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
#include <stdio.h>
|
||||
convert(char * name)
|
||||
{
|
||||
unsigned long number;
|
||||
number=name[3]+name[2]*256+name[1]*256*256+name[0]*256*256*256;
|
||||
printf(" #define PNG_%s 0x%xL\n",name, number);
|
||||
}
|
||||
main()
|
||||
{
|
||||
convert("AAAA");
|
||||
convert("IDAT");
|
||||
convert("IEND");
|
||||
convert("IHDR");
|
||||
convert("PLTE");
|
||||
convert("bKGD");
|
||||
convert("cHRM");
|
||||
convert("gAMA");
|
||||
convert("hIST");
|
||||
convert("iCCP");
|
||||
convert("iTXt");
|
||||
convert("oFFs");
|
||||
convert("pCAL");
|
||||
convert("pHYs");
|
||||
convert("sBIT");
|
||||
convert("sCAL");
|
||||
convert("sPLT");
|
||||
convert("sRGB");
|
||||
convert("tEXt");
|
||||
convert("tIME");
|
||||
convert("tRNS");
|
||||
convert("zTXt");
|
||||
convert("zzzz");
|
||||
}
|
||||
|
||||
46
png.c
46
png.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng version 1.0.6a - March 23, 2000
|
||||
* libpng version 1.0.6e - April 9, 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_6a Your_png_h_is_not_version_1_0_6a;
|
||||
typedef version_1_0_6e Your_png_h_is_not_version_1_0_6e;
|
||||
|
||||
/* 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.6a";
|
||||
char png_libpng_ver[12] = "1.0.6e";
|
||||
|
||||
/* png_sig was changed to a function in version 1.0.5c */
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
@@ -261,15 +261,32 @@ png_info_init(png_infop info_ptr)
|
||||
png_memset(info_ptr, 0, sizeof (png_info));
|
||||
}
|
||||
|
||||
void
|
||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
{
|
||||
png_debug(1, "in png_data_freer\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if(freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
info_ptr->free_me |= mask;
|
||||
else if(freer == PNG_USER_WILL_FREE_DATA)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Unknown freer parameter in png_data_freer.");
|
||||
}
|
||||
|
||||
void
|
||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
|
||||
{
|
||||
png_debug(1, "in png_free_data\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED)
|
||||
/* free text item num or (if num == -1) all text items */
|
||||
if (mask & PNG_FREE_TEXT)
|
||||
if (mask & info_ptr->free_me & PNG_FREE_TEXT)
|
||||
{
|
||||
if (num != -1)
|
||||
{
|
||||
@@ -306,7 +323,6 @@ if (mask & PNG_FREE_TRNS)
|
||||
|
||||
#if defined(PNG_sCAL_SUPPORTED)
|
||||
/* free any sCAL entry */
|
||||
if (mask & PNG_FREE_SCAL)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
{
|
||||
@@ -321,7 +337,6 @@ if (mask & PNG_FREE_SCAL)
|
||||
|
||||
#if defined(PNG_pCAL_SUPPORTED)
|
||||
/* free any pCAL entry */
|
||||
if (mask & PNG_FREE_PCAL)
|
||||
{
|
||||
if (info_ptr->valid & PNG_INFO_pCAL)
|
||||
{
|
||||
@@ -484,7 +499,9 @@ png_get_io_ptr(png_structp png_ptr)
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
/* Initialize the default input/output functions for the PNG file. If you
|
||||
* use your own read or write routines, you can call either png_set_read_fn()
|
||||
* or png_set_write_fn() instead of png_init_io().
|
||||
* or png_set_write_fn() instead of png_init_io(). If you have defined
|
||||
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
|
||||
* necessarily available.
|
||||
*/
|
||||
void
|
||||
png_init_io(png_structp png_ptr, FILE *fp)
|
||||
@@ -531,21 +548,20 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||
}
|
||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||
|
||||
#if 0
|
||||
/* Signature string for a PNG file. */
|
||||
png_bytep
|
||||
png_sig_bytes(png_structp png_ptr)
|
||||
png_sig_bytes(void)
|
||||
{
|
||||
const png_byte png_sig_numbers[9] = {137, 80, 78, 71, 13, 10, 26, 10, 0};
|
||||
if (png_ptr == NULL) /* silence compiler warning */
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
|
||||
return ((png_bytep)"\211\120\116\107\015\012\032\012");
|
||||
}
|
||||
#endif
|
||||
|
||||
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.6a - March 23, 2000\n\
|
||||
return ("\n libpng version 1.0.6e - April 9, 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");
|
||||
@@ -563,8 +579,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.6a");
|
||||
return("1.0.6a");
|
||||
return("1.0.6e");
|
||||
return("1.0.6e");
|
||||
}
|
||||
|
||||
png_charp
|
||||
|
||||
83
png.h
83
png.h
@@ -1,15 +1,15 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.0.6a - March 23, 2000
|
||||
* libpng version 1.0.6e - April 9, 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
|
||||
*
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
|
||||
* libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.0.6a - March 23, 2000: Glenn
|
||||
* 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.6e - April 9, 2000: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -42,22 +42,21 @@
|
||||
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d
|
||||
* 1.0.4 1.0.4 10004 2.1.0.4
|
||||
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f
|
||||
* 1.0.5 1.0.5 10005 2.1.0.5
|
||||
* 1.0.5 (+ 2 patches) 1.0.5 10005 2.1.0.5
|
||||
* 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d
|
||||
* 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible)
|
||||
* 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-w (compatible)
|
||||
* 1.0.6 1.0.6 10006 2.1.0.6
|
||||
* 1.0.6a 1.0.6a 10007 2.1.0.6a
|
||||
* 1.3.0 1.3.0 10300 3.1.3.0
|
||||
* 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (compatible)
|
||||
* 1.0.6 (+ 3 patches) 1.0.6 10006 2.1.0.6
|
||||
* 1.0.6d-e 1.0.6d-e 10007 2.1.0.6d-e
|
||||
* 1.0.7 1.0.7 10007 2.1.0.7 (still compatible)
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended. The
|
||||
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
* to the source version x.y.z (leading zeros in y and z). Internal
|
||||
* png-group beta versions (x.y.z[a-z]) will be given the next higher
|
||||
* number.
|
||||
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||
* are given the previous public release number plus a letter or two.
|
||||
*
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
@@ -65,14 +64,16 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE:
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||
*
|
||||
* If you modify libpng you may insert additional notices after this sentence.
|
||||
*
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* (libpng versions 0.5, May 1995, through 0.89c, May 1996)
|
||||
* (libpng versions 0.5, May 1995, through 0.88, January 1996)
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* (libpng versions 0.90, December 1996, through 0.96, May 1997)
|
||||
* (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.6a, March 23, 2000)
|
||||
* (libpng versions 0.97, January 1998, through 1.0.6e, April 9, 2000)
|
||||
*
|
||||
* For the purposes of this copyright and license, "Contributing Authors"
|
||||
* is defined as the following set of individuals:
|
||||
@@ -147,13 +148,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* March 23, 2000
|
||||
* April 9, 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.6a are Y2K compliant. It is my belief that earlier
|
||||
* upward through 1.0.6e 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
|
||||
@@ -231,7 +232,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.6a"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.6e"
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
@@ -427,16 +428,20 @@ typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
|
||||
* The following members may have allocated storage attached that should be
|
||||
* cleaned up before the structure is discarded: palette, trans, text,
|
||||
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
* splt_palettes, scal_unit, and row_pointers. These are automatically
|
||||
* freed when the info structure is deallocated.
|
||||
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these are
|
||||
* automatically freed when the info structure is deallocated, if they were
|
||||
* allocated internally by libpng. This behavior can be changed by means
|
||||
* of the png_data_freer() function.
|
||||
*
|
||||
* More allocation details: all the chunk-reading functions that change these
|
||||
* members go through the corresponding png_set_* functions. Functions to
|
||||
* clear these members are available: see png_free_*. The png_set_* functions
|
||||
* do not depend on being able to point info structure members to any of the
|
||||
* storage they are passed (they make their own copies), EXCEPT that the
|
||||
* png_set_text function uses the same storage passed to them
|
||||
* in the text_ptr or itxt_ptr structure argument.
|
||||
* members go through the corresponding png_set_* functions. A function to
|
||||
* clear these members is available: see png_free_data(). Some of the
|
||||
* png_set_* functions do not depend on being able to point info structure
|
||||
* members to any of the storage they are passed (they make their own copies),
|
||||
* EXCEPT that the png_set_text functions use the same storage passed to them
|
||||
* in the text_ptr or itxt_ptr structure argument, and the png_set_tRNS,
|
||||
* png_set_PLTE, png_set_hIST, png_set_iCCP, png_set_rows, png_set_sPLT,
|
||||
* and png_set_unknowns do not make their own copies.
|
||||
*/
|
||||
typedef struct png_info_struct
|
||||
{
|
||||
@@ -1056,9 +1061,9 @@ struct png_struct_def
|
||||
};
|
||||
|
||||
/* This prevents a compiler error in png_get_copyright() in png.c if png.c
|
||||
and png.h are both at * version 1.0.6a
|
||||
and png.h are both at * version 1.0.6e
|
||||
*/
|
||||
typedef png_structp version_1_0_6a;
|
||||
typedef png_structp version_1_0_6e;
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
@@ -1590,10 +1595,18 @@ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
|
||||
/* frees a pointer allocated by png_malloc() */
|
||||
extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
|
||||
|
||||
/* free data that was allocated internally */
|
||||
/* 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));
|
||||
/* flags for png_ptr->free_me and info_ptr->free_me */
|
||||
/* 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));
|
||||
/* 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
|
||||
@@ -1601,8 +1614,8 @@ extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
|
||||
#define PNG_FREE_ICCP 0x0010
|
||||
#define PNG_FREE_SPLT 0x0020
|
||||
#define PNG_FREE_ROWS 0x0040
|
||||
#define PNG_FREE_PCAL 0x0080
|
||||
#define PNG_FREE_SCAL 0x0100
|
||||
#define PNG_FREE_PCAL 0x0080 /* not used any more */
|
||||
#define PNG_FREE_SCAL 0x0100 /* not used any more */
|
||||
#define PNG_FREE_UNKN 0x0200
|
||||
#define PNG_FREE_LIST 0x0400
|
||||
#define PNG_FREE_ALL 0x07ff
|
||||
@@ -2023,7 +2036,7 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
|
||||
#define png_debug2(l, m, p1, p2)
|
||||
#endif
|
||||
|
||||
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((png_structp png_ptr));
|
||||
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
|
||||
|
||||
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
|
||||
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
|
||||
@@ -2031,7 +2044,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.6a - March 23, 2000 (header)\n"
|
||||
" libpng version 1.0.6e - April 9, 2000 (header)\n"
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
/* With these routines we avoid an integer divide, which will be slower on
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* pngasmrd.h - assembler version of utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
21
pngconf.h
21
pngconf.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
@@ -257,7 +257,7 @@
|
||||
* things to happen if the library and/or application ever change.
|
||||
*/
|
||||
|
||||
/* Any transformations you will not be using can be undef'ed here */
|
||||
/* Any features you will not be using can be undef'ed here */
|
||||
|
||||
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
|
||||
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
|
||||
@@ -269,7 +269,13 @@
|
||||
1.0.1c, for consistency)
|
||||
*/
|
||||
|
||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
||||
!defined(PNG_NO_READ_TRANSFORMS)
|
||||
@@ -389,7 +395,8 @@
|
||||
encoders, but can cause trouble
|
||||
if left undefined */
|
||||
|
||||
#ifndef PNG_NO_WRITE_WEIGHTED_FILTER
|
||||
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
#endif
|
||||
|
||||
@@ -430,14 +437,6 @@
|
||||
#define PNG_ASSEMBLER_CODE_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* Do not use global arrays (helps with building DLL's)
|
||||
* They are no longer used in libpng itself, since version 1.0.5c,
|
||||
* but might be required for some pre-1.0.5c applications.
|
||||
|
||||
289
pngcrush.c
289
pngcrush.c
@@ -15,11 +15,14 @@
|
||||
* occasionally creating Linux executables.
|
||||
*/
|
||||
|
||||
#define PNGCRUSH_VERSION "1.4.0"
|
||||
#define PNGCRUSH_VERSION "1.4.1"
|
||||
|
||||
/*
|
||||
* COPYRIGHT NOTICE, DISCLAIMER, AND LICENSE:
|
||||
*
|
||||
* If you have modified this source, you may insert additional notices
|
||||
* immediately after this sentence.
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson (randeg@alum.rpi.edu)
|
||||
*
|
||||
* The pngcrush program is supplied "AS IS". The Author disclaims all
|
||||
@@ -63,6 +66,14 @@
|
||||
*
|
||||
* Change log:
|
||||
*
|
||||
* Version 1.4.1 (built with libpng-1.0.6e and cexcept-0.6.0)
|
||||
*
|
||||
* Uses cexcept.h for error handling instead of libpng's built-in
|
||||
* setjmp/longjmp mechanism. See http://cexcept.sourceforge.net/
|
||||
*
|
||||
* Pngcrush.c will now run when compiled with old versions of libpng back
|
||||
* to version 0.96, although some features will not be available.
|
||||
*
|
||||
* Version 1.4.0 (built with libpng-1.0.6 + libpng-1.0.6-patch-a)
|
||||
*
|
||||
* Version 1.3.6 (built with libpng-1.0.5v)
|
||||
@@ -176,6 +187,8 @@
|
||||
* types, compression levels, or compression strategies.
|
||||
*/
|
||||
|
||||
#define USE_CEXCEPT
|
||||
|
||||
#if defined(__DJGPP__)
|
||||
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
|
||||
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
|
||||
@@ -205,17 +218,47 @@
|
||||
#define P1 if(verbose > 1)printf
|
||||
#define P2 if(verbose > 2)printf
|
||||
|
||||
/* we don't need the extra libpng tranformations
|
||||
/* we don't need the extra libpng transformations
|
||||
* so they are ifdef'ed out in a special version of pngconf.h */
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if (PNG_LIBPNG_VER > 95)
|
||||
|
||||
/* so we can load pngcrush with pre-1.0.6 versions of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
||||
#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)
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
|
||||
#define PNG_pHYs_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
|
||||
#define PNG_hIST_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
#define PNG_pCAL_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
#define PNG_tIME_SUPPORTED
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#endif
|
||||
@@ -256,12 +299,24 @@ int best;
|
||||
char buffer[256];
|
||||
char *str_return;
|
||||
|
||||
#ifdef USE_CEXCEPT
|
||||
/* The cexcept documentation recommends putting the following three lines in a
|
||||
* separate header file, but it appears to work with them embedded here.
|
||||
* There is only one "Throw" and it is in this file. */
|
||||
#include "cexcept.h"
|
||||
define_exception_type(const char *);
|
||||
extern struct exception_context the_exception_context[1];
|
||||
|
||||
struct exception_context the_exception_context[1];
|
||||
|
||||
#else
|
||||
#ifndef PNG_JMPBUF_SUPPORTED
|
||||
#ifndef PNG_SETJMP_NOT_SUPPORTED
|
||||
/* Old setjmp interface */
|
||||
jmp_buf jmpbuf;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static png_uint_32 total_input_length = 0;
|
||||
static png_uint_32 total_output_length = 0;
|
||||
@@ -299,17 +354,25 @@ static int methods_specified=0;
|
||||
static int intent=-1;
|
||||
static int plte_len=-1;
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
static int specified_gamma=0;
|
||||
static int force_specified_gamma=0;
|
||||
# else
|
||||
static double specified_gamma=0.0;
|
||||
static double force_specified_gamma=0.0;
|
||||
# endif
|
||||
static int double_gamma=0;
|
||||
#endif
|
||||
static int names;
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
static int have_trns=0;
|
||||
static png_uint_16 trns_index=0;
|
||||
static png_uint_16 trns_red=0;
|
||||
static png_uint_16 trns_green=0;
|
||||
static png_uint_16 trns_blue=0;
|
||||
static png_uint_16 trns_gray=0;
|
||||
#endif
|
||||
static png_byte trns_array[256];
|
||||
static int have_bkgd=0;
|
||||
static png_uint_16 bkgd_red=0;
|
||||
static png_uint_16 bkgd_green=0;
|
||||
@@ -317,7 +380,6 @@ static png_uint_16 bkgd_blue=0;
|
||||
|
||||
static png_colorp palette;
|
||||
static int num_palette;
|
||||
static png_byte trns_array[256];
|
||||
|
||||
#ifdef REORDER_PALETTE
|
||||
static png_byte palette_reorder[256];
|
||||
@@ -341,6 +403,18 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||
static int max_idat_size = PNG_ZBUF_SIZE;
|
||||
int ia;
|
||||
|
||||
/* cexcept interface */
|
||||
|
||||
#ifdef USE_CEXCEPT
|
||||
static void
|
||||
png_cexcept_error(png_structp png_ptr, png_const_charp msg)
|
||||
{
|
||||
if(png_ptr)
|
||||
;
|
||||
Throw msg;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* START of code to validate memory allocation and deallocation */
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
|
||||
@@ -582,7 +656,11 @@ main(int argc, char *argv[])
|
||||
int ntrial;
|
||||
int lev, strat, filt;
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point file_gamma=0;
|
||||
#else
|
||||
double file_gamma=0.;
|
||||
#endif
|
||||
#endif
|
||||
char *cp;
|
||||
int i;
|
||||
@@ -807,6 +885,7 @@ main(int argc, char *argv[])
|
||||
BUMP_I;
|
||||
if (intent < 0)
|
||||
{
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
int c;
|
||||
char number[16];
|
||||
char *n=number;
|
||||
@@ -828,6 +907,9 @@ main(int argc, char *argv[])
|
||||
*n++='0';
|
||||
*n='\0';
|
||||
specified_gamma=atoi(number);
|
||||
#else
|
||||
specified_gamma=atof(argv[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -882,6 +964,7 @@ main(int argc, char *argv[])
|
||||
names++;
|
||||
BUMP_I;
|
||||
{
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
int c;
|
||||
char number[16];
|
||||
char *n=number;
|
||||
@@ -903,6 +986,9 @@ main(int argc, char *argv[])
|
||||
*n++='0';
|
||||
*n='\0';
|
||||
force_specified_gamma=atoi(number);
|
||||
#else
|
||||
force_specified_gamma=atof(argv[i]);
|
||||
#endif
|
||||
}
|
||||
things_have_changed=1;
|
||||
}
|
||||
@@ -928,7 +1014,11 @@ main(int argc, char *argv[])
|
||||
!strncmp(argv[i],"-sRGB",5))
|
||||
{
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
specified_gamma=45455L;
|
||||
#else
|
||||
specified_gamma=0.45455;
|
||||
#endif
|
||||
#endif
|
||||
intent=0;
|
||||
BUMP_I;
|
||||
@@ -947,28 +1037,35 @@ main(int argc, char *argv[])
|
||||
else if(!strncmp(argv[i],"-s",2))
|
||||
verbose=0;
|
||||
else if( !strncmp(argv[i],"-text",5) || !strncmp(argv[i],"-tEXt",5) ||
|
||||
!strncmp(argv[i],"-ztxt",5) || !strncmp(argv[i],"-zTXt",5) ||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
!strncmp(argv[i],"-itxt",5) || !strncmp(argv[i],"-iTXt",5) ||
|
||||
!strncmp(argv[i],"-zitxt",6) || !strncmp(argv[i],"-ziTXt",6) ||
|
||||
!strncmp(argv[i],"-itxt",5) || !strncmp(argv[i],"-iTXt",5))
|
||||
#endif
|
||||
!strncmp(argv[i],"-ztxt",5) || !strncmp(argv[i],"-zTXt",5))
|
||||
{
|
||||
i+=2; BUMP_I; i-=3;
|
||||
if(strlen(argv[i+2]) < 80 && strlen(argv[i+3]) < 2048 &&
|
||||
text_inputs < 10)
|
||||
{
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if( !strncmp(argv[i],"-zi",3))
|
||||
{
|
||||
text_compression[text_inputs] = PNG_ITXT_COMPRESSION_zTXt;
|
||||
names+=2;
|
||||
}
|
||||
else if( !strncmp(argv[i],"-z",2))
|
||||
else
|
||||
#endif
|
||||
if( !strncmp(argv[i],"-z",2))
|
||||
text_compression[text_inputs] = PNG_TEXT_COMPRESSION_zTXt;
|
||||
else if( !strncmp(argv[i],"-t",2))
|
||||
text_compression[text_inputs] = PNG_TEXT_COMPRESSION_NONE;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
else
|
||||
{
|
||||
text_compression[text_inputs] = PNG_ITXT_COMPRESSION_NONE;
|
||||
names+=2;
|
||||
}
|
||||
#endif
|
||||
names+=3;
|
||||
if( !strncmp(argv[++i],"b",1))
|
||||
text_where[text_inputs]=1;
|
||||
@@ -1001,14 +1098,17 @@ main(int argc, char *argv[])
|
||||
"keyword exceeds 79 characters or text exceeds 2047 characters\n");
|
||||
i+=3;
|
||||
names+=3;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if( !strncmp(argv[i],"-i",2) || !strncmp(argv[i],"-zi",3))
|
||||
{
|
||||
i++;
|
||||
BUMP_I;
|
||||
names+=2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
else if( !strncmp(argv[i],"-trns",5) ||
|
||||
!strncmp(argv[i],"-tRNS",5))
|
||||
{
|
||||
@@ -1020,6 +1120,7 @@ main(int argc, char *argv[])
|
||||
trns_blue=(png_uint_16)atoi(argv[++i]);
|
||||
trns_gray=(png_uint_16)atoi(argv[++i]);
|
||||
}
|
||||
#endif
|
||||
else if(!strncmp(argv[i],"-version",8))
|
||||
{
|
||||
fprintf(STDERR,"libpng ");
|
||||
@@ -1090,10 +1191,14 @@ main(int argc, char *argv[])
|
||||
PNG_LIBPNG_VER_STRING);
|
||||
fprintf(STDERR,
|
||||
" | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,\n");
|
||||
#if PNG_LIBPNG_VER > 89
|
||||
fprintf(STDERR,
|
||||
" | Copyright (C) 1996, 1997 Andreas Dilger,\n");
|
||||
#endif
|
||||
#if PNG_LIBPNG_VER > 96
|
||||
fprintf(STDERR,
|
||||
" | Copyright (C) 1998, 1999, 2000 Glenn Randers-Pehrson,\n");
|
||||
#endif
|
||||
fprintf(STDERR,
|
||||
" | and zlib version %s, Copyright (C) 1998,\n",
|
||||
ZLIB_VERSION);
|
||||
@@ -1249,7 +1354,11 @@ main(int argc, char *argv[])
|
||||
" additions, removals, or changes were requested.\n\n");
|
||||
}
|
||||
fprintf(STDERR,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
" -g gamma (float or fixed*100000, e.g., 0.45455 or 45455)\n");
|
||||
#else
|
||||
" -g gamma (float, e.g., 0.45455)\n");
|
||||
#endif
|
||||
if(verbose > 1)
|
||||
fprintf(STDERR,
|
||||
"\n Value to insert in gAMA chunk, only if the input\n");
|
||||
@@ -1260,11 +1369,13 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,
|
||||
" gAMA chunk, use the '-replace_gamma' option.\n\n");
|
||||
png_crush_pause();
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
fprintf(STDERR,
|
||||
" -itxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
|
||||
if(verbose > 1)
|
||||
fprintf(STDERR,
|
||||
"\n Uncompressed iTXt chunk to insert (see -text).\n\n");
|
||||
#endif
|
||||
fprintf(STDERR,
|
||||
" -l zlib_compression_level [0-9]\n");
|
||||
if(verbose > 1)
|
||||
@@ -1359,7 +1470,11 @@ main(int argc, char *argv[])
|
||||
}
|
||||
png_crush_pause();
|
||||
fprintf(STDERR,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
"-replace_gamma gamma (float or fixed*100000) even if gAMA is present.\n");
|
||||
#else
|
||||
"-replace_gamma gamma (float, e.g. 0.45455) even if gAMA is present.\n");
|
||||
#endif
|
||||
if(verbose > 1)
|
||||
fprintf(STDERR,"\n");
|
||||
fprintf(STDERR,
|
||||
@@ -1401,6 +1516,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,
|
||||
" tEXt, iTXt, or zTXt chunks per pngcrush run.\n\n");
|
||||
}
|
||||
#ifdef PNG_tRNS_SUPPORTED
|
||||
fprintf(STDERR,
|
||||
" -trns index red green blue gray\n");
|
||||
if(verbose > 1)
|
||||
@@ -1412,6 +1528,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,
|
||||
" color type, scaled to the output bit depth.\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(STDERR,
|
||||
" -v (display more detailed information)\n");
|
||||
@@ -1445,11 +1562,13 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,
|
||||
" '-m method' argument.\n\n");
|
||||
}
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
fprintf(STDERR,
|
||||
" -zitxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
|
||||
if(verbose > 1)
|
||||
fprintf(STDERR,
|
||||
"\n Compressed iTXt chunk to insert (see -text).\n\n");
|
||||
#endif
|
||||
fprintf(STDERR,
|
||||
" -ztxt b[efore_IDAT]|a[fter_IDAT] \"keyword\" \"text\"\n");
|
||||
if(verbose > 1)
|
||||
@@ -1484,6 +1603,11 @@ main(int argc, char *argv[])
|
||||
for(;;) /* loop on input files */
|
||||
|
||||
{
|
||||
#ifdef USE_CEXCEPT
|
||||
png_const_charp msg;
|
||||
Try
|
||||
{
|
||||
#endif
|
||||
first_trial = 1;
|
||||
|
||||
if(png_row_filters != NULL)
|
||||
@@ -1742,33 +1866,40 @@ main(int argc, char *argv[])
|
||||
png_debug(0, "Allocating read and write structures\n");
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
#ifdef USE_CEXCEPT
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||
#else
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||
#endif
|
||||
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||
#else
|
||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
#ifdef USE_CEXCEPT
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
#else
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_NO_STDIO)
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error,
|
||||
png_default_warning);
|
||||
#endif
|
||||
|
||||
if(nosave == 0)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
#ifdef USE_CEXCEPT
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||
#else
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL,
|
||||
#endif
|
||||
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||
#else
|
||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
#ifdef USE_CEXCEPT
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
#else
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_NO_STDIO)
|
||||
png_set_error_fn(write_ptr, (png_voidp)outname, png_default_error,
|
||||
png_default_warning);
|
||||
#endif
|
||||
|
||||
}
|
||||
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
@@ -1787,13 +1918,7 @@ main(int argc, char *argv[])
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
# else
|
||||
# ifdef PNG_JMPBUF_SUPPORTED
|
||||
/* New setjmp interface */
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
# else
|
||||
/* old interface */
|
||||
if (setjmp(read_ptr->jmpbuf))
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
PNG_CRUSH_CLEANUP
|
||||
@@ -1807,13 +1932,7 @@ main(int argc, char *argv[])
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
# else
|
||||
# ifdef PNG_JMPBUF_SUPPORTED
|
||||
/* New setjmp interface */
|
||||
if (setjmp(png_jmpbuf(write_ptr)))
|
||||
# else
|
||||
/* Old interface */
|
||||
if (setjmp(write_ptr->jmpbuf))
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
PNG_CRUSH_CLEANUP
|
||||
@@ -1869,8 +1988,7 @@ main(int argc, char *argv[])
|
||||
P2("reinitializing write zbuf.\n");
|
||||
png_free(write_ptr, write_ptr->zbuf);
|
||||
write_ptr->zbuf_size = (png_size_t)max_idat_size;
|
||||
write_ptr->zbuf =
|
||||
(png_bytep)png_malloc(write_ptr,
|
||||
write_ptr->zbuf = (png_bytep)png_malloc(write_ptr,
|
||||
(png_uint_32)write_ptr->zbuf_size);
|
||||
}
|
||||
}
|
||||
@@ -1887,6 +2005,7 @@ main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
#ifndef PNG_UINT_IHDR
|
||||
/* We are using libpng-1.0.6 or earlier */
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
#if !defined(PNG_cHRM_SUPPORTED)
|
||||
PNG_cHRM;
|
||||
@@ -1942,7 +2061,7 @@ main(int argc, char *argv[])
|
||||
(png_bytep)png_tIME, 1);
|
||||
#endif
|
||||
|
||||
#else /* PNG_UINT_IHDR */
|
||||
#else /* PNG_UINT_IHDR is defined; we are using libpng newer than 1.0.6 */
|
||||
|
||||
#if !defined(PNG_cHRM_SUPPORTED) || !defined(PNG_hIST_SUPPORTED) || \
|
||||
!defined(PNG_iCCP_SUPPORTED) || !defined(PNG_sCAL_SUPPORTED) || \
|
||||
@@ -1992,7 +2111,7 @@ main(int argc, char *argv[])
|
||||
#endif /* PNG_UINT_IHDR */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
|
||||
png_debug(0, "Reading info struct\n");
|
||||
png_read_info(read_ptr, read_info_ptr);
|
||||
@@ -2031,15 +2150,19 @@ main(int argc, char *argv[])
|
||||
if(output_bit_depth != input_bit_depth)
|
||||
need_expand = 1;
|
||||
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
if((color_type == 2 || color_type == 6 || color_type == 3) &&
|
||||
(output_color_type == 0 || output_color_type == 4))
|
||||
{
|
||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_set_rgb_to_gray_fixed(read_ptr, 1, -1, -1);
|
||||
#else
|
||||
png_set_rgb_to_gray(read_ptr, 1, 0., 0.);
|
||||
#endif
|
||||
if(output_bit_depth < 8)output_bit_depth=8;
|
||||
if(color_type == 3) need_expand = 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if(color_type != 3 && output_color_type == 3)
|
||||
{
|
||||
@@ -2067,7 +2190,7 @@ main(int argc, char *argv[])
|
||||
(color_type != 4 && color_type != 6))
|
||||
{
|
||||
if(verbose > 0 && first_trial)
|
||||
fprintf(STDERR, " Adding an alpha channel.\n");
|
||||
fprintf(STDERR, " Adding an opaque alpha channel.\n");
|
||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||
png_set_filler(read_ptr, (png_uint_32)65535L, PNG_FILLER_AFTER);
|
||||
#endif
|
||||
@@ -2167,6 +2290,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED) && defined(PNG_WRITE_cHRM_SUPPORTED)
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
{
|
||||
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y,
|
||||
blue_x, blue_y;
|
||||
@@ -2179,7 +2303,22 @@ main(int argc, char *argv[])
|
||||
red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
double white_x, white_y, red_x, red_y, green_x, green_y,
|
||||
blue_x, blue_y;
|
||||
|
||||
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y,
|
||||
&red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))
|
||||
{
|
||||
if(keep_chunk("cHRM",argv))
|
||||
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y,
|
||||
red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_WRITE_gAMA_SUPPORTED)
|
||||
{
|
||||
if(force_specified_gamma > 0)
|
||||
@@ -2189,22 +2328,43 @@ main(int argc, char *argv[])
|
||||
things_have_changed=1;
|
||||
if(verbose > 0)
|
||||
fprintf(STDERR,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
" Inserting gAMA chunk with gamma=(%d/100000)\n",
|
||||
#else
|
||||
" Inserting gAMA chunk with gamma=%f\n",
|
||||
#endif
|
||||
force_specified_gamma);
|
||||
}
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_set_gAMA_fixed(write_ptr, write_info_ptr,
|
||||
(png_fixed_point)force_specified_gamma);
|
||||
file_gamma=(png_fixed_point)force_specified_gamma;
|
||||
#else
|
||||
png_set_gAMA(write_ptr, write_info_ptr,
|
||||
force_specified_gamma);
|
||||
file_gamma=force_specified_gamma;
|
||||
#endif
|
||||
}
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
else if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &file_gamma))
|
||||
#else
|
||||
else if (png_get_gAMA(read_ptr, read_info_ptr, &file_gamma))
|
||||
#endif
|
||||
{
|
||||
if(keep_chunk("gAMA",argv))
|
||||
{
|
||||
if(verbose > 1 && first_trial)
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
fprintf(STDERR, " gamma=(%d/100000)\n", (int)file_gamma);
|
||||
if(double_gamma)
|
||||
file_gamma+=file_gamma;
|
||||
png_set_gAMA_fixed(write_ptr, write_info_ptr, file_gamma);
|
||||
#else
|
||||
fprintf(STDERR, " gamma=%f\n", file_gamma);
|
||||
if(double_gamma)
|
||||
file_gamma+=file_gamma;
|
||||
png_set_gAMA(write_ptr, write_info_ptr, file_gamma);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if(specified_gamma > 0)
|
||||
@@ -2214,11 +2374,20 @@ main(int argc, char *argv[])
|
||||
things_have_changed=1;
|
||||
if(verbose > 0)
|
||||
fprintf(STDERR,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
" Inserting gAMA chunk with gamma=(%d/100000)\n",
|
||||
#else
|
||||
" Inserting gAMA chunk with gamma=%f\n",
|
||||
#endif
|
||||
specified_gamma);
|
||||
}
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_set_gAMA_fixed(write_ptr, write_info_ptr, specified_gamma);
|
||||
file_gamma=(png_fixed_point)specified_gamma;
|
||||
#else
|
||||
png_set_gAMA(write_ptr, write_info_ptr, specified_gamma);
|
||||
file_gamma=specified_gamma;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2234,7 +2403,11 @@ main(int argc, char *argv[])
|
||||
else if(intent >= 0)
|
||||
{
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
if(file_gamma >= 45000L && file_gamma <= 46000L)
|
||||
#else
|
||||
if(file_gamma >= 0.45000 && file_gamma <= 0.46000)
|
||||
#endif
|
||||
{
|
||||
things_have_changed=1;
|
||||
if(first_trial)
|
||||
@@ -2251,7 +2424,11 @@ main(int argc, char *argv[])
|
||||
if(first_trial)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
" Ignoring sRGB request; gamma=(%lu/100000) is not approx. 0.455\n",
|
||||
#else
|
||||
" Ignoring sRGB request; gamma=%f is not approx. 0.455\n",
|
||||
#endif
|
||||
file_gamma);
|
||||
}
|
||||
}
|
||||
@@ -2277,7 +2454,11 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED) && defined(PNG_WRITE_oFFs_SUPPORTED)
|
||||
{
|
||||
#if PNG_LIBPNG_VER < 10006
|
||||
png_uint_32 offset_x, offset_y;
|
||||
#else
|
||||
png_int_32 offset_x, offset_y;
|
||||
#endif
|
||||
int unit_type;
|
||||
|
||||
if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type))
|
||||
@@ -2556,6 +2737,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,"%d %s",ntext,text_ptr[ntext].key);
|
||||
if(text_ptr[ntext].text_length != 0)
|
||||
fprintf(STDERR,": %s\n",text_ptr[ntext].text);
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
else if (text_ptr[ntext].itxt_length != 0)
|
||||
{
|
||||
fprintf(STDERR," (%s: %s): \n",
|
||||
@@ -2563,6 +2745,7 @@ main(int argc, char *argv[])
|
||||
text_ptr[ntext].lang_key);
|
||||
fprintf(STDERR,"%s\n",text_ptr[ntext].text);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
fprintf(STDERR,"\n");
|
||||
}
|
||||
@@ -2594,6 +2777,7 @@ main(int argc, char *argv[])
|
||||
num_to_write--;
|
||||
}
|
||||
}
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(text_ptr[ntext].compression==PNG_ITXT_COMPRESSION_NONE
|
||||
||text_ptr[ntext].compression==PNG_ITXT_COMPRESSION_zTXt)
|
||||
{
|
||||
@@ -2603,6 +2787,7 @@ main(int argc, char *argv[])
|
||||
num_to_write--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (num_to_write > 0)
|
||||
png_set_text(write_ptr, write_info_ptr, text_ptr,
|
||||
@@ -2617,8 +2802,10 @@ main(int argc, char *argv[])
|
||||
added_text = (png_textp)
|
||||
png_malloc(write_ptr, (png_uint_32)sizeof(png_text));
|
||||
added_text[0].key = &text_keyword[ntext*80];
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
added_text[0].lang = &text_lang[ntext*80];
|
||||
added_text[0].lang_key = &text_lang_key[ntext*80];
|
||||
#endif
|
||||
added_text[0].text = &text_text[ntext*2048];
|
||||
added_text[0].compression = text_compression[ntext];
|
||||
png_set_text(write_ptr, write_info_ptr, added_text, 1);
|
||||
@@ -2626,10 +2813,12 @@ main(int argc, char *argv[])
|
||||
printf(" Added a tEXt chunk.\n");
|
||||
else if(added_text[0].compression == 0)
|
||||
printf(" Added a zTXt chunk.\n");
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
else if(added_text[0].compression == 1)
|
||||
printf(" Added an uncompressed iTXt chunk.\n");
|
||||
else
|
||||
printf(" Added a compressed iTXt chunk.\n");
|
||||
#endif
|
||||
png_free(write_ptr,added_text);
|
||||
}
|
||||
}
|
||||
@@ -2842,6 +3031,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR,"%d %s",ntext,text_ptr[ntext].key);
|
||||
if(text_ptr[ntext].text_length != 0)
|
||||
fprintf(STDERR,": %s\n",text_ptr[ntext].text);
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
else if (text_ptr[ntext].itxt_length != 0)
|
||||
{
|
||||
fprintf(STDERR," (%s: %s): \n",
|
||||
@@ -2849,6 +3039,7 @@ main(int argc, char *argv[])
|
||||
text_ptr[ntext].lang_key);
|
||||
fprintf(STDERR,"%s\n",text_ptr[ntext].text);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
fprintf(STDERR,"\n");
|
||||
}
|
||||
@@ -2880,6 +3071,7 @@ main(int argc, char *argv[])
|
||||
num_to_write--;
|
||||
}
|
||||
}
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(text_ptr[ntext].compression==PNG_ITXT_COMPRESSION_NONE
|
||||
||text_ptr[ntext].compression==PNG_ITXT_COMPRESSION_zTXt)
|
||||
{
|
||||
@@ -2889,6 +3081,7 @@ main(int argc, char *argv[])
|
||||
num_to_write--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (num_to_write > 0)
|
||||
png_set_text(write_ptr, write_end_info_ptr, text_ptr,
|
||||
@@ -2903,8 +3096,10 @@ main(int argc, char *argv[])
|
||||
added_text = (png_textp)
|
||||
png_malloc(write_ptr, (png_uint_32)sizeof(png_text));
|
||||
added_text[0].key = &text_keyword[ntext*80];
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
added_text[0].lang = &text_lang[ntext*80];
|
||||
added_text[0].lang_key = &text_lang_key[ntext*80];
|
||||
#endif
|
||||
added_text[0].text = &text_text[ntext*2048];
|
||||
added_text[0].compression = text_compression[ntext];
|
||||
png_set_text(write_ptr, write_end_info_ptr, added_text, 1);
|
||||
@@ -2912,10 +3107,12 @@ main(int argc, char *argv[])
|
||||
printf(" Added a tEXt chunk.\n");
|
||||
else if(added_text[0].compression == 0)
|
||||
printf(" Added a zTXt chunk.\n");
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
else if(added_text[0].compression == 1)
|
||||
printf(" Added an uncompressed iTXt chunk.\n");
|
||||
else
|
||||
printf(" Added a compressed iTXt chunk.\n");
|
||||
#endif
|
||||
png_free(write_ptr,added_text);
|
||||
}
|
||||
}
|
||||
@@ -3053,6 +3250,14 @@ main(int argc, char *argv[])
|
||||
if(verbose > 0) show_result();
|
||||
return 0;
|
||||
}
|
||||
#ifdef USE_CEXCEPT
|
||||
}
|
||||
Catch (msg)
|
||||
{
|
||||
fprintf(stderr, "Caught libpng error:\n %s\n\n",msg);
|
||||
PNG_CRUSH_CLEANUP
|
||||
}
|
||||
#endif
|
||||
} /* end of loop on input files */
|
||||
}
|
||||
|
||||
@@ -3063,9 +3268,10 @@ measure_idats(FILE *fpin)
|
||||
P2("measure_idats:\n");
|
||||
png_debug(0, "Allocating read structure\n");
|
||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
|
||||
#ifdef USE_CEXCEPT
|
||||
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
|
||||
#else
|
||||
(png_error_ptr)NULL, (png_error_ptr)NULL);
|
||||
#if defined(PNG_NO_STDIO)
|
||||
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error, png_default_warning);
|
||||
#endif
|
||||
png_debug(0, "Allocating read_info, end_info structures\n");
|
||||
read_info_ptr = png_create_info_struct(read_ptr);
|
||||
@@ -3076,13 +3282,7 @@ measure_idats(FILE *fpin)
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
# else
|
||||
# ifdef PNG_JMPBUF_SUPPORTED
|
||||
/* New setjmp interface */
|
||||
if (setjmp(png_jmpbuf(read_ptr)))
|
||||
# else
|
||||
/* old interface */
|
||||
if (setjmp(read_ptr->jmpbuf))
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
PNG_CRUSH_CLEANUP
|
||||
@@ -3176,4 +3376,9 @@ png_measure_idat(png_structp png_ptr, png_infop info_ptr)
|
||||
return sum_idat_length;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* PNG_LIBPNG_VER < 96 */
|
||||
main()
|
||||
{
|
||||
printf("Sorry, but pngcrush needs libpng version 0.96 or later\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
26
pngcrush.h
26
pngcrush.h
@@ -6,6 +6,13 @@
|
||||
#ifndef PNGCRUSH_H
|
||||
#define PNGCRUSH_H
|
||||
|
||||
#define PNG_SETJMP_NOT_SUPPORTED
|
||||
|
||||
#if PNG_LIBPNG_VER > 10006
|
||||
#define PNG_NO_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#endif
|
||||
|
||||
#define PNG_NO_READ_cHRM
|
||||
#define PNG_NO_WRITE_cHRM
|
||||
#define PNG_NO_READ_hIST
|
||||
@@ -33,7 +40,11 @@
|
||||
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_FILLER_SUPPORTED
|
||||
#define PNG_READ_RGB_TO_GRAY_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
|
||||
@@ -41,7 +52,18 @@
|
||||
#else
|
||||
# define PNG_NO_READ_RGB_TO_GRAY
|
||||
#endif
|
||||
#ifndef PNG_ZBUF_SIZE
|
||||
#if !defined(PNG_ZBUF_SIZE) && (PNG_LIBPNG_VER > 97)
|
||||
# define PNG_ZBUF_SIZE 524288 /* increases the IDAT size */
|
||||
#endif
|
||||
|
||||
/* Changed in version 0.99 */
|
||||
#if PNG_LIBPNG_VER < 99
|
||||
#undef PNG_CONST
|
||||
#ifndef PNG_NO_CONST
|
||||
# define PNG_CONST const
|
||||
#else
|
||||
# define PNG_CONST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef struct png_jmpbuf_struct
|
||||
typedef png_jmpbuf FAR * png_jmpbufp;
|
||||
typedef png_jmpbuf FAR * FAR * png_jmpbufpp;
|
||||
|
||||
#define png_jmp_env(png_ptr) png_get_jmpbuf(png_ptr)->env
|
||||
#define png_jmpbuf(png_ptr) png_get_jmpbuf(png_ptr)->env
|
||||
|
||||
extern PNG_EXPORT(png_jmpbufp,png_get_jmpbuf)
|
||||
PNGARG((png_structp));
|
||||
@@ -60,6 +60,9 @@ extern PNG_EXPORT(png_jmpbufp,png_get_jmpbuf)
|
||||
#define png_setjmp(png_ptr) setjmp(png_get_jmpbuf(png_ptr)->env)
|
||||
#define png_longjmp(png_ptr,val) longjmp(png_get_jmpbuf(png_ptr)->env,val)
|
||||
|
||||
#else
|
||||
# define png_jmpbuf(png_ptr) \
|
||||
(LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
|
||||
#endif /* PNG_SETJMP_SUPPORTED */
|
||||
|
||||
#endif /* _PNGERROR_H */
|
||||
|
||||
@@ -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.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
pngget.c
2
pngget.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
|
||||
2
pngmem.c
2
pngmem.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
@@ -641,7 +641,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.6a.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6e.
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -690,7 +690,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.6a.
|
||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6e.
|
||||
*/
|
||||
void
|
||||
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
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
@@ -622,7 +622,7 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
||||
#endif
|
||||
{
|
||||
png_uint_16 red_int, green_int;
|
||||
if(red > 0 && green > 0)
|
||||
if(red < 0 || green < 0)
|
||||
{
|
||||
red_int = 6968; /* .212671 * 32768 + .5 */
|
||||
green_int = 23434; /* .715160 * 32768 + .5 */
|
||||
|
||||
33
pngrutil.c
33
pngrutil.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* libpng 1.0.6a - March 25, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
@@ -392,8 +392,9 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
num = (int)length / 3;
|
||||
|
||||
palette = (png_colorp)png_zalloc(png_ptr, (uInt)num, sizeof (png_color));
|
||||
png_ptr->free_me |= PNG_FREE_PLTE;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_byte buf[3];
|
||||
@@ -431,7 +432,6 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
else
|
||||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
png_zfree(png_ptr, palette);
|
||||
return;
|
||||
}
|
||||
@@ -445,6 +445,9 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->num_palette = (png_uint_16)num;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||
png_ptr->free_me |= PNG_FREE_PLTE;
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||
|
||||
#if defined (PNG_READ_tRNS_SUPPORTED)
|
||||
@@ -452,10 +455,15 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
{
|
||||
if (png_ptr->num_trans > png_ptr->num_palette)
|
||||
if (png_ptr->num_trans > (png_uint_16)num)
|
||||
{
|
||||
png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
|
||||
png_ptr->num_trans = png_ptr->num_palette;
|
||||
png_ptr->num_trans = (png_uint_16)num;
|
||||
}
|
||||
if (info_ptr->num_trans > (png_uint_16)num)
|
||||
{
|
||||
png_warning(png_ptr, "Truncating incorrect info tRNS chunk length");
|
||||
info_ptr->num_trans = (png_uint_16)num;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +551,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
#ifndef PNG_NO_STDIO
|
||||
fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma);
|
||||
#endif
|
||||
return;
|
||||
@@ -753,7 +761,7 @@ png_handle_cHRM(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");
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
#ifndef PNG_NO_STDIO
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
|
||||
white_x, white_y, red_x, red_y);
|
||||
@@ -765,7 +773,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
|
||||
int_x_green, int_y_green, int_x_blue, int_y_blue);
|
||||
#endif
|
||||
#endif /* PNG_NO_CONSOLE_IO */
|
||||
#endif /* PNG_NO_STDIO */
|
||||
}
|
||||
png_crc_finish(png_ptr, 0);
|
||||
return;
|
||||
@@ -848,7 +856,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring incorrect gAMA value when sRGB is also present");
|
||||
#ifndef PNG_NO_CONSOLE_IO
|
||||
#ifndef PNG_NO_STDIO
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma);
|
||||
# else
|
||||
@@ -923,7 +931,6 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
#endif
|
||||
|
||||
chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
|
||||
png_ptr->free_me |= PNG_FREE_ICCP;
|
||||
slength = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
|
||||
|
||||
@@ -1103,7 +1110,6 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
}
|
||||
|
||||
png_ptr->trans = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_ptr->free_me |= PNG_FREE_TRNS;
|
||||
png_crc_read(png_ptr, png_ptr->trans, (png_size_t)length);
|
||||
png_ptr->num_trans = (png_uint_16)length;
|
||||
}
|
||||
@@ -1149,6 +1155,8 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
png_ptr->free_me |= PNG_FREE_TRNS;
|
||||
png_set_tRNS(png_ptr, info_ptr, png_ptr->trans, png_ptr->num_trans,
|
||||
&(png_ptr->trans_values));
|
||||
}
|
||||
@@ -1283,7 +1291,6 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
num = (int)length / 2 ;
|
||||
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(num * sizeof (png_uint_16)));
|
||||
png_ptr->free_me |= PNG_FREE_HIST;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_byte buf[2];
|
||||
@@ -1295,6 +1302,8 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
||||
if (png_crc_finish(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
|
||||
png_ptr->free_me |= PNG_FREE_HIST;
|
||||
png_set_hIST(png_ptr, info_ptr, png_ptr->hist);
|
||||
}
|
||||
#endif
|
||||
|
||||
5
pngset.c
5
pngset.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
@@ -425,6 +425,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
||||
return;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
|
||||
info_ptr->iccp_name = png_malloc(png_ptr, png_strlen(name)+1);
|
||||
strcpy(info_ptr->iccp_name, name);
|
||||
info_ptr->iccp_profile = png_malloc(png_ptr, proflen);
|
||||
@@ -754,8 +755,8 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* For Intel x86 CPU and Microsoft Visual C++ compiler
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.6a - March 23, 2000
|
||||
* libpng 1.0.6e - April 9, 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
|
||||
|
||||
Reference in New Issue
Block a user