зеркало из https://github.com/mozilla/gecko-dev.git
Bug 648690 - Update libpng to version 1.5.9 (upstream changes). r=joedrew
This commit is contained in:
Родитель
023acdb255
Коммит
51835388d8
2481
media/libpng/CHANGES
2481
media/libpng/CHANGES
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -10,8 +10,8 @@ this sentence.
|
|||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.4.8, July 7, 2011, are
|
||||
Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are
|
||||
Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
|
@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
|||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
July 7, 2011
|
||||
February 18, 2012
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
Changes made to pristine png source by mozilla.org developers.
|
||||
|
||||
2012/02/19 -- Synced with libpng-1.5.9 (bug #648690).
|
||||
|
||||
2011/07/20 -- Synced with libpng-1.4.8 (bug #669863).
|
||||
|
||||
2011/04/08 -- Synced with libpng-1.4.7 (bug #624133).
|
||||
|
|
|
@ -59,7 +59,7 @@ CSRCS = \
|
|||
pngtrans.c \
|
||||
$(NULL)
|
||||
|
||||
# These files enable support for reading/writting PNGs
|
||||
# These files enable support for reading/writing PNGs
|
||||
CSRCS += \
|
||||
pngpread.c \
|
||||
pngread.c \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
README for libpng version 1.4.8 - July 7, 2011 (shared library 14.0)
|
||||
README for libpng version 1.5.9 - February 18, 2012 (shared library 15.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
@ -58,7 +58,7 @@ on the PNG-implement mailing list and not on material submitted
|
|||
privately to Guy, Andreas, or Glenn. They will forward any good
|
||||
suggestions to the list.
|
||||
|
||||
For a detailed description on using libpng, read libpng.txt. For
|
||||
For a detailed description on using libpng, read libpng-manual.txt. For
|
||||
examples of libpng in a program, see example.c and pngtest.c. For usage
|
||||
information and restrictions (what little they are) on libpng, see
|
||||
png.h. For a description on using zlib (the compression library used by
|
||||
|
@ -138,13 +138,17 @@ Files in this distribution:
|
|||
TODO => Things not implemented in the current library
|
||||
Y2KINFO => Statement of Y2K compliance
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => manual page for libpng (includes libpng.txt)
|
||||
libpng.txt => Description of libpng and its functions
|
||||
libpng.3 => manual page for libpng (includes libpng-manual.txt)
|
||||
libpng-manual.txt => Description of libpng and its functions
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations
|
||||
pngconf.h => System specific library configuration
|
||||
png.h => Library function and interface declarations (public)
|
||||
pngpriv.h => Library function and interface declarations (private)
|
||||
pngconf.h => System specific library configuration (public)
|
||||
pngstruct.h => png_struct declaration (private)
|
||||
pnginfo.h => png_info struct declaration (private)
|
||||
pngdebug.h => debugging macros (private)
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
|
@ -173,72 +177,16 @@ Files in this distribution:
|
|||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
c5builder => Contains a Borland workspace for building
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
descrip.mms => VMS makefile for MMS or MMK
|
||||
makefile.std => Generic UNIX makefile (cc, creates static
|
||||
libpng.a)
|
||||
makefile.elf => Linux/ELF makefile symbol versioning,
|
||||
(gcc, creates libpng14.so.14.1.4.8)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng14.so.14.1.4.8)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
ftp://ftp.cs.wisc.edu/ghost)
|
||||
makefile.aix => AIX makefile
|
||||
makefile.cygwin => Cygwin/gcc makefile
|
||||
makefile.darwin => Darwin makefile
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.freebsd => FreeBSD makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
||||
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit
|
||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
|
||||
makefile.intel => Intel C/C++ version 4.0 and later
|
||||
makefile.mingw => Mingw/gcc makefile
|
||||
makefile.netbsd => NetBSD/cc makefile, makes libpng.so.
|
||||
makefile.ne14bsd => NetBSD/cc makefile, makes
|
||||
libpng14.so
|
||||
makefile.openbsd => OpenBSD makefile
|
||||
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
|
||||
makefile.sggcc => Silicon Graphics
|
||||
(gcc, creates libpng14.so.14.1.4.8)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates libpng14.so.14.1.4.8)
|
||||
makefile.so9 => Solaris 9 makefile
|
||||
(gcc, creates libpng14.so.14.1.4.8)
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
makefile.64sunu => Sun Ultra 64-bit makefile
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.mips => MIPS makefile
|
||||
makefile.acorn => Acorn makefile
|
||||
makefile.amiga => Amiga makefile
|
||||
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC
|
||||
compiler (Requires SCOPTIONS, copied from
|
||||
scripts/SCOPTIONS.ppc)
|
||||
makefile.atari => Atari makefile
|
||||
makefile.beos => BEOS makefile for X86
|
||||
makefile.bor => Borland makefile (uses bcc)
|
||||
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
|
||||
makefile.tc3 => Turbo C 3.0 makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.msc => Microsoft C makefile
|
||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
|
||||
later (does not use assembler code)
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
||||
png32ce.def => module definition for makefile.cegccg
|
||||
pngos2.def => OS/2 module definition file used by
|
||||
makefile.os2
|
||||
pngwin.def => module definition file used by
|
||||
makefile.cygwin and makefile.mingw
|
||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
||||
makevms.com => VMS build script
|
||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
||||
Good luck, and happy coding.
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s): Tim Rowley <tor@cs.brown.edu>
|
||||
* Glenn Randers-Pehrson <glennrp@gmail.com>
|
||||
* Max Stepin <maxstepin@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
|
||||
|
@ -38,9 +39,16 @@
|
|||
#ifndef MOZPNGCONF_H
|
||||
#define MOZPNGCONF_H
|
||||
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_MAX_GAMMA_8 11
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||
|
||||
#define PNG_NO_GLOBAL_ARRAYS
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* The PNG_PEDANTIC_WARNINGS (attributes) fail to build with some MSC
|
||||
|
@ -49,94 +57,61 @@
|
|||
#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 */
|
||||
#ifdef MOZ_PNG_READ
|
||||
#define PNG_READ_SUPPORTED
|
||||
#define PNG_READ_APNG_SUPPORTED
|
||||
#define PNG_READ_cHRM_SUPPORTED
|
||||
#define PNG_READ_gAMA_SUPPORTED
|
||||
#define PNG_READ_iCCP_SUPPORTED
|
||||
#define PNG_READ_sRGB_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_16BIT_SUPPORTED
|
||||
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_READ_EXPAND_SUPPORTED
|
||||
#define PNG_READ_GAMMA_SUPPORTED
|
||||
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
#define PNG_READ_INTERLACING_SUPPORTED
|
||||
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_TEXT_SUPPORTED
|
||||
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||
#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
|
||||
#ifdef MOZ_PNG_WRITE
|
||||
#define PNG_WRITE_SUPPORTED
|
||||
#define PNG_WRITE_APNG_SUPPORTED
|
||||
#define PNG_WRITE_tRNS_SUPPORTED
|
||||
#define PNG_WRITE_16BIT_SUPPORTED
|
||||
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||
#endif
|
||||
|
||||
#define PNG_APNG_SUPPORTED
|
||||
#define PNG_cHRM_SUPPORTED
|
||||
#define PNG_gAMA_SUPPORTED
|
||||
#define PNG_iCCP_SUPPORTED
|
||||
#define PNG_sRGB_SUPPORTED
|
||||
#define PNG_tRNS_SUPPORTED
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_CHECK_cHRM_SUPPORTED
|
||||
#define PNG_FIXED_POINT_SUPPORTED
|
||||
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
#define PNG_FLOATING_POINT_SUPPORTED
|
||||
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_TEXT_SUPPORTED
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_ERROR_TEXT_SUPPORTED
|
||||
#define PNG_WARNINGS_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* Mangle names of exported libpng functions so different libpng versions
|
||||
can coexist. It is recommended that if you do this, you give your
|
||||
|
@ -156,30 +131,34 @@
|
|||
/* 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 */
|
||||
#define png_sig_cmp MOZ_PNG_sig_cmp
|
||||
#define png_access_version_number MOZ_PNG_access_vn
|
||||
|
||||
/* 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 */
|
||||
#define png_set_sig_bytes MOZ_PNG_set_sig_b
|
||||
#define png_reset_zstream MOZ_PNG_reset_zs
|
||||
|
||||
/* The following may have changed, or can be affected by conditional compilation
|
||||
choices, and will be mangled. */
|
||||
#define png_64bit_product MOZ_PNG_64bit_product
|
||||
#define png_benign_error MOZ_PNG_benign_error
|
||||
#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_calloc MOZ_PNG_calloc
|
||||
#define png_check_cHRM_fixed MOZ_PNG_ck_cHRM_fixed
|
||||
#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_check_IHDR MOZ_PNG_ck_IHDR
|
||||
#define png_check_keyword MOZ_PNG_ck_keyword
|
||||
#define png_chunk_benign_error MOZ_PNG_ck_benign_error
|
||||
#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_correct_palette MOZ_PNG_correct_palette
|
||||
#define png_crc_error MOZ_PNG_crc_error
|
||||
#define png_crc_finish MOZ_PNG_crc_finish
|
||||
#define png_crc_read MOZ_PNG_crc_read
|
||||
|
@ -194,20 +173,17 @@
|
|||
#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_default_write_data MOZ_PNG_default_write_data
|
||||
#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
|
||||
|
@ -221,25 +197,28 @@
|
|||
#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_shift MOZ_PNG_do_shift
|
||||
#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_do_write_interlace MOZ_PNG_do_write_interlace
|
||||
#define png_do_write_intrapixel MOZ_PNG_do_write_intrapixel
|
||||
#define png_do_write_invert_alpha MOZ_PNG_do_write_invert_alpha
|
||||
#define png_do_write_swap_alpha MOZ_PNG_do_write_swap_alpha
|
||||
#define png_do_write_transformations MOZ_PNG_do_write_trans
|
||||
#define png_err MOZ_PNG_err
|
||||
#define png_far_to_near MOZ_PNG_far_to_near
|
||||
#define png_fixed MOZ_PNG_fixed
|
||||
#define png_flush MOZ_PNG_flush
|
||||
#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_bKGD MOZ_PNG_get_bKGD
|
||||
#define png_get_channels MOZ_PNG_get_channels
|
||||
#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
|
||||
|
@ -248,20 +227,25 @@
|
|||
#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_hIST MOZ_PNG_get_hIST
|
||||
#define png_get_iCCP MOZ_PNG_get_iCCP
|
||||
#define png_get_IHDR MOZ_PNG_get_IHDR
|
||||
#define png_get_image_height MOZ_PNG_get_image_h
|
||||
#define png_get_image_width MOZ_PNG_get_image_w
|
||||
#define png_get_int_32 MOZ_PNG_get_int_32
|
||||
#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_pHYs_dpi MOZ_PNG_get_pHYs_dpi
|
||||
#define png_get_pixel_aspect_ratio MOZ_PNG_get_pixel_aspect_ratio
|
||||
#define png_get_pixels_per_inch MOZ_PNG_get_pixels_per_inch
|
||||
#define png_get_pixels_per_meter MOZ_PNG_get_pixels_p_m
|
||||
#define png_get_PLTE MOZ_PNG_get_PLTE
|
||||
#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
|
||||
|
@ -269,34 +253,44 @@
|
|||
#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_signature MOZ_PNG_get_signature
|
||||
#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_text MOZ_PNG_get_text
|
||||
#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_uint_16 MOZ_PNG_get_uint_16
|
||||
#define png_get_uint_31 MOZ_PNG_get_uint_31
|
||||
#define png_get_uint_32 MOZ_PNG_get_uint_32
|
||||
#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_height_max MOZ_PNG_get_user_height_max
|
||||
#define png_get_user_transform_ptr MOZ_PNG_get_user_transform_ptr
|
||||
#define png_get_user_width_max MOZ_PNG_get_user_width_max
|
||||
#define png_get_valid MOZ_PNG_get_valid
|
||||
#define png_get_x_offset_inches MOZ_PNG_get_x_offset_inches
|
||||
#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_inch MOZ_PNG_get_x_pixels_per_inch
|
||||
#define png_get_x_pixels_per_meter MOZ_PNG_get_x_pix_per_meter
|
||||
#define png_get_y_offset_inches MOZ_PNG_get_y_offset_inches
|
||||
#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_inch MOZ_PNG_get_y_pixels_per_inch
|
||||
#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_IEND MOZ_PNG_handle_IEND
|
||||
#define png_handle_IHDR MOZ_PNG_handle_IHDR
|
||||
#define png_handle_iTXt MOZ_PNG_handle_iTXt
|
||||
#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_PLTE MOZ_PNG_handle_PLTE
|
||||
#define png_handle_sBIT MOZ_PNG_handle_sBIT
|
||||
#define png_handle_sCAL MOZ_PNG_handle_sCAL
|
||||
#define png_handle_sPLT MOZ_PNG_handle_sPLT
|
||||
|
@ -306,24 +300,24 @@
|
|||
#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_inflate MOZ_PNG_inflate
|
||||
#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_IDAT_data MOZ_PNG_proc_IDAT_data
|
||||
#define png_process_some_data MOZ_PNG_proc_some_data
|
||||
#define png_progressive_combine_row MOZ_PNG_progressive_combine_row
|
||||
#define png_push_check_crc MOZ_PNG_push_check_crc
|
||||
#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_iTXt MOZ_PNG_push_handle_iTXt
|
||||
#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
|
||||
|
@ -331,13 +325,16 @@
|
|||
#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_end MOZ_PNG_push_read_end
|
||||
#define png_push_read_IDAT MOZ_PNG_push_read_IDAT
|
||||
#define png_push_read_iTXt MOZ_PNG_push_read_iTXt
|
||||
#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_chunk_header MOZ_PNG_read_chunk_header
|
||||
#define png_read_data MOZ_PNG_read_data
|
||||
#define png_read_destroy MOZ_PNG_read_dest
|
||||
#define png_read_end MOZ_PNG_read_end
|
||||
|
@ -345,8 +342,6 @@
|
|||
#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
|
||||
|
@ -355,12 +350,14 @@
|
|||
#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_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
|
||||
#define png_set_add_alpha MOZ_PNG_set_add_alpha
|
||||
#define png_set_background MOZ_PNG_set_background
|
||||
#define png_set_benign_errors MOZ_PNG_set_benign_errors
|
||||
#define png_set_bgr MOZ_PNG_set_bgr
|
||||
#define png_set_bKGD MOZ_PNG_set_bKGD
|
||||
#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
|
||||
|
@ -370,9 +367,9 @@
|
|||
#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_expand_gray_1_2_4_to_8 MOZ_PNG_set_x_g_124_to_8
|
||||
#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
|
||||
|
@ -380,23 +377,23 @@
|
|||
#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_IHDR MOZ_PNG_set_IHDR
|
||||
#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_pCAL MOZ_PNG_set_pCAL
|
||||
#define png_set_pHYs MOZ_PNG_set_pHYs
|
||||
#define png_set_PLTE MOZ_PNG_set_PLTE
|
||||
#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
|
||||
|
@ -408,128 +405,230 @@
|
|||
#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_shift MOZ_PNG_set_shift
|
||||
#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_text MOZ_PNG_set_text
|
||||
#define png_set_text_2 MOZ_PNG_set_text_2
|
||||
#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_limits MOZ_PNG_set_user_limits
|
||||
#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_text_compress MOZ_PNG_text_compress
|
||||
#define png_write_bKGD MOZ_PNG_write_bKGD
|
||||
#define png_write_cHRM MOZ_PNG_write_cHRM
|
||||
#define png_write_cHRM_fixed MOZ_PNG_write_cHRM_fixed
|
||||
#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_compressed_data_out MOZ_PNG_write_compressed_data_out
|
||||
#define png_write_data MOZ_PNG_write_data
|
||||
#define png_write_destroy MOZ_PNG_write_destroy
|
||||
#define png_write_end MOZ_PNG_write_end
|
||||
#define png_write_filtered_row MOZ_PNG_write_filtered_row
|
||||
#define png_write_find_filter MOZ_PNG_write_find_filter
|
||||
#define png_write_finish_row MOZ_PNG_write_finish_row
|
||||
#define png_write_flush MOZ_PNG_write_flush
|
||||
#define png_write_gAMA MOZ_PNG_write_gAMA
|
||||
#define png_write_gAMA_fixed MOZ_PNG_write_gAMA_fixed
|
||||
#define png_write_hIST MOZ_PNG_write_hIST
|
||||
#define png_write_iCCP MOZ_PNG_write_iCCP
|
||||
#define png_write_IDAT MOZ_PNG_write_IDAT
|
||||
#define png_write_IEND MOZ_PNG_write_IEND
|
||||
#define png_write_IHDR MOZ_PNG_write_IHDR
|
||||
#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_iTXt MOZ_PNG_write_iTXt
|
||||
#define png_write_oFFs MOZ_PNG_write_oFFs
|
||||
#define png_write_pCAL MOZ_PNG_write_pCAL
|
||||
#define png_write_pHYs MOZ_PNG_write_pHYs
|
||||
#define png_write_PLTE MOZ_PNG_write_PLTE
|
||||
#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_write_sBIT MOZ_PNG_write_sBIT
|
||||
#define png_write_sCAL_s MOZ_PNG_write_sCAL_s
|
||||
#define png_write_sig MOZ_PNG_write_sig
|
||||
#define png_write_sPLT MOZ_PNG_write_sPLT
|
||||
#define png_write_sRGB MOZ_PNG_write_sRGB
|
||||
#define png_write_start_row MOZ_PNG_write_trans
|
||||
#define png_write_tEXt MOZ_PNG_write_tEXt
|
||||
#define png_write_tIME MOZ_PNG_write_tIME
|
||||
#define png_write_tRNS MOZ_PNG_write_tRNS
|
||||
#define png_write_zTXt MOZ_PNG_write_zTXt
|
||||
#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
|
||||
#define onebppswaptable MOZ_onebppswaptable
|
||||
#define twobppswaptable MOZ_twobppswaptable
|
||||
#define fourbppswaptable MOZ_fourbppswaptable
|
||||
|
||||
/* APNG additions */
|
||||
#define png_ensure_fcTL_is_valid MOZ_APNG_ensure_fcTL_is_valid
|
||||
#define png_ensure_sequence_number MOZ_APNG_ensure_seqno
|
||||
#define png_get_acTL MOZ_APNG_get_acTL
|
||||
#define png_get_first_frame_is_hidden MOZ_APNG_get_first_frame_is_hidden
|
||||
#define png_get_next_frame_blend_op MOZ_APNG_get_next_frame_blend_op
|
||||
#define png_get_next_frame_delay_den MOZ_APNG_get_next_frame_delay_den
|
||||
#define png_get_next_frame_delay_num MOZ_APNG_get_next_frame_delay_num
|
||||
#define png_get_next_frame_dispose_op MOZ_APNG_get_next_frame_dispose_op
|
||||
#define png_get_next_frame_fcTL MOZ_APNG_get_next_frame_fcTL
|
||||
#define png_get_next_frame_height MOZ_APNG_get_next_frame_height
|
||||
#define png_get_next_frame_width MOZ_APNG_get_next_frame_width
|
||||
#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_num_frames MOZ_APNG_set_num_frames
|
||||
#define png_get_num_plays MOZ_APNG_set_num_plays
|
||||
#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_frame_head MOZ_APNG_read_frame_head
|
||||
#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_set_acTL MOZ_APNG_set_acTL
|
||||
#define png_set_first_frame_is_hidden MOZ_APNG_set_first_frame_is_hidden
|
||||
#define png_set_next_frame_fcTL MOZ_APNG_set_next_frame_fcTL
|
||||
#define png_set_progressive_frame_fn MOZ_APNG_set_prog_frame_fn
|
||||
#define png_write_acTL MOZ_APNG_write_acTL
|
||||
#define png_write_fcTL MOZ_APNG_write_fcTL
|
||||
#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
|
||||
#define png_write_reset MOZ_APNG_write_reset
|
||||
|
||||
#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
|
||||
/* libpng-1.4.x additions */
|
||||
#define png_do_quantize MOZ_PNG_do_quantize
|
||||
#define png_get_chunk_cache_max MOZ_PNG_get_chunk_cache_max
|
||||
#define png_get_chunk_malloc_max MOZ_PNG_get_chunk_malloc_max
|
||||
#define png_get_io_chunk_name MOZ_PNG_get_io_chunk_name
|
||||
#define png_get_io_state MOZ_PNG_get_io_state
|
||||
#define png_longjmp MOZ_PNG_longjmp
|
||||
#define png_read_sig MOZ_PNG_read_sig
|
||||
#define png_set_chunk_cache_max MOZ_PNG_set_chunk_cache_max
|
||||
#define png_set_chunk_malloc_max MOZ_PNG_set_chunk_malloc_max
|
||||
#define png_set_longjmp_fn MOZ_PNG_set_longjmp_fn
|
||||
#define png_set_quantize MOZ_PNG_set_quantize
|
||||
|
||||
/* libpng-1.5.x additions */
|
||||
#define png_32bit_exp MOZ_PNG_32bit_exp
|
||||
#define png_8bit_l2 MOZ_PNG_8bit_l2
|
||||
#define png_ascii_from_fixed MOZ_PNG_ascii_from_fixed
|
||||
#define png_ascii_from_fp MOZ_PNG_ascii_from_fp
|
||||
#define png_build_16bit_table MOZ_PNG_build_16bit_table
|
||||
#define png_build_16to8_table MOZ_PNG_build_16to8_table
|
||||
#define png_build_8bit_table MOZ_PNG_build_8bit_table
|
||||
#define png_check_fp_number MOZ_PNG_check_fp_number
|
||||
#define png_check_fp_string MOZ_PNG_check_fp_string
|
||||
#define png_chunk_unknown_handling MOZ_PNG_chunk_unk_handling
|
||||
#define png_destroy_gamma_table MOZ_PNG_destroy_gamma_table
|
||||
#define png_do_compose MOZ_PNG_do_compose
|
||||
#define png_do_encode_alpha MOZ_PNG_do_encode_alpha
|
||||
#define png_do_expand_16 MOZ_PNG_do_expand_16
|
||||
#define png_do_scale_16_to_8 MOZ_PNG_do_scale_16_to_8
|
||||
#define png_do_strip_channel MOZ_PNG_do_strip_channel
|
||||
#define png_exp MOZ_PNG_exp
|
||||
#define png_exp16bit MOZ_PNG_exp16bit
|
||||
#define png_exp8bit MOZ_PNG_exp8bit
|
||||
#define png_fixed_error MOZ_PNG_fixed_error
|
||||
#define png_fixed_inches_from_microns MOZ_PNG_fixed_inch_from_micr
|
||||
#define png_format_number MOZ_PNG_format_number
|
||||
#define png_formatted_warning MOZ_PNG_formatted_warning
|
||||
#define png_gamma_16bit_correct MOZ_PNG_gamma_16bit_correct
|
||||
#define png_gamma_8bit_correct MOZ_PNG_gamma_8bit_correct
|
||||
#define png_gamma_correct MOZ_PNG_gamma_correct
|
||||
#define png_gamma_significant MOZ_PNG_gamma_significant
|
||||
#define png_gamma_threshold MOZ_PNG_gamma_threshold
|
||||
#define png_get_cHRM_XYZ MOZ_PNG_get_cHRM_XYZ
|
||||
#define png_get_cHRM_XYZ_fixed MOZ_PNG_get_cHRM_XYZ_fixed
|
||||
#define png_get_current_pass_number MOZ_PNG_get_cur_pass_number
|
||||
#define png_get_current_row_number MOZ_PNG_get_cur_row_number
|
||||
#define png_get_fixed_point MOZ_PNG_get_fixed_point
|
||||
#define png_get_io_chunk_type MOZ_PNG_get_io_chunk_type
|
||||
#define png_get_pixel_aspect_ratio_fixed MOZ_PNG_get_pixel_aspect_fx
|
||||
#define png_get_sCAL_fixed MOZ_PNG_get_sCAL_fixed
|
||||
#define png_get_x_offset_inches_fixed MOZ_PNG_get_x_offs_inches_fx
|
||||
#define png_get_y_offset_inches_fixed MOZ_PNG_get_y_offs_inches_fx
|
||||
#define png_have_hwcap MOZ_PNG_have_hwcap
|
||||
#define png_init_filter_functions MOZ_PNG_init_filt_func
|
||||
#define png_init_filter_functions_neon MOZ_PNG_init_filt_func_neon
|
||||
#define png_init_filter_heuristics MOZ_PNG_init_filt_heur
|
||||
#define png_init_palette_transformations MOZ_PNG_init_palette_transf
|
||||
#define png_init_rgb_transformations MOZ_PNG_init_rgb_transf
|
||||
#define png_log16bit MOZ_PNG_log16bit
|
||||
#define png_log8bit MOZ_PNG_log8bit
|
||||
#define png_muldiv MOZ_PNG_muldiv
|
||||
#define png_muldiv_warn MOZ_PNG_muldiv_warn
|
||||
#define png_pow10 MOZ_PNG_pow10
|
||||
#define png_process_data_pause MOZ_PNG_process_data_pause
|
||||
#define png_process_data_skip MOZ_PNG_process_data_skip
|
||||
#define png_product2 MOZ_PNG_product2
|
||||
#define png_read_filter_row_avg MOZ_PNG_read_filt_row_a
|
||||
#define png_read_filter_row_avg3_neon MOZ_PNG_read_filt_row_a3_neon
|
||||
#define png_read_filter_row_avg4_neon MOZ_PNG_read_filt_row_a4_neon
|
||||
#define png_read_filter_row_paeth_1byte_pixel MOZ_PNG_read_filt_row_p_1b_px
|
||||
#define png_read_filter_row_paeth_multibyte_pixel MOZ_PNG_read_filt_row_p_mb_px
|
||||
#define png_read_filter_row_paeth3_neon MOZ_PNG_read_filt_row_p3_neon
|
||||
#define png_read_filter_row_paeth4_neon MOZ_PNG_read_filt_row_p4_neon
|
||||
#define png_read_filter_row_sub MOZ_PNG_read_filt_row_s
|
||||
#define png_read_filter_row_sub3_neon MOZ_PNG_read_filt_row_s3_neon
|
||||
#define png_read_filter_row_sub4_neon MOZ_PNG_read_filt_row_s4_neon
|
||||
#define png_read_filter_row_up MOZ_PNG_read_filt_row_up
|
||||
#define png_read_filter_row_up_neon MOZ_PNG_read_filt_row_up_neon
|
||||
#define png_reciprocal MOZ_PNG_reciprocal
|
||||
#define png_reciprocal2 MOZ_PNG_reciprocal2
|
||||
#define png_reset_filter_heuristics MOZ_PNG_reset_filt_heur
|
||||
#define png_safecat MOZ_PNG_safecat
|
||||
#define png_set_alpha_mode MOZ_PNG_set_alpha_mode
|
||||
#define png_set_alpha_mode_fixed MOZ_PNG_set_alpha_mode_fx
|
||||
#define png_set_background_fixed MOZ_PNG_set_background_fx
|
||||
#define png_set_cHRM_XYZ MOZ_PNG_set_cHRM_XYZ
|
||||
#define png_set_cHRM_XYZ_fixed MOZ_PNG_set_cHRM_XYZ_fixed
|
||||
#define png_set_expand_16 MOZ_PNG_set_expand_16
|
||||
#define png_set_filter_heuristics_fixed MOZ_PNG_set_filter_heur_fx
|
||||
#define png_set_gamma_fixed MOZ_PNG_set_gamma_fixed
|
||||
#define png_set_sCAL_fixed MOZ_PNG_set_sCAL_fixed
|
||||
#define png_set_scale_16 MOZ_PNG_set_scale_16
|
||||
#define png_set_text_compression_level MOZ_PNG_set_text_c_level
|
||||
#define png_set_text_compression_mem_level MOZ_PNG_set_text_c_mem_level
|
||||
#define png_set_text_compression_method MOZ_PNG_set_text_c_method
|
||||
#define png_set_text_compression_strategy MOZ_PNG_set_text_c_strategy
|
||||
#define png_set_text_compression_window_bits MOZ_PNG_set_text_c_wnd_bits
|
||||
#define png_user_version_check MOZ_PNG_user_version_check
|
||||
#define png_warning_parameter MOZ_PNG_warn_param
|
||||
#define png_warning_parameter_signed MOZ_PNG_warn_param_signed
|
||||
#define png_warning_parameter_unsigned MOZ_PNG_warn_param_unsigned
|
||||
#define png_write_chunk_header MOZ_PNG_write_chunk_header
|
||||
#define png_write_complete_chunk MOZ_PNG_write_complete_chunk
|
||||
#define png_xy_from_XYZ MOZ_PNG_xy_from_XYZ
|
||||
#define png_XYZ_from_xy MOZ_PNG_XYZ_from_xy
|
||||
#define png_XYZ_from_xy_checked MOZ_PNG_XYZ_from_xy_checked
|
||||
#define png_zlib_claim MOZ_PNG_zlib_claim
|
||||
#define png_zlib_release MOZ_PNG_zlib_release
|
||||
#define convert_gamma_value MOZ_convert_gamma_value
|
||||
#define ppi_from_ppm MOZ_ppi_from_ppm
|
||||
#define translate_gamma_flags MOZ_translate_gamma_flags
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
#define png_warning MOZ_PNG_warning
|
||||
#define png_error MOZ_PNG_error
|
||||
#define png_chunk_error MOZ_PNG_chunk_err
|
||||
#define png_chunk_warning MOZ_PNG_chunk_warn
|
||||
#endif
|
||||
|
||||
#endif /* MOZPNGCONF_H */
|
||||
|
|
2310
media/libpng/png.c
2310
media/libpng/png.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
2876
media/libpng/png.h
2876
media/libpng/png.h
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,157 @@
|
|||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* 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.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Define PNG_DEBUG at compile time for debugging information. Higher
|
||||
* numbers for PNG_DEBUG mean more debugging information. This has
|
||||
* only been added since version 0.95 so it is not implemented throughout
|
||||
* libpng yet, but more support will be added as needed.
|
||||
*
|
||||
* png_debug[1-2]?(level, message ,arg{0-2})
|
||||
* Expands to a statement (either a simple expression or a compound
|
||||
* do..while(0) statement) that outputs a message with parameter
|
||||
* substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG
|
||||
* is undefined, 0 or 1 every png_debug expands to a simple expression
|
||||
* (actually ((void)0)).
|
||||
*
|
||||
* level: level of detail of message, starting at 0. A level 'n'
|
||||
* message is preceded by 'n' tab characters (not implemented
|
||||
* on Microsoft compilers unless PNG_DEBUG_FILE is also
|
||||
* defined, to allow debug DLL compilation with no standard IO).
|
||||
* message: a printf(3) style text string. A trailing '\n' is added
|
||||
* to the message.
|
||||
* arg: 0 to 2 arguments for printf(3) style substitution in message.
|
||||
*/
|
||||
#ifndef PNGDEBUG_H
|
||||
#define PNGDEBUG_H
|
||||
/* These settings control the formatting of messages in png.c and pngerror.c */
|
||||
/* Moved to pngdebug.h at 1.5.0 */
|
||||
# ifndef PNG_LITERAL_SHARP
|
||||
# define PNG_LITERAL_SHARP 0x23
|
||||
# endif
|
||||
# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
|
||||
# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
|
||||
# endif
|
||||
# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET
|
||||
# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d
|
||||
# endif
|
||||
# ifndef PNG_STRING_NEWLINE
|
||||
# define PNG_STRING_NEWLINE "\n"
|
||||
# endif
|
||||
|
||||
#ifdef PNG_DEBUG
|
||||
# if (PNG_DEBUG > 0)
|
||||
# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
|
||||
# include <crtdbg.h>
|
||||
# if (PNG_DEBUG > 1)
|
||||
# ifndef _DEBUG
|
||||
# define _DEBUG
|
||||
# endif
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
_RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
|
||||
# endif
|
||||
# endif
|
||||
# else /* PNG_DEBUG_FILE || !_MSC_VER */
|
||||
# ifndef PNG_STDIO_SUPPORTED
|
||||
# include <stdio.h> /* not included yet */
|
||||
# endif
|
||||
# ifndef PNG_DEBUG_FILE
|
||||
# define PNG_DEBUG_FILE stderr
|
||||
# endif /* PNG_DEBUG_FILE */
|
||||
|
||||
# if (PNG_DEBUG > 1)
|
||||
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
|
||||
* non-ISO compilers
|
||||
*/
|
||||
# ifdef __STDC__
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
|
||||
} while (0)
|
||||
# endif
|
||||
# else /* __STDC __ */
|
||||
# ifndef png_debug
|
||||
# define png_debug(l,m) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug1
|
||||
# define png_debug1(l,m,p1) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format,p1); \
|
||||
} while (0)
|
||||
# endif
|
||||
# ifndef png_debug2
|
||||
# define png_debug2(l,m,p1,p2) \
|
||||
do { \
|
||||
int num_tabs=l; \
|
||||
char format[256]; \
|
||||
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
|
||||
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
|
||||
m,PNG_STRING_NEWLINE); \
|
||||
fprintf(PNG_DEBUG_FILE,format,p1,p2); \
|
||||
} while (0)
|
||||
# endif
|
||||
# endif /* __STDC __ */
|
||||
# endif /* (PNG_DEBUG > 1) */
|
||||
|
||||
# endif /* _MSC_VER */
|
||||
# endif /* (PNG_DEBUG > 0) */
|
||||
#endif /* PNG_DEBUG */
|
||||
#ifndef png_debug
|
||||
# define png_debug(l, m) ((void)0)
|
||||
#endif
|
||||
#ifndef png_debug1
|
||||
# define png_debug1(l, m, p1) ((void)0)
|
||||
#endif
|
||||
#ifndef png_debug2
|
||||
# define png_debug2(l, m, p1, p2) ((void)0)
|
||||
#endif
|
||||
#endif /* PNGDEBUG_H */
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.4.8 [July 7, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.5.8 [February 1, 2011]
|
||||
* 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.)
|
||||
*
|
||||
|
@ -16,18 +16,17 @@
|
|||
* at each function.
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#include "pngpriv.h"
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_default_error PNGARG((png_structp png_ptr,
|
||||
png_const_charp error_message)) PNG_NORETURN;
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
static PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,
|
||||
png_const_charp error_message)),PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
static void /* PRIVATE */
|
||||
png_default_warning PNGARG((png_structp png_ptr,
|
||||
png_const_charp warning_message));
|
||||
png_const_charp warning_message));
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
/* This function is called whenever there is a fatal error. This function
|
||||
|
@ -36,42 +35,45 @@ png_default_warning PNGARG((png_structp png_ptr,
|
|||
* to replace the error function at run-time.
|
||||
*/
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_error(png_structp png_ptr, png_const_charp error_message)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
char msg[16];
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
for (offset = 1; offset<15; offset++)
|
||||
if (error_message[offset] == ' ')
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
{
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
for (offset = 1; offset<15; offset++)
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
msg[i] = error_message[i + 1];
|
||||
msg[i - 1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
else
|
||||
error_message += offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
msg[i] = error_message[i + 1];
|
||||
msg[i - 1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
|
||||
else
|
||||
error_message += offset;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,10 +86,10 @@ png_error(png_structp png_ptr, png_const_charp error_message)
|
|||
png_default_error(png_ptr, error_message);
|
||||
}
|
||||
#else
|
||||
void PNGAPI
|
||||
png_err(png_structp png_ptr)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_err,(png_structp png_ptr),PNG_NORETURN)
|
||||
{
|
||||
/* Prior to 1.4.8 the error_fn received a NULL pointer, expressed
|
||||
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
|
||||
* erroneously as '\0', instead of the empty string "". This was
|
||||
* apparently an error, introduced in libpng-1.2.20, and png_default_error
|
||||
* will crash in this case.
|
||||
|
@ -101,6 +103,107 @@ png_err(png_structp png_ptr)
|
|||
}
|
||||
#endif /* PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
/* Utility to safely appends strings to a buffer. This never errors out so
|
||||
* error checking is not required in the caller.
|
||||
*/
|
||||
size_t
|
||||
png_safecat(png_charp buffer, size_t bufsize, size_t pos,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (buffer != NULL && pos < bufsize)
|
||||
{
|
||||
if (string != NULL)
|
||||
while (*string != '\0' && pos < bufsize-1)
|
||||
buffer[pos++] = *string++;
|
||||
|
||||
buffer[pos] = '\0';
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||
/* Utility to dump an unsigned value into a buffer, given a start pointer and
|
||||
* and end pointer (which should point just *beyond* the end of the buffer!)
|
||||
* Returns the pointer to the start of the formatted string.
|
||||
*/
|
||||
png_charp
|
||||
png_format_number(png_const_charp start, png_charp end, int format,
|
||||
png_alloc_size_t number)
|
||||
{
|
||||
int count = 0; /* number of digits output */
|
||||
int mincount = 1; /* minimum number required */
|
||||
int output = 0; /* digit output (for the fixed point format) */
|
||||
|
||||
*--end = '\0';
|
||||
|
||||
/* This is written so that the loop always runs at least once, even with
|
||||
* number zero.
|
||||
*/
|
||||
while (end > start && (number != 0 || count < mincount))
|
||||
{
|
||||
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case PNG_NUMBER_FORMAT_fixed:
|
||||
/* Needs five digits (the fraction) */
|
||||
mincount = 5;
|
||||
if (output || number % 10 != 0)
|
||||
{
|
||||
*--end = digits[number % 10];
|
||||
output = 1;
|
||||
}
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
number /= 10;
|
||||
break;
|
||||
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
number >>= 4;
|
||||
break;
|
||||
|
||||
default: /* an error */
|
||||
number = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Keep track of the number of digits added */
|
||||
++count;
|
||||
|
||||
/* Float a fixed number here: */
|
||||
if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
|
||||
{
|
||||
/* End of the fraction, but maybe nothing was output? In that case
|
||||
* drop the decimal point. If the number is a true zero handle that
|
||||
* here.
|
||||
*/
|
||||
if (output)
|
||||
*--end = '.';
|
||||
else if (number == 0) /* and !output */
|
||||
*--end = '0';
|
||||
}
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
/* This function is called whenever there is a non-fatal error. This function
|
||||
* should not be changed. If there is a need to handle warnings differently,
|
||||
|
@ -115,22 +218,140 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
{
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (png_ptr->flags&
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||
#endif
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
for (offset = 1; offset < 15; offset++)
|
||||
if (warning_message[offset] == ' ')
|
||||
{
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
for (offset = 1; offset < 15; offset++)
|
||||
if (warning_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
|
||||
/* These functions support 'formatted' warning messages with up to
|
||||
* PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter
|
||||
* is introduced by @<number>, where 'number' starts at 1. This follows the
|
||||
* standard established by X/Open for internationalizable error messages.
|
||||
*/
|
||||
void
|
||||
png_warning_parameter(png_warning_parameters p, int number,
|
||||
png_const_charp string)
|
||||
{
|
||||
if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
|
||||
(void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
png_alloc_size_t value)
|
||||
{
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
|
||||
}
|
||||
|
||||
void
|
||||
png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
png_int_32 value)
|
||||
{
|
||||
png_alloc_size_t u;
|
||||
png_charp str;
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
|
||||
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
|
||||
u = (png_alloc_size_t)value;
|
||||
if (value < 0)
|
||||
u = ~u + 1;
|
||||
|
||||
str = PNG_FORMAT_NUMBER(buffer, format, u);
|
||||
|
||||
if (value < 0 && str > buffer)
|
||||
*--str = '-';
|
||||
|
||||
png_warning_parameter(p, number, str);
|
||||
}
|
||||
|
||||
void
|
||||
png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
|
||||
png_const_charp message)
|
||||
{
|
||||
/* The internal buffer is just 192 bytes - enough for all our messages,
|
||||
* overflow doesn't happen because this code checks! If someone figures
|
||||
* out how to send us a message longer than 192 bytes, all that will
|
||||
* happen is that the message will be truncated appropriately.
|
||||
*/
|
||||
size_t i = 0; /* Index in the msg[] buffer: */
|
||||
char msg[192];
|
||||
|
||||
/* Each iteration through the following loop writes at most one character
|
||||
* to msg[i++] then returns here to validate that there is still space for
|
||||
* the trailing '\0'. It may (in the case of a parameter) read more than
|
||||
* one character from message[]; it must check for '\0' and continue to the
|
||||
* test if it finds the end of string.
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *message != '\0')
|
||||
{
|
||||
/* '@' at end of string is now just printed (previously it was skipped);
|
||||
* it is an error in the calling code to terminate the string with @.
|
||||
*/
|
||||
if (p != NULL && *message == '@' && message[1] != '\0')
|
||||
{
|
||||
int parameter_char = *++message; /* Consume the '@' */
|
||||
static const char valid_parameters[] = "123456789";
|
||||
int parameter = 0;
|
||||
|
||||
/* Search for the parameter digit, the index in the string is the
|
||||
* parameter to use.
|
||||
*/
|
||||
while (valid_parameters[parameter] != parameter_char &&
|
||||
valid_parameters[parameter] != '\0')
|
||||
++parameter;
|
||||
|
||||
/* If the parameter digit is out of range it will just get printed. */
|
||||
if (parameter < PNG_WARNING_PARAMETER_COUNT)
|
||||
{
|
||||
/* Append this parameter */
|
||||
png_const_charp parm = p[parameter];
|
||||
png_const_charp pend = p[parameter] + (sizeof p[parameter]);
|
||||
|
||||
/* No need to copy the trailing '\0' here, but there is no guarantee
|
||||
* that parm[] has been initialized, so there is no guarantee of a
|
||||
* trailing '\0':
|
||||
*/
|
||||
while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
|
||||
msg[i++] = *parm++;
|
||||
|
||||
/* Consume the parameter digit too: */
|
||||
++message;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* else not a parameter and there is a character after the @ sign; just
|
||||
* copy that. This is known not to be '\0' because of the test above.
|
||||
*/
|
||||
}
|
||||
|
||||
/* At this point *message can't be '\0', even in the bad parameter case
|
||||
* above where there is a lone '@' at the end of the message string.
|
||||
*/
|
||||
msg[i++] = *message++;
|
||||
}
|
||||
|
||||
/* i is always less than (sizeof msg), so: */
|
||||
msg[i] = '\0';
|
||||
|
||||
/* And this is the formatted message, it may be larger than
|
||||
* PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
|
||||
* not (currently) formatted.
|
||||
*/
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
|
@ -138,9 +359,9 @@ void PNGAPI
|
|||
png_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_warning(png_ptr, error_message);
|
||||
png_warning(png_ptr, error_message);
|
||||
else
|
||||
png_error(png_ptr, error_message);
|
||||
png_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -160,13 +381,16 @@ static PNG_CONST char png_digit[16] = {
|
|||
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
static void /* PRIVATE */
|
||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||
error_message)
|
||||
error_message)
|
||||
{
|
||||
int iout = 0, iin = 0;
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
int iout = 0, ishift = 24;
|
||||
|
||||
while (iin < 4)
|
||||
while (ishift >= 0)
|
||||
{
|
||||
int c = png_ptr->chunk_name[iin++];
|
||||
int c = (int)(chunk_name >> ishift) & 0xff;
|
||||
|
||||
ishift -= 8;
|
||||
if (isnonalpha(c))
|
||||
{
|
||||
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
|
||||
|
@ -174,20 +398,23 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
|||
buffer[iout++] = png_digit[c & 0x0f];
|
||||
buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
buffer[iout++] = (png_byte)c;
|
||||
buffer[iout++] = (char)c;
|
||||
}
|
||||
}
|
||||
|
||||
if (error_message == NULL)
|
||||
buffer[iout] = '\0';
|
||||
|
||||
else
|
||||
{
|
||||
int iin = 0;
|
||||
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
|
||||
iin = 0;
|
||||
while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
|
||||
buffer[iout++] = error_message[iin++];
|
||||
|
||||
|
@ -195,22 +422,24 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
|||
buffer[iout] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
void PNGAPI
|
||||
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_chunk_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
png_error(png_ptr, error_message);
|
||||
png_error(png_ptr, error_message);
|
||||
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, error_message);
|
||||
png_error(png_ptr, msg);
|
||||
png_format_buffer(png_ptr, msg, error_message);
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
void PNGAPI
|
||||
|
@ -218,11 +447,12 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
{
|
||||
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||
if (png_ptr == NULL)
|
||||
png_warning(png_ptr, warning_message);
|
||||
png_warning(png_ptr, warning_message);
|
||||
|
||||
else
|
||||
{
|
||||
png_format_buffer(png_ptr, msg, warning_message);
|
||||
png_warning(png_ptr, msg);
|
||||
png_format_buffer(png_ptr, msg, warning_message);
|
||||
png_warning(png_ptr, msg);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
@ -232,14 +462,37 @@ png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
void PNGAPI
|
||||
png_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
else
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
|
||||
png_chunk_warning(png_ptr, error_message);
|
||||
|
||||
else
|
||||
png_chunk_error(png_ptr, error_message);
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
PNG_FUNCTION(void,
|
||||
png_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
{
|
||||
# define fixed_message "fixed point overflow in "
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
png_memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
|
||||
{
|
||||
msg[fixed_message_ln + iin] = name[iin];
|
||||
++iin;
|
||||
}
|
||||
msg[fixed_message_ln + iin] = 0;
|
||||
png_error(png_ptr, msg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* This API only exists if ANSI-C style error handling is used,
|
||||
* otherwise it is necessary for png_default_error to be overridden.
|
||||
|
@ -252,7 +505,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
|||
return NULL;
|
||||
|
||||
png_ptr->longjmp_fn = longjmp_fn;
|
||||
return &png_ptr->jmpbuf;
|
||||
return &png_ptr->longjmp_buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -261,63 +514,73 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
|
|||
* function is used by default, or if the program supplies NULL for the
|
||||
* error function pointer in png_set_error_fn().
|
||||
*/
|
||||
static void /* PRIVATE */
|
||||
png_default_error(png_structp png_ptr, png_const_charp error_message)
|
||||
static PNG_FUNCTION(void /* PRIVATE */,
|
||||
png_default_error,(png_structp png_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_CONSOLE_IO_SUPPORTED
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*error_message == PNG_LITERAL_SHARP)
|
||||
/* Check on NULL only added in 1.5.4 */
|
||||
if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset = 0; offset<15; offset++)
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset = 0; offset<15; offset++)
|
||||
{
|
||||
error_number[offset] = error_message[offset + 1];
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset - 1] = '\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s",
|
||||
error_number, error_message + offset + 1);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s, offset=%d",
|
||||
error_message, offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset - 1] = '\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s",
|
||||
error_number, error_message + offset + 1);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s, offset=%d",
|
||||
error_message, offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr, "libpng error: %s", error_message);
|
||||
fprintf(stderr, "libpng error: %s", error_message ? error_message :
|
||||
"undefined");
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(error_message) /* Make compiler happy */
|
||||
#endif
|
||||
png_longjmp(png_ptr, 1);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
if (png_ptr && png_ptr->longjmp_fn)
|
||||
{
|
||||
# ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
jmp_buf jmpbuf;
|
||||
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
png_ptr->longjmp_fn(jmpbuf, 1);
|
||||
}
|
||||
{
|
||||
jmp_buf tmp_jmpbuf;
|
||||
png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
|
||||
png_ptr->longjmp_fn(tmp_jmpbuf, val);
|
||||
}
|
||||
|
||||
# else
|
||||
png_ptr->longjmp_fn(png_ptr->jmpbuf, 1);
|
||||
png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
/* Here if not setjmp support or if png_ptr is null. */
|
||||
PNG_ABORT();
|
||||
#ifndef PNG_CONSOLE_IO_SUPPORTED
|
||||
PNG_UNUSED(error_message) /* Make compiler happy */
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
|
@ -333,33 +596,36 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
# ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*warning_message == PNG_LITERAL_SHARP)
|
||||
{
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset = 0; offset < 15; offset++)
|
||||
{
|
||||
warning_number[offset] = warning_message[offset + 1];
|
||||
if (warning_message[offset] == ' ')
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset = 0; offset < 15; offset++)
|
||||
{
|
||||
warning_number[offset] = warning_message[offset + 1];
|
||||
if (warning_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset + 1] = '\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s",
|
||||
warning_number, warning_message + offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng warning: %s",
|
||||
warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
}
|
||||
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset + 1] = '\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s",
|
||||
warning_number, warning_message + offset);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "libpng warning: %s",
|
||||
warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif
|
||||
|
||||
{
|
||||
fprintf(stderr, "libpng warning: %s", warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
fprintf(stderr, "libpng warning: %s", warning_message);
|
||||
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(warning_message) /* Make compiler happy */
|
||||
|
@ -371,17 +637,22 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
/* This function is called when the application wants to use another method
|
||||
* of handling errors and warnings. Note that the error function MUST NOT
|
||||
* return to the calling routine or serious problems will occur. The return
|
||||
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
|
||||
* method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
|
||||
*/
|
||||
void PNGAPI
|
||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->error_ptr = error_ptr;
|
||||
png_ptr->error_fn = error_fn;
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
#else
|
||||
PNG_UNUSED(warning_fn)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -394,6 +665,7 @@ png_get_error_ptr(png_const_structp png_ptr)
|
|||
{
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
}
|
||||
|
||||
|
@ -404,8 +676,9 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
|||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
|
||||
PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,282 @@
|
|||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* 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.)
|
||||
*
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* png_info is a structure that holds the information in a PNG file so
|
||||
* that the application can find out the characteristics of the image.
|
||||
* If you are reading the file, this structure will tell you what is
|
||||
* in the PNG file. If you are writing the file, fill in the information
|
||||
* you want to put into the PNG file, using png_set_*() functions, then
|
||||
* call png_write_info().
|
||||
*
|
||||
* The names chosen should be very close to the PNG specification, so
|
||||
* consult that document for information about the meaning of each field.
|
||||
*
|
||||
* With libpng < 0.95, it was only possible to directly set and read the
|
||||
* the values in the png_info_struct, which meant that the contents and
|
||||
* order of the values had to remain fixed. With libpng 0.95 and later,
|
||||
* however, there are now functions that abstract the contents of
|
||||
* png_info_struct from the application, so this makes it easier to use
|
||||
* libpng with dynamic libraries, and even makes it possible to use
|
||||
* libraries that don't have all of the libpng ancillary chunk-handing
|
||||
* functionality. In libpng-1.5.0 this was moved into a separate private
|
||||
* file that is not visible to applications.
|
||||
*
|
||||
* The following members may have allocated storage attached that should be
|
||||
* cleaned up before the structure is discarded: palette, trans, text,
|
||||
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
||||
* are automatically freed when the info structure is deallocated, if they were
|
||||
* allocated internally by libpng. This behavior can be changed by means
|
||||
* of the png_data_freer() function.
|
||||
*
|
||||
* More allocation details: all the chunk-reading functions that
|
||||
* change these members go through the corresponding png_set_*
|
||||
* functions. A function to clear these members is available: see
|
||||
* png_free_data(). The png_set_* functions do not depend on being
|
||||
* able to point info structure members to any of the storage they are
|
||||
* passed (they make their own copies), EXCEPT that the png_set_text
|
||||
* functions use the same storage passed to them in the text_ptr or
|
||||
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
||||
* functions do not make their own copies.
|
||||
*/
|
||||
#ifndef PNGINFO_H
|
||||
#define PNGINFO_H
|
||||
|
||||
struct png_info_def
|
||||
{
|
||||
/* the following are necessary for every PNG file */
|
||||
png_uint_32 width; /* width of image in pixels (from IHDR) */
|
||||
png_uint_32 height; /* height of image in pixels (from IHDR) */
|
||||
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
|
||||
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
|
||||
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
|
||||
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
|
||||
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
|
||||
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
|
||||
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
|
||||
/* The following three should have been named *_method not *_type */
|
||||
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
|
||||
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
|
||||
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
|
||||
/* The following is informational only on read, and not used on writes. */
|
||||
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte spare_byte; /* to align the data, and for future use */
|
||||
png_byte signature[8]; /* magic bytes read by libpng from start of file */
|
||||
|
||||
/* The rest of the data is optional. If you are reading, check the
|
||||
* valid field to see if the information in these are valid. If you
|
||||
* are writing, set the valid field to those chunks you want written,
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_gAMA_SUPPORTED)
|
||||
/* The gAMA chunk describes the gamma characteristics of the system
|
||||
* on which the image was created, normally in the range [1.0, 2.5].
|
||||
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
|
||||
*/
|
||||
png_fixed_point gamma;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
/* GR-P, 0.96a */
|
||||
/* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
|
||||
png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
/* The tEXt, and zTXt chunks contain human-readable textual data in
|
||||
* uncompressed, compressed, and optionally compressed forms, respectively.
|
||||
* The data in "text" is an array of pointers to uncompressed,
|
||||
* null-terminated C strings. Each chunk has a keyword that describes the
|
||||
* textual data contained in that chunk. Keywords are not required to be
|
||||
* unique, and the text string may be empty. Any number of text chunks may
|
||||
* be in an image.
|
||||
*/
|
||||
int num_text; /* number of comments read or comments to write */
|
||||
int max_text; /* current size of text array */
|
||||
png_textp text; /* array of comments read or comments to write */
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
|
||||
#ifdef PNG_tIME_SUPPORTED
|
||||
/* The tIME chunk holds the last time the displayed image data was
|
||||
* modified. See the png_time struct for the contents of this struct.
|
||||
*/
|
||||
png_time mod_time;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
/* The sBIT chunk specifies the number of significant high-order bits
|
||||
* in the pixel data. Values are in the range [1, bit_depth], and are
|
||||
* only specified for the channels in the pixel data. The contents of
|
||||
* the low-order bits is not specified. Data is valid if
|
||||
* (valid & PNG_INFO_sBIT) is non-zero.
|
||||
*/
|
||||
png_color_8 sig_bit; /* significant bits in color channels */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The tRNS chunk supplies transparency data for paletted images and
|
||||
* other image types that don't need a full alpha channel. There are
|
||||
* "num_trans" transparency values for a paletted image, stored in the
|
||||
* same order as the palette colors, starting from index 0. Values
|
||||
* for the data are in the range [0, 255], ranging from fully transparent
|
||||
* to fully opaque, respectively. For non-paletted images, there is a
|
||||
* single color specified that should be treated as fully transparent.
|
||||
* Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
*/
|
||||
png_bytep trans_alpha; /* alpha values for paletted image */
|
||||
png_color_16 trans_color; /* transparent color for non-palette image */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* The bKGD chunk gives the suggested image background color if the
|
||||
* display program does not have its own background color and the image
|
||||
* is needs to composited onto a background before display. The colors
|
||||
* in "background" are normally in the same color space/depth as the
|
||||
* pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
|
||||
*/
|
||||
png_color_16 background;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
/* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
|
||||
* and downwards from the top-left corner of the display, page, or other
|
||||
* application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
||||
* below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
||||
*/
|
||||
png_int_32 x_offset; /* x offset on page */
|
||||
png_int_32 y_offset; /* y offset on page */
|
||||
png_byte offset_unit_type; /* offset units type */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
/* The pHYs chunk gives the physical pixel density of the image for
|
||||
* display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
||||
* defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
||||
*/
|
||||
png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
|
||||
png_uint_32 y_pixels_per_unit; /* vertical pixel density */
|
||||
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
/* The hIST chunk contains the relative frequency or importance of the
|
||||
* various palette entries, so that a viewer can intelligently select a
|
||||
* reduced-color palette, if required. Data is an array of "num_palette"
|
||||
* values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
|
||||
* is non-zero.
|
||||
*/
|
||||
png_uint_16p hist;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
/* The cHRM chunk describes the CIE color characteristics of the monitor
|
||||
* on which the PNG was created. This data allows the viewer to do gamut
|
||||
* mapping of the input image to ensure that the viewer sees the same
|
||||
* colors in the image as the creator. Values are in the range
|
||||
* [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
|
||||
*/
|
||||
png_fixed_point x_white;
|
||||
png_fixed_point y_white;
|
||||
png_fixed_point x_red;
|
||||
png_fixed_point y_red;
|
||||
png_fixed_point x_green;
|
||||
png_fixed_point y_green;
|
||||
png_fixed_point x_blue;
|
||||
png_fixed_point y_blue;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
/* The pCAL chunk describes a transformation between the stored pixel
|
||||
* values and original physical data values used to create the image.
|
||||
* The integer range [0, 2^bit_depth - 1] maps to the floating-point
|
||||
* range given by [pcal_X0, pcal_X1], and are further transformed by a
|
||||
* (possibly non-linear) transformation function given by "pcal_type"
|
||||
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
||||
* defines below, and the PNG-Group's PNG extensions document for a
|
||||
* complete description of the transformations and how they should be
|
||||
* implemented, and for a description of the ASCII parameter strings.
|
||||
* Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
||||
*/
|
||||
png_charp pcal_purpose; /* pCAL chunk description string */
|
||||
png_int_32 pcal_X0; /* minimum value */
|
||||
png_int_32 pcal_X1; /* maximum value */
|
||||
png_charp pcal_units; /* Latin-1 string giving physical units */
|
||||
png_charpp pcal_params; /* ASCII strings containing parameter values */
|
||||
png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
|
||||
png_byte pcal_nparams; /* number of parameters given in pcal_params */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
/* iCCP chunk data. */
|
||||
png_charp iccp_name; /* profile name */
|
||||
png_bytep iccp_profile; /* International Color Consortium profile data */
|
||||
png_uint_32 iccp_proflen; /* ICC profile data length */
|
||||
png_byte iccp_compression; /* Always zero */
|
||||
#endif
|
||||
|
||||
#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;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
/* The sCAL chunk describes the actual physical dimensions of the
|
||||
* subject matter of the graphic. The chunk contains a unit specification
|
||||
* a byte value, and two ASCII strings representing floating-point
|
||||
* values. The values are width and height corresponsing to one pixel
|
||||
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
||||
* non-zero.
|
||||
*/
|
||||
png_byte scal_unit; /* unit of physical scale */
|
||||
png_charp scal_s_width; /* string containing height */
|
||||
png_charp scal_s_height; /* string containing width */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
||||
non-zero */
|
||||
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */
|
||||
png_bytepp row_pointers; /* the image bits */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_APNG_SUPPORTED
|
||||
png_uint_32 num_frames; /* including default image */
|
||||
png_uint_32 num_plays;
|
||||
png_uint_32 next_frame_width;
|
||||
png_uint_32 next_frame_height;
|
||||
png_uint_32 next_frame_x_offset;
|
||||
png_uint_32 next_frame_y_offset;
|
||||
png_uint_16 next_frame_delay_num;
|
||||
png_uint_16 next_frame_delay_den;
|
||||
png_byte next_frame_dispose_op;
|
||||
png_byte next_frame_blend_op;
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif /* PNGINFO_H */
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.4.6 [April 8, 2010]
|
||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
||||
* 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.)
|
||||
|
@ -17,52 +17,56 @@
|
|||
* identify the replacement functions.
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* If you change this, be sure to change the one in png.h also */
|
||||
|
||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||
by a single call to calloc() if this is thought to improve performance. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Alternate version of png_create_struct, for use with user-defined malloc. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (png_get_copyright(NULL));
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
|
||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
||||
dummy_struct.mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
|
||||
}
|
||||
|
||||
else
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
|
||||
|
@ -70,7 +74,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
|||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -79,19 +83,20 @@ void /* PRIVATE */
|
|||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif
|
||||
# endif
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
memset(&dummy_struct, 0, sizeof dummy_struct);
|
||||
dummy_struct.mem_ptr=mem_ptr;
|
||||
(*(free_fn))(&dummy_struct, struct_ptr);
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
farfree (struct_ptr);
|
||||
}
|
||||
}
|
||||
|
@ -115,55 +120,62 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|||
* result, we would be truncating potentially larger memory requests
|
||||
* (which should cause a fatal error) and introducing major problems.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_calloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
png_warning(png_ptr, "Cannot Allocate > 64K");
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
else
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
|
||||
else if (size == (png_uint_32)65536L)
|
||||
{
|
||||
if (png_ptr->offset_table == NULL)
|
||||
|
@ -175,8 +187,9 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
int num_blocks;
|
||||
png_uint_32 total_size;
|
||||
png_bytep table;
|
||||
int i;
|
||||
int i, mem_level, window_bits;
|
||||
png_byte huge * hptr;
|
||||
int window_bits
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
|
@ -184,12 +197,23 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
ret = NULL;
|
||||
}
|
||||
|
||||
if (png_ptr->zlib_window_bits > 14)
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
window_bits =
|
||||
png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
|
||||
png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
|
||||
|
||||
if (window_bits > 14)
|
||||
num_blocks = (int)(1 << (window_bits - 14));
|
||||
|
||||
else
|
||||
num_blocks = 1;
|
||||
if (png_ptr->zlib_mem_level >= 7)
|
||||
num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
|
||||
|
||||
mem_level =
|
||||
png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
|
||||
png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
|
||||
|
||||
if (mem_level >= 7)
|
||||
num_blocks += (int)(1 << (mem_level - 7));
|
||||
|
||||
else
|
||||
num_blocks++;
|
||||
|
||||
|
@ -199,25 +223,27 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
|
||||
if (table == NULL)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of Memory"); /* Note "O", "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of Memory");
|
||||
#endif
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((png_size_t)table & 0xfff0)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
"Farmalloc didn't return normalized pointer");
|
||||
#endif
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -227,12 +253,13 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out Of memory"); /* Note "O", "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out Of memory");
|
||||
#endif
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -242,6 +269,7 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
||||
hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
|
||||
}
|
||||
|
||||
for (i = 0; i < num_blocks; i++)
|
||||
{
|
||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
||||
|
@ -256,29 +284,32 @@ png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
|||
|
||||
if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */
|
||||
png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of Memory");
|
||||
#endif
|
||||
# endif
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
|
||||
}
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL)
|
||||
{
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Out of memory"); /* Note "o" and "m" */
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
@ -293,12 +324,13 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
@ -306,7 +338,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
@ -334,9 +366,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
|||
}
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
farfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Not the Borland DOS special memory handler */
|
||||
|
@ -344,52 +374,58 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
|||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct(int type)
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct,(int type),PNG_ALLOCATED)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
return (png_create_struct_2(type, NULL, NULL));
|
||||
}
|
||||
|
||||
/* Allocate memory for a png_struct or a png_info. The malloc and
|
||||
memset can be replaced by a single call to calloc() if this is thought
|
||||
to improve performance noticably. */
|
||||
png_voidp /* PRIVATE */
|
||||
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
|
||||
PNG_ALLOCATED)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_size_t size;
|
||||
png_voidp struct_ptr;
|
||||
|
||||
if (type == PNG_STRUCT_INFO)
|
||||
size = png_sizeof(png_info);
|
||||
|
||||
else if (type == PNG_STRUCT_PNG)
|
||||
size = png_sizeof(png_struct);
|
||||
|
||||
else
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
png_ptr->mem_ptr=mem_ptr;
|
||||
struct_ptr = (*(malloc_fn))(png_ptr, size);
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
return (struct_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size, 1);
|
||||
# else
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
if (struct_ptr != NULL)
|
||||
png_memset(struct_ptr, 0, size);
|
||||
|
||||
|
@ -401,7 +437,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
|||
void /* PRIVATE */
|
||||
png_destroy_struct(png_voidp struct_ptr)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2(struct_ptr, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -410,10 +446,10 @@ void /* PRIVATE */
|
|||
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||
png_voidp mem_ptr)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
|
@ -422,16 +458,19 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|||
(*(free_fn))(png_ptr, struct_ptr);
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(struct_ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(struct_ptr);
|
||||
# else
|
||||
|
||||
# else
|
||||
free(struct_ptr);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,80 +481,92 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|||
* have the ability to do that.
|
||||
*/
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_calloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
ret = (png_malloc(png_ptr, size));
|
||||
|
||||
if (ret != NULL)
|
||||
png_memset(ret,0,(png_size_t)size);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
png_voidp PNGAPI
|
||||
png_malloc_default(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
|
||||
else
|
||||
#endif
|
||||
# endif
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* Check for overflow */
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
|
||||
else
|
||||
ret = farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
if (size != (unsigned long)size)
|
||||
ret = NULL;
|
||||
|
||||
else
|
||||
ret = halloc(size, 1);
|
||||
# else
|
||||
|
||||
# else
|
||||
if (size != (size_t)size)
|
||||
ret = NULL;
|
||||
|
||||
else
|
||||
ret = malloc((size_t)size);
|
||||
# endif
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
# ifndef PNG_USER_MEM_SUPPORTED
|
||||
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Out of Memory");
|
||||
#endif
|
||||
# endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
@ -529,34 +580,38 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
|||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr->free_fn != NULL)
|
||||
{
|
||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
# endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
farfree(ptr);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
# else
|
||||
free(ptr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
# else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
hfree(ptr);
|
||||
|
||||
# else
|
||||
free(ptr);
|
||||
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif /* Not Borland DOS special memory handler */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
|
@ -564,8 +619,8 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
|||
* instead of issuing a png_error, if it fails to allocate the requested
|
||||
* memory.
|
||||
*/
|
||||
png_voidp PNGAPI
|
||||
png_malloc_warn(png_structp png_ptr, png_alloc_size_t size)
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
|
@ -605,6 +660,7 @@ png_get_mem_ptr(png_const_structp png_ptr)
|
|||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.4.6 [January 14, 2011]
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* 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.)
|
||||
|
@ -18,11 +18,10 @@
|
|||
* libpng use it at run time with png_set_read_fn(...).
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
* reads from a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
|
@ -36,6 +35,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL read function");
|
||||
}
|
||||
|
@ -46,14 +46,15 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGAPI
|
||||
# ifndef USE_FAR_KEYWORD
|
||||
void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
|
@ -62,7 +63,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
#else
|
||||
# else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
can't handle far buffers in the medium and small models, we have to copy
|
||||
the data.
|
||||
|
@ -71,7 +72,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
static void PNGAPI
|
||||
static void PNGCBAPI
|
||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
|
@ -80,46 +81,57 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t read, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||
err = fread(buf, 1, read, io_ptr);
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
|
||||
if (err != read)
|
||||
break;
|
||||
|
||||
else
|
||||
check += err;
|
||||
|
||||
data += read;
|
||||
remaining -= read;
|
||||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if ((png_uint_32)check != (png_uint_32)length)
|
||||
png_error(png_ptr, "read Error");
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply a new input function
|
||||
* for libpng if standard C streams aren't being used.
|
||||
*
|
||||
* This function takes as its arguments:
|
||||
*
|
||||
* png_ptr - pointer to a png input data structure
|
||||
*
|
||||
* io_ptr - pointer to user supplied structure containing info about
|
||||
* the input functions. May be NULL.
|
||||
*
|
||||
* read_data_fn - pointer to a new input function that takes as its
|
||||
* arguments a pointer to a png_struct, a pointer to
|
||||
* a location where input data can be stored, and a 32-bit
|
||||
|
@ -135,11 +147,13 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (read_data_fn != NULL)
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
|
||||
else
|
||||
png_ptr->read_data_fn = png_default_read_data;
|
||||
#else
|
||||
|
@ -151,9 +165,8 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||
{
|
||||
png_ptr->write_data_fn = NULL;
|
||||
png_warning(png_ptr,
|
||||
"It's an error to set both read_data_fn and write_data_fn in the ");
|
||||
png_warning(png_ptr,
|
||||
"same structure. Resetting write_data_fn to NULL");
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,379 @@
|
|||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* 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.)
|
||||
*
|
||||
* Last changed in libpng 1.5.9 [February 18, 2012]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* The structure that holds the information to read and write PNG files.
|
||||
* The only people who need to care about what is inside of this are the
|
||||
* people who will be modifying the library for their own special needs.
|
||||
* It should NOT be accessed directly by an application.
|
||||
*/
|
||||
|
||||
#ifndef PNGSTRUCT_H
|
||||
#define PNGSTRUCT_H
|
||||
/* zlib.h defines the structure z_stream, an instance of which is included
|
||||
* in this structure and is required for decompressing the LZ compressed
|
||||
* data in PNG files.
|
||||
*/
|
||||
#include "zlib.h"
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf longjmp_buffer; /* used in png_error */
|
||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||
#endif
|
||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_error_ptr warning_fn; /* function for printing warnings */
|
||||
#endif
|
||||
png_voidp error_ptr; /* user supplied struct for error functions */
|
||||
png_rw_ptr write_data_fn; /* function for writing output data */
|
||||
png_rw_ptr read_data_fn; /* function for reading input data */
|
||||
png_voidp io_ptr; /* ptr to application struct for I/O functions */
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
|
||||
/* These were added in libpng-1.0.2 */
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
png_voidp user_transform_ptr; /* user supplied struct for user transform */
|
||||
png_byte user_transform_depth; /* bit depth of user transformed pixels */
|
||||
png_byte user_transform_channels; /* channels in user transformed pixels */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
z_stream zstream; /* pointer to decompression structure (below) */
|
||||
png_bytep zbuf; /* buffer for zlib */
|
||||
uInt zbuf_size; /* size of zbuf (typically 65536) */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Added in 1.5.4: state to keep track of whether the zstream has been
|
||||
* initialized and if so whether it is for IDAT or some other chunk.
|
||||
*/
|
||||
#define PNG_ZLIB_UNINITIALIZED 0
|
||||
#define PNG_ZLIB_FOR_IDAT 1
|
||||
#define PNG_ZLIB_FOR_TEXT 2 /* anything other than IDAT */
|
||||
#define PNG_ZLIB_USE_MASK 3 /* bottom two bits */
|
||||
#define PNG_ZLIB_IN_USE 4 /* a flag value */
|
||||
|
||||
png_uint_32 zlib_state; /* State of zlib initialization */
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
int zlib_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_text_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
png_uint_32 usr_width; /* width of row at start of write */
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
png_byte pass; /* current interlace pass (0 - 6) */
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
png_byte io_chunk_string[5];
|
||||
/* string name of chunk */
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
png_fixed_point background_gamma;
|
||||
png_color_16 background; /* background color in screen gamma space */
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point gamma; /* file gamma value */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_bytep gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
png_color_8 sig_bit; /* significant bits in each available channel */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
png_color_8 shift; /* shift for significant bit tranformation */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|
||||
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep trans_alpha; /* alpha values for paletted files */
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif
|
||||
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
png_bytep current_buffer_ptr; /* current location in current_buffer */
|
||||
png_bytep current_buffer; /* buffer for recently used data */
|
||||
png_uint_32 push_length; /* size of current input chunk */
|
||||
png_uint_32 skip_length; /* bytes to skip in input data */
|
||||
png_size_t save_buffer_size; /* amount of data now in save_buffer */
|
||||
png_size_t save_buffer_max; /* total size of save_buffer */
|
||||
png_size_t buffer_size; /* total amount of available input data */
|
||||
png_size_t current_buffer_size; /* amount of data now in current_buffer */
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
# ifdef PNG_TEXT_SUPPORTED
|
||||
png_size_t current_text_size; /* current size of text input data */
|
||||
png_size_t current_text_left; /* how much text left to read in input */
|
||||
png_charp current_text; /* current text chunk buffer */
|
||||
png_charp current_text_ptr; /* current location in current_text */
|
||||
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
png_bytep offset_table;
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup; /* lookup table for quantizing */
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
|
||||
png_uint_16p hist; /* histogram */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
png_voidp user_chunk_ptr;
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
int num_chunk_list;
|
||||
png_bytep chunk_list;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
/* Added in 1.5.5 to record an sRGB chunk in the png. */
|
||||
png_byte is_sRGB;
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
/* Added in libpng 1.5.5 to record setting of coefficients: */
|
||||
png_byte rgb_to_gray_coefficients_set;
|
||||
/* These were changed from png_byte in libpng-1.0.6 */
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
png_uint_32 mng_features_permitted;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_byte filter_type;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_APNG_SUPPORTED
|
||||
png_uint_32 apng_flags;
|
||||
png_uint_32 next_seq_num; /* next fcTL/fdAT chunk sequence number */
|
||||
png_uint_32 first_frame_width;
|
||||
png_uint_32 first_frame_height;
|
||||
|
||||
#ifdef PNG_READ_APNG_SUPPORTED
|
||||
png_uint_32 num_frames_read; /* incremented after all image data of */
|
||||
/* a frame is read */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
|
||||
png_progressive_frame_ptr frame_end_fn; /* frame data read callback */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_APNG_SUPPORTED
|
||||
png_uint_32 num_frames_to_write;
|
||||
png_uint_32 num_frames_written;
|
||||
#endif
|
||||
#endif /* PNG_APNG_SUPPORTED */
|
||||
|
||||
/* New members added in libpng-1.2.0 */
|
||||
|
||||
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_voidp mem_ptr; /* user supplied struct for mem functions */
|
||||
png_malloc_ptr malloc_fn; /* function for allocating memory */
|
||||
png_free_ptr free_fn; /* function for freeing memory */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.13 and 1.2.0 */
|
||||
png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* The following three members were added at version 1.0.14 and 1.2.4 */
|
||||
png_bytep quantize_sort; /* working sort array */
|
||||
png_bytep index_to_palette; /* where the original index currently is
|
||||
in the palette */
|
||||
png_bytep palette_to_index; /* which original index points to this
|
||||
palette color */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.16 and 1.2.6 */
|
||||
png_byte compression_type;
|
||||
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
png_uint_32 user_width_max;
|
||||
png_uint_32 user_height_max;
|
||||
|
||||
/* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
|
||||
* chunks that can be stored (0 means unlimited).
|
||||
*/
|
||||
png_uint_32 user_chunk_cache_max;
|
||||
|
||||
/* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
* can occupy when decompressed. 0 means unlimited.
|
||||
*/
|
||||
png_alloc_size_t user_chunk_malloc_max;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunk that the library doesn't recognize. */
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
png_uint_32 io_state;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.4.6 [ April 8, 2010]
|
||||
* Last changed in libpng 1.5.4 [July 7, 2011]
|
||||
* 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.)
|
||||
|
@ -11,11 +11,10 @@
|
|||
* and license in png.h
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
#include "pngpriv.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||
/* Turn on BGR-to-RGB mapping */
|
||||
void PNGAPI
|
||||
|
@ -25,6 +24,7 @@ png_set_bgr(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_BGR;
|
||||
}
|
||||
#endif
|
||||
|
@ -38,6 +38,7 @@ png_set_swap(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth == 16)
|
||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||
}
|
||||
|
@ -52,6 +53,7 @@ png_set_packing(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
|
@ -69,6 +71,7 @@ png_set_packswap(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_ptr->bit_depth < 8)
|
||||
png_ptr->transformations |= PNG_PACKSWAP;
|
||||
}
|
||||
|
@ -76,12 +79,13 @@ png_set_packswap(png_structp png_ptr)
|
|||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
png_set_shift(png_structp png_ptr, png_const_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SHIFT;
|
||||
png_ptr->shift = *true_bits;
|
||||
}
|
||||
|
@ -117,10 +121,13 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_uint_16)filler;
|
||||
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
|
||||
|
||||
|
@ -135,7 +142,7 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
}
|
||||
|
||||
/* Also I added this in libpng-1.0.2a (what happens when we expand
|
||||
* a less-than-8-bit grayscale to GA? */
|
||||
* a less-than-8-bit grayscale to GA?) */
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
|
||||
{
|
||||
|
@ -151,6 +158,7 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
@ -166,6 +174,7 @@ png_set_swap_alpha(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
@ -179,6 +188,7 @@ png_set_invert_alpha(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
@ -191,6 +201,7 @@ png_set_invert_mono(png_structp png_ptr)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||
}
|
||||
|
||||
|
@ -206,8 +217,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
|||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
|
@ -215,36 +226,41 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
|||
rp++;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i+=2)
|
||||
for (i = 0; i < istop; i += 2)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
rp+=2;
|
||||
rp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < istop; i+=4)
|
||||
for (i = 0; i < istop; i += 4)
|
||||
{
|
||||
*rp = (png_byte)(~(*rp));
|
||||
*(rp+1) = (png_byte)(~(*(rp+1)));
|
||||
rp+=4;
|
||||
*(rp + 1) = (png_byte)(~(*(rp + 1)));
|
||||
rp += 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||
/* Swaps byte order on 16 bit depth images */
|
||||
void /* PRIVATE */
|
||||
|
@ -252,8 +268,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_swap");
|
||||
|
||||
if (
|
||||
row_info->bit_depth == 16)
|
||||
if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp = row;
|
||||
png_uint_32 i;
|
||||
|
@ -268,6 +283,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||
static PNG_CONST png_byte onebppswaptable[256] = {
|
||||
|
@ -381,19 +397,22 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_packswap");
|
||||
|
||||
if (
|
||||
row_info->bit_depth < 8)
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep rp, end, table;
|
||||
png_bytep rp;
|
||||
png_const_bytep end, table;
|
||||
|
||||
end = row + row_info->rowbytes;
|
||||
|
||||
if (row_info->bit_depth == 1)
|
||||
table = (png_bytep)onebppswaptable;
|
||||
table = onebppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 2)
|
||||
table = (png_bytep)twobppswaptable;
|
||||
table = twobppswaptable;
|
||||
|
||||
else if (row_info->bit_depth == 4)
|
||||
table = (png_bytep)fourbppswaptable;
|
||||
table = fourbppswaptable;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -405,158 +424,119 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
|||
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||
/* Remove filler or alpha byte(s) */
|
||||
/* Remove a channel - this used to be 'png_do_strip_filler' but it used a
|
||||
* somewhat weird combination of flags to determine what to do. All the calls
|
||||
* to png_do_strip_filler are changed in 1.5.2 to call this instead with the
|
||||
* correct arguments.
|
||||
*
|
||||
* The routine isn't general - the channel must be the channel at the start or
|
||||
* end (not in the middle) of each pixel.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||
png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
{
|
||||
png_debug(1, "in png_do_strip_filler");
|
||||
png_bytep sp = row; /* source pointer */
|
||||
png_bytep dp = row; /* destination pointer */
|
||||
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||
|
||||
/* At the start sp will point to the first byte to copy and dp to where
|
||||
* it is copied to. ep always points just beyond the end of the row, so
|
||||
* the loop simply copies (channels-1) channels until sp reaches ep.
|
||||
*
|
||||
* at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
|
||||
* nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
|
||||
*/
|
||||
|
||||
/* GA, GX, XG cases */
|
||||
if (row_info->channels == 2)
|
||||
{
|
||||
png_bytep sp=row;
|
||||
png_bytep dp=row;
|
||||
png_uint_32 row_width=row_info->width;
|
||||
png_uint_32 i;
|
||||
|
||||
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 4)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from RGBX or RGBA to RGB */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
dp+=3; sp+=4;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
}
|
||||
/* This converts from XRGB or ARGB to RGB */
|
||||
else
|
||||
{
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 24;
|
||||
row_info->rowbytes = row_width * 3;
|
||||
}
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
|
||||
sp += 8; dp += 6;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 2, ++dp;
|
||||
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
/* This could be (although png_memcpy is probably slower):
|
||||
png_memcpy(dp, sp, 6);
|
||||
sp += 8;
|
||||
dp += 6;
|
||||
*/
|
||||
/* For a 1 pixel wide image there is nothing to do */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp, sp += 2;
|
||||
|
||||
sp+=2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 48;
|
||||
row_info->rowbytes = row_width * 6;
|
||||
}
|
||||
row_info->channels = 3;
|
||||
row_info->pixel_depth = 8;
|
||||
}
|
||||
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||
row_info->channels == 2)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from GX or GA to G */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
sp++;
|
||||
}
|
||||
}
|
||||
/* This converts from XG or AG to G */
|
||||
else
|
||||
{
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 8;
|
||||
row_info->rowbytes = row_width;
|
||||
}
|
||||
else /* if (row_info->bit_depth == 16) */
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
/* This converts from GGXX or GGAA to GG */
|
||||
sp += 4; dp += 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This converts from XXGG or AAGG to GG */
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
sp += 2;
|
||||
*dp++ = *sp++;
|
||||
*dp++ = *sp++;
|
||||
}
|
||||
}
|
||||
row_info->pixel_depth = 16;
|
||||
row_info->rowbytes = row_width * 2;
|
||||
}
|
||||
row_info->channels = 1;
|
||||
if (at_start) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channel and, for sp, the filler */
|
||||
sp += 4, dp += 2;
|
||||
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||
|
||||
row_info->pixel_depth = 16;
|
||||
}
|
||||
if (flags & PNG_FLAG_STRIP_ALPHA)
|
||||
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 1;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_GRAY;
|
||||
}
|
||||
|
||||
/* RGBA, RGBX, XRGB cases */
|
||||
else if (row_info->channels == 4)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
++sp;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 4, dp += 3;
|
||||
|
||||
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||
while (sp < ep)
|
||||
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
|
||||
|
||||
row_info->pixel_depth = 24;
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (at_start) /* Skip initial filler */
|
||||
sp += 2;
|
||||
else /* Skip initial channels and, for sp, the filler */
|
||||
sp += 8, dp += 6;
|
||||
|
||||
while (sp < ep)
|
||||
{
|
||||
/* Copy 6 bytes, skip 2 */
|
||||
*dp++ = *sp++, *dp++ = *sp++;
|
||||
*dp++ = *sp++, *dp++ = *sp++;
|
||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
||||
}
|
||||
|
||||
row_info->pixel_depth = 48;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* bad bit depth */
|
||||
|
||||
row_info->channels = 3;
|
||||
|
||||
/* Finally fix the color type if it records an alpha channel */
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
row_info->color_type = PNG_COLOR_TYPE_RGB;
|
||||
}
|
||||
|
||||
else
|
||||
return; /* The filler channel has gone already */
|
||||
|
||||
/* Fix the rowbytes value. */
|
||||
row_info->rowbytes = dp-row;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -567,8 +547,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_bgr");
|
||||
|
||||
if (
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
png_uint_32 row_width = row_info->width;
|
||||
if (row_info->bit_depth == 8)
|
||||
|
@ -585,6 +564,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
*(rp + 2) = save;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
|
@ -598,6 +578,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
|
@ -615,6 +597,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
*(rp + 5) = save;
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
png_bytep rp;
|
||||
|
@ -631,12 +614,14 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
|
@ -645,33 +630,49 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
#else
|
||||
if (user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transform info");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function returns a pointer to the user_transform_ptr associated with
|
||||
* the user transform functions. The application should free any memory
|
||||
* associated with this pointer before png_write_destroy and png_read_destroy
|
||||
* are called.
|
||||
*/
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
|
||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||
#else
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_current_row_number(png_const_structp png_ptr)
|
||||
{
|
||||
/* See the comments in png.h - this is the sub-image row when reading and
|
||||
* interlaced image.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->row_number;
|
||||
|
||||
return PNG_UINT_32_MAX; /* help the app not to fail silently */
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
png_get_current_pass_number(png_const_structp png_ptr)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
return png_ptr->pass;
|
||||
return 8; /* invalid */
|
||||
}
|
||||
#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.4.0 [January 3, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.5.0 [January 6, 2011]
|
||||
* 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.)
|
||||
*
|
||||
|
@ -18,11 +18,10 @@
|
|||
* them at run time with png_set_write_fn(...).
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
/* Write the data to whatever output you are using. The default routine
|
||||
* writes to a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
|
@ -31,10 +30,12 @@
|
|||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)
|
||||
{
|
||||
/* NOTE: write_data_fn must not change the buffer! */
|
||||
if (png_ptr->write_data_fn != NULL )
|
||||
(*(png_ptr->write_data_fn))(png_ptr, data, length);
|
||||
(*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);
|
||||
|
||||
else
|
||||
png_error(png_ptr, "Call to NULL write function");
|
||||
}
|
||||
|
@ -46,14 +47,16 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
* than changing the library.
|
||||
*/
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
void PNGAPI
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
png_size_t check;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
@ -66,7 +69,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
#define NEAR_BUF_SIZE 1024
|
||||
#define MIN(a,b) (a <= b ? a : b)
|
||||
|
||||
void PNGAPI
|
||||
void PNGCBAPI
|
||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_uint_32 check;
|
||||
|
@ -75,24 +78,29 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
||||
if ((png_bytep)near_data == data)
|
||||
{
|
||||
check = fwrite(near_data, 1, length, io_ptr);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_byte buf[NEAR_BUF_SIZE];
|
||||
png_size_t written, remaining, err;
|
||||
check = 0;
|
||||
remaining = length;
|
||||
|
||||
do
|
||||
{
|
||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||
err = fwrite(buf, 1, written, io_ptr);
|
||||
|
||||
if (err != written)
|
||||
break;
|
||||
|
||||
|
@ -104,6 +112,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
}
|
||||
while (remaining != 0);
|
||||
}
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
@ -123,17 +132,19 @@ png_flush(png_structp png_ptr)
|
|||
(*(png_ptr->output_flush_fn))(png_ptr);
|
||||
}
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
void PNGAPI
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
void PNGCBAPI
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
fflush(io_ptr);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This function allows the application to supply new output functions for
|
||||
|
@ -167,7 +178,7 @@ png_default_flush(png_structp png_ptr)
|
|||
*/
|
||||
void PNGAPI
|
||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
@ -185,30 +196,32 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
|
||||
if (output_flush_fn != NULL)
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
|
||||
else
|
||||
png_ptr->output_flush_fn = png_default_flush;
|
||||
#else
|
||||
|
||||
# else
|
||||
png_ptr->output_flush_fn = output_flush_fn;
|
||||
#endif
|
||||
# endif
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
/* It is an error to read while writing a png file */
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
{
|
||||
png_ptr->read_data_fn = NULL;
|
||||
|
||||
png_warning(png_ptr,
|
||||
"Attempted to set both read_data_fn and write_data_fn in");
|
||||
png_warning(png_ptr,
|
||||
"the same structure. Resetting read_data_fn to NULL");
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
#ifdef _MSC_VER
|
||||
# ifdef _MSC_VER
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
|
@ -236,6 +249,6 @@ void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
|||
|
||||
return(near_ptr);
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.5.6 [November 3, 2011]
|
||||
* 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.)
|
||||
*
|
||||
|
@ -11,16 +11,16 @@
|
|||
* and license in png.h
|
||||
*/
|
||||
|
||||
#define PNG_NO_PEDANTIC_WARNINGS
|
||||
#include "png.h"
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#include "pngpriv.h"
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transform the data according to the user's wishes. The order of
|
||||
* transformations is significant.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_write_transformations(png_structp png_ptr)
|
||||
png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_write_transformations");
|
||||
|
||||
|
@ -30,56 +30,65 @@ png_do_write_transformations(png_structp png_ptr)
|
|||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
(*(png_ptr->write_user_transform_fn)) /* User write transform
|
||||
function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_uint_32 rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
(png_ptr, /* png_ptr */
|
||||
row_info, /* row_info: */
|
||||
/* png_uint_32 width; width of row */
|
||||
/* png_size_t rowbytes; number of bytes in row */
|
||||
/* png_byte color_type; color type of pixels */
|
||||
/* png_byte bit_depth; bit depth of samples */
|
||||
/* png_byte channels; number of channels (1-4) */
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->flags);
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
png_do_pack(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->bit_depth);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
png_do_shift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -114,9 +123,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
{
|
||||
if (*sp != 0)
|
||||
v |= mask;
|
||||
|
||||
sp++;
|
||||
|
||||
if (mask > 1)
|
||||
mask >>= 1;
|
||||
|
||||
else
|
||||
{
|
||||
mask = 0x80;
|
||||
|
@ -125,10 +137,13 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
v = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask != 0x80)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
|
@ -140,12 +155,14 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
dp = row;
|
||||
shift = 6;
|
||||
v = 0;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
||||
value = (png_byte)(*sp & 0x03);
|
||||
v |= (value << shift);
|
||||
|
||||
if (shift == 0)
|
||||
{
|
||||
shift = 6;
|
||||
|
@ -153,14 +170,19 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
|
||||
else
|
||||
shift -= 2;
|
||||
|
||||
sp++;
|
||||
}
|
||||
|
||||
if (shift != 6)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
|
@ -172,6 +194,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
dp = row;
|
||||
shift = 4;
|
||||
v = 0;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_byte value;
|
||||
|
@ -186,23 +209,27 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
dp++;
|
||||
v = 0;
|
||||
}
|
||||
|
||||
else
|
||||
shift -= 4;
|
||||
|
||||
sp++;
|
||||
}
|
||||
|
||||
if (shift != 4)
|
||||
*dp = (png_byte)v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
row_info->bit_depth = (png_byte)bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
|
||||
row_info->width);
|
||||
row_info->width);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -216,12 +243,12 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
* data to 0 to 15.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||
png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
png_const_color_8p bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_do_shift");
|
||||
|
||||
if (
|
||||
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
|
@ -231,19 +258,23 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||
shift_start[channels] = row_info->bit_depth - bit_depth->red;
|
||||
shift_dec[channels] = bit_depth->red;
|
||||
channels++;
|
||||
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->green;
|
||||
shift_dec[channels] = bit_depth->green;
|
||||
channels++;
|
||||
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->blue;
|
||||
shift_dec[channels] = bit_depth->blue;
|
||||
channels++;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->gray;
|
||||
shift_dec[channels] = bit_depth->gray;
|
||||
channels++;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
|
||||
|
@ -255,14 +286,16 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
png_bytep bp = row;
|
||||
png_uint_32 i;
|
||||
png_size_t i;
|
||||
png_byte mask;
|
||||
png_uint_32 row_bytes = row_info->rowbytes;
|
||||
png_size_t row_bytes = row_info->rowbytes;
|
||||
|
||||
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
|
||||
mask = 0x55;
|
||||
|
||||
else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
|
||||
mask = 0x11;
|
||||
|
||||
else
|
||||
mask = 0xff;
|
||||
|
||||
|
@ -273,15 +306,18 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
|
||||
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep bp = row;
|
||||
|
@ -297,15 +333,18 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||
|
||||
v = *bp;
|
||||
*bp = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
*bp |= (png_byte)((v << j) & 0xff);
|
||||
|
||||
else
|
||||
*bp |= (png_byte)((v >> (-j)) & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_bytep bp;
|
||||
|
@ -320,10 +359,12 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
|||
|
||||
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));
|
||||
value = 0;
|
||||
|
||||
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
|
||||
{
|
||||
if (j > 0)
|
||||
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);
|
||||
|
||||
else
|
||||
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);
|
||||
}
|
||||
|
@ -344,12 +385,13 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
/* This converts from ARGB to RGBA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from ARGB to RGBA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
png_byte save = *(sp++);
|
||||
|
@ -359,9 +401,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save;
|
||||
}
|
||||
}
|
||||
/* This converts from AARRGGBB to RRGGBBAA */
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This converts from AARRGGBB to RRGGBBAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -381,12 +425,14 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
/* This converts from AG to GA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This converts from AG to GA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -398,9 +444,11 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save;
|
||||
}
|
||||
}
|
||||
/* This converts from AAGG to GGAA */
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This converts from AAGG to GGAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -416,6 +464,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = save[1];
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -430,12 +479,13 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||
{
|
||||
/* Does nothing
|
||||
|
@ -447,9 +497,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -469,12 +521,14 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
/* This inverts the alpha channel in GA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This inverts the alpha channel in GA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -485,9 +539,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else
|
||||
{
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -503,10 +559,12 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Undoes intrapixel differencing */
|
||||
|
@ -515,8 +573,7 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_debug(1, "in png_do_write_intrapixel");
|
||||
|
||||
if (
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
int bytes_per_pixel;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
@ -527,17 +584,21 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 3;
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 4;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp+1))&0xff);
|
||||
*(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff);
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytep rp;
|
||||
|
@ -545,24 +606,27 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
bytes_per_pixel = 6;
|
||||
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
bytes_per_pixel = 8;
|
||||
|
||||
else
|
||||
return;
|
||||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp+1);
|
||||
png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3);
|
||||
png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5);
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp+1) = (png_byte)(red & 0xff);
|
||||
*(rp+4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp+5) = (png_byte)(blue & 0xff);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_16BIT_SUPPORTED */
|
||||
}
|
||||
}
|
||||
#endif /* PNG_MNG_FEATURES_SUPPORTED */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче