mirror of https://github.com/stella-emu/stella.git
Updated PNG library to latest version.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2918 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
6cb3b5c58a
commit
a0aa1c8e0a
|
@ -14,7 +14,7 @@
|
||||||
#include "pngpriv.h"
|
#include "pngpriv.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 png_libpng_version_1_6_9 Your_png_h_is_not_version_1_6_9;
|
typedef png_libpng_version_1_6_10 Your_png_h_is_not_version_1_6_10;
|
||||||
|
|
||||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||||
* of the PNG file signature. If the PNG data is embedded into another
|
* of the PNG file signature. If the PNG data is embedded into another
|
||||||
|
@ -773,13 +773,13 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.6.9 - February 6, 2014" PNG_STRING_NEWLINE \
|
"libpng version 1.6.10 - March 6, 2014" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.6.9 - February 6, 2014\
|
return "libpng version 1.6.10 - March 6, 2014\
|
||||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\
|
Copyright (c) 1996-1997 Andreas Dilger\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||||
|
@ -1742,7 +1742,8 @@ is_ICC_signature_char(png_alloc_size_t it)
|
||||||
(it >= 97 && it <= 122);
|
(it >= 97 && it <= 122);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_ICC_signature(png_alloc_size_t it)
|
static int
|
||||||
|
is_ICC_signature(png_alloc_size_t it)
|
||||||
{
|
{
|
||||||
return is_ICC_signature_char(it >> 24) /* checks all the top bits */ &&
|
return is_ICC_signature_char(it >> 24) /* checks all the top bits */ &&
|
||||||
is_ICC_signature_char((it >> 16) & 0xff) &&
|
is_ICC_signature_char((it >> 16) & 0xff) &&
|
||||||
|
@ -2295,15 +2296,16 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if PNG_sRGB_PROFILE_CHECKS > 0
|
# if PNG_sRGB_PROFILE_CHECKS > 0
|
||||||
/* The signature matched, but the profile had been changed in some
|
/* The signature matched, but the profile had been changed in some
|
||||||
* way. This is an apparent violation of the ICC terms of use and,
|
* way. This probably indicates a data error or uninformed hacking.
|
||||||
* anyway, probably indicates a data error or uninformed hacking.
|
* Fall through to "no match".
|
||||||
*/
|
*/
|
||||||
if (png_sRGB_checks[i].have_md5)
|
png_chunk_report(png_ptr,
|
||||||
png_benign_error(png_ptr,
|
"Not recognizing known sRGB profile that has been edited",
|
||||||
"copyright violation: edited ICC profile ignored");
|
PNG_CHUNK_WARNING);
|
||||||
# endif
|
break;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
137
src/libpng/png.h
137
src/libpng/png.h
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.6.9 - February 6, 2014
|
* libpng version 1.6.10 - March 6, 2014
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,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.6.9 - February 6, 2014: Glenn
|
* libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
|
@ -192,6 +192,9 @@
|
||||||
* 1.6.9beta01-04 16 10609 16.so.16.9[.0]
|
* 1.6.9beta01-04 16 10609 16.so.16.9[.0]
|
||||||
* 1.6.9rc01-02 16 10609 16.so.16.9[.0]
|
* 1.6.9rc01-02 16 10609 16.so.16.9[.0]
|
||||||
* 1.6.9 16 10609 16.so.16.9[.0]
|
* 1.6.9 16 10609 16.so.16.9[.0]
|
||||||
|
* 1.6.10beta01-03 16 10610 16.so.16.10[.0]
|
||||||
|
* 1.6.10betarc01-04 16 10610 16.so.16.10[.0]
|
||||||
|
* 1.6.10beta 16 10610 16.so.16.10[.0]
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -223,7 +226,7 @@
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.9, February 6, 2014, are
|
* libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are
|
||||||
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||||
* with the following individual added to the list of Contributing Authors:
|
* with the following individual added to the list of Contributing Authors:
|
||||||
|
@ -335,13 +338,13 @@
|
||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* February 6, 2014
|
* March 6, 2014
|
||||||
*
|
*
|
||||||
* 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.6.9 are Y2K compliant. It is my belief that
|
* upward through 1.6.10 are Y2K compliant. It is my belief that
|
||||||
* earlier versions were also Y2K compliant.
|
* earlier versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||||
|
@ -401,9 +404,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* 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.6.9"
|
#define PNG_LIBPNG_VER_STRING "1.6.10"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.6.9 - February 6, 2014\n"
|
" libpng version 1.6.10 - March 6, 2014\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 16
|
#define PNG_LIBPNG_VER_SONUM 16
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||||
|
@ -411,7 +414,7 @@
|
||||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||||
#define PNG_LIBPNG_VER_MAJOR 1
|
#define PNG_LIBPNG_VER_MAJOR 1
|
||||||
#define PNG_LIBPNG_VER_MINOR 6
|
#define PNG_LIBPNG_VER_MINOR 6
|
||||||
#define PNG_LIBPNG_VER_RELEASE 9
|
#define PNG_LIBPNG_VER_RELEASE 10
|
||||||
|
|
||||||
/* 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:
|
||||||
|
@ -442,7 +445,7 @@
|
||||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||||
*/
|
*/
|
||||||
#define PNG_LIBPNG_VER 10609 /* 1.6.9 */
|
#define PNG_LIBPNG_VER 10610 /* 1.6.10 */
|
||||||
|
|
||||||
/* Library configuration: these options cannot be changed after
|
/* Library configuration: these options cannot be changed after
|
||||||
* the library has been built.
|
* the library has been built.
|
||||||
|
@ -547,7 +550,7 @@ extern "C" {
|
||||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||||
* do not agree upon the version number.
|
* do not agree upon the version number.
|
||||||
*/
|
*/
|
||||||
typedef char* png_libpng_version_1_6_9;
|
typedef char* png_libpng_version_1_6_10;
|
||||||
|
|
||||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||||
*
|
*
|
||||||
|
@ -1209,9 +1212,9 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||||
/* How the alpha channel is interpreted - this affects how the color channels of
|
/* How the alpha channel is interpreted - this affects how the color channels
|
||||||
* a PNG file are returned when an alpha channel, or tRNS chunk in a palette
|
* of a PNG file are returned to the calling application when an alpha channel,
|
||||||
* file, is present.
|
* or a tRNS chunk in a palette file, is present.
|
||||||
*
|
*
|
||||||
* This has no effect on the way pixels are written into a PNG output
|
* This has no effect on the way pixels are written into a PNG output
|
||||||
* datastream. The color samples in a PNG datastream are never premultiplied
|
* datastream. The color samples in a PNG datastream are never premultiplied
|
||||||
|
@ -1219,33 +1222,19 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
|
||||||
*
|
*
|
||||||
* The default is to return data according to the PNG specification: the alpha
|
* The default is to return data according to the PNG specification: the alpha
|
||||||
* channel is a linear measure of the contribution of the pixel to the
|
* channel is a linear measure of the contribution of the pixel to the
|
||||||
* corresponding composited pixel. The gamma encoded color channels must be
|
* corresponding composited pixel, and the color channels are unassociated
|
||||||
* scaled according to the contribution and to do this it is necessary to undo
|
* (not premultiplied). The gamma encoded color channels must be scaled
|
||||||
|
* according to the contribution and to do this it is necessary to undo
|
||||||
* the encoding, scale the color values, perform the composition and reencode
|
* the encoding, scale the color values, perform the composition and reencode
|
||||||
* the values. This is the 'PNG' mode.
|
* the values. This is the 'PNG' mode.
|
||||||
*
|
*
|
||||||
* The alternative is to 'associate' the alpha with the color information by
|
* The alternative is to 'associate' the alpha with the color information by
|
||||||
* storing color channel values that have been scaled by the alpha. The
|
* storing color channel values that have been scaled by the alpha.
|
||||||
* advantage is that the color channels can be resampled (the image can be
|
* image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes
|
||||||
* scaled) in this form. The disadvantage is that normal practice is to store
|
* (the latter being the two common names for associated alpha color channels).
|
||||||
* linear, not (gamma) encoded, values and this requires 16-bit channels for
|
|
||||||
* still images rather than the 8-bit channels that are just about sufficient if
|
|
||||||
* gamma encoding is used. In addition all non-transparent pixel values,
|
|
||||||
* including completely opaque ones, must be gamma encoded to produce the final
|
|
||||||
* image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the
|
|
||||||
* latter being the two common names for associated alpha color channels.)
|
|
||||||
*
|
*
|
||||||
* Since it is not necessary to perform arithmetic on opaque color values so
|
* For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha
|
||||||
* long as they are not to be resampled and are in the final color space it is
|
* value is equal to the maximum value.
|
||||||
* possible to optimize the handling of alpha by storing the opaque pixels in
|
|
||||||
* the PNG format (adjusted for the output color space) while storing partially
|
|
||||||
* opaque pixels in the standard, linear, format. The accuracy required for
|
|
||||||
* standard alpha composition is relatively low, because the pixels are
|
|
||||||
* isolated, therefore typically the accuracy loss in storing 8-bit linear
|
|
||||||
* values is acceptable. (This is not true if the alpha channel is used to
|
|
||||||
* simulate transparency over large areas - use 16 bits or the PNG mode in
|
|
||||||
* this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is
|
|
||||||
* treated as opaque only if the alpha value is equal to the maximum value.
|
|
||||||
*
|
*
|
||||||
* The final choice is to gamma encode the alpha channel as well. This is
|
* The final choice is to gamma encode the alpha channel as well. This is
|
||||||
* broken because, in practice, no implementation that uses this choice
|
* broken because, in practice, no implementation that uses this choice
|
||||||
|
@ -1272,68 +1261,7 @@ PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
|
||||||
|
|
||||||
#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||||
/* The output_gamma value is a screen gamma in libpng terminology: it expresses
|
/* The output_gamma value is a screen gamma in libpng terminology: it expresses
|
||||||
* how to decode the output values, not how they are encoded. The values used
|
* how to decode the output values, not how they are encoded.
|
||||||
* correspond to the normal numbers used to describe the overall gamma of a
|
|
||||||
* computer display system; for example 2.2 for an sRGB conformant system. The
|
|
||||||
* values are scaled by 100000 in the _fixed version of the API (so 220000 for
|
|
||||||
* sRGB.)
|
|
||||||
*
|
|
||||||
* The inverse of the value is always used to provide a default for the PNG file
|
|
||||||
* encoding if it has no gAMA chunk and if png_set_gamma() has not been called
|
|
||||||
* to override the PNG gamma information.
|
|
||||||
*
|
|
||||||
* When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
|
|
||||||
* opaque pixels however pixels with lower alpha values are not encoded,
|
|
||||||
* regardless of the output gamma setting.
|
|
||||||
*
|
|
||||||
* When the standard Porter Duff handling is requested with mode 1 the output
|
|
||||||
* encoding is set to be linear and the output_gamma value is only relevant
|
|
||||||
* as a default for input data that has no gamma information. The linear output
|
|
||||||
* encoding will be overridden if png_set_gamma() is called - the results may be
|
|
||||||
* highly unexpected!
|
|
||||||
*
|
|
||||||
* The following numbers are derived from the sRGB standard and the research
|
|
||||||
* behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of
|
|
||||||
* 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing
|
|
||||||
* correction required to take account of any differences in the color
|
|
||||||
* environment of the original scene and the intended display environment; the
|
|
||||||
* value expresses how to *decode* the image for display, not how the original
|
|
||||||
* data was *encoded*.
|
|
||||||
*
|
|
||||||
* sRGB provides a peg for the PNG standard by defining a viewing environment.
|
|
||||||
* sRGB itself, and earlier TV standards, actually use a more complex transform
|
|
||||||
* (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is
|
|
||||||
* limited to simple power laws.) By saying that an image for direct display on
|
|
||||||
* an sRGB conformant system should be stored with a gAMA chunk value of 45455
|
|
||||||
* (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
|
|
||||||
* makes it possible to derive values for other display systems and
|
|
||||||
* environments.
|
|
||||||
*
|
|
||||||
* The Mac value is deduced from the sRGB based on an assumption that the actual
|
|
||||||
* extra viewing correction used in early Mac display systems was implemented as
|
|
||||||
* a power 1.45 lookup table.
|
|
||||||
*
|
|
||||||
* Any system where a programmable lookup table is used or where the behavior of
|
|
||||||
* the final display device characteristics can be changed requires system
|
|
||||||
* specific code to obtain the current characteristic. However this can be
|
|
||||||
* difficult and most PNG gamma correction only requires an approximate value.
|
|
||||||
*
|
|
||||||
* By default, if png_set_alpha_mode() is not called, libpng assumes that all
|
|
||||||
* values are unencoded, linear, values and that the output device also has a
|
|
||||||
* linear characteristic. This is only very rarely correct - it is invariably
|
|
||||||
* better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
|
|
||||||
* default if you don't know what the right answer is!
|
|
||||||
*
|
|
||||||
* The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
|
|
||||||
* 10.6) which used a correction table to implement a somewhat lower gamma on an
|
|
||||||
* otherwise sRGB system.
|
|
||||||
*
|
|
||||||
* Both these values are reserved (not simple gamma values) in order to allow
|
|
||||||
* more precise correction internally in the future.
|
|
||||||
*
|
|
||||||
* NOTE: the following values can be passed to either the fixed or floating
|
|
||||||
* point APIs, but the floating point API will also accept floating point
|
|
||||||
* values.
|
|
||||||
*/
|
*/
|
||||||
#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
|
#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */
|
||||||
#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
|
#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */
|
||||||
|
@ -1956,8 +1884,8 @@ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
|
||||||
* It is unlikely that this function works correctly as of 1.6.0 and using it
|
* It is unlikely that this function works correctly as of 1.6.0 and using it
|
||||||
* may result either in memory leaks or double free of allocated data.
|
* may result either in memory leaks or double free of allocated data.
|
||||||
*/
|
*/
|
||||||
PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr,
|
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||||
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED);
|
png_inforp info_ptr, int freer, png_uint_32 mask));
|
||||||
|
|
||||||
/* Assignments for png_data_freer */
|
/* Assignments for png_data_freer */
|
||||||
#define PNG_DESTROY_WILL_FREE_DATA 1
|
#define PNG_DESTROY_WILL_FREE_DATA 1
|
||||||
|
@ -1999,6 +1927,8 @@ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
|
||||||
#else
|
#else
|
||||||
/* Fatal error in PNG image of libpng - can't continue */
|
/* Fatal error in PNG image of libpng - can't continue */
|
||||||
PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
|
PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
|
||||||
|
# define png_error(s1,s2) png_err(s1)
|
||||||
|
# define png_chunk_error(s1,s2) png_err(s1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
@ -2009,6 +1939,9 @@ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,
|
||||||
/* Non-fatal error in libpng, chunk name is prepended to message. */
|
/* Non-fatal error in libpng, chunk name is prepended to message. */
|
||||||
PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
|
PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
|
#else
|
||||||
|
# define png_warning(s1,s2) ((void)(s1))
|
||||||
|
# define png_chunk_warning(s1,s2) ((void)(s1))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
@ -2519,11 +2452,15 @@ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
|
||||||
|
|
||||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||||
/* The "params" pointer is currently not used and is for future expansion. */
|
/* The "params" pointer is currently not used and is for future expansion. */
|
||||||
|
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
|
PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
|
||||||
int transforms, png_voidp params));
|
int transforms, png_voidp params));
|
||||||
|
#endif
|
||||||
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
|
PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
|
||||||
int transforms, png_voidp params));
|
int transforms, png_voidp params));
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
PNG_EXPORT(180, png_const_charp, png_get_copyright,
|
PNG_EXPORT(180, png_const_charp, png_get_copyright,
|
||||||
(png_const_structrp png_ptr));
|
(png_const_structrp png_ptr));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.6.9 - February 6, 2014
|
* libpng version 1.6.10 - March 6, 2014
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
@ -376,9 +376,11 @@
|
||||||
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||||
# endif
|
# endif
|
||||||
# if !defined(PNG_PRIVATE)
|
# if !defined(PNG_PRIVATE)
|
||||||
# if __has_extension(attribute_unavailable_with_message)
|
# ifdef __has_extension
|
||||||
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
# if __has_extension(attribute_unavailable_with_message)
|
||||||
"This function is not exported by libpng.")))
|
# define PNG_PRIVATE __attribute__((__unavailable__(\
|
||||||
|
"This function is not exported by libpng.")))
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_RESTRICT
|
# ifndef PNG_RESTRICT
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
*
|
*
|
||||||
|
@ -876,8 +876,8 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||||
* possible to implement without setjmp support just so long as there is some
|
* possible to implement without setjmp support just so long as there is some
|
||||||
* way to handle the error return here:
|
* way to handle the error return here:
|
||||||
*/
|
*/
|
||||||
PNG_FUNCTION(void /* PRIVATE */,
|
PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||||
png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||||
PNG_NORETURN)
|
PNG_NORETURN)
|
||||||
{
|
{
|
||||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
@ -912,7 +912,7 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */ PNGCBAPI
|
||||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
*
|
*
|
||||||
|
@ -234,6 +234,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||||
|
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
|
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||||
|
|
||||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||||
if (png_ptr->push_length == 0)
|
if (png_ptr->push_length == 0)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* (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.)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -254,6 +254,11 @@
|
||||||
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_INTERNAL_CALLBACK
|
||||||
|
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||||
|
extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If floating or fixed point APIs are disabled they may still be compiled
|
/* If floating or fixed point APIs are disabled they may still be compiled
|
||||||
* internally. To handle this make sure they are declared as the appropriate
|
* internally. To handle this make sure they are declared as the appropriate
|
||||||
* internal extern function (otherwise the symbol prefixing stuff won't work and
|
* internal extern function (otherwise the symbol prefixing stuff won't work and
|
||||||
|
@ -373,8 +378,6 @@
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
|
# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
|
||||||
#else
|
#else
|
||||||
# define png_warning(s1,s2) ((void)(s1))
|
|
||||||
# define png_chunk_warning(s1,s2) ((void)(s1))
|
|
||||||
# define png_warning_parameter(p,number,string) ((void)0)
|
# define png_warning_parameter(p,number,string) ((void)0)
|
||||||
# define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
|
# define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
|
||||||
# define png_warning_parameter_signed(p,number,format,value) ((void)0)
|
# define png_warning_parameter_signed(p,number,format,value) ((void)0)
|
||||||
|
@ -382,8 +385,6 @@
|
||||||
# define PNG_WARNING_PARAMETERS(p)
|
# define PNG_WARNING_PARAMETERS(p)
|
||||||
#endif
|
#endif
|
||||||
#ifndef PNG_ERROR_TEXT_SUPPORTED
|
#ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||||
# define png_error(s1,s2) png_err(s1)
|
|
||||||
# define png_chunk_error(s1,s2) png_err(s1)
|
|
||||||
# define png_fixed_error(s1,s2) png_err(s1)
|
# define png_fixed_error(s1,s2) png_err(s1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1883,11 +1884,11 @@ typedef struct png_control
|
||||||
* errors that might occur. Returns true on success, false on failure (either
|
* errors that might occur. Returns true on success, false on failure (either
|
||||||
* of the function or as a result of a png_error.)
|
* of the function or as a result of a png_error.)
|
||||||
*/
|
*/
|
||||||
PNG_INTERNAL_FUNCTION(void,png_safe_error,(png_structp png_ptr,
|
PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,
|
||||||
png_const_charp error_message),PNG_NORETURN);
|
png_const_charp error_message),PNG_NORETURN);
|
||||||
|
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
PNG_INTERNAL_FUNCTION(void,png_safe_warning,(png_structp png_ptr,
|
PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,
|
||||||
png_const_charp warning_message),PNG_EMPTY);
|
png_const_charp warning_message),PNG_EMPTY);
|
||||||
#else
|
#else
|
||||||
# define png_safe_warning 0/*dummy argument*/
|
# define png_safe_warning 0/*dummy argument*/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
|
@ -781,11 +781,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
png_uint_32 length = png_read_chunk_header(png_ptr);
|
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||||
|
|
||||||
if (chunk_name == png_IHDR)
|
if (chunk_name == png_IEND)
|
||||||
|
png_handle_IEND(png_ptr, info_ptr, length);
|
||||||
|
|
||||||
|
else if (chunk_name == png_IHDR)
|
||||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||||
|
|
||||||
else if (chunk_name == png_IEND)
|
else if (info_ptr == NULL)
|
||||||
png_handle_IEND(png_ptr, info_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
|
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||||
|
@ -1001,8 +1004,6 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
int transforms,
|
int transforms,
|
||||||
voidp params)
|
voidp params)
|
||||||
{
|
{
|
||||||
int row;
|
|
||||||
|
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1014,120 +1015,149 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
png_error(png_ptr, "Image is too high to process with png_read_png()");
|
png_error(png_ptr, "Image is too high to process with png_read_png()");
|
||||||
|
|
||||||
/* -------------- image transformations start here ------------------- */
|
/* -------------- image transformations start here ------------------- */
|
||||||
|
/* libpng 1.6.10: add code to cause a png_app_error if a selected TRANSFORM
|
||||||
|
* is not implemented. This will only happen in de-configured (non-default)
|
||||||
|
* libpng builds. The results can be unexpected - png_read_png may return
|
||||||
|
* short or mal-formed rows because the transform is skipped.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
|
||||||
/* Tell libpng to strip 16-bit/color files down to 8 bits per color.
|
/* Tell libpng to strip 16-bit/color files down to 8 bits per color.
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_SCALE_16)
|
if (transforms & PNG_TRANSFORM_SCALE_16)
|
||||||
{
|
|
||||||
/* Added at libpng-1.5.4. "strip_16" produces the same result that it
|
/* Added at libpng-1.5.4. "strip_16" produces the same result that it
|
||||||
* did in earlier versions, while "scale_16" is now more accurate.
|
* did in earlier versions, while "scale_16" is now more accurate.
|
||||||
*/
|
*/
|
||||||
|
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
png_set_scale_16(png_ptr);
|
png_set_scale_16(png_ptr);
|
||||||
}
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SCALE_16 not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
|
||||||
/* If both SCALE and STRIP are required pngrtran will effectively cancel the
|
/* If both SCALE and STRIP are required pngrtran will effectively cancel the
|
||||||
* latter by doing SCALE first. This is ok and allows apps not to check for
|
* latter by doing SCALE first. This is ok and allows apps not to check for
|
||||||
* which is supported to get the right answer.
|
* which is supported to get the right answer.
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||||
|
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_16 not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
|
||||||
/* Strip alpha bytes from the input data without combining with
|
/* Strip alpha bytes from the input data without combining with
|
||||||
* the background (not recommended).
|
* the background (not recommended).
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
||||||
|
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
png_set_strip_alpha(png_ptr);
|
png_set_strip_alpha(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_ALPHA not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)
|
|
||||||
/* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
|
/* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
|
||||||
* byte into separate bytes (useful for paletted and grayscale images).
|
* byte into separate bytes (useful for paletted and grayscale images).
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_PACKING)
|
if (transforms & PNG_TRANSFORM_PACKING)
|
||||||
|
#ifdef PNG_READ_PACK_SUPPORTED
|
||||||
png_set_packing(png_ptr);
|
png_set_packing(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
|
||||||
/* Change the order of packed pixels to least significant bit first
|
/* Change the order of packed pixels to least significant bit first
|
||||||
* (not useful if you are using png_set_packing).
|
* (not useful if you are using png_set_packing).
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||||
|
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||||
png_set_packswap(png_ptr);
|
png_set_packswap(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
|
||||||
/* Expand paletted colors into true RGB triplets
|
/* Expand paletted colors into true RGB triplets
|
||||||
* Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
|
* Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
|
||||||
* Expand paletted or RGB images with transparency to full alpha
|
* Expand paletted or RGB images with transparency to full alpha
|
||||||
* channels so the data will be available as RGBA quartets.
|
* channels so the data will be available as RGBA quartets.
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_EXPAND)
|
if (transforms & PNG_TRANSFORM_EXPAND)
|
||||||
if ((png_ptr->bit_depth < 8) ||
|
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
|
png_set_expand(png_ptr);
|
||||||
(info_ptr->valid & PNG_INFO_tRNS))
|
#else
|
||||||
png_set_expand(png_ptr);
|
png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We don't handle background color or gamma transformation or quantizing.
|
/* We don't handle background color or gamma transformation or quantizing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
|
||||||
/* Invert monochrome files to have 0 as white and 1 as black
|
/* Invert monochrome files to have 0 as white and 1 as black
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||||
|
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||||
png_set_invert_mono(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
|
||||||
/* If you want to shift the pixel values from the range [0,255] or
|
/* If you want to shift the pixel values from the range [0,255] or
|
||||||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||||
* colors were originally in:
|
* colors were originally in:
|
||||||
*/
|
*/
|
||||||
if ((transforms & PNG_TRANSFORM_SHIFT) && (info_ptr->valid & PNG_INFO_sBIT))
|
if (transforms & PNG_TRANSFORM_SHIFT)
|
||||||
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||||
|
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||||
|
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_BGR_SUPPORTED
|
|
||||||
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
|
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||||
if (transforms & PNG_TRANSFORM_BGR)
|
if (transforms & PNG_TRANSFORM_BGR)
|
||||||
|
#ifdef PNG_READ_BGR_SUPPORTED
|
||||||
png_set_bgr(png_ptr);
|
png_set_bgr(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
|
||||||
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||||
|
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
png_set_swap_alpha(png_ptr);
|
png_set_swap_alpha(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SWAP_SUPPORTED
|
|
||||||
/* Swap bytes of 16-bit files to least significant byte first */
|
/* Swap bytes of 16-bit files to least significant byte first */
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||||
|
#ifdef PNG_READ_SWAP_SUPPORTED
|
||||||
png_set_swap(png_ptr);
|
png_set_swap(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Added at libpng-1.2.41 */
|
/* Added at libpng-1.2.41 */
|
||||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
|
||||||
/* Invert the alpha channel from opacity to transparency */
|
/* Invert the alpha channel from opacity to transparency */
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||||
|
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
png_set_invert_alpha(png_ptr);
|
png_set_invert_alpha(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Added at libpng-1.2.41 */
|
/* Added at libpng-1.2.41 */
|
||||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
|
||||||
/* Expand grayscale image to RGB */
|
/* Expand grayscale image to RGB */
|
||||||
if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)
|
if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)
|
||||||
|
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_GRAY_TO_RGB not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Added at libpng-1.5.4 */
|
/* Added at libpng-1.5.4 */
|
||||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
|
||||||
if (transforms & PNG_TRANSFORM_EXPAND_16)
|
if (transforms & PNG_TRANSFORM_EXPAND_16)
|
||||||
|
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||||
png_set_expand_16(png_ptr);
|
png_set_expand_16(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND_16 not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We don't handle adding filler bytes */
|
/* We don't handle adding filler bytes */
|
||||||
|
@ -1150,16 +1180,17 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
{
|
{
|
||||||
png_uint_32 iptr;
|
png_uint_32 iptr;
|
||||||
|
|
||||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr,
|
||||||
info_ptr->height * (sizeof (png_bytep)));
|
info_ptr->height * (sizeof (png_bytep))));
|
||||||
|
|
||||||
for (iptr=0; iptr<info_ptr->height; iptr++)
|
for (iptr=0; iptr<info_ptr->height; iptr++)
|
||||||
info_ptr->row_pointers[iptr] = NULL;
|
info_ptr->row_pointers[iptr] = NULL;
|
||||||
|
|
||||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||||
|
|
||||||
for (row = 0; row < (int)info_ptr->height; row++)
|
for (iptr = 0; iptr < info_ptr->height; iptr++)
|
||||||
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
|
info_ptr->row_pointers[iptr] = png_voidcast(png_bytep,
|
||||||
png_get_rowbytes(png_ptr, info_ptr));
|
png_malloc(png_ptr, info_ptr->rowbytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
png_read_image(png_ptr, info_ptr->row_pointers);
|
png_read_image(png_ptr, info_ptr->row_pointers);
|
||||||
|
@ -1168,9 +1199,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
PNG_UNUSED(transforms) /* Quiet compiler warnings */
|
|
||||||
PNG_UNUSED(params)
|
PNG_UNUSED(params)
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
||||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||||
|
|
|
@ -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
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
|
@ -1363,12 +1363,12 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||||
* 12) PNG_EXPAND_16
|
* 12) PNG_EXPAND_16
|
||||||
* 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
|
* 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
|
||||||
* 14) PNG_INVERT_MONO
|
* 14) PNG_INVERT_MONO
|
||||||
* 15) PNG_SHIFT
|
* 15) PNG_INVERT_ALPHA
|
||||||
* 16) PNG_PACK
|
* 16) PNG_SHIFT
|
||||||
* 17) PNG_BGR
|
* 17) PNG_PACK
|
||||||
* 18) PNG_PACKSWAP
|
* 18) PNG_BGR
|
||||||
* 19) PNG_FILLER (includes PNG_ADD_ALPHA)
|
* 19) PNG_PACKSWAP
|
||||||
* 20) PNG_INVERT_ALPHA
|
* 20) PNG_FILLER (includes PNG_ADD_ALPHA)
|
||||||
* 21) PNG_SWAP_ALPHA
|
* 21) PNG_SWAP_ALPHA
|
||||||
* 22) PNG_SWAP_BYTES
|
* 22) PNG_SWAP_BYTES
|
||||||
* 23) PNG_USER_TRANSFORM [must be last]
|
* 23) PNG_USER_TRANSFORM [must be last]
|
||||||
|
@ -4907,6 +4907,11 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
|
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||||
|
png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||||
if (png_ptr->transformations & PNG_SHIFT)
|
if (png_ptr->transformations & PNG_SHIFT)
|
||||||
png_do_unshift(row_info, png_ptr->row_buf + 1,
|
png_do_unshift(row_info, png_ptr->row_buf + 1,
|
||||||
|
@ -4941,11 +4946,6 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||||
(png_uint_32)png_ptr->filler, png_ptr->flags);
|
(png_uint_32)png_ptr->filler, png_ptr->flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
|
||||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
|
||||||
png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||||
png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
|
png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
*
|
*
|
||||||
|
@ -227,10 +227,7 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
png_chunk_error(png_ptr, "CRC error");
|
||||||
png_chunk_benign_error(png_ptr, "CRC error");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -314,16 +311,11 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||||
|
|
||||||
else if (warn < 2) /* else silent */
|
else if (warn < 2) /* else silent */
|
||||||
{
|
{
|
||||||
#ifdef PNG_WARNINGS_SUPPORTED
|
|
||||||
if (warn)
|
if (warn)
|
||||||
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
|
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
|
||||||
|
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
|
||||||
png_chunk_error(png_ptr, "insufficient memory to read chunk");
|
png_chunk_error(png_ptr, "insufficient memory to read chunk");
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,22 +978,15 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
|
if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||||
{
|
return;
|
||||||
png_chunk_benign_error(png_ptr, "CRC error");
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
png_chunk_error(png_ptr, "CRC error");
|
||||||
png_chunk_warning(png_ptr, "CRC error");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, we (optionally) emit a warning and use the chunk. */
|
/* Otherwise, we (optionally) emit a warning and use the chunk. */
|
||||||
else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||||
{
|
|
||||||
png_chunk_warning(png_ptr, "CRC error");
|
png_chunk_warning(png_ptr, "CRC error");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1112,13 +1097,12 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
{
|
{
|
||||||
unsigned int truelen;
|
unsigned int truelen, i;
|
||||||
|
png_byte sample_depth;
|
||||||
png_byte buf[4];
|
png_byte buf[4];
|
||||||
|
|
||||||
png_debug(1, "in png_handle_sBIT");
|
png_debug(1, "in png_handle_sBIT");
|
||||||
|
|
||||||
buf[0] = buf[1] = buf[2] = buf[3] = 0;
|
|
||||||
|
|
||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||||
png_chunk_error(png_ptr, "missing IHDR");
|
png_chunk_error(png_ptr, "missing IHDR");
|
||||||
|
|
||||||
|
@ -1137,10 +1121,16 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
truelen = 3;
|
truelen = 3;
|
||||||
|
sample_depth = 8;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
truelen = png_ptr->channels;
|
truelen = png_ptr->channels;
|
||||||
|
sample_depth = png_ptr->bit_depth;
|
||||||
|
}
|
||||||
|
|
||||||
if (length != truelen || length > 4)
|
if (length != truelen || length > 4)
|
||||||
{
|
{
|
||||||
|
@ -1149,11 +1139,19 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
|
||||||
png_crc_read(png_ptr, buf, truelen);
|
png_crc_read(png_ptr, buf, truelen);
|
||||||
|
|
||||||
if (png_crc_finish(png_ptr, 0))
|
if (png_crc_finish(png_ptr, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (i=0; i<truelen; ++i)
|
||||||
|
if (buf[i] == 0 || buf[i] > sample_depth)
|
||||||
|
{
|
||||||
|
png_chunk_benign_error(png_ptr, "invalid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||||
{
|
{
|
||||||
png_ptr->sig_bit.red = buf[0];
|
png_ptr->sig_bit.red = buf[0];
|
||||||
|
@ -1423,7 +1421,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
(sizeof local_buffer), &length,
|
(sizeof local_buffer), &length,
|
||||||
profile + (sizeof profile_header), &size, 0);
|
profile + (sizeof profile_header), &size, 0);
|
||||||
|
|
||||||
/* Still expect a a buffer error because we expect
|
/* Still expect a buffer error because we expect
|
||||||
* there to be some tag data!
|
* there to be some tag data!
|
||||||
*/
|
*/
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2014 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.)
|
||||||
|
@ -1546,81 +1546,117 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ((info_ptr->valid & PNG_INFO_IDAT) == 0)
|
||||||
|
{
|
||||||
|
png_app_error(png_ptr, "no rows for png_write_image to write");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Write the file header information. */
|
/* Write the file header information. */
|
||||||
png_write_info(png_ptr, info_ptr);
|
png_write_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
/* ------ these transformations don't touch the info structure ------- */
|
/* ------ these transformations don't touch the info structure ------- */
|
||||||
|
|
||||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
|
||||||
/* Invert monochrome pixels */
|
/* Invert monochrome pixels */
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||||
|
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||||
png_set_invert_mono(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
|
||||||
/* Shift the pixels up to a legal bit depth and fill in
|
/* Shift the pixels up to a legal bit depth and fill in
|
||||||
* as appropriate to correctly scale the image.
|
* as appropriate to correctly scale the image.
|
||||||
*/
|
*/
|
||||||
if ((transforms & PNG_TRANSFORM_SHIFT)
|
if (transforms & PNG_TRANSFORM_SHIFT)
|
||||||
&& (info_ptr->valid & PNG_INFO_sBIT))
|
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||||
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||||
|
png_set_shift(png_ptr, &info_ptr->sig_bit);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
|
||||||
/* Pack pixels into bytes */
|
/* Pack pixels into bytes */
|
||||||
if (transforms & PNG_TRANSFORM_PACKING)
|
if (transforms & PNG_TRANSFORM_PACKING)
|
||||||
png_set_packing(png_ptr);
|
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||||
|
png_set_packing(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
|
||||||
/* Swap location of alpha bytes from ARGB to RGBA */
|
/* Swap location of alpha bytes from ARGB to RGBA */
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||||
|
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
png_set_swap_alpha(png_ptr);
|
png_set_swap_alpha(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into
|
||||||
|
* RGB, note that the code expects the input color type to be G or RGB; no
|
||||||
|
* alpha channel.
|
||||||
|
*/
|
||||||
|
if (transforms &
|
||||||
|
(PNG_TRANSFORM_STRIP_FILLER_AFTER|PNG_TRANSFORM_STRIP_FILLER_BEFORE))
|
||||||
|
{
|
||||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||||
/* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */
|
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
|
||||||
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
|
{
|
||||||
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
|
||||||
|
|
||||||
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
|
/* Continue if ignored - this is the pre-1.6.10 behavior */
|
||||||
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
|
||||||
|
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
|
||||||
/* Flip BGR pixels to RGB */
|
/* Flip BGR pixels to RGB */
|
||||||
if (transforms & PNG_TRANSFORM_BGR)
|
if (transforms & PNG_TRANSFORM_BGR)
|
||||||
|
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||||
png_set_bgr(png_ptr);
|
png_set_bgr(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
|
||||||
/* Swap bytes of 16-bit files to most significant byte first */
|
/* Swap bytes of 16-bit files to most significant byte first */
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||||
|
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||||
png_set_swap(png_ptr);
|
png_set_swap(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
|
||||||
/* Swap bits of 1, 2, 4 bit packed pixel formats */
|
/* Swap bits of 1, 2, 4 bit packed pixel formats */
|
||||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||||
|
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
png_set_packswap(png_ptr);
|
png_set_packswap(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
|
||||||
/* Invert the alpha channel from opacity to transparency */
|
/* Invert the alpha channel from opacity to transparency */
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||||
|
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
png_set_invert_alpha(png_ptr);
|
png_set_invert_alpha(png_ptr);
|
||||||
|
#else
|
||||||
|
png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------- end of transformations ------------------- */
|
/* ----------------------- end of transformations ------------------- */
|
||||||
|
|
||||||
/* Write the bits */
|
/* Write the bits */
|
||||||
if (info_ptr->valid & PNG_INFO_IDAT)
|
png_write_image(png_ptr, info_ptr->row_pointers);
|
||||||
png_write_image(png_ptr, info_ptr->row_pointers);
|
|
||||||
|
|
||||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||||
png_write_end(png_ptr, info_ptr);
|
png_write_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
PNG_UNUSED(transforms) /* Quiet compiler warnings */
|
|
||||||
PNG_UNUSED(params)
|
PNG_UNUSED(params)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2309,7 +2309,8 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||||
* been specified by the application, and then writes the row out with the
|
* been specified by the application, and then writes the row out with the
|
||||||
* chosen filter.
|
* chosen filter.
|
||||||
*/
|
*/
|
||||||
static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
static void
|
||||||
|
png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||||
png_size_t row_bytes);
|
png_size_t row_bytes);
|
||||||
|
|
||||||
#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)
|
#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)
|
||||||
|
|
Loading…
Reference in New Issue