summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2013-01-12 09:08:04 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2013-01-23 21:49:04 -0600
commitaff74911596a66e8c02949877355f38e42ab7d27 (patch)
tree76f9412ca15c9b9084ccc90eba81532722b92793
parent3b25126bef931ed8cffb2c8cfd3de20dece03828 (diff)
downloadlibpng-1.7.44.tar.gz
Imported from pngcrush-1.7.44.tarv1.7.44
-rw-r--r--ChangeLog.html10
-rw-r--r--gzguts.h132
-rw-r--r--mozpngconf.h535
-rw-r--r--png.c30
-rw-r--r--png.h27
-rw-r--r--pngconf.h26
-rw-r--r--pngcrush.c81
-rw-r--r--pngcrush.h1
-rw-r--r--pngerror.c8
-rw-r--r--pngget.c8
-rw-r--r--pnginfo.h2
-rw-r--r--pnglibconf.h2
-rw-r--r--pngpriv.h83
-rw-r--r--pngread.c2
-rw-r--r--pngrtran.c14
-rw-r--r--pngrutil.c102
-rw-r--r--pngset.c50
-rw-r--r--pngsimple.h497
-rw-r--r--pngwrite.c6
-rw-r--r--pngwutil.c15
20 files changed, 1455 insertions, 176 deletions
diff --git a/ChangeLog.html b/ChangeLog.html
index 5e0042c82..24431469d 100644
--- a/ChangeLog.html
+++ b/ChangeLog.html
@@ -3,9 +3,19 @@
Change log:
+Version 1.7.44 (built with libpng-1.5.14 and zlib-1.2.7)
+
+Version 1.7.43 (built with libpng-1.5.13 and zlib-1.2.7)
+ Added "remove(inname)" before "rename(outname, inname)" when using the "-ow"
+ option on CYGWIN/MinGW because "rename()" does not work if the target file
+ exists.
+ Use the bundled "zlib.h" when PNGCRUSH_H is defined, otherwise use the
+ system <zlib.h>.
+
Version 1.7.42 (built with libpng-1.5.13 and zlib-1.2.7)
Use malloc() and free() instead of png_malloc_default() and
png_free_default(). This will be required to run with libpng-1.7.x.
+ Revised the PNG_ABORT definition in pngcrush.h to work with libpng-1.7.x.
Revised zutil.h to avoid redefining ptrdiff_t on MinGW/CYGWIN platforms.
Version 1.7.41 (built with libpng-1.5.13 and zlib-1.2.7)
diff --git a/gzguts.h b/gzguts.h
new file mode 100644
index 000000000..84a979780
--- /dev/null
+++ b/gzguts.h
@@ -0,0 +1,132 @@
+/* gzguts.h -- zlib internal header definitions for gz* operations
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef _LARGEFILE64_SOURCE
+# ifndef _LARGEFILE_SOURCE
+# define _LARGEFILE_SOURCE
+# endif
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+#endif
+
+#define ZLIB_INTERNAL
+
+#include <stdio.h>
+#include "zlib.h"
+#ifdef STDC
+# include <string.h>
+# include <stdlib.h>
+# include <limits.h>
+#endif
+#include <fcntl.h>
+
+#ifdef NO_DEFLATE /* for compatibility with old definition */
+# define NO_GZCOMPRESS
+#endif
+
+#ifdef WIN32
+# include <io.h>
+# define vsnprintf _vsnprintf
+#endif
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+/* gz* functions always use library allocation functions */
+#ifndef STDC
+ extern voidp malloc OF((uInt size));
+ extern void free OF((voidpf ptr));
+#endif
+
+/* get errno and strerror definition */
+#if defined UNDER_CE && defined NO_ERRNO_H
+# include <windows.h>
+# define zstrerror() gz_strwinerror((DWORD)GetLastError())
+#else
+# ifdef STDC
+# include <errno.h>
+# define zstrerror() strerror(errno)
+# else
+# define zstrerror() "stdio error (consult errno)"
+# endif
+#endif
+
+/* MVS fdopen() */
+#ifdef __MVS__
+ #pragma map (fdopen , "\174\174FDOPEN")
+ FILE *fdopen(int, const char *);
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
+/* default i/o buffer size -- double this for output when reading */
+#define GZBUFSIZE 8192
+
+/* gzip modes, also provide a little integrity check on the passed structure */
+#define GZ_NONE 0
+#define GZ_READ 7247
+#define GZ_WRITE 31153
+#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
+
+/* values for gz_state how */
+#define LOOK 0 /* look for a gzip header */
+#define COPY 1 /* copy input directly */
+#define GZIP 2 /* decompress a gzip stream */
+
+/* internal gzip file state data structure */
+typedef struct {
+ /* used for both reading and writing */
+ int mode; /* see gzip modes above */
+ int fd; /* file descriptor */
+ char *path; /* path or fd for error messages */
+ z_off64_t pos; /* current position in uncompressed data */
+ unsigned size; /* buffer size, zero if not allocated yet */
+ unsigned want; /* requested buffer size, default is GZBUFSIZE */
+ unsigned char *in; /* input buffer */
+ unsigned char *out; /* output buffer (double-sized when reading) */
+ unsigned char *next; /* next output data to deliver or write */
+ /* just for reading */
+ unsigned have; /* amount of output data unused at next */
+ int eof; /* true if end of input file reached */
+ z_off64_t start; /* where the gzip data started, for rewinding */
+ z_off64_t raw; /* where the raw data started, for seeking */
+ int how; /* 0: get header, 1: copy, 2: decompress */
+ int direct; /* true if last read direct, false if gzip */
+ /* just for writing */
+ int level; /* compression level */
+ int strategy; /* compression strategy */
+ /* seek request */
+ z_off64_t skip; /* amount to skip (already rewound if backwards) */
+ int seek; /* true if seek request pending */
+ /* error information */
+ int err; /* error code */
+ char *msg; /* error message */
+ /* zlib inflate or deflate stream */
+ z_stream strm; /* stream structure in-place (not a pointer) */
+} gz_state;
+typedef gz_state FAR *gz_statep;
+
+/* shared functions */
+ZEXTERN void ZEXPORT gz_error OF((gz_statep, int, const char *));
+#if defined UNDER_CE && defined NO_ERRNO_H
+ZEXTERN char ZEXPORT *gz_strwinerror OF((DWORD error));
+#endif
+
+/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
+ value -- needed when comparing unsigned to z_off64_t, which is signed
+ (possible z_off64_t types off_t, off64_t, and long are all signed) */
+#ifdef INT_MAX
+# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
+#else
+ZEXTERN unsigned ZEXPORT gz_intmax OF((void));
+# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
+#endif
diff --git a/mozpngconf.h b/mozpngconf.h
new file mode 100644
index 000000000..b2f7de8f4
--- /dev/null
+++ b/mozpngconf.h
@@ -0,0 +1,535 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla libpng configuration.
+ *
+ * The Initial Developer of the Original Code is
+ * Tim Rowley.
+ * Portions created by the Initial Developer are Copyright (C) 2003
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Tim Rowley <tor@cs.brown.edu>
+ * Glenn Randers-Pehrson <glennrp@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef MOZPNGCONF_H
+#define MOZPNGCONF_H
+
+#define PNG_USER_CHUNK_MALLOC_MAX 4000000L
+
+#define PNG_NO_GLOBAL_ARRAYS
+
+#ifdef _MSC_VER
+/* The PNG_PEDANTIC_WARNINGS (attributes) fail to build with some MSC
+ * compilers; we'll play it safe and disable them for all MSC compilers.
+ */
+#define PNG_NO_PEDANTIC_WARNINGS
+#endif
+
+#ifndef MOZ_PNG_READ
+#define PNG_NO_READ_SUPPORTED
+#endif
+#define PNG_NO_READ_BGR
+#define PNG_NO_SET_USER_LIMITS
+#define PNG_NO_USER_LIMITS
+#define PNG_NO_ASSEMBLER_CODE
+#define PNG_NO_WARN_UNINITIALIZED_ROW
+#define PNG_NO_READ_BACKGROUND
+#define PNG_NO_READ_QUANTIZE
+#define PNG_NO_READ_INVERT
+#define PNG_NO_READ_SHIFT
+#define PNG_NO_READ_PACK
+#define PNG_NO_READ_PACKSWAP
+#define PNG_NO_READ_FILLER
+#define PNG_NO_READ_SWAP
+#define PNG_NO_READ_SWAP_ALPHA
+#define PNG_NO_READ_INVERT_ALPHA
+#define PNG_NO_READ_RGB_TO_GRAY
+#define PNG_NO_READ_USER_TRANSFORM
+
+#define PNG_NO_READ_bKGD
+#define PNG_NO_READ_hIST
+#define PNG_NO_READ_oFFs
+#define PNG_NO_READ_pCAL
+#define PNG_NO_READ_pHYs
+#define PNG_NO_READ_sBIT
+#define PNG_NO_READ_sCAL
+#define PNG_NO_READ_sPLT
+#define PNG_NO_READ_TEXT
+#define PNG_NO_READ_tIME
+#define PNG_NO_READ_UNKNOWN_CHUNKS
+#define PNG_NO_READ_USER_CHUNKS
+#define PNG_NO_READ_EMPTY_PLTE
+#define PNG_NO_READ_OPT_PLTE
+#define PNG_NO_READ_STRIP_ALPHA
+#define PNG_NO_SEQUENTIAL_READ_SUPPORTED
+
+#ifndef MOZ_PNG_WRITE
+#define PNG_NO_WRITE_SUPPORTED
+#else
+#define PNG_NO_WRITE_BACKGROUND
+#define PNG_NO_WRITE_DITHER
+#define PNG_NO_WRITE_INVERT
+#define PNG_NO_WRITE_SHIFT
+#define PNG_NO_WRITE_PACK
+#define PNG_NO_WRITE_PACKSWAP
+#define PNG_NO_WRITE_FILLER
+#define PNG_NO_WRITE_SWAP
+#define PNG_NO_WRITE_SWAP_ALPHA
+#define PNG_NO_WRITE_INVERT_ALPHA
+#define PNG_NO_WRITE_RGB_TO_GRAY
+#define PNG_NO_WRITE_USER_TRANSFORM
+#define PNG_NO_WRITE_bKGD
+#define PNG_NO_WRITE_cHRM
+#define PNG_NO_WRITE_gAMA
+#define PNG_NO_WRITE_sRGB
+#define PNG_NO_WRITE_hIST
+#define PNG_NO_WRITE_iCCP
+#define PNG_NO_WRITE_oFFs
+#define PNG_NO_WRITE_pCAL
+#define PNG_NO_WRITE_pHYs
+#define PNG_NO_WRITE_sBIT
+#define PNG_NO_WRITE_sCAL
+#define PNG_NO_WRITE_sPLT
+#define PNG_NO_WRITE_TEXT
+#define PNG_NO_WRITE_tIME
+#define PNG_NO_WRITE_UNKNOWN_CHUNKS
+#define PNG_NO_WRITE_USER_CHUNKS
+#define PNG_NO_WRITE_EMPTY_PLTE
+#define PNG_NO_WRITE_OPT_PLTE
+#define PNG_NO_WRITE_FILTER
+#define PNG_NO_WRITE_WEIGHTED_FILTER
+#define PNG_NO_WRITE_INTERLACING_SUPPORTED /* effective libpng-1.3.0 */
+#endif
+
+#define PNG_NO_HANDLE_AS_UNKNOWN
+#define PNG_NO_INFO_IMAGE
+#define PNG_NO_IO_STATE
+#define PNG_NO_USER_MEM
+#define PNG_NO_FIXED_POINT_SUPPORTED
+#define PNG_NO_MNG_FEATURES
+#define PNG_NO_USER_TRANSFORM_PTR
+#define PNG_NO_CONSOLE_IO
+#define PNG_NO_ZALLOC_ZERO
+#define PNG_NO_ERROR_NUMBERS
+#define PNG_NO_EASY_ACCESS
+#define PNG_NO_TIME_RFC1123
+
+/* Mangle names of exported libpng functions so different libpng versions
+ can coexist. It is recommended that if you do this, you give your
+ library a different name such as "mozlibpng" instead of "libpng". */
+
+/* The following has been present since libpng-0.88, has never changed, and
+ is unaffected by conditional compilation macros. It will not be mangled
+ and it is the only choice for use in configure scripts for detecting the
+ presence of any libpng version since 0.88.
+
+ png_get_io_ptr
+*/
+
+/* Mozilla: mangle it anyway. */
+#define png_get_io_ptr MOZ_PNG_get_io_ptr
+
+/* The following weren't present in libpng-0.88 but have never changed since
+ they were first introduced and are not affected by any conditional compile
+ choices and therefore don't need to be mangled. We'll mangle them anyway. */
+#define png_sig_cmp MOZ_PNG_sig_cmp /* 0.90 */
+#define png_memcpy_check MOZ_PNG_memcpy_ck /* 1.0.0 */
+#define png_memset_check MOZ_PNG_memset_ck /* 1.0.0 */
+#define png_access_version_number MOZ_PNG_access_vn /* 1.0.7 */
+
+/* These have never changed since they were first introduced but they
+ make direct reference to members of png_ptr that might have been moved,
+ so they will be mangled. */
+
+#define png_set_sig_bytes MOZ_PNG_set_sig_b /* 0.90 */
+#define png_reset_zstream MOZ_PNG_reset_zs /* 1.0.7 */
+
+/* The following may have changed, or can be affected by conditional compilation
+ choices, and will be mangled. */
+#define png_build_gamma_table MOZ_PNG_build_gamma_tab
+#define png_build_grayscale_palette MOZ_PNG_build_g_p
+#define png_calculate_crc MOZ_PNG_calc_crc
+#define png_check_chunk_name MOZ_PNG_ck_chunk_name
+#define png_chunk_error MOZ_PNG_chunk_err
+#define png_chunk_warning MOZ_PNG_chunk_warn
+#define png_combine_row MOZ_PNG_combine_row
+#define png_convert_from_struct_tm MOZ_PNG_cv_from_struct_tm
+#define png_convert_from_time_t MOZ_PNG_cv_from_time_t
+#define png_convert_to_rfc1123 MOZ_PNG_cv_to_rfc1123
+#define png_crc_error MOZ_PNG_crc_error
+#define png_crc_finish MOZ_PNG_crc_finish
+#define png_crc_read MOZ_PNG_crc_read
+#define png_create_info_struct MOZ_PNG_cr_info_str
+#define png_create_read_struct MOZ_PNG_cr_read_str
+#define png_create_read_struct_2 MOZ_PNG_cr_read_str_2
+#define png_create_struct MOZ_PNG_create_st
+#define png_create_struct_2 MOZ_PNG_create_s2
+#define png_create_write_struct MOZ_PNG_cr_write_str
+#define png_create_write_struct_2 MOZ_PNG_cr_write_str_2
+#define png_data_freer MOZ_PNG_data_freer
+#define png_decompress_chunk MOZ_PNG_decomp_chunk
+#define png_default_error MOZ_PNG_def_error
+#define png_default_flush MOZ_PNG_def_flush
+#define png_default_read MOZ_PNG_def_read
+#define png_default_read_data MOZ_PNG_def_read_data
+#define png_default_warning MOZ_PNG_def_warning
+#define png_default_write MOZ_PNG_def_write
+#define png_destroy_info_struct MOZ_PNG_dest_info_str
+#define png_destroy_read_struct MOZ_PNG_dest_read_str
+#define png_destroy_struct MOZ_PNG_dest_str
+#define png_destroy_struct_2 MOZ_PNG_dest_str_2
+#define png_destroy_write_struct MOZ_PNG_dest_write_str
+#define png_digit MOZ_PNG_digit
+#define png_do_background MOZ_PNG_do_back
+#define png_do_bgr MOZ_PNG_do_bgr
+#define png_do_chop MOZ_PNG_do_chop
+#define png_do_dither MOZ_PNG_do_dith
+#define png_do_expand MOZ_PNG_do_expand
+#define png_do_expand_palette MOZ_PNG_do_expand_plte
+#define png_do_gamma MOZ_PNG_do_gamma
+#define png_do_gray_to_rgb MOZ_PNG_do_g_to_rgb
+#define png_do_invert MOZ_PNG_do_invert
+#define png_do_packswap MOZ_PNG_do_packswap
+#define png_do_read_filler MOZ_PNG_do_read_fill
+#define png_do_read_interlace MOZ_PNG_do_read_int
+#define png_do_read_intrapixel MOZ_PNG_do_read_intra
+#define png_do_read_invert_alpha MOZ_PNG_do_read_inv_alph
+#define png_do_read_swap_alpha MOZ_PNG_do_read_swap_alph
+#define png_do_read_transformations MOZ_PNG_do_read_trans
+#define png_do_rgb_to_gray MOZ_PNG_do_rgb_to_g
+#define png_do_strip_filler MOZ_PNG_do_strip_fill
+#define png_do_swap MOZ_PNG_do_swap
+#define png_do_unpack MOZ_PNG_do_unpack
+#define png_do_unshift MOZ_PNG_do_unshift
+#define png_error MOZ_PNG_error
+#define png_format_buffer MOZ_PNG_format_buf
+#define png_free MOZ_PNG_free
+#define png_free_data MOZ_PNG_free_data
+#define png_free_default MOZ_PNG_free_def
+#define png_gamma_shift MOZ_PNG_gamma_shift
+#define png_get_IHDR MOZ_PNG_get_IHDR
+#define png_get_PLTE MOZ_PNG_get_PLTE
+#define png_get_asm_flagmask MOZ_PNG_get_asm_mask
+#define png_get_asm_flags MOZ_PNG_get_asm_flags
+#define png_get_bKGD MOZ_PNG_get_bKGD
+#define png_get_bit_depth MOZ_PNG_get_bit_depth
+#define png_get_cHRM MOZ_PNG_get_cHRM
+#define png_get_cHRM_fixed MOZ_PNG_get_cHRM_fixed
+#define png_get_channels MOZ_PNG_get_channels
+#define png_get_color_type MOZ_PNG_get_color_type
+#define png_get_compression_buffer_size MOZ_PNG_get_comp_buf_siz
+#define png_get_compression_type MOZ_PNG_get_comp_type
+#define png_get_copyright MOZ_PNG_get_copyright
+#define png_get_error_ptr MOZ_PNG_get_error_ptr
+#define png_get_filter_type MOZ_PNG_get_filter_type
+#define png_get_gAMA MOZ_PNG_get_gAMA
+#define png_get_gAMA_fixed MOZ_PNG_get_gAMA_fixed
+#define png_get_hIST MOZ_PNG_get_hIST
+#define png_get_header_ver MOZ_PNG_get_hdr_ver
+#define png_get_header_version MOZ_PNG_get_hdr_vn
+#define png_get_iCCP MOZ_PNG_get_iCCP
+#define png_get_image_height MOZ_PNG_get_image_h
+#define png_get_image_width MOZ_PNG_get_image_w
+#define png_get_interlace_type MOZ_PNG_get_interlace_type
+#define png_get_libpng_ver MOZ_PNG_get_libpng_ver
+#define png_get_mem_ptr MOZ_PNG_get_mem_ptr
+#define png_get_oFFs MOZ_PNG_get_oFFs
+#define png_get_pCAL MOZ_PNG_get_pCAL
+#define png_get_pHYs MOZ_PNG_get_pHYs
+#define png_get_pixel_aspect_ratio MOZ_PNG_get_pixel_aspect_ratio
+#define png_get_pixels_per_meter MOZ_PNG_get_pixels_p_m
+#define png_get_progressive_ptr MOZ_PNG_get_progressive_ptr
+#define png_get_rgb_to_gray_status MOZ_PNG_get_rgb_to_gray_status
+#define png_get_rowbytes MOZ_PNG_get_rowbytes
+#define png_get_rows MOZ_PNG_get_rows
+#define png_get_sBIT MOZ_PNG_get_sBIT
+#define png_get_sCAL MOZ_PNG_get_sCAL
+#define png_get_sCAL_s MOZ_PNG_get_sCAL_s
+#define png_get_sPLT MOZ_PNG_get_sPLT
+#define png_get_sRGB MOZ_PNG_get_sRGB
+#define png_get_signature MOZ_PNG_get_signature
+#define png_get_tIME MOZ_PNG_get_tIME
+#define png_get_tRNS MOZ_PNG_get_tRNS
+#define png_get_text MOZ_PNG_get_text
+#define png_get_unknown_chunks MOZ_PNG_get_unk_chunks
+#define png_get_user_chunk_ptr MOZ_PNG_get_user_chunk_ptr
+#define png_get_user_transform_ptr MOZ_PNG_get_user_transform_ptr
+#define png_get_valid MOZ_PNG_get_valid
+#define png_get_x_offset_microns MOZ_PNG_get_x_offs_microns
+#define png_get_x_offset_pixels MOZ_PNG_get_x_offs_pixels
+#define png_get_x_pixels_per_meter MOZ_PNG_get_x_pix_per_meter
+#define png_get_y_offset_microns MOZ_PNG_get_y_offs_microns
+#define png_get_y_offset_pixels MOZ_PNG_get_y_offs_pixels
+#define png_get_y_pixels_per_meter MOZ_PNG_get_y_pix_per_meter
+#define png_handle_IEND MOZ_PNG_handle_IEND
+#define png_handle_IHDR MOZ_PNG_handle_IHDR
+#define png_handle_PLTE MOZ_PNG_handle_PLTE
+#define png_handle_as_unknown MOZ_PNG_handle_as_unknown
+#define png_handle_bKGD MOZ_PNG_handle_bKGD
+#define png_handle_cHRM MOZ_PNG_handle_cHRM
+#define png_handle_gAMA MOZ_PNG_handle_gAMA
+#define png_handle_hIST MOZ_PNG_handle_hIST
+#define png_handle_iCCP MOZ_PNG_handle_iCCP
+#define png_handle_oFFs MOZ_PNG_handle_oFFs
+#define png_handle_pCAL MOZ_PNG_handle_pCAL
+#define png_handle_pHYs MOZ_PNG_handle_pHYs
+#define png_handle_sBIT MOZ_PNG_handle_sBIT
+#define png_handle_sCAL MOZ_PNG_handle_sCAL
+#define png_handle_sPLT MOZ_PNG_handle_sPLT
+#define png_handle_sRGB MOZ_PNG_handle_sRGB
+#define png_handle_tEXt MOZ_PNG_handle_tEXt
+#define png_handle_tIME MOZ_PNG_handle_tIME
+#define png_handle_tRNS MOZ_PNG_handle_tRNS
+#define png_handle_unknown MOZ_PNG_handle_unknown
+#define png_handle_zTXt MOZ_PNG_handle_zTXt
+#define png_info_destroy MOZ_PNG_info_dest
+#define png_info_init_3 MOZ_PNG_info_init_3
+#define png_init_io MOZ_PNG_init_io
+#define png_init_mmx_flags MOZ_PNG_init_mmx_flags
+#define png_init_read_transformations MOZ_PNG_init_read_transf
+#define png_malloc MOZ_PNG_malloc
+#define png_malloc_default MOZ_PNG_malloc_default
+#define png_malloc_warn MOZ_PNG_malloc_warn
+#define png_mmx_support MOZ_PNG_mmx_support
+#define png_permit_empty_plte MOZ_PNG_permit_mng_empty_plte
+#define png_permit_mng_features MOZ_PNG_permit_mng_features
+#define png_process_IDAT_data MOZ_PNG_proc_IDAT_data
+#define png_process_data MOZ_PNG_process_data
+#define png_process_some_data MOZ_PNG_proc_some_data
+#define png_progressive_combine_row MOZ_PNG_progressive_combine_row
+#define png_push_crc_finish MOZ_PNG_push_crc_finish
+#define png_push_crc_skip MOZ_PNG_push_crc_skip
+#define png_push_fill_buffer MOZ_PNG_push_fill_buffer
+#define png_push_handle_tEXt MOZ_PNG_push_handle_tEXt
+#define png_push_handle_unknown MOZ_PNG_push_handle_unk
+#define png_push_handle_zTXt MOZ_PNG_push_handle_ztXt
+#define png_push_have_end MOZ_PNG_push_have_end
+#define png_push_have_info MOZ_PNG_push_have_info
+#define png_push_have_row MOZ_PNG_push_have_row
+#define png_push_process_row MOZ_PNG_push_proc_row
+#define png_push_read_IDAT MOZ_PNG_push_read_IDAT
+#define png_push_read_chunk MOZ_PNG_push_read_chunk
+#define png_push_read_sig MOZ_PNG_push_read_sig
+#define png_push_read_tEXt MOZ_PNG_push_read_tEXt
+#define png_push_read_zTXt MOZ_PNG_push_read_zTXt
+#define png_push_restore_buffer MOZ_PNG_push_rest_buf
+#define png_push_save_buffer MOZ_PNG_push_save_buf
+#define png_read_data MOZ_PNG_read_data
+#define png_read_destroy MOZ_PNG_read_dest
+#define png_read_end MOZ_PNG_read_end
+#define png_read_filter_row MOZ_PNG_read_filt_row
+#define png_read_finish_row MOZ_PNG_read_finish_row
+#define png_read_image MOZ_PNG_read_image
+#define png_read_info MOZ_PNG_read_info
+#define png_read_init_2 MOZ_PNG_read_init_2
+#define png_read_init_3 MOZ_PNG_read_init_3
+#define png_read_png MOZ_PNG_read_png
+#define png_read_push_finish_row MOZ_PNG_read_push_finish_row
+#define png_read_row MOZ_PNG_read_row
+#define png_read_rows MOZ_PNG_read_rows
+#define png_read_start_row MOZ_PNG_read_start_row
+#define png_read_transform_info MOZ_PNG_read_transform_info
+#define png_read_update_info MOZ_PNG_read_update_info
+#define png_reset_crc MOZ_PNG_reset_crc
+#define png_set_IHDR MOZ_PNG_set_IHDR
+#define png_set_PLTE MOZ_PNG_set_PLTE
+#define png_set_asm_flags MOZ_PNG_set_asm_flags
+#define png_set_bKGD MOZ_PNG_set_bKGD
+#define png_set_background MOZ_PNG_set_background
+#define png_set_bgr MOZ_PNG_set_bgr
+#define png_set_cHRM MOZ_PNG_set_cHRM
+#define png_set_cHRM_fixed MOZ_PNG_set_cHRM_fixed
+#define png_set_compression_buffer_size MOZ_PNG_set_comp_buf_siz
+#define png_set_compression_level MOZ_PNG_set_comp_level
+#define png_set_compression_mem_level MOZ_PNG_set_comp_mem_lev
+#define png_set_compression_method MOZ_PNG_set_comp_method
+#define png_set_compression_strategy MOZ_PNG_set_comp_strategy
+#define png_set_compression_window_bits MOZ_PNG_set_comp_win_bits
+#define png_set_crc_action MOZ_PNG_set_crc_action
+#define png_set_quantize MOZ_PNG_set_quantize
+#define png_set_error_fn MOZ_PNG_set_error_fn
+#define png_set_expand MOZ_PNG_set_expand
+#define png_set_filler MOZ_PNG_set_filler
+#define png_set_filter MOZ_PNG_set_filter
+#define png_set_filter_heuristics MOZ_PNG_set_filter_heur
+#define png_set_flush MOZ_PNG_set_flush
+#define png_set_gAMA MOZ_PNG_set_gAMA
+#define png_set_gAMA_fixed MOZ_PNG_set_gAMA_fixed
+#define png_set_gamma MOZ_PNG_set_gamma
+#define png_set_gray_1_2_4_to_8 MOZ_PNG_set_gray_1_2_4_to_8
+#define png_set_gray_to_rgb MOZ_PNG_set_gray_to_rgb
+#define png_set_hIST MOZ_PNG_set_hIST
+#define png_set_iCCP MOZ_PNG_set_iCCP
+#define png_set_interlace_handling MOZ_PNG_set_interlace_handling
+#define png_set_invalid MOZ_PNG_set_invalid
+#define png_set_invert_alpha MOZ_PNG_set_invert_alpha
+#define png_set_invert_mono MOZ_PNG_set_invert_mono
+#define png_set_keep_unknown_chunks MOZ_PNG_set_keep_unknown_chunks
+#define png_set_mem_fn MOZ_PNG_set_mem_fn
+#define png_set_mmx_thresholds MOZ_PNG_set_mmx_thr
+#define png_set_oFFs MOZ_PNG_set_oFFs
+#define png_set_pCAL MOZ_PNG_set_pCAL
+#define png_set_pHYs MOZ_PNG_set_pHYs
+#define png_set_packing MOZ_PNG_set_packing
+#define png_set_packswap MOZ_PNG_set_packswap
+#define png_set_palette_to_rgb MOZ_PNG_set_palette_to_rgb
+#define png_set_progressive_read_fn MOZ_PNG_set_progressive_read_fn
+#define png_set_read_fn MOZ_PNG_set_read_fn
+#define png_set_read_status_fn MOZ_PNG_set_read_status_fn
+#define png_set_read_user_chunk_fn MOZ_PNG_set_read_user_chunk_fn
+#define png_set_read_user_transform_fn MOZ_PNG_set_read_user_trans_fn
+#define png_set_rgb_to_gray MOZ_PNG_set_rgb_to_gray
+#define png_set_rgb_to_gray_fixed MOZ_PNG_set_rgb_to_gray_fixed
+#define png_set_rows MOZ_PNG_set_rows
+#define png_set_sBIT MOZ_PNG_set_sBIT
+#define png_set_sCAL MOZ_PNG_set_sCAL
+#define png_set_sCAL_s MOZ_PNG_set_sCAL_s
+#define png_set_sPLT MOZ_PNG_set_sPLT
+#define png_set_sRGB MOZ_PNG_set_sRGB
+#define png_set_sRGB_gAMA_and_cHRM MOZ_PNG_set_sRGB_gAMA_and_cHRM
+#define png_set_shift MOZ_PNG_set_shift
+#define png_set_strip_16 MOZ_PNG_set_strip_16
+#define png_set_strip_alpha MOZ_PNG_set_strip_alpha
+#define png_set_strip_error_numbers MOZ_PNG_set_strip_err_nums
+#define png_set_swap MOZ_PNG_set_swap
+#define png_set_swap_alpha MOZ_PNG_set_swap_alpha
+#define png_set_tIME MOZ_PNG_set_tIME
+#define png_set_tRNS MOZ_PNG_set_tRNS
+#define png_set_tRNS_to_alpha MOZ_PNG_set_tRNS_to_alpha
+#define png_set_text MOZ_PNG_set_text
+#define png_set_text_2 MOZ_PNG_set_text_2
+#define png_set_unknown_chunk_location MOZ_PNG_set_unknown_chunk_loc
+#define png_set_unknown_chunks MOZ_PNG_set_unknown_chunks
+#define png_set_user_transform_info MOZ_PNG_set_user_transform_info
+#define png_set_write_fn MOZ_PNG_set_write_fn
+#define png_set_write_status_fn MOZ_PNG_set_write_status_fn
+#define png_set_write_user_transform_fn MOZ_PNG_set_write_user_trans_fn
+#define png_sig_bytes MOZ_PNG_sig_bytes
+#define png_start_read_image MOZ_PNG_start_read_image
+#define png_warning MOZ_PNG_warning
+#define png_write_chunk MOZ_PNG_write_chunk
+#define png_write_chunk_data MOZ_PNG_write_chunk_data
+#define png_write_chunk_end MOZ_PNG_write_chunk_end
+#define png_write_chunk_start MOZ_PNG_write_chunk_start
+#define png_write_end MOZ_PNG_write_end
+#define png_write_flush MOZ_PNG_write_flush
+#define png_write_image MOZ_PNG_write_image
+#define png_write_info MOZ_PNG_write_info
+#define png_write_info_before_PLTE MOZ_PNG_write_info_before_PLTE
+#define png_write_init MOZ_PNG_write_init
+#define png_write_init_2 MOZ_PNG_write_init_2
+#define png_write_init_3 MOZ_PNG_write_init_3
+#define png_write_png MOZ_PNG_write_png
+#define png_write_row MOZ_PNG_write_row
+#define png_write_rows MOZ_PNG_write_rows
+#define png_zalloc MOZ_PNG_zalloc
+#define png_zfree MOZ_PNG_zfree
+#define png_write_data MOZ_PNG_write_data
+#define png_default_write_data MOZ_PNG_default_write_data
+#define png_flush MOZ_PNG_flush
+#define png_write_sig MOZ_PNG_write_sig
+#define png_write_IHDR MOZ_PNG_write_IHDR
+#define png_write_IDAT MOZ_PNG_write_IDAT
+#define png_write_gAMA MOZ_PNG_write_gAMA
+#define png_write_sRGB MOZ_PNG_write_sRGB
+#define png_write_PLTE MOZ_PNG_write_PLTE
+#define png_write_tRNS MOZ_PNG_write_tRNS
+#define png_write_oFFs MOZ_PNG_write_oFFs
+#define png_write_IEND MOZ_PNG_write_IEND
+#define png_write_init MOZ_PNG_write_init
+#define png_write_start_row MOZ_PNG_write_trans
+#define png_do_write_transformations MOZ_PNG_do_write_trans
+#define png_write_find_filter MOZ_PNG_write_find_filter
+#define png_write_destroy MOZ_PNG_write_destroy
+#define png_write_finish_row MOZ_PNG_write_finish_row
+#define png_write_filtered_row MOZ_PNG_write_filtered_row
+
+/* libpng-1.2.6 additions */
+#define png_convert_size MOZ_PNG_convert_size
+#define png_get_uint_31 MOZ_PNG_get_uint_31
+#define png_get_user_height_max MOZ_PNG_get_user_height_max
+#define png_get_user_width_max MOZ_PNG_get_user_width_max
+#define png_set_user_limits MOZ_PNG_set_user_limits
+
+/* libpng-1.2.7 addition */
+#define png_set_add_alpha MOZ_PNG_set_add_alpha
+
+/* libpng-1.2.9 additions */
+#define png_set_expand_gray_1_2_4_to_8 MOZ_PNG_set_x_g_124_to_8
+#define png_save_int_32 MOZ_PNG_save_int_32
+#define png_save_uint_16 MOZ_PNG_save_uint_16
+#define png_save_uint_32 MOZ_PNG_save_uint_32
+
+/* libpng-1.2.22 addition */
+#define png_err MOZ_PNG_err
+
+/* APNG additions */
+#define png_handle_acTL MOZ_APNG_handle_acTL
+#define png_handle_fcTL MOZ_APNG_handle_fcTL
+#define png_handle_fdAT MOZ_APNG_handle_fdAT
+#define png_have_info MOZ_APNG_have_info
+#define png_progressive_read_reset MOZ_APNG_prog_read_reset
+#define png_read_reinit MOZ_APNG_read_reinit
+#define png_read_reset MOZ_APNG_read_reset
+#define png_ensure_sequence_number MOZ_APNG_ensure_seqno
+#define png_write_frame_head MOZ_APNG_write_frame_head
+#define png_write_frame_tail MOZ_APNG_write_frame_tail
+#define png_set_progressive_frame_fn MOZ_APNG_set_prog_frame_fn
+#define png_set_acTL MOZ_APNG_set_acTL
+#define png_get_num_frames MOZ_APNG_set_num_frames
+#define png_get_num_plays MOZ_APNG_set_num_plays
+#define png_get_next_frame_fcTL MOZ_APNG_get_next_frame_fcTL
+#define png_set_next_frame_fcTL MOZ_APNG_set_next_frame_fcTL
+#define png_ensure_fcTL_is_valid MOZ_APNG_ensure_fcTL_is_valid
+#define png_get_next_frame_width MOZ_APNG_get_next_frame_width
+#define png_get_next_frame_height MOZ_APNG_get_next_frame_height
+#define png_get_next_frame_x_offset MOZ_APNG_get_next_frame_x_offset
+#define png_get_next_frame_y_offset MOZ_APNG_get_next_frame_y_offset
+#define png_get_next_frame_delay_num MOZ_APNG_get_next_frame_delay_num
+#define png_get_next_frame_delay_den MOZ_APNG_get_next_frame_delay_den
+#define png_get_next_frame_dispose_op MOZ_APNG_get_next_frame_dispose_op
+#define png_get_next_frame_blend_op MOZ_APNG_get_next_frame_blend_op
+#define png_get_first_frame_is_hidden MOZ_APNG_get_first_frame_is_hidden
+#define png_set_first_frame_is_hidden MOZ_APNG_set_first_frame_is_hidden
+#define png_write_acTL MOZ_APNG_write_acTL
+#define png_write_reset MOZ_APNG_write_reset
+#define png_write_reinit MOZ_APNG_write_reinit
+#define png_write_fcTL MOZ_APNG_write_fcTL
+#define png_read_frame_head MOZ_APNG_read_frame_head
+
+#ifndef PR_LOGGING
+ #define MOZ_PNG_warning(s1,s2) (void)0
+ #define MOZ_PNG_chunk_warn(s1,s2) (void)0
+ #if PNG_LIBPNG_VER > 10221
+ #define PNG_NO_WARNINGS
+ #define PNG_NO_ERROR_TEXT
+ #define MOZ_PNG_error(s1,s2) MOZ_PNG_err(s1)
+ #define MOZ_PNG_chunk_err(s1,s2) MOZ_PNG_err(s1)
+ #endif
+#endif
+
+#endif /* MOZPNGCONF_H */
diff --git a/png.c b/png.c
index 6e42c792b..2fbcf4599 100644
--- a/png.c
+++ b/png.c
@@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.5.11 [June 14, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_13 Your_png_h_is_not_version_1_5_13;
+typedef png_libpng_version_1_5_14 Your_png_h_is_not_version_1_5_14;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -73,13 +73,16 @@ PNG_FUNCTION(voidpf /* PRIVATE */,
png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
{
png_voidp ptr;
- png_structp p=(png_structp)png_ptr;
- png_uint_32 save_flags=p->flags;
+ png_structp p;
+ png_uint_32 save_flags;
png_alloc_size_t num_bytes;
if (png_ptr == NULL)
return (NULL);
+ p=(png_structp)png_ptr;
+ save_flags=p->flags;
+
if (items > PNG_UINT_32_MAX/size)
{
png_warning (p, "Potential overflow in png_zalloc()");
@@ -655,14 +658,14 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.5.13 - September 27, 2012" PNG_STRING_NEWLINE \
- "Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
+ "libpng version 1.5.14 - January 24, 2013" PNG_STRING_NEWLINE \
+ "Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.5.13 - September 27, 2012\
- Copyright (c) 1998-2012 Glenn Randers-Pehrson\
+ return "libpng version 1.5.14 - January 24, 2013\
+ Copyright (c) 1998-2013 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
# endif
@@ -1458,7 +1461,7 @@ png_check_fp_string(png_const_charp string, png_size_t size)
}
#endif /* pCAL or sCAL */
-#ifdef PNG_READ_sCAL_SUPPORTED
+#ifdef PNG_sCAL_SUPPORTED
# ifdef PNG_FLOATING_POINT_SUPPORTED
/* Utility used below - a simple accurate power of ten from an integral
* exponent.
@@ -2044,7 +2047,8 @@ png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times,
}
#endif
-#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gamma */
+#if (defined PNG_READ_GAMMA_SUPPORTED) || (defined PNG_cHRM_SUPPORTED)
+/* more fixed point functions for gamma and cHRM (xy/XYZ) suport. */
/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */
png_fixed_point
png_reciprocal(png_fixed_point a)
@@ -2064,6 +2068,7 @@ png_reciprocal(png_fixed_point a)
return 0; /* error/overflow */
}
+#ifdef PNG_READ_GAMMA_SUPPORTED
/* A local convenience routine. */
static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b)
@@ -2085,6 +2090,7 @@ png_product2(png_fixed_point a, png_fixed_point b)
return 0; /* overflow */
}
+#endif /* READ_GAMMA */
/* The inverse of the above. */
png_fixed_point
@@ -2112,7 +2118,7 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
return 0; /* overflow */
}
-#endif /* READ_GAMMA */
+#endif /* READ_GAMMA || cHRM */
#ifdef PNG_CHECK_cHRM_SUPPORTED
/* Added at libpng version 1.2.34 (Dec 8, 2008) and 1.4.0 (Jan 2,
diff --git a/png.h b/png.h
index 7b74433c6..a08966476 100644
--- a/png.h
+++ b/png.h
@@ -1,8 +1,8 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.5.13 - September 27, 2012
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * libpng version 1.5.14 - January 24, 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.)
*
@@ -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.5.13 - September 27, 2012: Glenn
+ * libpng versions 0.97, January 1998, through 1.5.14 - January 24, 2013: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -181,6 +181,9 @@
* 1.5.13beta01-02 15 10513 15.so.15.13[.0]
* 1.5.13rc01 15 10513 15.so.15.13[.0]
* 1.5.13 15 10513 15.so.15.13[.0]
+ * 1.5.14beta01-08 15 10514 15.so.15.14[.0]
+ * 1.5.14rc01-03 15 10514 15.so.15.14[.0]
+ * 1.5.14 15 10514 15.so.15.14[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -212,8 +215,8 @@
*
* This code is released under the libpng license.
*
- * libpng versions 1.2.6, August 15, 2004, through 1.5.13, September 27, 2012, are
- * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.14, January 24, 2013, are
+ * Copyright (c) 2004, 2006-2013 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:
*
@@ -324,13 +327,13 @@
* Y2K compliance in libpng:
* =========================
*
- * September 27, 2012
+ * January 24, 2013
*
* 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.5.13 are Y2K compliant. It is my belief that
+ * upward through 1.5.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
@@ -389,9 +392,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.5.13"
+#define PNG_LIBPNG_VER_STRING "1.5.14"
#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.5.13 - September 27, 2012\n"
+ " libpng version 1.5.14 - January 24, 2013\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@@ -399,7 +402,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 5
-#define PNG_LIBPNG_VER_RELEASE 13
+#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:
@@ -430,7 +433,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 10513 /* 1.5.13 */
+#define PNG_LIBPNG_VER 10514 /* 1.5.14 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -552,7 +555,7 @@ extern "C" {
/* 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_5_13;
+typedef char* png_libpng_version_1_5_14;
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to
diff --git a/pngconf.h b/pngconf.h
index a571d9811..cf7153931 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng version 1.5.13 - September 27, 2012
+ * libpng version 1.5.14 - January 24, 2013
*
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * 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.)
*
@@ -13,6 +13,7 @@
*
* This file has been modified, by Glenn Randers-Pehrson, from the original
* libpng distribution by adding a line reading
+ *
* #include "pngcrush.h"
*/
@@ -182,18 +183,16 @@
* ==========================
* This code is used at build time to find PNG_IMPEXP, the API settings
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
- * import processing is possible. On Windows/x86 systems it also sets
+ * import processing is possible. On Windows systems it also sets
* compiler-specific macros to the values required to change the calling
* conventions of the various functions.
*/
-#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
- defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
- ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
- defined(_M_X64) || defined(_M_IA64) )
- /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
- * builds under Cygwin or MinGW. Also includes Watcom builds but these need
- * special treatment because they are not compatible with GCC or Visual C
- * because of different calling conventions.
+#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
+ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+ /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
+ * MinGW on any architecture currently supported by Windows. Also includes
+ * Watcom builds but these need special treatment because they are not
+ * compatible with GCC or Visual C because of different calling conventions.
*/
# if PNG_API_RULE == 2
/* If this line results in an error, either because __watcall is not
@@ -207,6 +206,9 @@
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
# define PNGCAPI __cdecl
# if PNG_API_RULE == 1
+ /* If this line results in an error __stdcall is not understood and
+ * PNG_API_RULE should not have been set to '1'.
+ */
# define PNGAPI __stdcall
# endif
# else
@@ -244,7 +246,7 @@
# endif
# endif /* compiler */
-#else /* !Windows/x86 */
+#else /* !Windows */
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
# define PNGAPI _System
# else /* !Windows/x86 && !OS/2 */
diff --git a/pngcrush.c b/pngcrush.c
index be4e5a195..06fcbd7bf 100644
--- a/pngcrush.c
+++ b/pngcrush.c
@@ -1,6 +1,6 @@
/*
* pngcrush.c - recompresses png files
- * Copyright (C) 1998-2002, 2006-2012 Glenn Randers-Pehrson
+ * Copyright (C) 1998-2002, 2006-2013 Glenn Randers-Pehrson
* (glennrp at users.sf.net)
* Portions copyright (C) 2005 Greg Roelofs
*
@@ -80,7 +80,7 @@
*
*/
-#define PNGCRUSH_VERSION "1.7.43"
+#define PNGCRUSH_VERSION "1.7.44"
/* Experimental: define these if you wish, but, good luck.
#define PNGCRUSH_COUNT_COLORS
@@ -96,7 +96,7 @@
*
* COPYRIGHT:
*
- * Copyright (C) 1998-2002, 2006-2012 Glenn Randers-Pehrson
+ * Copyright (C) 1998-2002, 2006-2013 Glenn Randers-Pehrson
* (glennrp at users.sf.net)
* Portions copyright (C) 2005 Greg Roelofs
*
@@ -133,6 +133,12 @@
/* To do:
*
+ * (As noted below, some of the features that aren't yet implemented
+ * in pngcrush are already available in ImageMagick; you can try a
+ * workflow that makes a first pass over the image with ImageMagick
+ * to select the bit depth, color type, interlacing, etc., and then makes
+ * another pass with pngcrush to optimize the compression.)
+ *
* 1. Reset CINFO to reflect decoder's required window size (instead of
* libz-1.1.3 encoder's required window size, which is 262 bytes larger).
* See discussion about zlib in png-list archives for April 2001.
@@ -143,7 +149,8 @@
* This has no effect on the "crushed" filesize. The reason for setting
* CINFO properly is to provide the *decoder* with information that will
* allow it to request only the minimum amount of memory required to decode
- * the image.
+ * the image (note that libpng-based decoders don't make use of this
+ * hint until libpng-1.6.0).
*
* In the meantime, one can just do the following and select the smallest
* window that does not increase the filesize, after running pngcrush once
@@ -175,7 +182,8 @@
* settings, then attempt to decode the zlib datastream, and choose
* the smallest setting whose datastream can still be decoded
* successfully. This is likely to be the simplest and fastest
- * solution.
+ * solution; however, it will only work with libpng-1.6.0 and later,
+ * where the decoder actually uses the CINFO hint.
*
* 2. Check for unused alpha channel in color-type 4 and 6.
*
@@ -186,24 +194,30 @@
* fully transparent, and they all have the same underlying color,
* and no opaque pixel has that same color, then write a tRNS
* chunk and reduce the color-type to 0 or 2. This is a lossless
- * operation. If the lossy "-blacken" option is present, do that
- * operation first.
+ * operation. ImageMagick already does this, as of version 6.7.0.
+ * If the lossy "-blacken" option is present, do that operation first.
*
* 3. Check for equal R-G-B channels in color-type 2 or 6.
*
- * If this is true for all pixels, reduce the color-type to 0 or 4.
- * This operation is lossless.
+ * If this is true for all pixels, reduce the color-type to 0 or 4
+ * (i.e., grayscale). This operation is lossless. ImageMagick already
+ * does this.
*
* 4. Check for ok-to-reduce-depth (i.e., every pixel has color samples
* that can be expressed exactly using a smaller depth).
*
* If so, reduce the bit depth accordingly. This operation is lossless.
+ * ImageMagick does this.
*
* Note for 2, 3, 4: Take care that sBIT and bKGD data are not lost or
* become invalid when reducing images from truecolor to grayscale or
* when reducing the bit depth.
*
- * 5. Use a better compression algorithm for "deflating" (result must
+ * 5. Add choice of interlaced or non-interlaced output. Currently you
+ * can change interlaced to non-interlaced and vice versa by using
+ * ImageMagick before running pngcrush.
+ *
+ * 6. Use a better compression algorithm for "deflating" (result must
* still be readable with zlib!) e.g., http://en.wikipedia.org/wiki/7-Zip
* says that the 7-zip deflate compressor achieves better compression
* (smaller files) than zlib. If tests show that this would be worth
@@ -213,8 +227,6 @@
* is incorporated in pngcrush, then pngcrush would have to be re-licensed,
* or released in two versions, one libpng-licensed and one GPL-licensed!
*
- * 6. Improve the -help output and/or write a good man page.
- *
* 7. Implement palette-building (from ImageMagick-6.7.0 or later, minus
* the "PNG8" part) -- actually ImageMagick puts the transparent colors
* first, then the semitransparent colors, and finally the opaque colors,
@@ -226,22 +238,30 @@
* package which counts RGB pixels in an image; this and its supporting
* lib/libppmcmap.c would need to be revised to count RGBA pixels instead.
*
- * 8. Finish pplt (MNG partial palette) feature.
+ * 8. Check the "-plte_len n" option to be sure that no pixel contains
+ * an index value that is out of range due to truncation of the PLTE chunk.
+ * Implementing item "7" will take care of this, since that will always
+ * build a palette of the right length, and the -plte_len option can be
+ * eliminated.
+ *
+ * 9. Improve the -help output and/or write a good man page.
+ *
+ * 10. Finish pplt (MNG partial palette) feature.
*
- * 9. Remove text-handling and color-handling features and put
+ * 11. Remove text-handling and color-handling features and put
* those in a separate program or programs, to avoid unnecessary
* recompressing. Note that in pngcrush-1.7.34, pngcrush began doing
* this extra work only once instead of for every trial, so the potential
* benefit in CPU savings is much smaller now.
*
- * 10. Add a "pcRu" ancillary chunk that keeps track of the best method,
+ * 12. Add a "pcRu" ancillary chunk that keeps track of the best method,
* methods already tried, and whether "loco crushing" was effective.
*
- * 11. Try both transformed and untransformed colors when "-loco" is used.
+ * 13. Try both transformed and untransformed colors when "-loco" is used.
*
- * 12. Move the Photoshop-fixing stuff into a separate program.
+ * 14. Move the Photoshop-fixing stuff into a separate program.
*
- * 13. GRR: More generally (superset of previous 3 items): split into
+ * 15. GRR: More generally (superset of previous 3 items): split into
* separate "edit" and "crush" programs (or functions). Former is fully
* libpng-aware, much like current pngcrush; latter makes little or no use of
* libpng (maybe IDAT-compression parts only?), instead handling virtually
@@ -261,14 +281,19 @@
Change log:
+Version 1.7.44 (built with libpng-1.5.14 and zlib-1.2.7)
+
Version 1.7.43 (built with libpng-1.5.13 and zlib-1.2.7)
Added "remove(inname)" before "rename(outname, inname)" when using the "-ow"
option on CYGWIN/MinGW because "rename()" does not work if the target file
exists.
+ Use the bundled "zlib.h" when PNGCRUSH_H is defined, otherwise use the
+ system <zlib.h>.
Version 1.7.42 (built with libpng-1.5.13 and zlib-1.2.7)
Use malloc() and free() instead of png_malloc_default() and
png_free_default(). This will be required to run with libpng-1.7.x.
+ Revised the PNG_ABORT definition in pngcrush.h to work with libpng-1.7.x.
Revised zutil.h to avoid redefining ptrdiff_t on MinGW/CYGWIN platforms.
Version 1.7.41 (built with libpng-1.5.13 and zlib-1.2.7)
@@ -951,8 +976,14 @@ Version 1.1.4: added ability to restrict brute_force to one or more filter
#endif
#if PNGCRUSH_LIBPNG_VER >= 10500
- /* Not provided by libpng15 */
+ /* "#include <zlib.h>" is not provided by libpng15 */
+#ifdef PNGCRUSH_H
+ /* Use the bundled zlib */
+# include "zlib.h"
+#else
+ /* Use the system zlib */
# include <zlib.h>
+#endif
# ifndef PNG_UNUSED
# define PNG_UNUSED(param) (void)param;
@@ -6138,7 +6169,7 @@ int main(int argc, char *argv[])
png_uint_32 measure_idats(FILE * fp_in)
{
- /* Copyright (C) 1999-2002, 2006-2012 Glenn Randers-Pehrson
+ /* Copyright (C) 1999-2002, 2006-2013 Glenn Randers-Pehrson
(glennrp@users.sf.net). See notice in pngcrush.c for conditions of
use and distribution */
P2("\nmeasure_idats:\n");
@@ -6182,7 +6213,7 @@ png_uint_32 measure_idats(FILE * fp_in)
png_uint_32 png_measure_idat(png_structp png_ptr)
{
- /* Copyright (C) 1999-2002, 2006-2012 Glenn Randers-Pehrson
+ /* Copyright (C) 1999-2002, 2006-2013 Glenn Randers-Pehrson
(glennrp@users.sf.net)
See notice in pngcrush.c for conditions of use and distribution */
@@ -6575,7 +6606,7 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
#define USE_HASHCODE
int count_colors(FILE * fp_in)
{
- /* Copyright (C) 2000-2002, 2006-2012 Glenn Randers-Pehrson
+ /* Copyright (C) 2000-2002, 2006-2013 Glenn Randers-Pehrson
(glennrp@users.sf.net)
See notice in pngcrush.c for conditions of use and distribution */
int bit_depth, color_type, interlace_method, filter_method,
@@ -7171,7 +7202,7 @@ void print_version_info(void)
" | pngcrush %s\n"
/* If you have modified this source, you may insert additional notices
* immediately after this sentence: */
- " | Copyright (C) 1998-2002, 2006-2012 Glenn Randers-Pehrson\n"
+ " | Copyright (C) 1998-2002, 2006-2013 Glenn Randers-Pehrson\n"
" | Portions copyright (C) 2005 Greg Roelofs\n"
" | This is a free, open-source program. Permission is irrevocably\n"
" | granted to everyone to use this version of pngcrush without\n"
@@ -7179,7 +7210,7 @@ void print_version_info(void)
" | Executable name is %s\n"
" | It was built with libpng version %s, and is\n"
" | running with %s"
- " | Copyright (C) 1998-2004, 2006-2012 Glenn Randers-Pehrson,\n"
+ " | Copyright (C) 1998-2004, 2006-2013 Glenn Randers-Pehrson,\n"
" | Copyright (C) 1996, 1997 Andreas Dilger,\n"
" | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,\n"
" | and zlib version %s, Copyright (C) 1995%s,\n"
@@ -7217,7 +7248,7 @@ static const char *pngcrush_legal[] = {
"",
"If you have modified this source, you may insert additional notices",
"immediately after this sentence.",
- "Copyright (C) 1998-2002, 2006-2012 Glenn Randers-Pehrson",
+ "Copyright (C) 1998-2002, 2006-2013 Glenn Randers-Pehrson",
"Portions copyright (C) 2005 Greg Roelofs",
"",
"DISCLAIMER: The pngcrush computer program is supplied \"AS IS\".",
diff --git a/pngcrush.h b/pngcrush.h
index 3384fc21c..7fe298b29 100644
--- a/pngcrush.h
+++ b/pngcrush.h
@@ -14,6 +14,7 @@
own exception handling, which only returns after "Too many IDAT's",
or anything else that we might want to handle as a warning instead of
an error. */
+
#if PNGCRUSH_LIBPNG_VER >= 10700
# define PNG_ABORT exit(1)
#else
diff --git a/pngerror.c b/pngerror.c
index e0585a856..ba3987977 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,8 +1,8 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
- * Last changed in libpng 1.5.8 [February 1, 2011]
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -161,7 +161,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */
mincount = 2;
- /* fall through */
+ /* FALL THROUGH */
case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10];
@@ -171,7 +171,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */
mincount = 2;
- /* fall through */
+ /* FALL THROUGH */
case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf];
diff --git a/pngget.c b/pngget.c
index 43400cda7..c9a663f29 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
- * Last changed in libpng 1.5.7 [December 15, 2011]
+ * Last changed in libpng 1.5.14 [January 24, 2013]
* Copyright (c) 1998-2011 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.)
@@ -175,6 +175,9 @@ png_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)
return ((float)((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit));
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return ((float)0.0);
@@ -203,6 +206,9 @@ png_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,
(png_int_32)info_ptr->x_pixels_per_unit))
return res;
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return 0;
diff --git a/pnginfo.h b/pnginfo.h
index a33bfab06..0e5c977dd 100644
--- a/pnginfo.h
+++ b/pnginfo.h
@@ -242,7 +242,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
#ifdef PNG_sPLT_SUPPORTED
/* Data on sPLT chunks (there may be more than one). */
png_sPLT_tp splt_palettes;
- png_uint_32 splt_palettes_num;
+ int splt_palettes_num;
#endif
#ifdef PNG_sCAL_SUPPORTED
diff --git a/pnglibconf.h b/pnglibconf.h
index 92a92ee33..b5f56840c 100644
--- a/pnglibconf.h
+++ b/pnglibconf.h
@@ -3,7 +3,7 @@
/* pnglibconf.h - library build configuration */
-/* Libpng 1.5.13 - September 27, 2012 */
+/* Libpng 1.5.14 - January 24, 2013 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
diff --git a/pngpriv.h b/pngpriv.h
index dd35e52a5..b961bd3b2 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -416,7 +416,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
/* This is used because in some compiler implementations non-aligned
* structure members are supported, so the offsetof approach below fails.
- * Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access
+ * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
* is good for performance. Do not do this unless you have tested the result
* and understand it.
*/
@@ -823,10 +823,8 @@ PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
# ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
# endif
-# ifdef PNG_FIXED_POINT_SUPPORTED
PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,
png_fixed_point file_gamma));
-# endif
#endif
#ifdef PNG_WRITE_sBIT_SUPPORTED
@@ -1491,14 +1489,16 @@ PNG_EXTERN void png_formatted_warning(png_structp png_ptr,
/* ASCII to FP interfaces, currently only implemented if sCAL
* support is required.
*/
-#if defined(PNG_READ_sCAL_SUPPORTED)
+#ifdef PNG_sCAL_SUPPORTED
/* MAX_DIGITS is actually the maximum number of characters in an sCAL
* width or height, derived from the precision (number of significant
* digits - a build time settable option) and assumpitions about the
* maximum ridiculous exponent.
*/
#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)
+#endif
+#ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_EXTERN void png_ascii_from_fp PNGARG((png_structp png_ptr, png_charp ascii,
png_size_t size, double fp, unsigned int precision));
@@ -1583,14 +1583,14 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
-/* The actual parser. This can be called repeatedly, it updates
+/* The actual parser. This can be called repeatedly. It updates
* the index into the string and the state variable (which must
- * be initialzed to 0). It returns a result code, as above. There
+ * be initialized to 0). It returns a result code, as above. There
* is no point calling the parser any more if it fails to advance to
* the end of the string - it is stuck on an invalid character (or
* terminated by '\0').
*
- * Note that the pointer will consume an E or even an E+ then leave
+ * Note that the pointer will consume an E or even an E+ and then leave
* a 'maybe' state even though a preceding integer.fraction is valid.
* The PNG_FP_WAS_VALID flag indicates that a preceding substring was
* a valid number. It's possible to recover from this by calling
@@ -1629,7 +1629,7 @@ PNG_EXTERN png_fixed_point png_muldiv_warn PNGARG((png_structp png_ptr,
png_fixed_point a, png_int_32 multiplied_by, png_int_32 divided_by));
#endif
-#ifdef PNG_READ_GAMMA_SUPPORTED
+#if (defined PNG_READ_GAMMA_SUPPORTED) || (defined PNG_cHRM_SUPPORTED)
/* Calculate a reciprocal - used for gamma values. This returns
* 0 if the argument is 0 in order to maintain an undefined value,
* there are no warnings.
@@ -1664,7 +1664,72 @@ PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
int bit_depth));
#endif
-/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
+/* Missing declarations if FIXED_POINT is *not* supported - fixed properly
+ * in libpng 1.6
+ */
+#ifndef PNG_FIXED_POINT_SUPPORTED
+#ifdef PNG_cHRM_SUPPORTED
+PNG_EXTERN png_uint_32 png_get_cHRM_XYZ_fixed PNGARG(
+ (png_structp png_ptr, png_const_infop info_ptr,
+ png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
+ png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
+ png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+ png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
+ png_fixed_point *int_blue_Z));
+PNG_EXTERN void png_set_cHRM_XYZ_fixed PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
+ png_fixed_point int_red_Z, png_fixed_point int_green_X,
+ png_fixed_point int_green_Y, png_fixed_point int_green_Z,
+ png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
+ png_fixed_point int_blue_Z));
+PNG_EXTERN void png_set_cHRM_fixed PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_fixed_point int_white_x,
+ png_fixed_point int_white_y, png_fixed_point int_red_x,
+ png_fixed_point int_red_y, png_fixed_point int_green_x,
+ png_fixed_point int_green_y, png_fixed_point int_blue_x,
+ png_fixed_point int_blue_y));
+#endif
+
+#ifdef PNG_gAMA_SUPPORTED
+PNG_EXTERN png_uint_32 png_get_gAMA_fixed PNGARG(
+ (png_const_structp png_ptr, png_const_infop info_ptr,
+ png_fixed_point *int_file_gamma));
+PNG_EXTERN void png_set_gAMA_fixed PNGARG((png_structp png_ptr,
+ png_infop info_ptr, png_fixed_point int_file_gamma));
+#endif
+
+#ifdef PNG_READ_BACKGROUND_SUPPORTED
+PNG_EXTERN void png_set_background_fixed PNGARG((png_structp png_ptr,
+ png_const_color_16p background_color, int background_gamma_code,
+ int need_expand, png_fixed_point background_gamma));
+#endif
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+PNG_EXTERN void png_set_alpha_mode_fixed PNGARG((png_structp png_ptr,
+ int mode, png_fixed_point output_gamma));
+#endif
+
+#ifdef PNG_READ_GAMMA_SUPPORTED
+PNG_EXTERN void png_set_gamma_fixed PNGARG((png_structp png_ptr,
+ png_fixed_point screen_gamma, png_fixed_point override_file_gamma));
+#endif
+
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+PNG_EXTERN void png_set_rgb_to_gray_fixed PNGARG((png_structp png_ptr,
+ int error_action, png_fixed_point red, png_fixed_point green));
+#endif
+#endif /* FIX MISSING !FIXED_POINT DECLARATIONS */
+
+#ifdef PNG_FILTER_OPTIMIZATIONS
+PNG_EXTERN void PNG_FILTER_OPTIMIZATIONS(png_structp png_ptr, unsigned int bpp);
+ /* This is the initialization function for hardware specific optimizations,
+ * one implementation (for ARM NEON machines) is contained in
+ * arm/filter_neon.c. It need not be defined - the generic code will be used
+ * if not.
+ */
+#endif
+
+/* Maintainer: Put new private prototypes here ^ */
#include "pngdebug.h"
diff --git a/pngread.c b/pngread.c
index 1d8c6b334..4296cf1cb 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
- * Last changed in libpng 1.5.10 [March 8, 2012]
+ * Last changed in libpng 1.5.14 [January 24, 2013]
* Copyright (c) 1998-2012 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.)
diff --git a/pngrtran.c b/pngrtran.c
index 1e31c7520..064d92b7e 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Last changed in libpng 1.5.11 [June 14, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -1221,7 +1221,7 @@ png_init_rgb_transformations(png_structp png_ptr)
default:
case 8:
- /* Already 8 bits, fall through */
+ /* FALL THROUGH (already 8 bits) */
case 16:
/* Already a full 16 bits */
@@ -3920,7 +3920,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
*sp = (png_byte)png_ptr->background.gray;
else if (a < 0xff)
- png_composite(*sp, *sp, a, png_ptr->background_1.gray);
+ png_composite(*sp, *sp, a, png_ptr->background.gray);
}
}
}
@@ -3989,7 +3989,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
png_uint_16 g, v;
g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_composite_16(v, g, a, png_ptr->background_1.gray);
+ png_composite_16(v, g, a, png_ptr->background.gray);
*sp = (png_byte)((v >> 8) & 0xff);
*(sp + 1) = (png_byte)(v & 0xff);
}
@@ -4746,7 +4746,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
if (row_info->bit_depth == 8)
{
- gray = gray & 0xff;
+ /* NOTE: prior to libpng 1.5.14 this cleared out the top bits of
+ * 'gray', however if those are set it is an error.
+ */
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 1) - 1;
diff --git a/pngrutil.c b/pngrutil.c
index 4ef05fe44..5ee452d57 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,8 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
- * Last changed in libpng 1.5.10 [March 8, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -2452,7 +2452,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_textp text_ptr;
png_charp key, lang, text, lang_key;
int comp_flag;
- int comp_type = 0;
+ int comp_type;
int ret;
png_size_t slength, prefix_len, data_len;
@@ -2533,15 +2533,24 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
- else
+ comp_flag = *lang++;
+ comp_type = *lang++;
+
+ /* 1.5.14: The spec says "for uncompressed text decoders shall ignore [the
+ * compression type]". The compression flag shall be 0 (no compression) or
+ * 1 (compressed with method 0 - deflate.)
+ */
+ if (comp_flag != 0 && comp_flag != 1)
{
- comp_flag = *lang++;
- comp_type = *lang++;
+ png_warning(png_ptr, "invalid iTXt compression flag");
+ png_free(png_ptr, png_ptr->chunkdata);
+ png_ptr->chunkdata = NULL;
+ return;
}
- if (comp_type || (comp_flag && comp_flag != PNG_TEXT_COMPRESSION_zTXt))
+ if (comp_flag/*compressed*/ && comp_type != 0)
{
- png_warning(png_ptr, "Unknown iTXt compression type or method");
+ png_warning(png_ptr, "unknown iTXt compression type");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
return;
@@ -2577,7 +2586,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
key=png_ptr->chunkdata;
- if (comp_flag)
+ if (comp_flag/*compressed*/)
png_decompress_chunk(png_ptr, comp_type,
(size_t)length, prefix_len, &data_len);
@@ -2595,7 +2604,8 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
- text_ptr->compression = (int)comp_flag + 1;
+ text_ptr->compression =
+ (comp_flag ? PNG_ITXT_COMPRESSION_zTXt : PNG_ITXT_COMPRESSION_NONE);
text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key);
text_ptr->lang = png_ptr->chunkdata + (lang - key);
text_ptr->itxt_length = data_len;
@@ -3660,66 +3670,6 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
}
}
-#ifdef PNG_ARM_NEON
-
-#ifdef __linux__
-#include <stdio.h>
-#include <elf.h>
-#include <asm/hwcap.h>
-
-static int png_have_hwcap(unsigned cap)
-{
- FILE *f = fopen("/proc/self/auxv", "r");
- Elf32_auxv_t aux;
- int have_cap = 0;
-
- if (!f)
- return 0;
-
- while (fread(&aux, sizeof(aux), 1, f) > 0)
- {
- if (aux.a_type == AT_HWCAP &&
- aux.a_un.a_val & cap)
- {
- have_cap = 1;
- break;
- }
- }
-
- fclose(f);
-
- return have_cap;
-}
-#endif /* __linux__ */
-
-static void
-png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
-{
-#ifdef __linux__
- if (!png_have_hwcap(HWCAP_NEON))
- return;
-#endif
-
- pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
-
- if (bpp == 3)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth3_neon;
- }
-
- else if (bpp == 4)
- {
- pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
- pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
- pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
- png_read_filter_row_paeth4_neon;
- }
-}
-#endif /* PNG_ARM_NEON */
-
static void
png_init_filter_functions(png_structp pp)
{
@@ -3735,8 +3685,16 @@ png_init_filter_functions(png_structp pp)
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth_multibyte_pixel;
-#ifdef PNG_ARM_NEON
- png_init_filter_functions_neon(pp, bpp);
+#ifdef PNG_FILTER_OPTIMIZATIONS
+ /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to
+ * call to install hardware optimizations for the above functions; simply
+ * replace whatever elements of the pp->read_filter[] array with a hardware
+ * specific (or, for that matter, generic) optimization.
+ *
+ * To see an example of this examine what configure.ac does when
+ * --enable-arm-neon is specified on the command line.
+ */
+ PNG_FILTER_OPTIMIZATIONS(pp, bpp);
#endif
}
diff --git a/pngset.c b/pngset.c
index 8c07eec3e..6e9358b28 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
- * Last changed in libpng 1.5.11 [June 14, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -690,6 +690,17 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
/* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects.
*/
+
+ if (num_text < 0 ||
+ num_text > INT_MAX - info_ptr->num_text - 8 ||
+ (unsigned int)/*SAFE*/(num_text +/*SAFE*/
+ info_ptr->num_text + 8) >=
+ PNG_SIZE_MAX/png_sizeof(png_text))
+ {
+ png_warning(png_ptr, "too many text chunks");
+ return(0);
+ }
+
if (info_ptr->num_text + num_text > info_ptr->max_text)
{
int old_max_text = info_ptr->max_text;
@@ -897,6 +908,12 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
+ if (num_trans < 0 || num_trans > PNG_MAX_PALETTE_LENGTH)
+ {
+ png_warning(png_ptr, "Ignoring invalid num_trans value");
+ return;
+ }
+
if (trans_alpha != NULL)
{
/* It may not actually be necessary to set png_ptr->trans_alpha here;
@@ -963,9 +980,18 @@ png_set_sPLT(png_structp png_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
- np = (png_sPLT_tp)png_malloc_warn(png_ptr,
- (info_ptr->splt_palettes_num + nentries) *
- (png_size_t)png_sizeof(png_sPLT_t));
+ if (nentries < 0 ||
+ nentries > INT_MAX-info_ptr->splt_palettes_num ||
+ (unsigned int)/*SAFE*/(nentries +/*SAFE*/
+ info_ptr->splt_palettes_num) >=
+ PNG_SIZE_MAX/png_sizeof(png_sPLT_t))
+ np=NULL;
+
+ else
+
+ np = (png_sPLT_tp)png_malloc_warn(png_ptr,
+ (info_ptr->splt_palettes_num + nentries) *
+ (png_size_t)png_sizeof(png_sPLT_t));
if (np == NULL)
{
@@ -1033,9 +1059,17 @@ png_set_unknown_chunks(png_structp png_ptr,
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
return;
- np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
- (png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
- png_sizeof(png_unknown_chunk));
+ if (num_unknowns < 0 ||
+ num_unknowns > INT_MAX-info_ptr->unknown_chunks_num ||
+ (unsigned int)/*SAFE*/(num_unknowns +/*SAFE*/
+ info_ptr->unknown_chunks_num) >=
+ PNG_SIZE_MAX/png_sizeof(png_unknown_chunk))
+ np=NULL;
+
+ else
+ np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
+ (png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
+ png_sizeof(png_unknown_chunk));
if (np == NULL)
{
diff --git a/pngsimple.h b/pngsimple.h
new file mode 100644
index 000000000..ca7cbbef8
--- /dev/null
+++ b/pngsimple.h
@@ -0,0 +1,497 @@
+/*- pngsimple.h
+ *
+ * Proposed prototypes for a simpler interface to libpng.
+ *
+ * Date: 20111107
+ * Copyright: Published in the public domain for comment and use without
+ * restriction.
+ * Original copyright (c) John Bowler <jbowler@acm.org>
+ *
+ * 1) INTRODUCTION
+ * ---------------
+ * These APIs provide support for reading writing a limited number of in-memory
+ * bitmap formats from and to the PNG format. They hide the details of the
+ * necessary transformations and the libpng error handling.
+ *
+ * The supported formats are limited to 8-bit RGB or RGBA data encoded according
+ * to the sRGB specification and 16-bit RGBA data using the sRGB color space
+ * with a linear encoding. The 8-bit formats are intended for image display and
+ * distribution, the 16-bit format for real-world image data used as the input
+ * or output of image processing.
+ *
+ * The APIs use a common control structure, 'png_image', to describe the
+ * in-memory format and to hold libpng control data via a pointer to an opaque
+ * structure of type 'png_controlp'. The structure should be allocated on the
+ * stack or in the data of an appropriate object.
+ *
+ * 1.2) Reading an existing PNG image
+ * ----------------------------------
+ * Reading an existing image requires two calls to the libpng APIs, the first to
+ * find the size of the PNG image and the second to decode the image into the
+ * application provided buffer. The application should take the following
+ * steps:
+ *
+ * 1.2.1) Initialize the png_controlp member of a png_image to NULL.
+ * 1.2.2) Call one of the png_image_begin_read functions to fill in the
+ * remainder of the png_image structure.
+ * 1.2.3) Change the png_image 'format' parameter to the desired in-memory
+ * format and allocate sufficient memory to hold the complete image.
+ * 1.2.4) Call png_image_finish_read to read the PNG image into the supplied
+ * buffer.
+ *
+ * At any step the application can abort the image read by calling
+ * png_image_free to release any data held in the png_controlp.
+ *
+ * 1.3 Writing a new PNG image
+ * ---------------------------
+ * Writing a new PNG image can be accomplished with a single call to libpng:
+ *
+ * 1.3.1) Initialize a png_image structure with a description of the in-memory
+ * format and a NULL png_controlp.
+ * 1.3.2) Call one of the png_image_write functions with a pointer to the
+ * in-memory bitmap.
+ *
+ * The png_controlp member is used by libpng during the write but will be NULL
+ * on exit. Nevertheless is must be initialized to NULL to allow for future
+ * extensions.
+ *
+ * 2) STRUCTURES
+ * -------------
+ *
+ * 2.1) struct png_control
+ * -----------------------
+ * An opaque structure used during the read or write of a PNG image.
+ */
+typedef struct png_control *png_controlp;
+
+/* 2.2) png_image
+ * --------------
+ * A structure containing a description of an in-memory bitmap plus control
+ * information (png_controlp) used by libpng while reading or writing the bitmap
+ * from or to the PNG format.
+ *
+ * On read the information is filled in from the information in the PNG file
+ * header. This includes a suggested memory format, but this will normally be
+ * changed by the application to the format required.
+ *
+ * On write the information is filled in by the application before calling
+ * libpng.
+ */
+typedef struct
+{
+ png_uint_32 width; /* Image width in pixels (columns) */
+ png_uint_32 height; /* Image height in pixels (rows) */
+ png_uint_32 format; /* Image format as defined below */
+ png_uint_32 flags; /* A bit mask containing informational flags */
+ png_controlp opaque; /* Initialize to NULL, free with png_image_free */
+
+ /* In the event of an error or warning the following field will be set to a
+ * non-zero value and the 'message' field will contain a '\0' terminated
+ * string with the libpng error message. The error message will be truncated
+ * to 63 characters if necessary.
+ */
+ png_uint_32 warning_or_error;
+ char message[64];
+} png_image, *png_imagep;
+
+/* The pixels (samples) of the image have one to four channels in the range 0 to
+ * 1.0:
+ *
+ * 1: A single gray or luminance channel (G).
+ * 2: A gray/luminance channel and an alpha channel (GA).
+ * 3: Three red, green, blue color channels (RGB).
+ * 4: Three color channels and an alpha channel (RGBA).
+ *
+ * The channels are encoded in one of two ways:
+ *
+ * a) As a small integer, value 0..255, contained in a (png_byte). For the
+ * alpha channel the original value is simply value/255. For the color or
+ * luminance channels the value is encoded according to the sRGB specification
+ * and matches the 8-bit format expected by typical display devices.
+ *
+ * The color/gray channels are not scaled (pre-multiplied) by the alpha
+ * channel and are suitable for passing to color management software.
+ *
+ * b) As a value in the range 0..65535, contained in a (png_uint_16). All
+ * channels can be converted to the original value by dividing by 65535; all
+ * channels are linear. Color channels use the RGB encoding (RGB end-points) of
+ * the sRGB specification. This encoding is identified by the
+ * PNG_FORMAT_FLAG_LINEAR flag below.
+ *
+ * When an alpha channel is present it is expected to denote pixel coverage
+ * of the color or luminance channels and is returned as an associated alpha
+ * channel: the color/gray channels are scaled (pre-multiplied) the alpha value.
+ */
+
+/* PNG_FORMAT_*
+ *
+ * #defines to be used in png_image::format. Each #define identifies a
+ * particular layout of channel data and, if present, alpha values. There are
+ * separate defines for each of the two channel encodings.
+ *
+ * A format is built up using single bit flag values. Not all combinations are
+ * valid: use the bit flag values below for testing a format returned by the
+ * read APIs, but set formats from the derived values.
+ *
+ * First basic desciptions of the channels:
+ */
+#define PNG_FORMAT_FLAG_ALPHA 0x01 /* format with an alpha channel */
+#define PNG_FORMAT_FLAG_COLOR 0x02 /* color format: otherwise grayscale */
+#define PNG_FORMAT_FLAG_LINEAR 0x04 /* png_uint_16 channels else png_byte */
+
+/* Then layout descriptions. The implementation will ignore flags below that
+ * aren't applicable given the flags above, but the application should use the
+ * pre-defined constants below because some combinations of the flags may not be
+ * supported.
+ *
+ * NOTE: libpng can be built with particular features disabled, if you see
+ * compiler errors because the definition of one of the following flags has been
+ * compiled out it is because libpng does not have the required support. It is
+ * possible, however, for the libpng configuration to enable the format on just
+ * read or just write, in that case you will may see an error at run time. You
+ * can guard against this by checking for the definition of:
+ *
+ * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED
+ */
+#ifdef PNG_FORMAT_BGR_SUPPORTED
+# define PNG_FORMAT_FLAG_BGR 0x08 /* BGR colors, else order is RGB */
+#endif
+
+#ifdef PNG_FORMAT_AFIRST_SUPPORTED
+# define PNG_FORMAT_FLAG_AFIRST 0x10 /* alpha channel comes first */
+#endif
+
+/* Supported formats are as follows. Future versions of libpng may support more
+ * formats, for compatibility with older versions simply check if the format
+ * macro is defined using #ifdef. These defines describe the in-memory layout
+ * of the components of the pixels of the image.
+ *
+ * First the single byte formats:
+ */
+#define PNG_FORMAT_GRAY 0
+#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA
+#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)
+#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR
+#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)
+#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)
+#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)
+#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)
+#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)
+
+/* Then the linear (png_uint_16) formats. When naming these "Y" is used to
+ * indicate a luminance channel. The component order within the pixel is
+ * always the same - there is no provision for swapping the order of the
+ * components in the linear format.
+ */
+#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
+#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)
+#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)
+#define PNG_FORMAT_LINEAR_RGB_ALPHA \
+ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)
+
+/* PNG_IMAGE macros
+ *
+ * These are convenience macros to derive information from a png_image structure
+ */
+#define PNG_IMAGE_CHANNELS(fmt)\
+ (1+((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)))
+ /* Return the total number of channels in a given format: 1..4 */
+
+#define PNG_IMAGE_COMPONENT_SIZE(fmt)\
+ (((fmt) & PNG_FORMAT_FLAG_LINEAR) ? sizeof (png_uint_16) : sizeof (png_byte))
+ /* Return the size in bytes of a single component of a pixel in the image. */
+
+#define PNG_IMAGE_PIXEL_SIZE(fmt)\
+ (PNG_IMAGE_CHANNELS(fmt) * PNG_IMAGE_COMPONENT_SIZE(fmt))
+ /* Return the size in bytes of a single pixel in the image. */
+
+#define PNG_IMAGE_ROW_STRIDE(image)\
+ (PNG_IMAGE_CHANNELS((image).format) * (image).width)
+ /* Return the total number of components in a single row of the image; this
+ * is the minimum 'row stride', the minimum count of components between each
+ * row. */
+
+#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\
+ (PNG_IMAGE_COMPONENT_SIZE((image).format) * (image).height * (row_stride))
+ /* Return the size, in bytes, of an image buffer given a png_image and a row
+ * stride - the number of components to leave space for in each row. */
+
+/* PNG_IMAGE_FLAG_*
+ *
+ * Flags containing additional information about the image are held in the
+ * 'flags' field of png_image.
+ */
+#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 1
+ /* This indicates the the RGB values of the in-memory bitmap do not
+ * correspond to the red, green and blue end-points defined by sRGB. If this
+ * flag is set on read the PNG file contained information which identified a
+ * different colorspace. The application should set the flag on write if it
+ * knows that the data being written has different end-points.
+ *
+ * When writing 8-bit format files libpng will write an 'sRGB' chunk, to
+ * indicate sRGB data, unless this flag is set. When writing 16-bit format
+ * files libpng will write color space information matching the sRGB
+ * end-points unless the flag is set.
+ *
+ * Regardless of the setting of this flag the gamma encoding is always either
+ * linear or (approximately) sRGB; a gamma of about 2.2
+ */
+
+#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
+/* 3) READ APIs
+ * ------------
+ *
+ * The png_image passed to the read APIs must have been initialized by setting
+ * the png_controlp field 'opaque' to NULL.
+ */
+#ifdef PNG_STDIO_SUPPORTED
+int png_image_begin_read_from_file(png_imagep image, const char *file_name);
+ /* The named file is opened for read and the image filled in from the PNG
+ * header in the file, the file may remain open until the image is read from
+ * it.
+ */
+
+int png_image_begin_read_from_stdio(png_imagep image, FILE* file);
+ /* The PNG header is read from the stdio FILE object. The FILE must be open
+ * for read and positioned at the start of the PNG data (the signature), the
+ * FILE will be retained until the image has been read from it, however it is
+ * not closed. After a successful image read the FILE will point to just
+ * after the end of the PNG data.
+ */
+#endif
+
+int png_image_begin_read_from_memory(png_imagep image, png_const_voidp memory,
+ png_size_t size);
+ /* The PNG header is read from the given memory buffer. A pointer to the
+ * buffer is retained until the image has been read from it - the buffer is
+ * not copied.
+ */
+
+/* After initialization all members of the png_image structure will have been
+ * filled in. In the event of error the APIs return false and fill in
+ * png_image::warning_or_error and png_image::message with information about the
+ * nature of the error.
+ *
+ * After a successful return (true) the application can immediately call
+ * png_image_finish_read (below) with an appropriately sized buffer. More
+ * usually, however, the application will change the png_image::format field to
+ * the desired format.
+ *
+ * The initialization APIs fill in png_image::format as follows:
+ *
+ * 1) For any PNG image with a component bit depth of 16 PNG_FORMAT_FLAG_LINEAR
+ * is set in the result. PNG_FORMAT_FLAG_RGB and PNG_FORMAT_FLAG_ALPHA are
+ * added as appropriate.
+ *
+ * 2) For any other image with an alpha channel or with transparency information
+ * PNG_FORMAT_RGBA or PNG_FORMAT_GA is returned.
+ *
+ * 3) For all other images PNG_FORMAT_RGB or PNG_FORMAT_GRAY is returned.
+ *
+ * The presence of alpha/transparency information can be detected by using a
+ * bitwise 'and' for the format value with PNG_FORMAT_FLAG_ALPHA. The presence
+ * of color channels (as opposed to a single gray/luminance channel) can be
+ * detected using PNG_FORMAT_FLAG_COLOR.
+ *
+ * The format field may be changed after the first read API has been called to
+ * any of the formats defined above.
+ *
+ * png_image::flags will be set to indicate potential problems decoding the
+ * image to one of the in-memory formats. At present only one flag is set:
+ *
+ * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB
+ * If set this indicates that the PNG file contains color data with end
+ * points that do not match those used in the sRGB specification, for example
+ * if the file uses one of the wide gamut color spaces. The field is only
+ * set if a cHRM chunk or iCCP chunk was present, the image was in a color
+ * format (not grayscale) and the cHRM chunk or (if absent) the iCCP chunk
+ * did not match the sRGB color end points. The gamma encoding of the PNG
+ * file is irrelevant - it is always converted to either linear (for the
+ * 16-bit format) or a gamma approximating sRGB.
+ *
+ * To read the image the application must first allocate or identify a buffer
+ * large enough for the whole image in the desired format. If the output format
+ * will not contain an alpha channel yet the format from the PNG file does have
+ * alpha information (PNG_FORMAT_FLAG_ALPHA is set) the application must decide
+ * how to remove the alpha channel:
+ *
+ * 1) For 16-bit linear output the alpha channel is simply stripped - the
+ * remaining channels contain the pre-multiplied component values. This is
+ * equivalent to compositing the image onto a black background.
+ *
+ * 2) For 8-bit sRGB output the application can chose to provide an sRGB
+ * background color. The image is composited onto this color. If the output
+ * will only have one channel the sRGB green value is used as the background
+ * (gray) color.
+ *
+ * 3) If a background color is not supplied the application must initialize the
+ * output buffer with the background. The image will be composited directly
+ * onto this.
+ *
+ * Once a buffer has been prepared the application should call:
+ */
+int png_image_finish_read(png_imagep image, png_colorp background, void *buffer,
+ png_int_32 row_stride);
+ /* Finish reading the image into the supplied buffer and clean up the
+ * png_image structure.
+ *
+ * row_stride is the step, in png_byte or png_uint_16 units as appropriate,
+ * between adjacent rows. A positive stride indicates that the top-most row
+ * is first in the buffer - the normal top-down arrangement. A negative
+ * stride indicates that the bottom-most row is first in the buffer.
+ *
+ * background need only be supplied if an alpha channel must be removed from
+ * a png_byte format and the removal is to be done by compositing on a solid
+ * color; otherwise it may be NULL and any composition will be done directly
+ * onto the buffer. The value is an sRGB color to use for the background,
+ * for grayscale output the green channel is used.
+ *
+ * For linear output removing an alpha channel is always done by compositing
+ * on black.
+ *
+ * The buffer must be large enough to contain the whole image -
+ * height*row_stride pixels. Each pixel will contain between 1 and 4
+ * png_byte or png_uint_16 values. Use the PNG_IMAGE_ macros above to
+ * perform the required calculations.
+ *
+ * After png_image_finish_read returns the png_image::opaque structure left
+ * by the initialization routine will have been cleaned up; the pointer will
+ * be NULL. If you don't call png_image_finish_read for some reason,
+ * however, simply call:
+ */
+#endif
+
+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. It
+ * is not necessary to use this with the write API, but it can be called
+ * because the opaque pointer must be initialized to NULL for write.
+ *
+ * The function does not change, or use, any other field in the png_image it
+ * is passed unless an error or warning occurs, in which case the error
+ * fields will be set.
+ */
+
+#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
+/* 4) WRITE APIS
+ * -------------
+ * For write you must initialize a png_image structure. It is suggested that
+ * you use memset(&image, 0, sizeof image) to ensure safe initialization. Doing
+ * this will also ensure that extensions to png_image in the future will be
+ * safe.
+ *
+ * You need to explicitly initialize the following fields:
+ *
+ * opaque: must be initialized to NULL
+ * width: image width in pixels
+ * height: image height in rows
+ * format: the format of the data you wish to write
+ * flags: set to 0 unless one of the defined flags applies; set
+ * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB
+ * values do not correspond to the colors in sRGB.
+ *
+ * At present STDIO support is required for the write API and write only
+ * supports output to a named file or a stdio stream (FILE*). Once the
+ * png_image structure is initialized call one of:
+ */
+#ifdef PNG_STDIO_SUPPORTED
+int png_image_write_to_file(png_imagep image, const char *file,
+ int convert_to_8bit, const void *buffer, png_int_32 row_stride);
+ /* Write the image to the named file. The file will be opened for write and
+ * truncated. In the event of error the API will attempt to remove a
+ * partially written file (but it will not attempt to remove a file if the
+ * open fails.) In the event of success the file will have been closed
+ * before the API returns. The API does not fsync() the file.
+ */
+
+int png_image_write_to_stdio(png_imagep image, FILE *file,
+ int convert_to_8_bit, const void *buffer, png_int_32 row_stride);
+ /* Write the image to the given (FILE*). This is only supported on operating
+ * systems with stdio support. The PNG data is written to the given FILE*
+ * using the standard stdio function fwrite(), fflush() will not necessarily
+ * be called and the file pointer will be left at the end of the PNG data.
+ */
+#endif
+
+/* With all APIs if image->format is PNG_FORMAT_FP then setting convert_to_8_bit
+ * will cause the output to be an 8-bit RGBA PNG gamma encoded according to the
+ * sRGB specification. If the flag is not set PNG_FORMAT_FP is written as a
+ * linear 16-bit component depth PNG. In either case the color components and
+ * alpha channel, if present, are converted to match the PNG format.
+ *
+ * With all APIs row_stride is handled as in the read APIs - it is the spacing
+ * from one row to the next in component sized units (float) and if negative
+ * indicates a bottom-up row layout in the buffer.
+ *
+ * All APIs clear the error handling fields, however the opaque pointer must
+ * have been initialized to NULL. Future extensions may used this field to
+ * communicate information to a subsequent write. You may call png_image_free
+ * on the png_image, but it is not currently necessary.
+ */
+
+/* 5) WRITING TO MEMORY
+ * --------------------
+ * libpng does not provide a png_image API to write directly to memory. This is
+ * both because of the wide variety of restrictions and variations in efficiency
+ * of memory allocators on different platforms and because the simple approach
+ * of reallocing a memory block to accomodate the PNG data as it is written is
+ * disastrously slow for large PNG files.
+ *
+ * Instead you may copy and paste the following code into your application,
+ * changing the call to 'malloc' if required. Notice that the size of data
+ * required may exceed the capacity of malloc on some older, smaller, systems.
+ *
+ * The ANSI-C function tmpfile() is used here because it is normally extremely
+ * efficient and fast (more so than realloc.) You can also use png_image_write
+ * to write to memory in a different format, for instance a linked list of
+ * memory blocks, if this is appropriate.
+ */
+#ifdef PNG_EXAMPLE_CODE_IN_PNG_H
+#include <stdlib.h>
+#include <stdio.h>
+#include <png.h>
+
+void *png_image_write_to_memory(png_imagep image, size_t *size,
+ int convert_to_8bit, const void *buffer, png_int_32 row_stride)
+{
+ FILE *tmp = tmpfile();
+ void *mem = NULL;
+
+ if (tmp != NULL)
+ {
+ if (png_image_write_to_file(image, tmp, convert_to_8_bit, buffer,
+ row_stride))
+ {
+ long int cb = ftell(tmp);
+
+ image->error_or_warning = 0;
+
+ if (cb > 0)
+ {
+ /* On some systems (size_t) may be smaller than (long int), in that
+ * case you may need to use a function other than malloc to obtain
+ * the required memory here, depending on how big the PNG is.
+ */
+ *size = cb;
+ mem = malloc(*size);
+
+ if (mem != NULL)
+ {
+ rewind(tmp);
+
+ if (fread(mem, *size, 1, tmp) != 1)
+ {
+ free(mem);
+ mem = NULL;
+ }
+ }
+ }
+ }
+
+ fclose(tmp);
+ }
+
+ return mem;
+}
+#endif
+#endif
diff --git a/pngwrite.c b/pngwrite.c
index 2a72ad33f..18f535cd6 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
- * Last changed in libpng 1.5.11 [June 14, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -420,7 +420,6 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
}
#ifdef PNG_CONVERT_tIME_SUPPORTED
-/* "tm" structure is not supported on WindowsCE */
void PNGAPI
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm FAR * ttime)
{
@@ -1042,6 +1041,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
case 5:
case 6:
case 7: png_warning(png_ptr, "Unknown row filter for method 0");
+ /* FALL THROUGH */
#endif /* PNG_WRITE_FILTER_SUPPORTED */
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
diff --git a/pngwutil.c b/pngwutil.c
index 19b75afa3..604ad32aa 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file
*
- * Last changed in libpng 1.5.10 [March 8, 2012]
- * Copyright (c) 1998-2012 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.14 [January 24, 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.)
*
@@ -460,24 +460,21 @@ png_text_compress(png_structp png_ptr,
old_ptr = comp->output_ptr;
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
- (png_alloc_size_t)
- (comp->max_output_ptr * png_sizeof(png_charpp)));
+ (comp->max_output_ptr * png_sizeof(png_bytep)));
png_memcpy(comp->output_ptr, old_ptr, old_max
- * png_sizeof(png_charp));
+ * png_sizeof(png_bytep));
png_free(png_ptr, old_ptr);
}
else
comp->output_ptr = (png_bytepp)png_malloc(png_ptr,
- (png_alloc_size_t)
- (comp->max_output_ptr * png_sizeof(png_charp)));
+ (comp->max_output_ptr * png_sizeof(png_bytep)));
}
/* Save the data */
comp->output_ptr[comp->num_output_ptr] =
- (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)png_ptr->zbuf_size);
+ (png_bytep)png_malloc(png_ptr, png_ptr->zbuf_size);
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);