зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 3947f817fc0a (bug 1102523) for breaking device b2g builds
This commit is contained in:
Родитель
1ec93d3e5c
Коммит
1857927626
|
@ -5033,71 +5033,6 @@ Version 1.6.14rc02 [October 17, 2014]
|
|||
Version 1.6.14 [October 23, 2014]
|
||||
No changes.
|
||||
|
||||
Version 1.6.15beta01 [October 29, 2014]
|
||||
Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
|
||||
Simplified png_free_data().
|
||||
Added missing "ptr = NULL" after some instances of png_free().
|
||||
|
||||
Version 1.6.15beta02 [November 1, 2014]
|
||||
Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
|
||||
|
||||
Version 1.6.15beta03 [November 3, 2014]
|
||||
Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz).
|
||||
|
||||
Version 1.6.15beta04 [November 4, 2014]
|
||||
Removed new PNG_USE_ARM_NEON configuration flag and made a one-line
|
||||
revision to configure.ac to support ARM on aarch64 instead (John Bowler).
|
||||
|
||||
Version 1.6.15beta05 [November 5, 2014]
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
Fixed GCC unsigned int->float warnings. Various versions of GCC
|
||||
seem to generate warnings when an unsigned value is implicitly
|
||||
converted to double. This is probably a GCC bug but this change
|
||||
avoids the issue by explicitly converting to (int) where safe.
|
||||
Free all allocated memory in pngimage. The file buffer cache was left
|
||||
allocated at the end of the program, harmless but it causes memory
|
||||
leak reports from clang.
|
||||
Fixed array size calculations to avoid warnings. At various points
|
||||
in the code the number of elements in an array is calculated using
|
||||
sizeof. This generates a compile time constant of type (size_t) which
|
||||
is then typically assigned to an (unsigned int) or (int). Some versions
|
||||
of GCC on 64-bit systems warn about the apparent narrowing, even though
|
||||
the same compiler does apparently generate the correct, in-range,
|
||||
numeric constant. This adds appropriate, safe, casts to make the
|
||||
warnings go away.
|
||||
|
||||
Version 1.6.15beta06 [November 6, 2014]
|
||||
Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING
|
||||
in the manual, example.c, pngtest.c, and applications in the contrib
|
||||
directory. It was incorrect advice.
|
||||
|
||||
Version 1.6.15beta07 [November 7, 2014]
|
||||
Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
|
||||
needed by png_reciprocal2().
|
||||
Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
|
||||
png_do_swap().
|
||||
Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */"
|
||||
|
||||
Version 1.6.15beta08 [November 8, 2014]
|
||||
More housecleaning in *.h
|
||||
|
||||
Version 1.6.15rc01 [November 13, 2014]
|
||||
|
||||
Version 1.6.15rc02 [November 14, 2014]
|
||||
The macros passed in the command line to Borland make were ignored if
|
||||
similarly-named macros were already defined in makefiles. This behavior
|
||||
is different from POSIX make and other make programs. Surround the
|
||||
macro definitions with ifndef guards (Cosmin).
|
||||
|
||||
Version 1.6.15rc03 [November 16, 2014]
|
||||
Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32.
|
||||
Removed the obsolete $ARCH variable from scripts/makefile.darwin.
|
||||
|
||||
Version 1.6.15 [November 20, 2014]
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
|
|
@ -10,7 +10,7 @@ this sentence.
|
|||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.15, November 20, 2014, are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.14, October 23, 2014, are
|
||||
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
|||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
November 20, 2014
|
||||
October 23, 2014
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
Changes made to pristine libpng source by mozilla.org developers.
|
||||
|
||||
2014/11/20 -- Synced with libpng-1.6.15 (bug #1102523).
|
||||
|
||||
2014/10/23 -- Synced with libpng-1.6.14 (bug #1087841).
|
||||
2014/10/23 -- Synced with libpng-1.6.14 (bug #10xxxxx).
|
||||
|
||||
2014/08/21 -- Synced with libpng-1.6.13 (bug #1021713).
|
||||
Renamed mozpngconf.h to pnglibconf.h.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
README for libpng version 1.6.15 - November 20, 2014 (shared library 16.0)
|
||||
README for libpng version 1.6.14 - October 23, 2014 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
|
|
@ -32,7 +32,7 @@ Index: pngread.c
|
|||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
@@ -254,6 +268,72 @@
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
+#ifdef PNG_READ_APNG_SUPPORTED
|
||||
+void PNGAPI
|
||||
|
@ -42,7 +42,7 @@ Index: pngread.c
|
|||
+
|
||||
+ png_debug(0, "Reading frame head");
|
||||
+
|
||||
+ if ((png_ptr->mode & PNG_HAVE_acTL) == 0)
|
||||
+ if (!(png_ptr->mode & PNG_HAVE_acTL))
|
||||
+ png_error(png_ptr, "attempt to png_read_frame_head() but "
|
||||
+ "no acTL present");
|
||||
+
|
||||
|
@ -62,7 +62,7 @@ Index: pngread.c
|
|||
+ if (png_ptr->chunk_name == png_IDAT)
|
||||
+ {
|
||||
+ /* discard trailing IDATs for the first frame */
|
||||
+ if (have_chunk_after_DAT != 0 || png_ptr->num_frames_read > 1)
|
||||
+ if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
|
||||
+ png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
|
||||
+ png_crc_finish(png_ptr, length);
|
||||
+ }
|
||||
|
@ -78,7 +78,7 @@ Index: pngread.c
|
|||
+ png_ensure_sequence_number(png_ptr, length);
|
||||
+
|
||||
+ /* discard trailing fdATs for frames other than the first */
|
||||
+ if (have_chunk_after_DAT == 0 && png_ptr->num_frames_read > 1)
|
||||
+ if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
|
||||
+ png_crc_finish(png_ptr, length - 4);
|
||||
+ else if(png_ptr->mode & PNG_HAVE_fcTL)
|
||||
+ {
|
||||
|
@ -98,7 +98,7 @@ Index: pngread.c
|
|||
+ }
|
||||
+ }
|
||||
+}
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
+
|
||||
/* Optional call to update the users info_ptr structure */
|
||||
void PNGAPI
|
||||
|
@ -107,7 +107,7 @@ Index: pngget.c
|
|||
===================================================================
|
||||
--- pngget.c
|
||||
+++ pngget.c
|
||||
@@ -1210,4 +1210,166 @@
|
||||
@@ -1195,4 +1195,166 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -119,7 +119,7 @@ Index: pngget.c
|
|||
+ png_debug1(1, "in %s retrieval function", "acTL");
|
||||
+
|
||||
+ if (png_ptr != NULL && info_ptr != NULL &&
|
||||
+ (info_ptr->valid & PNG_INFO_acTL) != 0 &&
|
||||
+ (info_ptr->valid & PNG_INFO_acTL) &&
|
||||
+ num_frames != NULL && num_plays != NULL)
|
||||
+ {
|
||||
+ *num_frames = info_ptr->num_frames;
|
||||
|
@ -160,7 +160,7 @@ Index: pngget.c
|
|||
+ png_debug1(1, "in %s retrieval function", "fcTL");
|
||||
+
|
||||
+ if (png_ptr != NULL && info_ptr != NULL &&
|
||||
+ (info_ptr->valid & PNG_INFO_fcTL) != 0 &&
|
||||
+ (info_ptr->valid & PNG_INFO_fcTL) &&
|
||||
+ width != NULL && height != NULL &&
|
||||
+ x_offset != NULL && y_offset != NULL &&
|
||||
+ delay_num != NULL && delay_den != NULL &&
|
||||
|
@ -272,13 +272,13 @@ Index: pngget.c
|
|||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* APNG */
|
||||
#endif /* READ || WRITE */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
Index: png.h
|
||||
===================================================================
|
||||
--- png.h
|
||||
+++ png.h
|
||||
@@ -473,6 +473,10 @@
|
||||
@@ -470,6 +470,10 @@
|
||||
# include "pnglibconf.h"
|
||||
#endif
|
||||
|
||||
|
@ -289,7 +289,7 @@ Index: png.h
|
|||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Machine specific configuration. */
|
||||
# include "pngconf.h"
|
||||
@@ -563,6 +567,17 @@
|
||||
@@ -560,6 +564,17 @@
|
||||
* See pngconf.h for base types that vary by machine/system
|
||||
*/
|
||||
|
||||
|
@ -302,12 +302,12 @@ Index: png.h
|
|||
+/* blend_op flags from inside fcTL */
|
||||
+#define PNG_BLEND_OP_SOURCE 0x00
|
||||
+#define PNG_BLEND_OP_OVER 0x01
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
+
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
@@ -883,6 +898,10 @@
|
||||
@@ -880,6 +895,10 @@
|
||||
#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
|
||||
#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
|
||||
#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */
|
||||
|
@ -318,7 +318,7 @@ Index: png.h
|
|||
|
||||
/* This is used for the transformation routines, as some of them
|
||||
* change these values for the row. It also should enable using
|
||||
@@ -920,6 +939,10 @@
|
||||
@@ -917,6 +936,10 @@
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
|
||||
typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
|
||||
|
@ -329,7 +329,7 @@ Index: png.h
|
|||
|
||||
/* The following callback receives png_uint_32 row_number, int pass for the
|
||||
* png_bytep data of the row. When transforming an interlaced image the
|
||||
@@ -3259,6 +3282,75 @@
|
||||
@@ -3256,6 +3279,75 @@
|
||||
* END OF HARDWARE AND SOFTWARE OPTIONS
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -386,8 +386,8 @@ Index: png.h
|
|||
+PNG_EXPORT(262, void, png_set_progressive_frame_fn, (png_structp png_ptr,
|
||||
+ png_progressive_frame_ptr frame_info_fn,
|
||||
+ png_progressive_frame_ptr frame_end_fn));
|
||||
+#endif /* PROGRESSIVE_READ */
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
+
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+PNG_EXPORT(263, void, png_write_frame_head, (png_structp png_ptr,
|
||||
|
@ -399,13 +399,13 @@ Index: png.h
|
|||
+
|
||||
+PNG_EXPORT(264, void, png_write_frame_tail, (png_structp png_ptr,
|
||||
+ png_infop info_ptr));
|
||||
+#endif /* WRITE_APNG */
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
+
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
|
||||
* defs, and in scripts/symbols.def.
|
||||
*/
|
||||
@@ -3267,7 +3359,11 @@
|
||||
@@ -3264,7 +3356,11 @@
|
||||
* one to use is one more than this.)
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
|
@ -413,7 +413,7 @@ Index: png.h
|
|||
+ PNG_EXPORT_LAST_ORDINAL(264);
|
||||
+#else
|
||||
PNG_EXPORT_LAST_ORDINAL(244);
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -451,7 +451,7 @@ Index: pngpriv.h
|
|||
*/
|
||||
@@ -1456,6 +1470,49 @@
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
+#ifdef PNG_APNG_SUPPORTED
|
||||
+PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
|
||||
|
@ -477,8 +477,8 @@ Index: pngpriv.h
|
|||
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
+PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),
|
||||
+ PNG_EMPTY);
|
||||
+#endif /* PROGRESSIVE_READ */
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
+
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
|
||||
|
@ -493,8 +493,8 @@ Index: pngpriv.h
|
|||
+PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
|
||||
+PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
|
||||
+ png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
|
||||
+#endif /* WRITE_APNG */
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
+
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
|
@ -549,7 +549,7 @@ Index: pngstruct.h
|
|||
+ png_uint_32 num_frames_to_write;
|
||||
+ png_uint_32 num_frames_written;
|
||||
+#endif
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
+
|
||||
/* New members added in libpng-1.2.0 */
|
||||
|
||||
|
@ -563,14 +563,14 @@ Index: pngwrite.c
|
|||
* too.
|
||||
*/
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+ if ((info_ptr->valid & PNG_INFO_acTL) != 0)
|
||||
+ if (info_ptr->valid & PNG_INFO_acTL)
|
||||
+ png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
|
||||
+#endif
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
@@ -354,6 +358,11 @@
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -581,9 +581,9 @@ Index: pngwrite.c
|
|||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
if (png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
|
||||
@@ -2452,4 +2461,42 @@
|
||||
@@ -2437,4 +2446,42 @@
|
||||
}
|
||||
#endif /* STDIO */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
+
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -598,15 +598,15 @@ Index: pngwrite.c
|
|||
+
|
||||
+ /* there is a chance this has been set after png_write_info was called,
|
||||
+ * so it would be set but not written. is there a way to be sure? */
|
||||
+ if ((info_ptr->valid & PNG_INFO_acTL) == 0)
|
||||
+ if (!(info_ptr->valid & PNG_INFO_acTL))
|
||||
+ png_error(png_ptr, "png_write_frame_head(): acTL not set");
|
||||
+
|
||||
+ png_write_reset(png_ptr);
|
||||
+
|
||||
+ png_write_reinit(png_ptr, info_ptr, width, height);
|
||||
+
|
||||
+ if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) == 0 ||
|
||||
+ png_ptr->num_frames_written != 0)
|
||||
+ if ( !(png_ptr->num_frames_written == 0 &&
|
||||
+ (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
|
||||
+ png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
|
||||
+ delay_num, delay_den, dispose_op, blend_op);
|
||||
+
|
||||
|
@ -622,13 +622,13 @@ Index: pngwrite.c
|
|||
+
|
||||
+ PNG_UNUSED(info_ptr)
|
||||
+}
|
||||
+#endif /* WRITE_APNG */
|
||||
#endif /* WRITE */
|
||||
+#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
Index: pngpread.c
|
||||
===================================================================
|
||||
--- pngpread.c
|
||||
+++ pngpread.c
|
||||
@@ -219,6 +219,86 @@
|
||||
@@ -219,6 +219,85 @@
|
||||
|
||||
chunk_name = png_ptr->chunk_name;
|
||||
|
||||
|
@ -639,8 +639,7 @@ Index: pngpread.c
|
|||
+ if (chunk_name == png_IDAT)
|
||||
+ {
|
||||
+ /* Discard trailing IDATs for the first frame */
|
||||
+ if ((png_ptr->mode & PNG_HAVE_fcTL) != 0 ||
|
||||
+ png_ptr->num_frames_read > 1)
|
||||
+ if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
|
||||
+ png_error(png_ptr, "out of place IDAT");
|
||||
+
|
||||
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
|
@ -653,7 +652,7 @@ Index: pngpread.c
|
|||
+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
+ png_ensure_sequence_number(png_ptr, 4);
|
||||
+
|
||||
+ if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
|
||||
+ if (!(png_ptr->mode & PNG_HAVE_fcTL))
|
||||
+ {
|
||||
+ /* Discard trailing fdATs for frames other than the first */
|
||||
+ if (png_ptr->num_frames_read < 2)
|
||||
|
@ -684,7 +683,7 @@ Index: pngpread.c
|
|||
+
|
||||
+ png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
+
|
||||
+ if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
|
||||
+ if (!(png_ptr->mode & PNG_HAVE_fcTL))
|
||||
+ png_error(png_ptr, "missing required fcTL chunk");
|
||||
+
|
||||
+ png_read_reinit(png_ptr, info_ptr);
|
||||
|
@ -710,12 +709,12 @@ Index: pngpread.c
|
|||
+
|
||||
+ return;
|
||||
+ }
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
+
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
@@ -283,6 +363,9 @@
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
@@ -283,6 +362,9 @@
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
|
@ -725,7 +724,7 @@ Index: pngpread.c
|
|||
png_ptr->idat_size = png_ptr->push_length;
|
||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||
png_push_have_info(png_ptr, info_ptr);
|
||||
@@ -429,6 +512,20 @@
|
||||
@@ -429,6 +511,20 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -742,11 +741,11 @@ Index: pngpread.c
|
|||
+ png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
+ }
|
||||
+
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
else
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
@@ -623,7 +720,11 @@
|
||||
@@ -621,7 +717,11 @@
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
/* TODO: this code can be commoned up with the same code in push_read */
|
||||
|
@ -758,14 +757,14 @@ Index: pngpread.c
|
|||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
@@ -631,17 +732,60 @@
|
||||
@@ -629,17 +729,60 @@
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
|
||||
+#ifdef PNG_READ_APNG_SUPPORTED
|
||||
+ if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
|
||||
+ {
|
||||
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) != 0)
|
||||
+ if (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)
|
||||
+ {
|
||||
+ png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
+ if (png_ptr->frame_end_fn != NULL)
|
||||
|
@ -795,7 +794,7 @@ Index: pngpread.c
|
|||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
png_error(png_ptr, "Not enough compressed data");
|
||||
|
||||
+#ifdef PNG_READ_APNG_SUPPORTED
|
||||
|
@ -818,25 +817,24 @@ Index: pngpread.c
|
|||
+#endif
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
|
||||
@@ -714,6 +858,16 @@
|
||||
if (png_ptr->idat_size && png_ptr->save_buffer_size)
|
||||
@@ -712,6 +855,15 @@
|
||||
if (!(buffer_length > 0) || buffer == NULL)
|
||||
png_error(png_ptr, "No IDAT data (internal error)");
|
||||
|
||||
+#ifdef PNG_READ_APNG_SUPPORTED
|
||||
+ /* If the app is not APNG-aware, decode only the first frame */
|
||||
+ if ((png_ptr->apng_flags & PNG_APNG_APP) == 0 &&
|
||||
+ png_ptr->num_frames_read > 0)
|
||||
+ if (!(png_ptr->apng_flags & PNG_APNG_APP) && png_ptr->num_frames_read > 0)
|
||||
+ {
|
||||
+ png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
+ return;
|
||||
+ png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
+ return;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
/* This routine must process all the data it has been given
|
||||
* before returning, calling the row callback as required to
|
||||
* handle the uncompressed results.
|
||||
@@ -1157,6 +1311,18 @@
|
||||
@@ -1154,6 +1306,18 @@
|
||||
png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
|
||||
}
|
||||
|
||||
|
@ -859,7 +857,7 @@ Index: pngset.c
|
|||
===================================================================
|
||||
--- pngset.c
|
||||
+++ pngset.c
|
||||
@@ -240,6 +240,11 @@
|
||||
@@ -239,6 +239,11 @@
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
|
@ -871,9 +869,9 @@ Index: pngset.c
|
|||
}
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
@@ -1071,6 +1076,147 @@
|
||||
@@ -1065,6 +1070,147 @@
|
||||
}
|
||||
#endif /* sPLT */
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
+#ifdef PNG_APNG_SUPPORTED
|
||||
+png_uint_32 PNGAPI
|
||||
|
@ -940,8 +938,8 @@ Index: pngset.c
|
|||
+
|
||||
+ if (blend_op == PNG_BLEND_OP_OVER)
|
||||
+ {
|
||||
+ if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0 &&
|
||||
+ png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == 0)
|
||||
+ if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) &&
|
||||
+ !(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
||||
+ {
|
||||
+ png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
|
||||
+ "and wasteful for opaque images, ignored");
|
||||
|
@ -1005,7 +1003,7 @@ Index: pngset.c
|
|||
+ if (png_ptr == NULL)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (is_hidden != 0)
|
||||
+ if (is_hidden)
|
||||
+ png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
|
||||
+ else
|
||||
+ png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
|
||||
|
@ -1014,7 +1012,7 @@ Index: pngset.c
|
|||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+#endif /* APNG */
|
||||
+#endif /* PNG_APNG_SUPPORTED */
|
||||
+
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_byte
|
||||
|
@ -1023,7 +1021,7 @@ Index: pngrutil.c
|
|||
===================================================================
|
||||
--- pngrutil.c
|
||||
+++ pngrutil.c
|
||||
@@ -818,6 +818,11 @@
|
||||
@@ -817,6 +817,11 @@
|
||||
filter_type = buf[11];
|
||||
interlace_type = buf[12];
|
||||
|
||||
|
@ -1035,7 +1033,7 @@ Index: pngrutil.c
|
|||
/* Set internal variables */
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
@@ -2700,6 +2705,180 @@
|
||||
@@ -2697,6 +2702,179 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1050,17 +1048,17 @@ Index: pngrutil.c
|
|||
+
|
||||
+ png_debug(1, "in png_handle_acTL");
|
||||
+
|
||||
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
+ {
|
||||
+ png_error(png_ptr, "Missing IHDR before acTL");
|
||||
+ }
|
||||
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||
+ else if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
+ {
|
||||
+ png_warning(png_ptr, "Invalid acTL after IDAT skipped");
|
||||
+ png_crc_finish(png_ptr, length);
|
||||
+ return;
|
||||
+ }
|
||||
+ else if ((png_ptr->mode & PNG_HAVE_acTL) != 0)
|
||||
+ else if (png_ptr->mode & PNG_HAVE_acTL)
|
||||
+ {
|
||||
+ png_warning(png_ptr, "Duplicate acTL skipped");
|
||||
+ png_crc_finish(png_ptr, length);
|
||||
|
@ -1081,7 +1079,7 @@ Index: pngrutil.c
|
|||
+
|
||||
+ /* the set function will do error checking on num_frames */
|
||||
+ didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
|
||||
+ if (didSet != 0)
|
||||
+ if(didSet)
|
||||
+ png_ptr->mode |= PNG_HAVE_acTL;
|
||||
+}
|
||||
+
|
||||
|
@ -1102,11 +1100,11 @@ Index: pngrutil.c
|
|||
+
|
||||
+ png_ensure_sequence_number(png_ptr, length);
|
||||
+
|
||||
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
+ if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
+ {
|
||||
+ png_error(png_ptr, "Missing IHDR before fcTL");
|
||||
+ }
|
||||
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||
+ else if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
+ {
|
||||
+ /* for any frames other then the first this message may be misleading,
|
||||
+ * but correct. PNG_HAVE_IDAT is unset before the frame head is read
|
||||
|
@ -1115,7 +1113,7 @@ Index: pngrutil.c
|
|||
+ png_crc_finish(png_ptr, length-4);
|
||||
+ return;
|
||||
+ }
|
||||
+ else if ((png_ptr->mode & PNG_HAVE_fcTL) != 0)
|
||||
+ else if (png_ptr->mode & PNG_HAVE_fcTL)
|
||||
+ {
|
||||
+ png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
|
||||
+ png_crc_finish(png_ptr, length-4);
|
||||
|
@ -1170,8 +1168,7 @@ Index: pngrutil.c
|
|||
+void /* PRIVATE */
|
||||
+png_have_info(png_structp png_ptr, png_infop info_ptr)
|
||||
+{
|
||||
+ if ((info_ptr->valid & PNG_INFO_acTL) != 0 &&
|
||||
+ (info_ptr->valid & PNG_INFO_fcTL) == 0)
|
||||
+ if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL))
|
||||
+ {
|
||||
+ png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
|
||||
+ info_ptr->num_frames++;
|
||||
|
@ -1211,12 +1208,12 @@ Index: pngrutil.c
|
|||
+
|
||||
+ png_ptr->next_seq_num++;
|
||||
+}
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
+
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
|
||||
static int
|
||||
@@ -3959,6 +4138,38 @@
|
||||
@@ -3954,6 +4132,38 @@
|
||||
uInt avail_in;
|
||||
png_bytep buffer;
|
||||
|
||||
|
@ -1255,15 +1252,15 @@ Index: pngrutil.c
|
|||
while (png_ptr->idat_size == 0)
|
||||
{
|
||||
png_crc_finish(png_ptr, 0);
|
||||
@@ -3970,6 +4181,7 @@
|
||||
@@ -3965,6 +4175,7 @@
|
||||
if (png_ptr->chunk_name != png_IDAT)
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
}
|
||||
+#endif /* READ_APNG */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
avail_in = png_ptr->IDAT_read_size;
|
||||
|
||||
@@ -4033,6 +4245,9 @@
|
||||
@@ -4028,6 +4239,9 @@
|
||||
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
|
@ -1273,7 +1270,7 @@ Index: pngrutil.c
|
|||
|
||||
if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
|
||||
png_chunk_benign_error(png_ptr, "Extra compressed data");
|
||||
@@ -4471,4 +4686,80 @@
|
||||
@@ -4465,4 +4679,80 @@
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||
}
|
||||
|
@ -1299,7 +1296,7 @@ Index: pngrutil.c
|
|||
+ png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
|
||||
+ png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
|
||||
+ png_ptr->width);
|
||||
+ if (png_ptr->prev_row != NULL)
|
||||
+ if (png_ptr->prev_row)
|
||||
+ memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
+}
|
||||
+
|
||||
|
@ -1323,9 +1320,9 @@ Index: pngrutil.c
|
|||
+ /* Offset to next interlace block in the y direction */
|
||||
+ static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||
+
|
||||
+ if (png_ptr->interlaced != 0)
|
||||
+ if (png_ptr->interlaced)
|
||||
+ {
|
||||
+ if ((png_ptr->transformations & PNG_INTERLACE) == 0)
|
||||
+ if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
+ png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
|
||||
+ png_pass_ystart[0]) / png_pass_yinc[0];
|
||||
+ else
|
||||
|
@ -1337,7 +1334,7 @@ Index: pngrutil.c
|
|||
+ png_pass_inc[png_ptr->pass];
|
||||
+ }
|
||||
+ else
|
||||
+#endif /* READ_INTERLACING */
|
||||
+#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
+ {
|
||||
+ png_ptr->num_rows = png_ptr->height;
|
||||
+ png_ptr->iwidth = png_ptr->width;
|
||||
|
@ -1351,14 +1348,14 @@ Index: pngrutil.c
|
|||
+ png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||
+ png_ptr->iwidth) + 1;
|
||||
+}
|
||||
+#endif /* PROGRESSIVE_READ */
|
||||
+#endif /* READ_APNG */
|
||||
#endif /* READ */
|
||||
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
+#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
Index: pngwutil.c
|
||||
===================================================================
|
||||
--- pngwutil.c
|
||||
+++ pngwutil.c
|
||||
@@ -901,6 +901,11 @@
|
||||
@@ -902,6 +902,11 @@
|
||||
/* Write the chunk */
|
||||
png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||
|
||||
|
@ -1370,39 +1367,39 @@ Index: pngwutil.c
|
|||
if ((png_ptr->do_filter) == PNG_NO_FILTERS)
|
||||
{
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
|
||||
@@ -1079,7 +1084,15 @@
|
||||
@@ -1080,7 +1085,15 @@
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
#endif
|
||||
# endif
|
||||
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+ if (png_ptr->num_frames_written == 0)
|
||||
+#endif
|
||||
+# endif
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+ else
|
||||
+ png_write_fdAT(png_ptr, data, size);
|
||||
+#endif /* WRITE_APNG */
|
||||
+# endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
+
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
png_ptr->zstream.next_out = data;
|
||||
@@ -1125,7 +1138,15 @@
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
#endif
|
||||
@@ -1126,7 +1139,15 @@
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
# endif
|
||||
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+ if (png_ptr->num_frames_written == 0)
|
||||
+#endif
|
||||
+# endif
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
+ else
|
||||
+ png_write_fdAT(png_ptr, data, size);
|
||||
+#endif /* WRITE_APNG */
|
||||
+# endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
+
|
||||
png_ptr->zstream.avail_out = 0;
|
||||
png_ptr->zstream.next_out = NULL;
|
||||
png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
|
||||
@@ -1938,6 +1959,82 @@
|
||||
@@ -1939,6 +1960,82 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1417,7 +1414,7 @@ Index: pngwutil.c
|
|||
+
|
||||
+ png_ptr->num_frames_to_write = num_frames;
|
||||
+
|
||||
+ if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) != 0)
|
||||
+ if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
|
||||
+ num_frames--;
|
||||
+
|
||||
+ png_save_uint_32(buf, num_frames);
|
||||
|
@ -1480,14 +1477,14 @@ Index: pngwutil.c
|
|||
+
|
||||
+ png_ptr->next_seq_num++;
|
||||
+}
|
||||
+#endif /* WRITE_APNG */
|
||||
+#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
+
|
||||
/* Initializes the row writing capability of libpng */
|
||||
void /* PRIVATE */
|
||||
png_write_start_row(png_structrp png_ptr)
|
||||
@@ -3026,4 +3123,39 @@
|
||||
}
|
||||
#endif /* WRITE_FLUSH */
|
||||
#endif
|
||||
}
|
||||
+
|
||||
+#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -1523,8 +1520,8 @@ Index: pngwutil.c
|
|||
+ png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
|
||||
+ png_ptr->usr_width = png_ptr->width;
|
||||
+}
|
||||
+#endif /* WRITE_APNG */
|
||||
#endif /* WRITE */
|
||||
+#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
Index: scripts/symbols.def
|
||||
===================================================================
|
||||
--- scripts/symbols.def
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* These are required because Mozilla's moz.build system doesn't pass
|
||||
* -DDefined macros to the assembler.
|
||||
*/
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define MOZ_PNG_HAVE_ARM_NEON
|
||||
|
||||
/* This is required to get the symbol renames, which are #defines, and also
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT and
|
||||
* PNG_ARM_NEON_IMPLEMENTATION.
|
||||
|
@ -47,6 +53,14 @@ ELF .size \name, . - \name
|
|||
.purgem endfunc
|
||||
.endm
|
||||
.text
|
||||
|
||||
/* Explicitly specifying alignment here because some versions of
|
||||
gas don't align code correctly. See
|
||||
http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
|
||||
and https://bugzilla.mozilla.org/show_bug.cgi?id=920992
|
||||
*/
|
||||
.align 2
|
||||
|
||||
.if \export
|
||||
.global \name
|
||||
.endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.15 - November 20, 2014
|
||||
libpng version 1.6.14 - October 23, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
|
@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
|||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.15 - November 20, 2014
|
||||
libpng versions 0.97, January 1998, through 1.6.14 - October 23, 2014
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
|
||||
|
@ -5277,13 +5277,13 @@ Other rules can be inferred by inspecting the libpng source.
|
|||
|
||||
XVI. Y2K Compliance in libpng
|
||||
|
||||
November 20, 2014
|
||||
October 23, 2014
|
||||
|
||||
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.6.15 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.6.14 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.15, November 20, 2014
|
||||
* libpng version 1.6.14 - October 23, 2014
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -11,7 +11,7 @@
|
|||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.15, November 20, 2014: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.6.14 - October 23, 2014: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
|
@ -206,9 +206,6 @@
|
|||
* 1.6.14beta01-07 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14rc01-02 16 10614 16.so.16.14[.0]
|
||||
* 1.6.14 16 10614 16.so.16.14[.0]
|
||||
* 1.6.15beta01-08 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15rc01-03 16 10615 16.so.16.15[.0]
|
||||
* 1.6.15 16 10615 16.so.16.15[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -240,7 +237,7 @@
|
|||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.15, November 20, 2014, are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.14, October 23, 2014, are
|
||||
* Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
|
@ -352,13 +349,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* November 20, 2014
|
||||
* October 23, 2014
|
||||
*
|
||||
* 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.6.15 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.14 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
@ -420,9 +417,9 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.15"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.14"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.15 - November 20, 2014\n"
|
||||
" libpng version 1.6.14 - October 23, 2014\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
|
@ -430,7 +427,7 @@
|
|||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 15
|
||||
#define PNG_LIBPNG_VER_RELEASE 14
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
|
@ -461,7 +458,7 @@
|
|||
* 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
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10615 /* 1.6.15 */
|
||||
#define PNG_LIBPNG_VER 10614 /* 1.6.14 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -576,12 +573,12 @@ extern "C" {
|
|||
/* blend_op flags from inside fcTL */
|
||||
#define PNG_BLEND_OP_SOURCE 0x00
|
||||
#define PNG_BLEND_OP_OVER 0x01
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_15;
|
||||
typedef char* png_libpng_version_1_6_14;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
@ -1202,7 +1199,7 @@ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
|
|||
|
||||
/* Convert from time_t to png_time. Uses gmtime() */
|
||||
PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
|
||||
#endif /* CONVERT_tIME */
|
||||
#endif /* PNG_CONVERT_tIME_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
|
||||
|
@ -1408,7 +1405,7 @@ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
|
|||
/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
|
||||
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
|
||||
png_uint_32 filler, int flags));
|
||||
#endif /* READ_FILLER || WRITE_FILLER */
|
||||
#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swap bytes in 16-bit depth files. */
|
||||
|
@ -1672,7 +1669,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
|||
(png_structrp png_ptr, int heuristic_method, int num_weights,
|
||||
png_const_fixed_point_p filter_weights,
|
||||
png_const_fixed_point_p filter_costs))
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
|
||||
/* Heuristic used for row filter selection. These defines should NOT be
|
||||
* changed.
|
||||
|
@ -1728,7 +1725,7 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
|
|||
|
||||
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
|
||||
int method));
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
|
||||
/* These next functions are called for input/output, memory, and error
|
||||
* handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
|
||||
|
@ -1895,7 +1892,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
|
|||
*/
|
||||
PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
|
||||
png_bytep old_row, png_const_bytep new_row));
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
|
||||
png_alloc_size_t size), PNG_ALLOCATED);
|
||||
|
@ -2096,7 +2093,7 @@ PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
|
|||
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr));
|
||||
|
||||
#endif /* EASY_ACCESS */
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Returns pointer to signature string read from PNG header */
|
||||
|
@ -2348,7 +2345,7 @@ PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
|
|||
PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int unit,
|
||||
png_const_charp swidth, png_const_charp sheight));
|
||||
#endif /* sCAL */
|
||||
#endif /* PNG_sCAL_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Provide the default handling for all unknown chunks or, optionally, for
|
||||
|
@ -2576,8 +2573,8 @@ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
|
|||
PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
|
||||
int *unit_type));
|
||||
# endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
# endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
||||
|
||||
/* Added in libpng-1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
|
@ -2600,7 +2597,7 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||
# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
|
||||
# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
|
||||
# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
|
||||
#endif /* IO_STATE */
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
/* Interlace support. The following macros are always defined so that if
|
||||
* libpng interlace handling is turned off the macros may be used to handle
|
||||
|
@ -2704,7 +2701,7 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
|
||||
32767) / 65535)
|
||||
#endif /* READ_COMPOSITE_NODIV */
|
||||
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
|
||||
|
@ -3132,7 +3129,7 @@ PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
|
|||
PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
|
||||
FILE* file));
|
||||
/* The PNG header is read from the stdio FILE object. */
|
||||
#endif /* STDIO */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
|
||||
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
|
||||
png_const_voidp memory, png_size_t size));
|
||||
|
@ -3177,7 +3174,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
|||
/* Free any data allocated by libpng in image->opaque, setting the pointer to
|
||||
* NULL. May be called at any time after the structure is initialized.
|
||||
*/
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
|
@ -3223,12 +3220,12 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
|||
*
|
||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
||||
*/
|
||||
#endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
|
||||
/*******************************************************************************
|
||||
* END OF SIMPLIFIED API
|
||||
******************************************************************************/
|
||||
#endif /* SIMPLIFIED_{READ|WRITE} */
|
||||
#endif /* PNG_SIMPLIFIED_{READ|WRITE}_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
|
@ -3276,7 +3273,7 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
|
|||
|
||||
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
||||
int onoff));
|
||||
#endif /* SET_OPTION */
|
||||
#endif /* PNG_SET_OPTION_SUPPORTED */
|
||||
|
||||
/*******************************************************************************
|
||||
* END OF HARDWARE AND SOFTWARE OPTIONS
|
||||
|
@ -3335,8 +3332,8 @@ PNG_EXPORT(261, void, png_read_frame_head, (png_structp png_ptr,
|
|||
PNG_EXPORT(262, void, png_set_progressive_frame_fn, (png_structp png_ptr,
|
||||
png_progressive_frame_ptr frame_info_fn,
|
||||
png_progressive_frame_ptr frame_end_fn));
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* READ_APNG */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
PNG_EXPORT(263, void, png_write_frame_head, (png_structp png_ptr,
|
||||
|
@ -3348,8 +3345,8 @@ PNG_EXPORT(263, void, png_write_frame_head, (png_structp png_ptr,
|
|||
|
||||
PNG_EXPORT(264, void, png_write_frame_tail, (png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
#endif /* WRITE_APNG */
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
|
||||
* defs, and in scripts/symbols.def.
|
||||
|
@ -3363,7 +3360,7 @@ PNG_EXPORT(264, void, png_write_frame_tail, (png_structp png_ptr,
|
|||
PNG_EXPORT_LAST_ORDINAL(264);
|
||||
#else
|
||||
PNG_EXPORT_LAST_ORDINAL(244);
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.15,November 20, 2014
|
||||
* libpng version 1.6.14 - October 23, 2014
|
||||
*
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.13 [August 21, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
|
|||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_const_structrp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
* should not be changed. If there is a need to handle errors differently,
|
||||
|
@ -43,8 +43,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
|
@ -69,7 +69,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|||
|
||||
else
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
|
@ -103,7 +103,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN)
|
|||
use the default handler, which will not return. */
|
||||
png_default_error(png_ptr, "");
|
||||
}
|
||||
#endif /* ERROR_TEXT */
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
|
@ -152,7 +152,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
|||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output != 0 || number % 10 != 0)
|
||||
if (output || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
|
@ -189,7 +189,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
|||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
|
@ -219,8 +219,8 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
|||
if (png_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if ((png_ptr->flags &
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
|
@ -355,13 +355,13 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,
|
|||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
void PNGAPI
|
||||
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
{
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
|
@ -391,7 +391,7 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
|
|||
void /* PRIVATE */
|
||||
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
@ -404,7 +404,7 @@ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
|
|||
void /* PRIVATE */
|
||||
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
|
@ -442,7 +442,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
|||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c) != 0)
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
|
||||
|
@ -473,7 +473,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
|
|||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* WARNINGS || ERROR_TEXT */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
|
@ -490,7 +490,7 @@ png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),
|
|||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* READ && ERROR_TEXT */
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
|
@ -506,7 +506,7 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
|||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
|
@ -514,7 +514,7 @@ void PNGAPI
|
|||
png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
||||
error_message)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
|
||||
else
|
||||
|
@ -525,7 +525,7 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
|
|||
# endif
|
||||
}
|
||||
#endif
|
||||
#endif /* READ */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
|
@ -538,7 +538,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
|||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_SUPPORTED
|
||||
|
@ -552,7 +552,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
|||
# endif
|
||||
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
|
@ -577,12 +577,11 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
|||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL)
|
||||
while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
|
@ -758,8 +757,7 @@ PNG_FUNCTION(void,PNGAPI
|
|||
png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
|
||||
png_ptr->jmp_buf_ptr != NULL)
|
||||
if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
|
@ -824,7 +822,7 @@ png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
|
|||
#endif
|
||||
PNG_UNUSED(png_ptr) /* Make compiler happy */
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
|
@ -959,5 +957,5 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
|||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -116,8 +116,7 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
|||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_x_pixels_per_meter");
|
||||
|
@ -138,8 +137,7 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
|||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_y_pixels_per_meter");
|
||||
|
@ -159,8 +157,7 @@ png_uint_32 PNGAPI
|
|||
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
||||
|
||||
|
@ -182,8 +179,7 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
|
|||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
|
||||
|
||||
|
@ -206,11 +202,10 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
|||
png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0 &&
|
||||
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
|
||||
info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
|
||||
info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
|
||||
&& info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
|
||||
&& info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
|
||||
&& info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
|
||||
{
|
||||
png_fixed_point res;
|
||||
|
||||
|
@ -220,7 +215,7 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
|||
* range of 0..2^31-1; otherwise the cast might overflow.
|
||||
*/
|
||||
if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
|
||||
(png_int_32)info_ptr->x_pixels_per_unit) != 0)
|
||||
(png_int_32)info_ptr->x_pixels_per_unit))
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
|
@ -236,8 +231,7 @@ png_int_32 PNGAPI
|
|||
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
||||
|
||||
|
@ -256,8 +250,7 @@ png_int_32 PNGAPI
|
|||
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
||||
|
||||
|
@ -276,8 +269,7 @@ png_int_32 PNGAPI
|
|||
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
|
||||
|
||||
|
@ -296,8 +288,7 @@ png_int_32 PNGAPI
|
|||
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
|
||||
|
||||
|
@ -337,7 +328,7 @@ ppi_from_ppm(png_uint_32 ppm)
|
|||
*/
|
||||
png_fixed_point result;
|
||||
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
||||
5000) != 0)
|
||||
5000))
|
||||
return result;
|
||||
|
||||
/* Overflow. */
|
||||
|
@ -423,8 +414,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
|
@ -455,12 +445,12 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
|
||||
return (retval);
|
||||
}
|
||||
#endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
#endif /* PNG_pHYs_SUPPORTED */
|
||||
#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
|
||||
|
||||
/* png_get_channels really belongs in here, too, but it's been around longer */
|
||||
|
||||
#endif /* EASY_ACCESS */
|
||||
#endif /* PNG_EASY_ACCESS_SUPPORTED */
|
||||
|
||||
|
||||
png_byte PNGAPI
|
||||
|
@ -488,9 +478,8 @@ png_uint_32 PNGAPI
|
|||
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
|
||||
background != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||
&& background != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "bKGD");
|
||||
|
||||
|
@ -520,7 +509,7 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
* consistent.
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
|
@ -561,7 +550,7 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
double *blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
|
@ -609,7 +598,7 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
|
@ -646,7 +635,7 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||
|
@ -681,7 +670,7 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
|
@ -700,7 +689,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
|
@ -720,8 +709,8 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "sRGB");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||
&& file_srgb_intent != NULL)
|
||||
{
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
|
@ -739,10 +728,9 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "iCCP");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP) != 0 &&
|
||||
name != NULL && compression_type != NULL && profile != NULL &&
|
||||
proflen != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||
&& name != NULL && compression_type != NULL && profile != NULL &&
|
||||
proflen != NULL)
|
||||
{
|
||||
*name = info_ptr->iccp_name;
|
||||
*profile = info_ptr->iccp_profile;
|
||||
|
@ -780,8 +768,8 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||
&& hist != NULL)
|
||||
{
|
||||
*hist = info_ptr->hist;
|
||||
return (PNG_INFO_hIST);
|
||||
|
@ -836,9 +824,8 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "oFFs");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0 &&
|
||||
offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
||||
{
|
||||
*offset_x = info_ptr->x_offset;
|
||||
*offset_y = info_ptr->y_offset;
|
||||
|
@ -858,9 +845,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "pCAL");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pCAL) != 0 &&
|
||||
purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
|
||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||
nparams != NULL && units != NULL && params != NULL)
|
||||
{
|
||||
*purpose = info_ptr->pcal_purpose;
|
||||
|
@ -886,7 +872,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
/*TODO: make this work without FP support; the API is currently eliminated
|
||||
|
@ -909,7 +895,7 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
int *unit, double *width, double *height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = atof(info_ptr->scal_s_width);
|
||||
|
@ -925,7 +911,7 @@ png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
(info_ptr->valid & PNG_INFO_sCAL))
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
|
@ -947,7 +933,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
(info_ptr->valid & PNG_INFO_pHYs))
|
||||
{
|
||||
if (res_x != NULL)
|
||||
{
|
||||
|
@ -978,8 +964,8 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||
&& palette != NULL)
|
||||
{
|
||||
*palette = info_ptr->palette;
|
||||
*num_palette = info_ptr->num_palette;
|
||||
|
@ -997,8 +983,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "sBIT");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||
&& sig_bit != NULL)
|
||||
{
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
return (PNG_INFO_sBIT);
|
||||
|
@ -1041,8 +1027,8 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "tIME");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||
&& mod_time != NULL)
|
||||
{
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
return (PNG_INFO_tIME);
|
||||
|
@ -1058,8 +1044,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_tRNS) != 0)
|
||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "tRNS");
|
||||
|
||||
|
@ -1136,7 +1121,7 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
|||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
|
@ -1180,7 +1165,7 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
|||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||
}
|
||||
#endif /* SET_USER_LIMITS */
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
|
||||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
|
@ -1195,7 +1180,7 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
|||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
#endif /* IO_STATE */
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
|
@ -1218,7 +1203,7 @@ png_get_acTL(png_structp png_ptr, png_infop info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "acTL");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_acTL) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_acTL) &&
|
||||
num_frames != NULL && num_plays != NULL)
|
||||
{
|
||||
*num_frames = info_ptr->num_frames;
|
||||
|
@ -1259,7 +1244,7 @@ png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
|
|||
png_debug1(1, "in %s retrieval function", "fcTL");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_fcTL) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_fcTL) &&
|
||||
width != NULL && height != NULL &&
|
||||
x_offset != NULL && y_offset != NULL &&
|
||||
delay_num != NULL && delay_den != NULL &&
|
||||
|
@ -1371,5 +1356,5 @@ png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* APNG */
|
||||
#endif /* READ || WRITE */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -121,7 +121,7 @@ struct png_info_def
|
|||
int num_text; /* number of comments read or comments to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read or comments to write */
|
||||
#endif /* TEXT */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -199,7 +199,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif /* USER_MEM */
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
|
@ -244,7 +244,7 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
|||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
#endif /* USER_MEM */
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
@ -277,5 +277,5 @@ png_get_mem_ptr(png_const_structrp png_ptr)
|
|||
|
||||
return png_ptr->mem_ptr;
|
||||
}
|
||||
#endif /* USER_MEM */
|
||||
#endif /* READ || WRITE */
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.14 [October 23, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -202,7 +202,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
* sure we have enough data in the buffer for the 4-byte CRC at the
|
||||
* end of every chunk (except IDAT, which is handled separately).
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
@ -226,8 +226,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
/* Discard trailing IDATs for the first frame */
|
||||
if ((png_ptr->mode & PNG_HAVE_fcTL) != 0 ||
|
||||
png_ptr->num_frames_read > 1)
|
||||
if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
|
||||
png_error(png_ptr, "out of place IDAT");
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
|
@ -240,7 +239,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_ensure_sequence_number(png_ptr, 4);
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_fcTL))
|
||||
{
|
||||
/* Discard trailing fdATs for frames other than the first */
|
||||
if (png_ptr->num_frames_read < 2)
|
||||
|
@ -271,7 +270,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
|
||||
png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_fcTL))
|
||||
png_error(png_ptr, "missing required fcTL chunk");
|
||||
|
||||
png_read_reinit(png_ptr, info_ptr);
|
||||
|
@ -297,32 +296,32 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
|
||||
return;
|
||||
}
|
||||
#endif /* READ_APNG */
|
||||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
|
||||
/* If we reach an IDAT chunk, this means we have read all of the
|
||||
* header chunks, and we can start reading the image (or if this
|
||||
* is called after the image has been read - we have an error).
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_ptr->process_mode = PNG_READ_IDAT_MODE;
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
if (png_ptr->push_length == 0)
|
||||
return;
|
||||
|
||||
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
|
@ -525,7 +524,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif /* READ_APNG */
|
||||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
else
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
|
@ -546,7 +545,7 @@ png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
|||
void /* PRIVATE */
|
||||
png_push_crc_finish(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
|
||||
if (png_ptr->skip_length && png_ptr->save_buffer_size)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
|
@ -570,7 +569,7 @@ png_push_crc_finish(png_structrp png_ptr)
|
|||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
|
||||
if (png_ptr->skip_length && png_ptr->current_buffer_size)
|
||||
{
|
||||
png_size_t save_size = png_ptr->current_buffer_size;
|
||||
png_uint_32 skip_length = png_ptr->skip_length;
|
||||
|
@ -591,7 +590,7 @@ png_push_crc_finish(png_structrp png_ptr)
|
|||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->skip_length == 0)
|
||||
if (!png_ptr->skip_length)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
|
@ -608,7 +607,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
|||
return;
|
||||
|
||||
ptr = buffer;
|
||||
if (png_ptr->save_buffer_size != 0)
|
||||
if (png_ptr->save_buffer_size)
|
||||
{
|
||||
png_size_t save_size;
|
||||
|
||||
|
@ -625,7 +624,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
|||
png_ptr->save_buffer_size -= save_size;
|
||||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
if (length != 0 && png_ptr->current_buffer_size != 0)
|
||||
if (length && png_ptr->current_buffer_size)
|
||||
{
|
||||
png_size_t save_size;
|
||||
|
||||
|
@ -645,7 +644,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
|||
void /* PRIVATE */
|
||||
png_push_save_buffer(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->save_buffer_size != 0)
|
||||
if (png_ptr->save_buffer_size)
|
||||
{
|
||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||
{
|
||||
|
@ -681,13 +680,11 @@ png_push_save_buffer(png_structrp png_ptr)
|
|||
if (png_ptr->save_buffer == NULL)
|
||||
{
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
if (png_ptr->current_buffer_size)
|
||||
|
@ -714,7 +711,7 @@ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
|
|||
void /* PRIVATE */
|
||||
png_push_read_IDAT(png_structrp png_ptr)
|
||||
{
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
@ -735,7 +732,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
#ifdef PNG_READ_APNG_SUPPORTED
|
||||
if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)
|
||||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
if (png_ptr->frame_end_fn != NULL)
|
||||
|
@ -765,7 +762,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
{
|
||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
png_error(png_ptr, "Not enough compressed data");
|
||||
|
||||
#ifdef PNG_READ_APNG_SUPPORTED
|
||||
|
@ -788,7 +785,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
|
||||
if (png_ptr->idat_size && png_ptr->save_buffer_size)
|
||||
{
|
||||
png_size_t save_size = png_ptr->save_buffer_size;
|
||||
png_uint_32 idat_size = png_ptr->idat_size;
|
||||
|
@ -815,7 +812,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
png_ptr->save_buffer_ptr += save_size;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0)
|
||||
if (png_ptr->idat_size && png_ptr->current_buffer_size)
|
||||
{
|
||||
png_size_t save_size = png_ptr->current_buffer_size;
|
||||
png_uint_32 idat_size = png_ptr->idat_size;
|
||||
|
@ -840,7 +837,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
|||
png_ptr->current_buffer_size -= save_size;
|
||||
png_ptr->current_buffer_ptr += save_size;
|
||||
}
|
||||
if (png_ptr->idat_size == 0)
|
||||
if (!png_ptr->idat_size)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
png_crc_finish(png_ptr, 0);
|
||||
|
@ -860,11 +857,10 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
|||
|
||||
#ifdef PNG_READ_APNG_SUPPORTED
|
||||
/* If the app is not APNG-aware, decode only the first frame */
|
||||
if ((png_ptr->apng_flags & PNG_APNG_APP) == 0 &&
|
||||
png_ptr->num_frames_read > 0)
|
||||
if (!(png_ptr->apng_flags & PNG_APNG_APP) && png_ptr->num_frames_read > 0)
|
||||
{
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
return;
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -997,7 +993,7 @@ png_push_process_row(png_structrp png_ptr)
|
|||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations != 0)
|
||||
if (png_ptr->transformations)
|
||||
png_do_read_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
|
@ -1015,8 +1011,7 @@ png_push_process_row(png_structrp png_ptr)
|
|||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Expand interlaced rows to full size */
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
|
||||
|
@ -1223,7 +1218,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
|||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
if (png_ptr->interlaced != 0)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||
|
@ -1247,7 +1242,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
|||
png_pass_start[png_ptr->pass]) /
|
||||
png_pass_inc[png_ptr->pass];
|
||||
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
break;
|
||||
|
||||
png_ptr->num_rows = (png_ptr->height +
|
||||
|
@ -1331,4 +1326,4 @@ png_get_progressive_ptr(png_const_structrp png_ptr)
|
|||
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
*/
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __ARM_NEON__ */
|
||||
# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
|
||||
# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
|
||||
|
||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
||||
/* Use the intrinsics code by default. */
|
||||
|
@ -869,7 +869,7 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
|||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
* encoded value with maximum error 0.646365. Note that the input is not a
|
||||
* 16-bit value; it has been multiplied by 255! */
|
||||
#endif /* SIMPLIFIED_READ/WRITE */
|
||||
#endif /* PNG_SIMPLIFIED_READ/WRITE */
|
||||
|
||||
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
|
@ -1243,7 +1243,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
|
|||
PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
/* Finish a row while reading, dealing with interlacing passes, etc. */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
/* Initialize the row buffers, etc. */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||
|
@ -1319,7 +1319,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,
|
|||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* READ_iCCP */
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
|
||||
|
@ -1354,7 +1354,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,
|
|||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* READ_sPLT */
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
|
||||
|
@ -1468,7 +1468,7 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
|
|||
png_inforp info_ptr),PNG_EMPTY);
|
||||
# endif
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_APNG_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
|
||||
|
@ -1494,8 +1494,8 @@ PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr,
|
|||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),
|
||||
PNG_EMPTY);
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* READ_APNG */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
|
||||
|
@ -1510,8 +1510,8 @@ PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr,
|
|||
PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
|
||||
#endif /* WRITE_APNG */
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -44,7 +44,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
{
|
||||
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* USER_MEM */
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
|
@ -113,20 +113,20 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
*/
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_chunk_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_chunk_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
|
||||
else if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||
png_chunk_benign_error(png_ptr, "Too many IDATs found");
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
}
|
||||
|
||||
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||
else if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
/* This should be a binary subdivision search or a hash for
|
||||
|
@ -266,7 +266,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
}
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_APNG_SUPPORTED
|
||||
void PNGAPI
|
||||
|
@ -276,7 +276,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
png_debug(0, "Reading frame head");
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_acTL) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_acTL))
|
||||
png_error(png_ptr, "attempt to png_read_frame_head() but "
|
||||
"no acTL present");
|
||||
|
||||
|
@ -296,7 +296,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
|
|||
if (png_ptr->chunk_name == png_IDAT)
|
||||
{
|
||||
/* discard trailing IDATs for the first frame */
|
||||
if (have_chunk_after_DAT != 0 || png_ptr->num_frames_read > 1)
|
||||
if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
|
||||
png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
|
|||
png_ensure_sequence_number(png_ptr, length);
|
||||
|
||||
/* discard trailing fdATs for frames other than the first */
|
||||
if (have_chunk_after_DAT == 0 && png_ptr->num_frames_read > 1)
|
||||
if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
|
||||
png_crc_finish(png_ptr, length - 4);
|
||||
else if(png_ptr->mode & PNG_HAVE_fcTL)
|
||||
{
|
||||
|
@ -332,7 +332,7 @@ png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* READ_APNG */
|
||||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
/* Optional call to update the users info_ptr structure */
|
||||
void PNGAPI
|
||||
|
@ -382,7 +382,7 @@ png_start_read_image(png_structrp png_ptr)
|
|||
"png_start_read_image/png_read_update_info: duplicate call");
|
||||
}
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
|
@ -395,7 +395,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
png_debug(1, "in png_do_read_intrapixel");
|
||||
|
||||
if (
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -449,7 +449,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* MNG_FEATURES */
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
|
||||
void PNGAPI
|
||||
png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
|
@ -465,7 +465,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
/* png_read_start_row sets the information (in particular iwidth) for this
|
||||
* interlace pass.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
|
||||
/* 1.5.6: row_info moved out of png_struct to a local here. */
|
||||
|
@ -481,42 +481,42 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
{
|
||||
/* Check for transforms that have been set but were defined out */
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
|
||||
!defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* If interlaced and we do not need a new row, combine row and return.
|
||||
|
@ -525,8 +525,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
* untransformed) and, because of the libpng API for interlaced images, this
|
||||
* means we must transform before de-interlacing.
|
||||
*/
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
|
@ -597,7 +596,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
|
||||
default:
|
||||
case 6:
|
||||
if ((png_ptr->row_number & 1) == 0)
|
||||
if (!(png_ptr->row_number & 1))
|
||||
{
|
||||
png_read_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -607,7 +606,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
}
|
||||
#endif
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "Invalid attempt to read row data");
|
||||
|
||||
/* Fill the row with IDAT data: */
|
||||
|
@ -630,7 +629,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
|
@ -656,8 +655,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Expand interlaced rows to full size */
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->interlaced &&
|
||||
(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
if (png_ptr->pass < 6)
|
||||
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
|
||||
|
@ -685,7 +684,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read one or more rows of image data. If the image is interlaced,
|
||||
|
@ -752,7 +751,7 @@ png_read_rows(png_structrp png_ptr, png_bytepp row,
|
|||
dp++;
|
||||
}
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the entire image. If the image has an alpha channel or a tRNS
|
||||
|
@ -780,7 +779,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
|
|||
return;
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
{
|
||||
pass = png_set_interlace_handling(png_ptr);
|
||||
/* And make sure transforms are initialized. */
|
||||
|
@ -788,8 +787,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) == 0)
|
||||
if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
/* Caller called png_start_read_image or png_read_update_info without
|
||||
* first turning on the PNG_INTERLACE transform. We can fix this here,
|
||||
|
@ -826,7 +824,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
/* Read the end of the PNG file. Will not read past the end of the
|
||||
|
@ -849,7 +847,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
* still be pending IDAT data and an owned zstream. Deal with this here.
|
||||
*/
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0)
|
||||
if (!png_chunk_unknown_handling(png_ptr, png_IDAT))
|
||||
#endif
|
||||
png_read_finish_IDAT(png_ptr);
|
||||
|
||||
|
@ -879,8 +877,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
{
|
||||
if (chunk_name == png_IDAT)
|
||||
{
|
||||
if ((length > 0) ||
|
||||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
png_handle_unknown(png_ptr, info_ptr, length, keep);
|
||||
|
@ -894,8 +891,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
* read, but not after other chunks have been read.
|
||||
*/
|
||||
if ((length > 0) ||
|
||||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
@ -991,9 +987,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
} while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
|
||||
} while (!(png_ptr->mode & PNG_HAVE_IEND));
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
/* Free all memory used in the read struct */
|
||||
static void
|
||||
|
@ -1006,33 +1002,22 @@ png_read_destroy(png_structrp png_ptr)
|
|||
#endif
|
||||
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_ptr->big_row_buf = NULL;
|
||||
png_free(png_ptr, png_ptr->big_prev_row);
|
||||
png_ptr->big_prev_row = NULL;
|
||||
png_free(png_ptr, png_ptr->read_buffer);
|
||||
png_ptr->read_buffer = NULL;
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->palette_lookup);
|
||||
png_ptr->palette_lookup = NULL;
|
||||
png_free(png_ptr, png_ptr->quantize_index);
|
||||
png_ptr->quantize_index = NULL;
|
||||
#endif
|
||||
|
||||
if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
|
||||
{
|
||||
if (png_ptr->free_me & PNG_FREE_PLTE)
|
||||
png_zfree(png_ptr, png_ptr->palette);
|
||||
png_ptr->palette = NULL;
|
||||
}
|
||||
png_ptr->free_me &= ~PNG_FREE_PLTE;
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
|
||||
{
|
||||
if (png_ptr->free_me & PNG_FREE_TRNS)
|
||||
png_free(png_ptr, png_ptr->trans_alpha);
|
||||
png_ptr->trans_alpha = NULL;
|
||||
}
|
||||
png_ptr->free_me &= ~PNG_FREE_TRNS;
|
||||
#endif
|
||||
|
||||
|
@ -1040,18 +1025,15 @@ png_read_destroy(png_structrp png_ptr)
|
|||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->save_buffer);
|
||||
png_ptr->save_buffer = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list = NULL;
|
||||
#endif
|
||||
|
||||
/* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
|
||||
|
@ -1123,7 +1105,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Tell libpng to strip 16-bit/color files down to 8 bits per color.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SCALE_16) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SCALE_16)
|
||||
/* 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.
|
||||
*/
|
||||
|
@ -1137,7 +1119,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
* latter by doing SCALE first. This is ok and allows apps not to check for
|
||||
* which is supported to get the right answer.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_16) != 0)
|
||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
png_set_strip_16(png_ptr);
|
||||
#else
|
||||
|
@ -1147,7 +1129,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
/* Strip alpha bytes from the input data without combining with
|
||||
* the background (not recommended).
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_ALPHA) != 0)
|
||||
if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
png_set_strip_alpha(png_ptr);
|
||||
#else
|
||||
|
@ -1157,7 +1139,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
/* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
|
||||
* byte into separate bytes (useful for paletted and grayscale images).
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_PACKING) != 0)
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
png_set_packing(png_ptr);
|
||||
#else
|
||||
|
@ -1167,7 +1149,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
/* Change the order of packed pixels to least significant bit first
|
||||
* (not useful if you are using png_set_packing).
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
png_set_packswap(png_ptr);
|
||||
#else
|
||||
|
@ -1179,7 +1161,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
* Expand paletted or RGB images with transparency to full alpha
|
||||
* channels so the data will be available as RGBA quartets.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_EXPAND) != 0)
|
||||
if (transforms & PNG_TRANSFORM_EXPAND)
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
png_set_expand(png_ptr);
|
||||
#else
|
||||
|
@ -1191,7 +1173,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Invert monochrome files to have 0 as white and 1 as black
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||
png_set_invert_mono(png_ptr);
|
||||
#else
|
||||
|
@ -1202,16 +1184,16 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
* [0,65535] to the original [0,7] or [0,31], or whatever range the
|
||||
* colors were originally in:
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SHIFT)
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
|
||||
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
|
||||
|
||||
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
|
||||
if ((transforms & PNG_TRANSFORM_BGR) != 0)
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
#ifdef PNG_READ_BGR_SUPPORTED
|
||||
png_set_bgr(png_ptr);
|
||||
#else
|
||||
|
@ -1219,7 +1201,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#else
|
||||
|
@ -1227,7 +1209,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Swap bytes of 16-bit files to least significant byte first */
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
#ifdef PNG_READ_SWAP_SUPPORTED
|
||||
png_set_swap(png_ptr);
|
||||
#else
|
||||
|
@ -1236,7 +1218,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Added at libpng-1.2.41 */
|
||||
/* Invert the alpha channel from opacity to transparency */
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#else
|
||||
|
@ -1245,7 +1227,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Added at libpng-1.2.41 */
|
||||
/* Expand grayscale image to RGB */
|
||||
if ((transforms & PNG_TRANSFORM_GRAY_TO_RGB) != 0)
|
||||
if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
#else
|
||||
|
@ -1253,7 +1235,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Added at libpng-1.5.4 */
|
||||
if ((transforms & PNG_TRANSFORM_EXPAND_16) != 0)
|
||||
if (transforms & PNG_TRANSFORM_EXPAND_16)
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
png_set_expand_16(png_ptr);
|
||||
#else
|
||||
|
@ -1301,8 +1283,8 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
PNG_UNUSED(params)
|
||||
}
|
||||
#endif /* INFO_IMAGE */
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
||||
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
/* SIMPLIFIED READ
|
||||
|
@ -1411,10 +1393,10 @@ png_image_format(png_structrp png_ptr)
|
|||
{
|
||||
png_uint_32 format = 0;
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
format |= PNG_FORMAT_FLAG_COLOR;
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
format |= PNG_FORMAT_FLAG_ALPHA;
|
||||
|
||||
/* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS
|
||||
|
@ -1428,7 +1410,7 @@ png_image_format(png_structrp png_ptr)
|
|||
if (png_ptr->bit_depth == 16)
|
||||
format |= PNG_FORMAT_FLAG_LINEAR;
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0)
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_PALETTE)
|
||||
format |= PNG_FORMAT_FLAG_COLORMAP;
|
||||
|
||||
return format;
|
||||
|
@ -1528,7 +1510,7 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file)
|
|||
{
|
||||
if (file != NULL)
|
||||
{
|
||||
if (png_image_read_init(image) != 0)
|
||||
if (png_image_read_init(image))
|
||||
{
|
||||
/* This is slightly evil, but png_init_io doesn't do anything other
|
||||
* than this and we haven't changed the standard IO functions so
|
||||
|
@ -1562,7 +1544,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
|
|||
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (png_image_read_init(image) != 0)
|
||||
if (png_image_read_init(image))
|
||||
{
|
||||
image->opaque->png_ptr->io_ptr = fp;
|
||||
image->opaque->owned_file = 1;
|
||||
|
@ -1588,7 +1570,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* STDIO */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
|
||||
static void PNGCBAPI
|
||||
png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
|
||||
|
@ -1627,7 +1609,7 @@ int PNGAPI png_image_begin_read_from_memory(png_imagep image,
|
|||
{
|
||||
if (memory != NULL && size > 0)
|
||||
{
|
||||
if (png_image_read_init(image) != 0)
|
||||
if (png_image_read_init(image))
|
||||
{
|
||||
/* Now set the IO functions to read from the memory buffer and
|
||||
* store it into io_ptr. Again do this in-place to avoid calling a
|
||||
|
@ -1699,14 +1681,14 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
|||
|
||||
/* But do not ignore image data handling chunks */
|
||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
|
||||
chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
|
||||
chunks_to_process, (sizeof chunks_to_process)/5);
|
||||
}
|
||||
}
|
||||
|
||||
# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)
|
||||
#else
|
||||
# define PNG_SKIP_CHUNKS(p) ((void)0)
|
||||
#endif /* HANDLE_AS_UNKNOWN */
|
||||
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||
|
||||
/* The following macro gives the exact rounded answer for all values in the
|
||||
* range 0..255 (it actually divides by 51.2, but the rounding still generates
|
||||
|
@ -1719,9 +1701,9 @@ static void
|
|||
set_file_encoding(png_image_read_control *display)
|
||||
{
|
||||
png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
|
||||
if (png_gamma_significant(g) != 0)
|
||||
if (png_gamma_significant(g))
|
||||
{
|
||||
if (png_gamma_not_sRGB(g) != 0)
|
||||
if (png_gamma_not_sRGB(g))
|
||||
{
|
||||
display->file_encoding = P_FILE;
|
||||
display->gamma_to_linear = png_reciprocal(g);
|
||||
|
@ -1816,7 +1798,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||
png_uint_32 alpha, int encoding)
|
||||
{
|
||||
png_imagep image = display->image;
|
||||
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ?
|
||||
P_LINEAR : P_sRGB;
|
||||
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(red != green || green != blue);
|
||||
|
@ -1846,7 +1828,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||
green = png_gamma_16bit_correct(green*257, g);
|
||||
blue = png_gamma_16bit_correct(blue*257, g);
|
||||
|
||||
if (convert_to_Y != 0 || output_encoding == P_LINEAR)
|
||||
if (convert_to_Y || output_encoding == P_LINEAR)
|
||||
{
|
||||
alpha *= 257;
|
||||
encoding = P_LINEAR;
|
||||
|
@ -1873,8 +1855,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||
encoding = P_LINEAR;
|
||||
}
|
||||
|
||||
else if (encoding == P_sRGB &&
|
||||
(convert_to_Y != 0 || output_encoding == P_LINEAR))
|
||||
else if (encoding == P_sRGB && (convert_to_Y || output_encoding == P_LINEAR))
|
||||
{
|
||||
/* The values are 8-bit sRGB values, but must be converted to 16-bit
|
||||
* linear.
|
||||
|
@ -1932,7 +1913,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||
# define afirst 0
|
||||
# endif
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
|
@ -2144,7 +2125,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
|
||||
const png_structrp png_ptr = image->opaque->png_ptr;
|
||||
const png_uint_32 output_format = image->format;
|
||||
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ?
|
||||
P_LINEAR : P_sRGB;
|
||||
|
||||
unsigned int cmap_entries;
|
||||
|
@ -2183,7 +2164,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
else
|
||||
{
|
||||
back_g = display->background->green;
|
||||
if ((output_format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
if (output_format & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
back_r = display->background->red;
|
||||
back_b = display->background->blue;
|
||||
|
@ -2325,7 +2306,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
{
|
||||
unsigned int back_alpha;
|
||||
|
||||
if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (output_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
back_alpha = 0;
|
||||
|
||||
else
|
||||
|
@ -2406,7 +2387,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
*/
|
||||
data_encoding = P_sRGB;
|
||||
|
||||
if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (output_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "gray+alpha color-map: too few entries");
|
||||
|
@ -2601,7 +2582,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
*/
|
||||
if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
png_ptr->num_trans > 0) &&
|
||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
|
||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma))
|
||||
{
|
||||
cmap_entries = make_gray_file_colormap(display);
|
||||
data_encoding = P_FILE;
|
||||
|
@ -2689,7 +2670,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
/* Is there alpha in the output too? If so all four channels are
|
||||
* processed into a special RGB cube with alpha support.
|
||||
*/
|
||||
if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (output_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
png_uint_32 r;
|
||||
|
||||
|
@ -2863,7 +2844,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
|
||||
for (i=0; i < cmap_entries; ++i)
|
||||
{
|
||||
if (do_background != 0 && i < num_trans && trans[i] < 255)
|
||||
if (do_background && i < num_trans && trans[i] < 255)
|
||||
{
|
||||
if (trans[i] == 0)
|
||||
png_create_colormap_entry(display, i, back_r, back_g,
|
||||
|
@ -2908,8 +2889,8 @@ png_image_read_colormap(png_voidp argument)
|
|||
}
|
||||
|
||||
/* Now deal with the output processing */
|
||||
if (expand_tRNS != 0 && png_ptr->num_trans > 0 &&
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)
|
||||
if (expand_tRNS && png_ptr->num_trans > 0 &&
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)
|
||||
png_set_tRNS_to_alpha(png_ptr);
|
||||
|
||||
switch (data_encoding)
|
||||
|
@ -3325,8 +3306,7 @@ png_image_read_composite(png_voidp argument)
|
|||
png_uint_32 height = image->height;
|
||||
png_uint_32 width = image->width;
|
||||
ptrdiff_t step_row = display->row_bytes;
|
||||
unsigned int channels =
|
||||
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
int pass;
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
|
@ -3624,8 +3604,7 @@ png_image_read_background(png_voidp argument)
|
|||
int swap_alpha = 0;
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
if (preserve_alpha != 0 &&
|
||||
(image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST))
|
||||
swap_alpha = 1;
|
||||
# endif
|
||||
|
||||
|
@ -3734,10 +3713,10 @@ png_image_read_direct(png_voidp argument)
|
|||
int mode; /* alpha mode */
|
||||
|
||||
/* Do this first so that we have a record if rgb to gray is happening. */
|
||||
if ((change & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
if (change & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
/* gray<->color transformation required. */
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
|
||||
else
|
||||
|
@ -3755,7 +3734,7 @@ png_image_read_direct(png_voidp argument)
|
|||
* enormous change) 'do_local_background' is used to indicate that
|
||||
* the problem exists.
|
||||
*/
|
||||
if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (base_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
do_local_background = 1/*maybe*/;
|
||||
|
||||
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
|
||||
|
@ -3770,8 +3749,8 @@ png_image_read_direct(png_voidp argument)
|
|||
{
|
||||
png_fixed_point input_gamma_default;
|
||||
|
||||
if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
if ((base_format & PNG_FORMAT_FLAG_LINEAR) &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
input_gamma_default = PNG_GAMMA_LINEAR;
|
||||
else
|
||||
input_gamma_default = PNG_DEFAULT_sRGB;
|
||||
|
@ -3787,7 +3766,7 @@ png_image_read_direct(png_voidp argument)
|
|||
/* If there *is* an alpha channel in the input it must be multiplied
|
||||
* out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG.
|
||||
*/
|
||||
if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (base_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
mode = PNG_ALPHA_STANDARD; /* associated alpha */
|
||||
|
||||
else
|
||||
|
@ -3818,7 +3797,7 @@ png_image_read_direct(png_voidp argument)
|
|||
* final value.
|
||||
*/
|
||||
if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma,
|
||||
PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
|
||||
PNG_FP_1) && !png_gamma_significant(gtest))
|
||||
do_local_background = 0;
|
||||
|
||||
else if (mode == PNG_ALPHA_STANDARD)
|
||||
|
@ -3831,9 +3810,9 @@ png_image_read_direct(png_voidp argument)
|
|||
}
|
||||
|
||||
/* If the bit-depth changes then handle that here. */
|
||||
if ((change & PNG_FORMAT_FLAG_LINEAR) != 0)
|
||||
if (change & PNG_FORMAT_FLAG_LINEAR)
|
||||
{
|
||||
if (linear != 0 /*16-bit output*/)
|
||||
if (linear /*16-bit output*/)
|
||||
png_set_expand_16(png_ptr);
|
||||
|
||||
else /* 8-bit output */
|
||||
|
@ -3843,13 +3822,13 @@ png_image_read_direct(png_voidp argument)
|
|||
}
|
||||
|
||||
/* Now the background/alpha channel changes. */
|
||||
if ((change & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (change & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
/* Removing an alpha channel requires composition for the 8-bit
|
||||
* formats; for the 16-bit it is already done, above, by the
|
||||
* pre-multiplication and the channel just needs to be stripped.
|
||||
*/
|
||||
if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (base_format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
/* If RGB->gray is happening the alpha channel must be left and the
|
||||
* operation completed locally.
|
||||
|
@ -3914,7 +3893,7 @@ png_image_read_direct(png_voidp argument)
|
|||
filler = 255;
|
||||
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
where = PNG_FILLER_BEFORE;
|
||||
change &= ~PNG_FORMAT_FLAG_AFIRST;
|
||||
|
@ -3938,12 +3917,12 @@ png_image_read_direct(png_voidp argument)
|
|||
png_set_alpha_mode_fixed(png_ptr, mode, output_gamma);
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if ((change & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
if (change & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
/* Check only the output format; PNG is never BGR; don't do this if
|
||||
* the output is gray, but fix up the 'format' value in that case.
|
||||
*/
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
png_set_bgr(png_ptr);
|
||||
|
||||
else
|
||||
|
@ -3954,14 +3933,14 @@ png_image_read_direct(png_voidp argument)
|
|||
# endif
|
||||
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if ((change & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (change & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
/* Only relevant if there is an alpha channel - it's particularly
|
||||
* important to handle this correctly because do_local_compose may
|
||||
* be set above and then libpng will keep the alpha channel for this
|
||||
* code to remove.
|
||||
*/
|
||||
if ((format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
/* Disable this if doing a local background,
|
||||
* TODO: remove this when local background is no longer required.
|
||||
|
@ -3984,7 +3963,7 @@ png_image_read_direct(png_voidp argument)
|
|||
{
|
||||
PNG_CONST png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
if (*(png_const_bytep)&le)
|
||||
png_set_swap(png_ptr);
|
||||
}
|
||||
|
||||
|
@ -4009,10 +3988,10 @@ png_image_read_direct(png_voidp argument)
|
|||
{
|
||||
png_uint_32 info_format = 0;
|
||||
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
info_format |= PNG_FORMAT_FLAG_COLOR;
|
||||
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
/* do_local_compose removes this channel below. */
|
||||
if (do_local_compose == 0)
|
||||
|
@ -4031,14 +4010,14 @@ png_image_read_direct(png_voidp argument)
|
|||
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
info_format |= PNG_FORMAT_FLAG_BGR;
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (do_local_background == 2)
|
||||
{
|
||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
info_format |= PNG_FORMAT_FLAG_AFIRST;
|
||||
}
|
||||
|
||||
|
@ -4167,7 +4146,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||
/* Choose the correct 'end' routine; for the color-map case all the
|
||||
* setup has already been done.
|
||||
*/
|
||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
if (image->format & PNG_FORMAT_FLAG_COLORMAP)
|
||||
result =
|
||||
png_safe_execute(image, png_image_read_colormap, &display) &&
|
||||
png_safe_execute(image, png_image_read_colormapped, &display);
|
||||
|
@ -4197,5 +4176,5 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
#endif /* READ */
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -117,4 +117,4 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
|||
png_ptr->output_flush_fn = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif /* READ */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -91,15 +91,14 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
|||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
/* Is it OK to set a transformation now? Only if png_start_read_image or
|
||||
* png_read_update_info have not been called. It is not necessary for the IHDR
|
||||
* to have been read in all cases; the need_IHDR parameter allows for this
|
||||
* check too.
|
||||
* to have been read in all cases, the parameter allows for this check too.
|
||||
*/
|
||||
static int
|
||||
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||
png_app_error(png_ptr,
|
||||
"invalid after png_start_read_image or png_read_update_info");
|
||||
|
||||
|
@ -128,7 +127,7 @@ png_set_background_fixed(png_structrp png_ptr,
|
|||
{
|
||||
png_debug(1, "in png_set_background_fixed");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL)
|
||||
if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
|
||||
return;
|
||||
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
|
@ -172,7 +171,7 @@ png_set_scale_16(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_scale_16");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
|
@ -186,7 +185,7 @@ png_set_strip_16(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_strip_16");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
|
@ -199,7 +198,7 @@ png_set_strip_alpha(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_strip_alpha");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
|
@ -280,7 +279,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
|||
|
||||
png_debug(1, "in png_set_alpha_mode");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
|
@ -372,7 +371,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
|||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
png_error(png_ptr,
|
||||
"conflicting calls to set alpha mode and background");
|
||||
|
||||
|
@ -416,7 +415,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||
{
|
||||
png_debug(1, "in png_set_quantize");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_QUANTIZE;
|
||||
|
@ -794,7 +793,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||
png_free(png_ptr, distance);
|
||||
}
|
||||
}
|
||||
#endif /* READ_QUANTIZE */
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
|
@ -803,7 +802,7 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
|||
{
|
||||
png_debug(1, "in png_set_gamma_fixed");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
|
@ -843,7 +842,7 @@ png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)
|
|||
png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
|
||||
convert_gamma_value(png_ptr, file_gamma));
|
||||
}
|
||||
# endif /* FLOATING_POINT */
|
||||
# endif /* FLOATING_POINT_SUPPORTED */
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
|
@ -856,7 +855,7 @@ png_set_expand(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_expand");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
|
@ -886,7 +885,7 @@ png_set_palette_to_rgb(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_palette_to_rgb");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
|
@ -898,7 +897,7 @@ png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
|
@ -910,12 +909,12 @@ png_set_tRNS_to_alpha(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_tRNS_to_alpha");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
}
|
||||
#endif /* READ_EXPAND */
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise
|
||||
|
@ -926,7 +925,7 @@ png_set_expand_16(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_expand_16");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
|
@ -939,7 +938,7 @@ png_set_gray_to_rgb(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
return;
|
||||
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
|
@ -957,7 +956,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
|||
|
||||
/* Need the IHDR here because of the check on color_type below. */
|
||||
/* TODO: fix this */
|
||||
if (png_rtran_ok(png_ptr, 1) == 0)
|
||||
if (!png_rtran_ok(png_ptr, 1))
|
||||
return;
|
||||
|
||||
switch (error_action)
|
||||
|
@ -999,7 +998,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
|||
png_uint_16 red_int, green_int;
|
||||
|
||||
/* NOTE: this calculation does not round, but this behavior is retained
|
||||
* for consistency; the inaccuracy is very small. The code here always
|
||||
* for consistency, the inaccuracy is very small. The code here always
|
||||
* overwrites the coefficients, regardless of whether they have been
|
||||
* defaulted or set already.
|
||||
*/
|
||||
|
@ -1092,7 +1091,7 @@ png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
|
|||
* the palette.
|
||||
*/
|
||||
|
||||
/* For the moment 'png_init_palette_transformations' and
|
||||
/*For the moment 'png_init_palette_transformations' and
|
||||
* 'png_init_rgb_transformations' only do some flag canceling optimizations.
|
||||
* The intent is that these two routines should have palette or rgb operations
|
||||
* extracted from 'png_init_read_transformations'.
|
||||
|
@ -1154,8 +1153,8 @@ png_init_palette_transformations(png_structrp png_ptr)
|
|||
/* The following code cannot be entered in the alpha pre-multiplication case
|
||||
* because PNG_BACKGROUND_EXPAND is cancelled below.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND))
|
||||
{
|
||||
{
|
||||
png_ptr->background.red =
|
||||
|
@ -1166,9 +1165,9 @@ png_init_palette_transformations(png_structrp png_ptr)
|
|||
png_ptr->palette[png_ptr->background.index].blue;
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
{
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
{
|
||||
/* Invert the alpha channel (in tRNS) unless the pixels are
|
||||
* going to be expanded, in which case leave it for later
|
||||
|
@ -1180,10 +1179,10 @@ png_init_palette_transformations(png_structrp png_ptr)
|
|||
png_ptr->trans_alpha[i]);
|
||||
}
|
||||
}
|
||||
#endif /* READ_INVERT_ALPHA */
|
||||
#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */
|
||||
}
|
||||
} /* background expand and (therefore) no alpha association. */
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
|
@ -1221,9 +1220,9 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
|||
/* The following code cannot be entered in the alpha pre-multiplication case
|
||||
* because PNG_BACKGROUND_EXPAND is cancelled below.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) != 0 &&
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND) &&
|
||||
!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
/* i.e., GRAY or GRAY_ALPHA */
|
||||
{
|
||||
{
|
||||
|
@ -1261,14 +1260,14 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
|||
png_ptr->background.red = png_ptr->background.green =
|
||||
png_ptr->background.blue = (png_uint_16)gray;
|
||||
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
{
|
||||
png_ptr->trans_color.red = png_ptr->trans_color.green =
|
||||
png_ptr->trans_color.blue = (png_uint_16)trans_gray;
|
||||
}
|
||||
}
|
||||
} /* background expand and (therefore) no alpha association. */
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
|
@ -1346,7 +1345,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
#endif
|
||||
|
||||
/* Certain transformations have the effect of preventing other
|
||||
* transformations that happen afterward in png_do_read_transformations;
|
||||
* transformations that happen afterward in png_do_read_transformations,
|
||||
* resolve the interdependencies here. From the code of
|
||||
* png_do_read_transformations the order is:
|
||||
*
|
||||
|
@ -1375,8 +1374,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
* 23) PNG_USER_TRANSFORM [must be last]
|
||||
*/
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) == 0)
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
!(png_ptr->transformations & PNG_COMPOSE))
|
||||
{
|
||||
/* Stripping the alpha channel happens immediately after the 'expand'
|
||||
* transformations, before all other transformation, so it cancels out
|
||||
|
@ -1402,7 +1401,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
/* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA
|
||||
* settings will have no effect.
|
||||
*/
|
||||
if (png_gamma_significant(png_ptr->screen_gamma) == 0)
|
||||
if (!png_gamma_significant(png_ptr->screen_gamma))
|
||||
{
|
||||
png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
|
||||
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
|
||||
|
@ -1413,7 +1412,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
/* Make sure the coefficients for the rgb to gray conversion are set
|
||||
* appropriately.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||
#endif
|
||||
|
||||
|
@ -1434,23 +1433,23 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
* png_set_background, along with the bit depth, then the code has a record
|
||||
* of exactly what color space the background is currently in.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
{
|
||||
/* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
|
||||
* the file was grayscale the background value is gray.
|
||||
*/
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
||||
}
|
||||
|
||||
else if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
else if (png_ptr->transformations & PNG_COMPOSE)
|
||||
{
|
||||
/* PNG_COMPOSE: png_set_background was called with need_expand false,
|
||||
* so the color is in the color space of the output or png_set_alpha_mode
|
||||
* was called and the color is black. Ignore RGB_TO_GRAY because that
|
||||
* happens before GRAY_TO_RGB.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
{
|
||||
if (png_ptr->background.red == png_ptr->background.green &&
|
||||
png_ptr->background.red == png_ptr->background.blue)
|
||||
|
@ -1460,8 +1459,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
#endif /* READ_GRAY_TO_RGB */
|
||||
#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
|
||||
#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
|
||||
|
||||
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
|
||||
* can be performed directly on the palette, and some (such as rgb to gray)
|
||||
|
@ -1482,10 +1481,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_READ_EXPAND_16_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
|
||||
png_ptr->bit_depth != 16)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
png_ptr->bit_depth != 16)
|
||||
{
|
||||
/* TODO: fix this. Because the expand_16 operation is after the compose
|
||||
* handling the background color must be 8, not 16, bits deep, but the
|
||||
|
@ -1504,15 +1503,15 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
CHOP(png_ptr->background.gray);
|
||||
# undef CHOP
|
||||
}
|
||||
#endif /* READ_BACKGROUND && READ_EXPAND_16 */
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
(defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
|
||||
png_ptr->bit_depth == 16)
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
png_ptr->bit_depth == 16)
|
||||
{
|
||||
/* On the other hand, if a 16-bit file is to be reduced to 8-bits per
|
||||
* component this will also happen after PNG_COMPOSE and so the background
|
||||
|
@ -1555,24 +1554,25 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
* file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
|
||||
* tables.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
|
||||
((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
|
||||
((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0
|
||||
if ((png_ptr->transformations & PNG_GAMMA)
|
||||
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma) ||
|
||||
png_gamma_significant(png_ptr->screen_gamma)))
|
||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma)
|
||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
|
||||
png_gamma_significant(png_ptr->background_gamma) != 0)
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||
&& png_gamma_significant(png_ptr->background_gamma))
|
||||
# endif
|
||||
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0))
|
||||
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
|
||||
&& png_gamma_significant(png_ptr->screen_gamma))
|
||||
)
|
||||
{
|
||||
png_build_gamma_table(png_ptr, png_ptr->bit_depth);
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
{
|
||||
/* Issue a warning about this combination: because RGB_TO_GRAY is
|
||||
* optimized to do the gamma transform if present yet do_background has
|
||||
|
@ -1580,11 +1580,11 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
* double-gamma-correction happens. This is true in all versions of
|
||||
* libpng to date.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
png_warning(png_ptr,
|
||||
"libpng does not support gamma+background+rgb_to_gray");
|
||||
|
||||
if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
/* We don't get to here unless there is a tRNS chunk with non-opaque
|
||||
* entries - see the checking code at the start of this function.
|
||||
|
@ -1632,7 +1632,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
break;
|
||||
}
|
||||
|
||||
if (png_gamma_significant(gs) != 0)
|
||||
if (png_gamma_significant(gs))
|
||||
{
|
||||
back.red = png_gamma_8bit_correct(png_ptr->background.red,
|
||||
gs);
|
||||
|
@ -1649,7 +1649,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
back.blue = (png_byte)png_ptr->background.blue;
|
||||
}
|
||||
|
||||
if (png_gamma_significant(g) != 0)
|
||||
if (png_gamma_significant(g))
|
||||
{
|
||||
back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
|
||||
g);
|
||||
|
@ -1798,7 +1798,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
|
||||
else
|
||||
/* Transformation does not include PNG_BACKGROUND */
|
||||
#endif /* READ_BACKGROUND */
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* RGB_TO_GRAY needs to have non-gamma-corrected values! */
|
||||
|
@ -1828,11 +1828,11 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
else
|
||||
#endif
|
||||
#endif /* READ_GAMMA */
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* No GAMMA transformation (see the hanging else 4 lines above) */
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
|
@ -1867,11 +1867,11 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
|
||||
png_ptr->transformations &= ~PNG_COMPOSE;
|
||||
}
|
||||
#endif /* READ_BACKGROUND */
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) == 0 &&
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
!(png_ptr->transformations & PNG_EXPAND) &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
|
@ -1913,7 +1913,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
|||
png_ptr->palette[i].blue = (png_byte)component;
|
||||
}
|
||||
}
|
||||
#endif /* READ_SHIFT */
|
||||
#endif /* PNG_READ_SHIFT_SUPPORTED */
|
||||
}
|
||||
|
||||
/* Modify the info structure to reflect the transformations. The
|
||||
|
@ -1926,7 +1926,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
png_debug(1, "in png_read_transform_info");
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
if (png_ptr->transformations & PNG_EXPAND)
|
||||
{
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
|
@ -1948,9 +1948,9 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->num_trans != 0)
|
||||
if (png_ptr->num_trans)
|
||||
{
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
|
||||
if (png_ptr->transformations & PNG_EXPAND_tRNS)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
if (info_ptr->bit_depth < 8)
|
||||
|
@ -1966,7 +1966,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
/* The following is almost certainly wrong unless the background value is in
|
||||
* the screen space!
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
info_ptr->background = png_ptr->background;
|
||||
#endif
|
||||
|
||||
|
@ -1987,12 +1987,12 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
{
|
||||
# ifdef PNG_READ_16BIT_SUPPORTED
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) != 0)
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
|
@ -2018,27 +2018,27 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
CONFIGURATION ERROR: you must enable at least one 16 to 8 method
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !READ_16BIT */
|
||||
#endif /* !READ_16BIT_SUPPORTED */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type |
|
||||
PNG_COLOR_MASK_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
{
|
||||
if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
|
||||
png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8)
|
||||
png_ptr->palette_lookup && info_ptr->bit_depth == 8)
|
||||
{
|
||||
info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
|
||||
}
|
||||
|
@ -2046,31 +2046,29 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
|
||||
info_ptr->bit_depth == 8 &&
|
||||
info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
|
||||
info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
info_ptr->bit_depth = 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0 &&
|
||||
(info_ptr->bit_depth < 8))
|
||||
if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info_ptr->channels = 1;
|
||||
|
||||
else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
info_ptr->channels = 3;
|
||||
|
||||
else
|
||||
info_ptr->channels = 1;
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_STRIP_ALPHA)
|
||||
{
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA);
|
||||
|
@ -2078,25 +2076,25 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||
}
|
||||
#endif
|
||||
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info_ptr->channels++;
|
||||
|
||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0 &&
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
|
||||
if ((png_ptr->transformations & PNG_FILLER) &&
|
||||
((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
|
||||
{
|
||||
info_ptr->channels++;
|
||||
/* If adding a true alpha channel not just filler */
|
||||
if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_ADD_ALPHA)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
info_ptr->bit_depth = png_ptr->user_transform_depth;
|
||||
|
@ -2247,7 +2245,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
|||
int channels = 0;
|
||||
int bit_depth = row_info->bit_depth;
|
||||
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
shift[channels++] = bit_depth - sig_bits->red;
|
||||
shift[channels++] = bit_depth - sig_bits->green;
|
||||
|
@ -2259,7 +2257,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
|||
shift[channels++] = bit_depth - sig_bits->gray;
|
||||
}
|
||||
|
||||
if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
shift[channels++] = bit_depth - sig_bits->alpha;
|
||||
}
|
||||
|
@ -2673,7 +2671,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This changes the data from G to GX */
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
|
@ -2708,7 +2706,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This changes the data from GG to GGXX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 2;
|
||||
|
@ -2750,7 +2748,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This changes the data from RGB to RGBX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 3;
|
||||
|
@ -2789,7 +2787,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This changes the data from RRGGBB to RRGGBBXX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 6;
|
||||
|
@ -2850,7 +2848,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
|||
png_debug(1, "in png_do_gray_to_rgb");
|
||||
|
||||
if (row_info->bit_depth >= 8 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
!(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
|
@ -2988,8 +2986,8 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
|
||||
png_debug(1, "in png_do_rgb_to_gray");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
|
@ -3088,15 +3086,15 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red == green && red == blue)
|
||||
{
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
w = png_ptr->gamma_16_table[(red & 0xff)
|
||||
>> png_ptr->gamma_shift][red >> 8];
|
||||
w = png_ptr->gamma_16_table[(red&0xff)
|
||||
>> png_ptr->gamma_shift][red>>8];
|
||||
|
||||
else
|
||||
w = red;
|
||||
|
@ -3139,9 +3137,9 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
@ -3152,7 +3150,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
*/
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
|
||||
15);
|
||||
*(dp++) = (png_byte)((gray16 >> 8) & 0xff);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
|
||||
if (have_alpha != 0)
|
||||
|
@ -3912,7 +3910,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE */
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* Gamma correct the image, avoiding the alpha channel. Make sure
|
||||
|
@ -4129,7 +4127,7 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
|
||||
png_debug(1, "in png_do_encode_alpha");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
|
@ -4355,7 +4353,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
unsigned int gray = trans_color != NULL ? trans_color->gray : 0;
|
||||
unsigned int gray = trans_color ? trans_color->gray : 0;
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
|
@ -4499,8 +4497,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
row_width);
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
trans_color != NULL)
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
|
@ -4691,7 +4688,7 @@ png_do_quantize(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* READ_QUANTIZE */
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
|
||||
/* Transform the row. The order of transformations is significant,
|
||||
* and is very touchy. If you add a transformation, take care to
|
||||
|
@ -4718,7 +4715,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
* demand, if necessary.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
{
|
||||
/* Application has failed to call either png_read_start_image() or
|
||||
* png_read_update_info() after setting transforms that expand pixels.
|
||||
|
@ -4728,7 +4725,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
}
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
if (png_ptr->transformations & PNG_EXPAND)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
|
@ -4738,8 +4735,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
|
||||
else
|
||||
{
|
||||
if (png_ptr->num_trans != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
|
||||
if (png_ptr->num_trans &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
png_do_expand(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->trans_color));
|
||||
|
||||
|
@ -4751,16 +4748,16 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) == 0 &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
!(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
{
|
||||
int rgb_error =
|
||||
png_do_rgb_to_gray(png_ptr, row_info,
|
||||
|
@ -4815,22 +4812,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* If gray -> RGB, do so now only if background is non-gray; else do later
|
||||
* for performance reasons
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
!(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GAMMA) != 0 &&
|
||||
if ((png_ptr->transformations & PNG_GAMMA) &&
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Because RGB_TO_GRAY does the gamma transform. */
|
||||
(png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 &&
|
||||
!(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
|
@ -4839,7 +4836,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
*/
|
||||
!((png_ptr->transformations & PNG_COMPOSE) &&
|
||||
((png_ptr->num_trans != 0) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
|
||||
#endif
|
||||
/* Because png_init_read_transformations transforms the palette, unless
|
||||
* RGB_TO_GRAY will do the transform.
|
||||
|
@ -4849,22 +4846,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA))
|
||||
png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
|
@ -4873,12 +4870,12 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
* by putting the 'scale' option first if the app asks for scale (either by
|
||||
* calling the API or in a TRANSFORM flag) this is what happens.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) != 0)
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_do_chop(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
{
|
||||
png_do_quantize(row_info, png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->quantize_index);
|
||||
|
@ -4886,7 +4883,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
if (row_info->rowbytes == 0)
|
||||
png_error(png_ptr, "png_do_quantize returned rowbytes=0");
|
||||
}
|
||||
#endif /* READ_QUANTIZE */
|
||||
#endif /* PNG_READ_QUANTIZE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
/* Do the expansion now, after all the arithmetic has been done. Notice
|
||||
|
@ -4894,35 +4891,35 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
* is efficient (particularly true in the case of gamma correction, where
|
||||
* better accuracy results faster!)
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
|
||||
if (png_ptr->transformations & PNG_EXPAND_16)
|
||||
png_do_expand_16(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
/* NOTE: moved here in 1.5.4 (from much later in this list.) */
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
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
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_unshift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_unpack(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
|
@ -4934,36 +4931,36 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_read_filler(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->filler, png_ptr->flags);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
#ifdef PNG_READ_SWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if (png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* User read transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
|
@ -4976,10 +4973,10 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
if (png_ptr->user_transform_depth != 0)
|
||||
if (png_ptr->user_transform_depth)
|
||||
row_info->bit_depth = png_ptr->user_transform_depth;
|
||||
|
||||
if (png_ptr->user_transform_channels != 0)
|
||||
if (png_ptr->user_transform_channels)
|
||||
row_info->channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth *
|
||||
|
@ -4990,5 +4987,5 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* READ_TRANSFORMS */
|
||||
#endif /* READ */
|
||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -59,7 +59,7 @@ png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
xy.whitey = white_y;
|
||||
|
||||
if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
|
||||
2/* override with app values*/) != 0)
|
||||
2/* override with app values*/))
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
@ -90,8 +90,7 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
XYZ.blue_Y = int_blue_Y;
|
||||
XYZ.blue_Z = int_blue_Z;
|
||||
|
||||
if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
|
||||
&XYZ, 2) != 0)
|
||||
if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2))
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
@ -130,9 +129,9 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
|||
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
|
||||
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
|
||||
}
|
||||
# endif /* FLOATING_POINT */
|
||||
# endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||
|
||||
#endif /* cHRM */
|
||||
#endif /* PNG_cHRM_SUPPORTED */
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
void PNGFAPI
|
||||
|
@ -228,13 +227,13 @@ png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info_ptr->channels = 1;
|
||||
|
||||
else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
info_ptr->channels = 3;
|
||||
|
||||
else
|
||||
info_ptr->channels = 1;
|
||||
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info_ptr->channels++;
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
|
@ -294,14 +293,12 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Validate params[nparams] */
|
||||
for (i=0; i<nparams; ++i)
|
||||
{
|
||||
if (params[i] == NULL ||
|
||||
!png_check_fp_string(params[i], strlen(params[i])))
|
||||
!png_check_fp_string(params[i], strlen(params[i])))
|
||||
png_error(png_ptr, "Invalid format for pCAL parameter");
|
||||
}
|
||||
|
||||
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
|
@ -602,8 +599,7 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
|
||||
srgb_intent) != 0)
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent))
|
||||
{
|
||||
/* This causes the gAMA and cHRM to be written too */
|
||||
info_ptr->colorspace.flags |=
|
||||
|
@ -670,7 +666,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
png_free(png_ptr, new_iccp_name);
|
||||
new_iccp_name = NULL;
|
||||
png_benign_error(png_ptr,
|
||||
"Insufficient memory to process iCCP profile");
|
||||
return;
|
||||
|
@ -900,7 +895,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
png_debug1(1, "in %s storage function", "tIME");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
|
||||
(png_ptr->mode & PNG_WROTE_tIME) != 0)
|
||||
(png_ptr->mode & PNG_WROTE_tIME))
|
||||
return;
|
||||
|
||||
if (mod_time->month == 0 || mod_time->month > 12 ||
|
||||
|
@ -1051,7 +1046,6 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||
if (np->entries == NULL)
|
||||
{
|
||||
png_free(png_ptr, np->name);
|
||||
np->name = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1074,7 +1068,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||
if (nentries > 0)
|
||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||
}
|
||||
#endif /* sPLT */
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_APNG_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
|
@ -1141,8 +1135,8 @@ png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
if (blend_op == PNG_BLEND_OP_OVER)
|
||||
{
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0 &&
|
||||
png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == 0)
|
||||
if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) &&
|
||||
!(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
||||
{
|
||||
png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
|
||||
"and wasteful for opaque images, ignored");
|
||||
|
@ -1206,7 +1200,7 @@ png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
|
|||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (is_hidden != 0)
|
||||
if (is_hidden)
|
||||
png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
|
||||
else
|
||||
png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
|
||||
|
@ -1215,7 +1209,7 @@ png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
static png_byte
|
||||
|
@ -1227,7 +1221,7 @@ check_location(png_const_structrp png_ptr, int location)
|
|||
* change; previously the app had to use the
|
||||
* png_set_unknown_chunk_location API below for each chunk.
|
||||
*/
|
||||
if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
/* Write struct, so unknown chunks come from the app */
|
||||
png_app_warning(png_ptr,
|
||||
|
@ -1273,7 +1267,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
|||
*/
|
||||
# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
return;
|
||||
|
@ -1281,7 +1275,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
|||
# endif
|
||||
# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_WRITE_SUPPORTED)
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
return;
|
||||
|
@ -1367,7 +1361,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_app_error(png_ptr, "invalid unknown chunk location");
|
||||
/* Fake out the pre 1.6.0 behavior: */
|
||||
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
||||
if ((location & PNG_HAVE_IDAT)) /* undocumented! */
|
||||
location = PNG_AFTER_IDAT;
|
||||
|
||||
else
|
||||
|
@ -1405,13 +1399,10 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
|
|||
/* Utility function: update the 'keep' state of a chunk if it is already in
|
||||
* the list, otherwise add it to the list.
|
||||
*/
|
||||
for (i=0; i<count; ++i, list += 5)
|
||||
for (i=0; i<count; ++i, list += 5) if (memcmp(list, add, 4) == 0)
|
||||
{
|
||||
if (memcmp(list, add, 4) == 0)
|
||||
{
|
||||
list[4] = (png_byte)keep;
|
||||
return count;
|
||||
}
|
||||
list[4] = (png_byte)keep;
|
||||
return count;
|
||||
}
|
||||
|
||||
if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)
|
||||
|
@ -1475,7 +1466,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
};
|
||||
|
||||
chunk_list = chunks_to_ignore;
|
||||
num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
|
||||
num_chunks = (sizeof chunks_to_ignore)/5;
|
||||
}
|
||||
|
||||
else /* num_chunks_in > 0 */
|
||||
|
@ -1535,15 +1526,12 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
unsigned int i;
|
||||
|
||||
for (i=0; i<num_chunks; ++i)
|
||||
{
|
||||
old_num_chunks = add_one_chunk(new_list, old_num_chunks,
|
||||
chunk_list+5*i, keep);
|
||||
}
|
||||
|
||||
/* Now remove any spurious 'default' entries. */
|
||||
num_chunks = 0;
|
||||
for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)
|
||||
{
|
||||
if (inlist[4])
|
||||
{
|
||||
if (outlist != inlist)
|
||||
|
@ -1551,7 +1539,6 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
outlist += 5;
|
||||
++num_chunks;
|
||||
}
|
||||
}
|
||||
|
||||
/* This means the application has removed all the specialized handling. */
|
||||
if (num_chunks == 0)
|
||||
|
@ -1603,8 +1590,7 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (info_ptr->row_pointers != NULL &&
|
||||
(info_ptr->row_pointers != row_pointers))
|
||||
if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
|
@ -1624,7 +1610,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
|||
png_error(png_ptr, "invalid compression buffer size");
|
||||
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
|
||||
return;
|
||||
|
@ -1632,7 +1618,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
|||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
|
@ -1670,7 +1656,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
|||
void PNGAPI
|
||||
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
if (png_ptr && info_ptr)
|
||||
info_ptr->valid &= ~mask;
|
||||
}
|
||||
|
||||
|
@ -1708,7 +1694,7 @@ png_set_chunk_malloc_max (png_structrp png_ptr,
|
|||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
#endif /* ?SET_USER_LIMITS */
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
|
@ -1731,7 +1717,7 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
|
|||
png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
|
||||
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);
|
||||
}
|
||||
#endif /* BENIGN_ERRORS */
|
||||
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Whether to report invalid palette index; added at libng-1.5.10.
|
||||
|
@ -1754,4 +1740,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
|||
png_ptr->num_palette_max = -1;
|
||||
}
|
||||
#endif
|
||||
#endif /* READ || WRITE */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -274,7 +274,7 @@ struct png_struct_def
|
|||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* bKGD */
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
|
@ -331,7 +331,7 @@ struct png_struct_def
|
|||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
|
@ -428,7 +428,7 @@ struct png_struct_def
|
|||
png_uint_32 num_frames_to_write;
|
||||
png_uint_32 num_frames_written;
|
||||
#endif
|
||||
#endif /* APNG */
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
/* New members added in libpng-1.2.0 */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -100,7 +100,7 @@ png_set_interlace_handling(png_structrp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_interlace handling");
|
||||
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
if (png_ptr && png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
|
@ -127,7 +127,7 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
/* In libpng 1.6 it is possible to determine whether this is a read or write
|
||||
* operation and therefore to do more checking here for a valid call.
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
# ifdef PNG_READ_FILLER_SUPPORTED
|
||||
/* On read png_set_filler is always valid, regardless of the base PNG
|
||||
|
@ -210,7 +210,7 @@ png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
/* The above may fail to do anything. */
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
|||
*rp = table[*rp];
|
||||
}
|
||||
}
|
||||
#endif /* PACKSWAP || WRITE_PACKSWAP */
|
||||
#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
|
@ -605,7 +605,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_bgr");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
|
@ -675,7 +675,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* READ_BGR || WRITE_BGR */
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
|
@ -778,7 +778,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
|
@ -844,6 +844,7 @@ png_get_current_pass_number(png_const_structrp png_ptr)
|
|||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* USER_TRANSFORM_INFO */
|
||||
#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
|
||||
#endif /* READ || WRITE */
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -151,7 +151,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
|||
# endif
|
||||
#else
|
||||
PNG_UNUSED(output_flush_fn)
|
||||
#endif /* WRITE_FLUSH */
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
|
@ -165,4 +165,4 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* WRITE */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.14 [October 23, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -24,7 +24,7 @@ static void
|
|||
write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
unsigned int where)
|
||||
{
|
||||
if (info_ptr->unknown_chunks_num != 0)
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
png_const_unknown_chunkp up;
|
||||
|
||||
|
@ -33,7 +33,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
|||
for (up = info_ptr->unknown_chunks;
|
||||
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
|
||||
++up)
|
||||
if ((up->location & where) != 0)
|
||||
if (up->location & where)
|
||||
{
|
||||
/* If per-chunk unknown chunk handling is enabled use it, otherwise
|
||||
* just write the chunks the application has set.
|
||||
|
@ -69,7 +69,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_UNKNOWN_CHUNKS */
|
||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||
|
||||
/* Writes all the PNG information. This is the suggested way to use the
|
||||
* library. If you have a new chunk to add, make a function to write it,
|
||||
|
@ -88,14 +88,14 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
{
|
||||
/* Write PNG signature */
|
||||
png_write_sig(png_ptr);
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
|
||||
png_ptr->mng_features_permitted != 0)
|
||||
if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \
|
||||
(png_ptr->mng_features_permitted))
|
||||
{
|
||||
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
|
||||
png_ptr->mng_features_permitted = 0;
|
||||
|
@ -128,14 +128,14 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
* too.
|
||||
*/
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_acTL) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_acTL)
|
||||
png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
|
||||
#endif
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) &&
|
||||
(info_ptr->valid & PNG_INFO_gAMA))
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
|
||||
# endif
|
||||
#endif
|
||||
|
@ -145,11 +145,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
* and it matches one of the known sRGB ones issue a warning.
|
||||
*/
|
||||
# ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP) != 0)
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP))
|
||||
{
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_sRGB)
|
||||
png_app_warning(png_ptr,
|
||||
"profile matches sRGB but writing iCCP instead");
|
||||
# endif
|
||||
|
@ -163,22 +163,22 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB))
|
||||
png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
|
||||
# endif /* WRITE_sRGB */
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#ifdef PNG_WRITE_sBIT_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_sBIT)
|
||||
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
# ifdef PNG_WRITE_cHRM_SUPPORTED
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) &&
|
||||
(info_ptr->valid & PNG_INFO_cHRM))
|
||||
png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
|
||||
# endif
|
||||
#endif
|
||||
|
@ -205,19 +205,19 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
|
||||
png_write_info_before_PLTE(png_ptr, info_ptr);
|
||||
|
||||
if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_PLTE)
|
||||
png_write_PLTE(png_ptr, info_ptr->palette,
|
||||
(png_uint_32)info_ptr->num_palette);
|
||||
|
||||
else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
|
||||
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_error(png_ptr, "Valid palette required for paletted images");
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
|
||||
if (info_ptr->valid & PNG_INFO_tRNS)
|
||||
{
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
/* Invert the alpha channel (in tRNS) */
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
|
@ -231,42 +231,42 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
}
|
||||
#endif
|
||||
#ifdef PNG_WRITE_bKGD_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_bKGD)
|
||||
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_hIST) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_hIST)
|
||||
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_oFFs_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
|
||||
info_ptr->offset_unit_type);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_pCAL_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_pCAL)
|
||||
png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
|
||||
info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
|
||||
info_ptr->pcal_units, info_ptr->pcal_params);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_sCAL_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_sCAL)
|
||||
png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
|
||||
info_ptr->scal_s_width, info_ptr->scal_s_height);
|
||||
#endif /* sCAL */
|
||||
|
||||
#ifdef PNG_WRITE_pHYs_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
|
||||
info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
|
||||
#endif /* pHYs */
|
||||
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_tIME)
|
||||
{
|
||||
png_write_tIME(png_ptr, &(info_ptr->mod_time));
|
||||
png_ptr->mode |= PNG_WROTE_tIME;
|
||||
|
@ -274,7 +274,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||
#endif /* tIME */
|
||||
|
||||
#ifdef PNG_WRITE_sPLT_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
|
||||
if (info_ptr->valid & PNG_INFO_sPLT)
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
|
||||
#endif /* sPLT */
|
||||
|
@ -355,7 +355,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -376,8 +376,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
#endif
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
/* Check to see if user has supplied a time chunk */
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
|
||||
(png_ptr->mode & PNG_WROTE_tIME) == 0)
|
||||
if ((info_ptr->valid & PNG_INFO_tIME) &&
|
||||
!(png_ptr->mode & PNG_WROTE_tIME))
|
||||
png_write_tIME(png_ptr, &(info_ptr->mod_time));
|
||||
|
||||
#endif
|
||||
|
@ -506,7 +506,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
{
|
||||
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* USER_MEM */
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
|
@ -530,7 +530,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
|
@ -627,7 +627,7 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -680,10 +680,10 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
#endif /* MNG_FEATURES */
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
|
||||
/* Called by user to write a row of image data */
|
||||
void PNGAPI
|
||||
|
@ -702,44 +702,44 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
{
|
||||
/* Make sure we wrote the header info */
|
||||
if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
png_error(png_ptr,
|
||||
"png_write_info was never called before png_write_row");
|
||||
|
||||
/* Check for transforms that have been set but were defined out */
|
||||
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
|
||||
#endif
|
||||
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
|
||||
defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_warning(png_ptr,
|
||||
"PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
|
||||
#endif
|
||||
|
||||
|
@ -748,13 +748,12 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced and not interested in row, return */
|
||||
if (png_ptr->interlaced != 0 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
switch (png_ptr->pass)
|
||||
{
|
||||
case 0:
|
||||
if ((png_ptr->row_number & 0x07) != 0)
|
||||
if (png_ptr->row_number & 0x07)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -762,7 +761,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
break;
|
||||
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -778,7 +777,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
break;
|
||||
|
||||
case 3:
|
||||
if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
|
||||
if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -794,7 +793,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
break;
|
||||
|
||||
case 5:
|
||||
if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
|
||||
if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -802,7 +801,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
break;
|
||||
|
||||
case 6:
|
||||
if ((png_ptr->row_number & 0x01) == 0)
|
||||
if (!(png_ptr->row_number & 0x01))
|
||||
{
|
||||
png_write_finish_row(png_ptr);
|
||||
return;
|
||||
|
@ -836,7 +835,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Handle interlacing */
|
||||
if (png_ptr->interlaced && png_ptr->pass < 6 &&
|
||||
(png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
|
||||
/* This should always get caught above, but still ... */
|
||||
|
@ -850,7 +849,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Handle other transformations */
|
||||
if (png_ptr->transformations != 0)
|
||||
if (png_ptr->transformations)
|
||||
png_do_write_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
|
@ -871,7 +870,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
|||
* 4. The filter_method is 64 and
|
||||
* 5. The color_type is RGB or RGBA
|
||||
*/
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
|
@ -924,7 +923,7 @@ png_write_flush(png_structrp png_ptr)
|
|||
png_ptr->flush_rows = 0;
|
||||
png_flush(png_ptr);
|
||||
}
|
||||
#endif /* WRITE_FLUSH */
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
||||
|
@ -937,24 +936,18 @@ png_write_destroy(png_structrp png_ptr)
|
|||
png_debug(1, "in png_write_destroy");
|
||||
|
||||
/* Free any memory zlib uses */
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
deflateEnd(&png_ptr->zstream);
|
||||
|
||||
/* Free our memory. png_free checks NULL for us. */
|
||||
png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
|
||||
png_free(png_ptr, png_ptr->row_buf);
|
||||
png_ptr->row_buf = NULL;
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->sub_row);
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
png_free(png_ptr, png_ptr->avg_row);
|
||||
png_free(png_ptr, png_ptr->paeth_row);
|
||||
png_ptr->prev_row = NULL;
|
||||
png_ptr->sub_row = NULL;
|
||||
png_ptr->up_row = NULL;
|
||||
png_ptr->avg_row = NULL;
|
||||
png_ptr->paeth_row = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
|
@ -962,13 +955,10 @@ png_write_destroy(png_structrp png_ptr)
|
|||
png_reset_filter_heuristics(png_ptr);
|
||||
png_free(png_ptr, png_ptr->filter_costs);
|
||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
||||
png_ptr->filter_costs = NULL;
|
||||
png_ptr->inv_filter_costs = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list = NULL;
|
||||
#endif
|
||||
|
||||
/* The error handling and memory handling information is left intact at this
|
||||
|
@ -1014,7 +1004,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
return;
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(method == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
method = PNG_FILTER_TYPE_BASE;
|
||||
|
||||
|
@ -1028,7 +1018,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
case 6:
|
||||
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
/* FALL THROUGH */
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||
|
||||
|
@ -1050,7 +1040,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
#else
|
||||
default:
|
||||
png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
}
|
||||
|
||||
/* If we have allocated the row_buf, this means we have already started
|
||||
|
@ -1065,16 +1055,14 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
if (png_ptr->row_buf != NULL)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
|
||||
png_ptr->sub_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
|
||||
png_ptr->up_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
|
@ -1091,8 +1079,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
|
||||
png_ptr->avg_row == NULL)
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
|
@ -1109,7 +1096,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
|
||||
png_ptr->paeth_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
|
@ -1127,7 +1114,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
}
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -1270,7 +1257,7 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
|||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
|
@ -1325,7 +1312,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
|||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
||||
if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
|
||||
return;
|
||||
|
||||
/* If using the weighted method copy in the weights. */
|
||||
|
@ -1379,7 +1366,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
|||
}
|
||||
}
|
||||
#endif /* FIXED_POINT */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
|
||||
|
||||
void PNGAPI
|
||||
png_set_compression_level(png_structrp png_ptr, int level)
|
||||
|
@ -1536,7 +1523,7 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
|||
|
||||
png_ptr->zlib_text_method = method;
|
||||
}
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
|
||||
/* end of API added to libpng-1.5.4 */
|
||||
|
||||
void PNGAPI
|
||||
|
@ -1584,7 +1571,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
/* ------ these transformations don't touch the info structure ------- */
|
||||
|
||||
/* Invert monochrome pixels */
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
|
||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
png_set_invert_mono(png_ptr);
|
||||
#else
|
||||
|
@ -1594,16 +1581,16 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
/* Shift the pixels up to a legal bit depth and fill in
|
||||
* as appropriate to correctly scale the image.
|
||||
*/
|
||||
if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SHIFT)
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
|
||||
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
|
||||
|
||||
/* Pack pixels into bytes */
|
||||
if ((transforms & PNG_TRANSFORM_PACKING) != 0)
|
||||
if (transforms & PNG_TRANSFORM_PACKING)
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
png_set_packing(png_ptr);
|
||||
#else
|
||||
|
@ -1611,7 +1598,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Swap location of alpha bytes from ARGB to RGBA */
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
png_set_swap_alpha(png_ptr);
|
||||
#else
|
||||
|
@ -1622,13 +1609,13 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
* 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)) != 0)
|
||||
if (transforms &
|
||||
(PNG_TRANSFORM_STRIP_FILLER_AFTER|PNG_TRANSFORM_STRIP_FILLER_BEFORE))
|
||||
{
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
|
||||
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
|
||||
{
|
||||
if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
|
||||
if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
|
||||
png_app_error(png_ptr,
|
||||
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
|
||||
|
||||
|
@ -1636,7 +1623,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
|
||||
}
|
||||
|
||||
else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
|
||||
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");
|
||||
|
@ -1644,7 +1631,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
}
|
||||
|
||||
/* Flip BGR pixels to RGB */
|
||||
if ((transforms & PNG_TRANSFORM_BGR) != 0)
|
||||
if (transforms & PNG_TRANSFORM_BGR)
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
png_set_bgr(png_ptr);
|
||||
#else
|
||||
|
@ -1652,7 +1639,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Swap bytes of 16-bit files to most significant byte first */
|
||||
if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
|
||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
png_set_swap(png_ptr);
|
||||
#else
|
||||
|
@ -1660,7 +1647,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Swap bits of 1, 2, 4 bit packed pixel formats */
|
||||
if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
|
||||
if (transforms & PNG_TRANSFORM_PACKSWAP)
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
png_set_packswap(png_ptr);
|
||||
#else
|
||||
|
@ -1668,7 +1655,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
#endif
|
||||
|
||||
/* Invert the alpha channel from opacity to transparency */
|
||||
if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
png_set_invert_alpha(png_ptr);
|
||||
#else
|
||||
|
@ -1759,14 +1746,14 @@ png_write_image_16bit(png_voidp argument)
|
|||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (image->format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (image->format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
|
@ -1916,15 +1903,15 @@ png_write_image_8bit(png_voidp argument)
|
|||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
|
||||
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (image->format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
png_bytep row_end;
|
||||
int aindex;
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (image->format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
aindex = -1;
|
||||
++input_row; /* To point to the first component */
|
||||
|
@ -2021,7 +2008,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
# endif
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
|
@ -2038,13 +2025,13 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
/* This gets automatically converted to sRGB with reversal of the
|
||||
* pre-multiplication if the color-map has an alpha channel.
|
||||
*/
|
||||
if ((format & PNG_FORMAT_FLAG_LINEAR) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_LINEAR)
|
||||
{
|
||||
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
||||
|
||||
entry += i * channels;
|
||||
|
||||
if ((channels & 1) != 0) /* no alpha */
|
||||
if (channels & 1) /* no alpha */
|
||||
{
|
||||
if (channels >= 3) /* RGB */
|
||||
{
|
||||
|
@ -2156,11 +2143,10 @@ png_image_write_main(png_voidp argument)
|
|||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
png_uint_32 format = image->format;
|
||||
|
||||
/* The following four ints are actually booleans */
|
||||
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
|
||||
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
|
||||
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
|
||||
int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
|
||||
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP) != 0;
|
||||
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR) != 0; /* input */
|
||||
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
int write_16bit = linear && !colormap && !display->convert_to_8bit;
|
||||
|
||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
/* Make sure we error out on any bad situation */
|
||||
|
@ -2172,7 +2158,7 @@ png_image_write_main(png_voidp argument)
|
|||
display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
|
||||
|
||||
/* Set the required transforms then write the rows in the correct order. */
|
||||
if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_COLORMAP)
|
||||
{
|
||||
if (display->colormap != NULL && image->colormap_entries > 0)
|
||||
{
|
||||
|
@ -2209,7 +2195,7 @@ png_image_write_main(png_voidp argument)
|
|||
/* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);
|
||||
|
||||
if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
|
||||
if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
/* color x y */
|
||||
/* white */ 31270, 32900,
|
||||
|
@ -2219,7 +2205,7 @@ png_image_write_main(png_voidp argument)
|
|||
);
|
||||
}
|
||||
|
||||
else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
|
||||
else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
|
||||
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);
|
||||
|
||||
/* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit
|
||||
|
@ -2240,23 +2226,23 @@ png_image_write_main(png_voidp argument)
|
|||
{
|
||||
PNG_CONST png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
if (*(png_const_bytep)&le)
|
||||
png_set_swap(png_ptr);
|
||||
}
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
if ((format & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0)
|
||||
png_set_bgr(png_ptr);
|
||||
format &= ~PNG_FORMAT_FLAG_BGR;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
png_set_swap_alpha(png_ptr);
|
||||
format &= ~PNG_FORMAT_FLAG_AFIRST;
|
||||
}
|
||||
|
@ -2265,7 +2251,7 @@ png_image_write_main(png_voidp argument)
|
|||
/* If there are 16 or fewer color-map entries we wrote a lower bit depth
|
||||
* above, but the application data is still byte packed.
|
||||
*/
|
||||
if (colormap != 0 && image->colormap_entries <= 16)
|
||||
if (colormap && image->colormap_entries <= 16)
|
||||
png_set_packing(png_ptr);
|
||||
|
||||
/* That should have handled all (both) the transforms. */
|
||||
|
@ -2303,8 +2289,7 @@ png_image_write_main(png_voidp argument)
|
|||
* before it is written. This only applies when the input is 16-bit and
|
||||
* either there is an alpha channel or it is converted to 8-bit.
|
||||
*/
|
||||
if ((linear != 0 && alpha != 0 ) ||
|
||||
(colormap == 0 && display->convert_to_8bit != 0))
|
||||
if ((linear && alpha) || (!colormap && display->convert_to_8bit))
|
||||
{
|
||||
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
png_get_rowbytes(png_ptr, info_ptr)));
|
||||
|
@ -2353,7 +2338,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
|||
{
|
||||
if (file != NULL)
|
||||
{
|
||||
if (png_image_write_init(image) != 0)
|
||||
if (png_image_write_init(image))
|
||||
{
|
||||
png_image_write_control display;
|
||||
int result;
|
||||
|
@ -2408,7 +2393,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
|||
if (fp != NULL)
|
||||
{
|
||||
if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
|
||||
row_stride, colormap) != 0)
|
||||
row_stride, colormap))
|
||||
{
|
||||
int error; /* from fflush/fclose */
|
||||
|
||||
|
@ -2459,7 +2444,7 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
#endif /* STDIO */
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -2474,15 +2459,15 @@ png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
/* there is a chance this has been set after png_write_info was called,
|
||||
* so it would be set but not written. is there a way to be sure? */
|
||||
if ((info_ptr->valid & PNG_INFO_acTL) == 0)
|
||||
if (!(info_ptr->valid & PNG_INFO_acTL))
|
||||
png_error(png_ptr, "png_write_frame_head(): acTL not set");
|
||||
|
||||
png_write_reset(png_ptr);
|
||||
|
||||
png_write_reinit(png_ptr, info_ptr, width, height);
|
||||
|
||||
if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) == 0 ||
|
||||
png_ptr->num_frames_written != 0)
|
||||
if ( !(png_ptr->num_frames_written == 0 &&
|
||||
(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
|
||||
png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
|
||||
delay_num, delay_den, dispose_op, blend_op);
|
||||
|
||||
|
@ -2498,5 +2483,5 @@ png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
PNG_UNUSED(info_ptr)
|
||||
}
|
||||
#endif /* WRITE_APNG */
|
||||
#endif /* WRITE */
|
||||
#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.9 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
|||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
shift_dec[channels] = bit_depth->red;
|
||||
|
@ -199,7 +199,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
|||
channels++;
|
||||
}
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||
shift_dec[channels] = bit_depth->alpha;
|
||||
|
@ -353,7 +353,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
|
@ -392,7 +392,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
|
@ -487,7 +487,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
return;
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
|
@ -521,54 +521,52 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
# ifdef PNG_16BIT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
#endif /* WRITE */
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Last changed in libpng 1.6.14 [October 23, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -211,7 +211,7 @@ png_image_size(png_structrp png_ptr)
|
|||
|
||||
if (png_ptr->rowbytes < 32768 && h < 32768)
|
||||
{
|
||||
if (png_ptr->interlaced != 0)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
/* Interlacing makes the image larger because of the replication of
|
||||
* both the filter byte and the padding to a byte boundary.
|
||||
|
@ -286,7 +286,9 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_OPTIMIZE_CMF */
|
||||
#else
|
||||
# define optimize_cmf(dp,dl) ((void)0)
|
||||
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
|
||||
|
||||
/* Initialize the compressor for the appropriate type of compression. */
|
||||
static int
|
||||
|
@ -295,7 +297,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
# if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
char msg[64];
|
||||
|
||||
PNG_STRING_FROM_CHUNK(msg, owner);
|
||||
|
@ -307,8 +309,8 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
* are minimal.
|
||||
*/
|
||||
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
|
||||
#endif
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
# endif
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_warning(png_ptr, msg);
|
||||
|
||||
/* Attempt sane error recovery */
|
||||
|
@ -319,9 +321,9 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
}
|
||||
|
||||
png_ptr->zowner = 0;
|
||||
#else
|
||||
# else
|
||||
png_error(png_ptr, msg);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -334,7 +336,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
|
||||
if (owner == png_IDAT)
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)
|
||||
strategy = png_ptr->zlib_strategy;
|
||||
|
||||
else if (png_ptr->do_filter != PNG_FILTER_NONE)
|
||||
|
@ -346,20 +348,20 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
|
||||
else
|
||||
{
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
level = png_ptr->zlib_text_level;
|
||||
method = png_ptr->zlib_text_method;
|
||||
windowBits = png_ptr->zlib_text_window_bits;
|
||||
memLevel = png_ptr->zlib_text_mem_level;
|
||||
strategy = png_ptr->zlib_text_strategy;
|
||||
#else
|
||||
# else
|
||||
/* If customization is not supported the values all come from the
|
||||
* IDAT values except for the strategy, which is fixed to the
|
||||
* default. (This is the pre-1.6.0 behavior too, although it was
|
||||
* implemented in a very different way.)
|
||||
*/
|
||||
strategy = Z_DEFAULT_STRATEGY;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Adjust 'windowBits' down if larger than 'data_size'; to stop this
|
||||
|
@ -386,7 +388,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
}
|
||||
|
||||
/* Check against the previous initialized values, if any. */
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 &&
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) &&
|
||||
(png_ptr->zlib_set_level != level ||
|
||||
png_ptr->zlib_set_method != method ||
|
||||
png_ptr->zlib_set_window_bits != windowBits ||
|
||||
|
@ -410,7 +412,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
/* Now initialize if required, setting the new parameters, otherwise just
|
||||
* to a simple reset to the previous parameters.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
ret = deflateReset(&png_ptr->zstream);
|
||||
|
||||
else
|
||||
|
@ -617,10 +619,9 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
|
|||
*/
|
||||
if (ret == Z_STREAM_END && input_len == 0)
|
||||
{
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
/* Fix up the deflate header, if required */
|
||||
optimize_cmf(comp->output, comp->input_len);
|
||||
#endif
|
||||
|
||||
/* But Z_OK is returned, not Z_STREAM_END; this allows the claim
|
||||
* function above to return Z_STREAM_END on an error (though it never
|
||||
* does in the current versions of zlib.)
|
||||
|
@ -663,7 +664,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
|
|||
if (output_len > 0)
|
||||
png_error(png_ptr, "error writing ancillary chunked compressed data");
|
||||
}
|
||||
#endif /* WRITE_COMPRESSED_TEXT */
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
|
||||
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
|
||||
|
@ -716,7 +717,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||
bad_character = ch; /* just skip it, record the first error */
|
||||
}
|
||||
|
||||
if (key_len > 0 && space != 0) /* trailing space */
|
||||
if (key_len > 0 && space) /* trailing space */
|
||||
{
|
||||
--key_len, --new_key;
|
||||
if (bad_character == 0)
|
||||
|
@ -731,7 +732,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* Try to only output one warning per keyword: */
|
||||
if (*key != 0) /* keyword too long */
|
||||
if (*key) /* keyword too long */
|
||||
png_warning(png_ptr, "keyword truncated");
|
||||
|
||||
else if (bad_character != 0)
|
||||
|
@ -743,11 +744,11 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
#endif /* WRITE_TEXT || WRITE_pCAL || WRITE_iCCP || WRITE_sPLT */
|
||||
#endif
|
||||
|
||||
/* Write the IHDR chunk, and update the png_struct with the necessary
|
||||
* information. Note that the rest of this code depends upon this
|
||||
|
@ -848,8 +849,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||
*/
|
||||
if (
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
|
||||
((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
(color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
|
||||
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
|
||||
|
@ -935,7 +936,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
|||
|
||||
if ((
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
|
||||
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
|
||||
#endif
|
||||
num_pal == 0) || num_pal > 256)
|
||||
{
|
||||
|
@ -951,7 +952,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
|
|||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring request to write a PLTE chunk in grayscale PNG");
|
||||
|
@ -1078,20 +1079,20 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
|||
/* Write an IDAT containing the data then reset the buffer. The
|
||||
* first IDAT may need deflate header optimization.
|
||||
*/
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
if (png_ptr->num_frames_written == 0)
|
||||
#endif
|
||||
# endif
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
else
|
||||
png_write_fdAT(png_ptr, data, size);
|
||||
#endif /* WRITE_APNG */
|
||||
# endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
|
||||
|
@ -1132,20 +1133,20 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
|||
png_bytep data = png_ptr->zbuffer_list->output;
|
||||
uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;
|
||||
|
||||
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
#endif
|
||||
# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
|
||||
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
|
||||
optimize_cmf(data, png_image_size(png_ptr));
|
||||
# endif
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
if (png_ptr->num_frames_written == 0)
|
||||
#endif
|
||||
# endif
|
||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
# ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
else
|
||||
png_write_fdAT(png_ptr, data, size);
|
||||
#endif /* WRITE_APNG */
|
||||
# endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
|
||||
png_ptr->zstream.avail_out = 0;
|
||||
png_ptr->zstream.next_out = NULL;
|
||||
|
@ -1365,7 +1366,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
|
|||
png_debug(1, "in png_write_sBIT");
|
||||
|
||||
/* Make sure we don't depend upon the order of PNG_COLOR_8 */
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_byte maxbits;
|
||||
|
||||
|
@ -1398,7 +1399,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)
|
|||
size = 1;
|
||||
}
|
||||
|
||||
if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)
|
||||
{
|
||||
|
@ -1485,9 +1486,9 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
|||
png_save_uint_16(buf + 2, tran->green);
|
||||
png_save_uint_16(buf + 4, tran->blue);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
#else
|
||||
if ((buf[0] | buf[2] | buf[4]) != 0)
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
#endif
|
||||
{
|
||||
png_app_warning(png_ptr,
|
||||
|
@ -1518,8 +1519,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
|||
{
|
||||
if (
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
(png_ptr->num_palette != 0 ||
|
||||
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) &&
|
||||
(png_ptr->num_palette ||
|
||||
(!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
|
||||
#endif
|
||||
back->index >= png_ptr->num_palette)
|
||||
{
|
||||
|
@ -1531,15 +1532,15 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
|||
png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
|
||||
}
|
||||
|
||||
else if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
else if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_save_uint_16(buf, back->red);
|
||||
png_save_uint_16(buf + 2, back->green);
|
||||
png_save_uint_16(buf + 4, back->blue);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
#else
|
||||
if ((buf[0] | buf[2] | buf[4]) != 0)
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
|
@ -1970,7 +1971,7 @@ png_write_acTL(png_structp png_ptr,
|
|||
|
||||
png_ptr->num_frames_to_write = num_frames;
|
||||
|
||||
if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) != 0)
|
||||
if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
|
||||
num_frames--;
|
||||
|
||||
png_save_uint_32(buf, num_frames);
|
||||
|
@ -2033,7 +2034,7 @@ png_write_fdAT(png_structp png_ptr,
|
|||
|
||||
png_ptr->next_seq_num++;
|
||||
}
|
||||
#endif /* WRITE_APNG */
|
||||
#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
|
||||
/* Initializes the row writing capability of libpng */
|
||||
void /* PRIVATE */
|
||||
|
@ -2082,13 +2083,12 @@ png_write_start_row(png_structrp png_ptr)
|
|||
}
|
||||
|
||||
/* We only need to keep the previous row if we are using one of these. */
|
||||
if ((png_ptr->do_filter &
|
||||
(PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
|
||||
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
{
|
||||
/* Set up previous row buffer */
|
||||
png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) != 0)
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
@ -2096,7 +2096,7 @@ png_write_start_row(png_structrp png_ptr)
|
|||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0)
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG)
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
@ -2104,7 +2104,7 @@ png_write_start_row(png_structrp png_ptr)
|
|||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0)
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
@ -2112,13 +2112,13 @@ png_write_start_row(png_structrp png_ptr)
|
|||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced, we need to set up width and height of pass */
|
||||
if (png_ptr->interlaced != 0)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) == 0)
|
||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||
{
|
||||
png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
|
||||
png_pass_ystart[0]) / png_pass_yinc[0];
|
||||
|
@ -2173,10 +2173,10 @@ png_write_finish_row(png_structrp png_ptr)
|
|||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* If interlaced, go to next pass */
|
||||
if (png_ptr->interlaced != 0)
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
{
|
||||
png_ptr->pass++;
|
||||
}
|
||||
|
@ -2201,7 +2201,7 @@ png_write_finish_row(png_structrp png_ptr)
|
|||
png_pass_ystart[png_ptr->pass]) /
|
||||
png_pass_yinc[png_ptr->pass];
|
||||
|
||||
if ((png_ptr->transformations & PNG_INTERLACE) != 0)
|
||||
if (png_ptr->transformations & PNG_INTERLACE)
|
||||
break;
|
||||
|
||||
} while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);
|
||||
|
@ -2480,7 +2480,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* We don't need to test the 'no filter' case if this is the only filter
|
||||
* that has been chosen, as it doesn't actually do anything to the data.
|
||||
*/
|
||||
if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
|
||||
if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)
|
||||
{
|
||||
png_bytep rp;
|
||||
png_uint_32 sum = 0;
|
||||
|
@ -2556,7 +2556,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
best_row = png_ptr->sub_row;
|
||||
}
|
||||
|
||||
else if ((filter_to_do & PNG_FILTER_SUB) != 0)
|
||||
else if (filter_to_do & PNG_FILTER_SUB)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
|
@ -2677,7 +2677,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
best_row = png_ptr->up_row;
|
||||
}
|
||||
|
||||
else if ((filter_to_do & PNG_FILTER_UP) != 0)
|
||||
else if (filter_to_do & PNG_FILTER_UP)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
|
@ -2791,7 +2791,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
best_row = png_ptr->avg_row;
|
||||
}
|
||||
|
||||
else if ((filter_to_do & PNG_FILTER_AVG) != 0)
|
||||
else if (filter_to_do & PNG_FILTER_AVG)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
|
@ -2893,7 +2893,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
}
|
||||
|
||||
/* Paeth filter */
|
||||
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
||||
if (filter_to_do == PNG_FILTER_PAETH)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_size_t i;
|
||||
|
@ -2932,7 +2932,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
|
||||
else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
|
||||
else if (filter_to_do & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_uint_32 sum = 0, lmins = mins;
|
||||
|
@ -3002,7 +3002,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
#else /* SLOW_PAETH */
|
||||
#else /* PNG_SLOW_PAETH */
|
||||
p = a + b - c;
|
||||
pa = abs(p - a);
|
||||
pb = abs(p - b);
|
||||
|
@ -3016,7 +3016,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
|
||||
else
|
||||
p = c;
|
||||
#endif /* SLOW_PAETH */
|
||||
#endif /* PNG_SLOW_PAETH */
|
||||
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
|
||||
|
@ -3065,7 +3065,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
best_row = png_ptr->paeth_row;
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||
png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
|
||||
|
@ -3085,7 +3085,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
png_ptr->prev_filters[j] = best_row[0];
|
||||
}
|
||||
#endif
|
||||
#endif /* WRITE_FILTER */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
}
|
||||
|
||||
|
||||
|
@ -3121,7 +3121,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
|||
{
|
||||
png_write_flush(png_ptr);
|
||||
}
|
||||
#endif /* WRITE_FLUSH */
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
|
@ -3157,5 +3157,5 @@ png_write_reinit(png_structp png_ptr, png_infop info_ptr,
|
|||
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
|
||||
png_ptr->usr_width = png_ptr->width;
|
||||
}
|
||||
#endif /* WRITE_APNG */
|
||||
#endif /* WRITE */
|
||||
#endif /* PNG_WRITE_APNG_SUPPORTED */
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
|
Загрузка…
Ссылка в новой задаче