backing out bug 334110/libpng 1.2.12 until I can figure out why it is broken on mac.

This commit is contained in:
pavlov%pavlov.net 2006-09-25 22:38:55 +00:00
Родитель d3746e7b46
Коммит 36223e5472
28 изменённых файлов: 567 добавлений и 1334 удалений

Просмотреть файл

@ -3944,12 +3944,8 @@ if test "$SYSTEM_PNG" = 1; then
#include <sys/types.h>
#include <png.h>
int main () {
#if PNG_LIBPNG_VER >= $MOZPNG
#ifdef PNG_UINT_31_MAX
exit(0);
#else
exit(1);
#endif
#if PNG_LIBPNG_VER >= $MOZPNG
exit(0);
#else
exit(1);
#endif
@ -5620,10 +5616,6 @@ MOZ_ARG_ENABLE_STRING(image-decoders,
done],
MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS_DEFAULT")
if test `echo "$MOZ_IMG_DECODERS" | grep -c png` -ne 0; then
MOZ_PNG_CFLAGS="$MOZ_PNG_CFLAGS -DMOZ_PNG_READ"
fi
dnl Dupes are removed in the encoder section because it will also add decoders
dnl ========================================================
@ -5650,10 +5642,6 @@ MOZ_ARG_ENABLE_STRING(image-encoders,
done],
MOZ_IMG_ENCODERS="$MOZ_IMG_ENCODERS_DEFAULT")
if test `echo "$MOZ_IMG_ENCODERS" | grep -c png` -ne 0; then
MOZ_PNG_CFLAGS="$MOZ_PNG_CFLAGS -DMOZ_PNG_WRITE"
fi
dnl Remove dupes
MOZ_IMG_DECODERS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_IMG_DECODERS}`
MOZ_IMG_ENCODERS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_IMG_ENCODERS}`

Просмотреть файл

@ -10,7 +10,7 @@ version 0.3
split up pngwrite.c to several files
added pnglib.txt
added example.c
cleaned up writer, adding a few new transformations
cleaned up writer, adding a few new tranformations
fixed some bugs in writer
interfaced with zlib 0.5
added K&R support
@ -22,7 +22,7 @@ version 0.4
created png_color_16 and png_color_8 to handle color needs
cleaned up color type defines
fixed various bugs
made various names more consistent
made various names more consistant
interfaced with zlib 0.71
cleaned up zTXt reader and writer (using zlib's Reset functions)
split transformations into pngrtran.c and pngwtran.c
@ -151,7 +151,7 @@ version 0.95 [March, 1997]
added "packswap" transformation, which changes the endianness of
packed-pixel bytes (Kevin Bracey)
added "strip_alpha" transformation, which removes the alpha channel of
input images without using it (not necessarily a good idea)
input images without using it (not neccesarily a good idea)
added "swap_alpha" transformation, which puts the alpha channel in front
of the color bytes instead of after
removed all implicit variable tests which assume NULL == 0 (I think)
@ -172,7 +172,7 @@ version 0.95 [March, 1997]
more chunk types tested in pngtest.c
renamed pngrcb.c to pngset.c, and all png_read_<chunk> functions to be
png_set_<chunk>. We now have corresponding png_get_<chunk>
functions in pngget.c to get information in info_ptr. This isolates
functions in pngget.c to get infomation in info_ptr. This isolates
the application from the internal organization of png_info_struct
(good for shared library implementations).
@ -522,9 +522,9 @@ version 1.0.5b [November 23, 1999]
Updated scripts/makevms.com and added makevms.com to contrib/gregbook
and contrib/pngminus (Martin Zinser)
version 1.0.5c [November 26, 1999]
Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr.
Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
accommodate making DLL's: Moved usr_png_ver from global variable to function
accomodate making DLL's: Moved usr_png_ver from global variable to function
png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and
eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays
into pngtypes.h. Eliminated use of global png_pass arrays. Declared the
@ -1345,7 +1345,7 @@ version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004]
Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED
section of png.h where they were inadvertently placed in version rc3.
version 1.2.6 and 1.0.16 [August 15, 2004]
version 1.0.16 and 1.2.6 [August 15, 2004]
Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1.
version 1.2.7beta1 [August 26, 2004]
Removed unused pngasmrd.h file.
@ -1361,264 +1361,13 @@ version 1.2.7beta2 [August 28, 2004]
Added png_set_add_alpha() that updates color type.
version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004]
Revised png_set_strip_filler() to not remove alpha if color_type has alpha.
version 1.2.7 and 1.0.17 [September 12, 2004]
version 1.0.17 and 1.2.7 [September 12, 2004]
Added makefile.hp64
Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin
version 1.2.8beta1 [November 1, 2004]
Fixed bug in png_text_compress() that would fail to complete a large block.
Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during
strip alpha operation in png_do_strip_filler().
Added PNG_1_2_X definition in pngconf.h
#ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0)
version 1.2.8beta2 [November 2, 2004]
Reduce color_type to a nonalpha type after strip alpha operation in
png_do_strip_filler().
version 1.2.8beta3 [November 3, 2004]
Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM
version 1.2.8beta4 [November 12, 2004]
Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin).
Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin).
Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection
of data type in deflate (Cosmin).
Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of
PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
version 1.2.8beta5 [November 20, 2004]
Use png_ptr->flags instead of png_ptr->transformations to pass
PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI
compatibility.
Revised handling of SPECIALBUILD, PRIVATEBUILD,
PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
version 1.2.8rc1 [November 24, 2004]
Moved handling of BUILD macros from pngconf.h to png.h
Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently
omitted from beta5.
Revised scripts/pngw32.rc
Despammed mailing addresses by masking "@" with "at".
Inadvertently installed a supposedly faster test version of pngrutil.c
version 1.2.8rc2 [November 26, 2004]
Added two missing "\" in png.h
Change tests in pngread.c and pngpread.c to
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
png_do_read_transformations(png_ptr);
version 1.2.8rc3 [November 28, 2004]
Reverted pngrutil.c to version libpng-1.2.8beta5.
Added scripts/makefile.elf with supporting code in pngconf.h for symbol
versioning (John Bowler).
version 1.2.8rc4 [November 29, 2004]
Added projects/visualc7 (Simon-pierre).
version 1.2.8rc5 [November 29, 2004]
Fixed new typo in scripts/pngw32.rc
version 1.2.8 [December 3, 2004]
Removed projects/visualc7, added projects/visualc71.
version 1.2.9beta1 [February 21, 2006]
Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints
Revised man page and libpng.txt to make it clear that one should not call
png_read_end or png_write_end after png_read_png or png_write_png.
Updated references to png-mng-implement mailing list.
Fixed an incorrect typecast in pngrutil.c
Added PNG_NO_READ_SUPPORTED conditional for making a write-only library.
Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional.
Optimized alpha-inversion loops in pngwtran.c
Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c
Make sure num_trans is <= 256 before copying data in png_set_tRNS().
Make sure num_palette is <= 256 before copying data in png_set_PLTE().
Interchanged order of write_swap_alpha and write_invert_alpha transforms.
Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin).
Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin).
Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin).
Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16,
png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin).
Added type cast (png_byte) in png_write_sCAL() (Cosmin).
Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin).
Default iTXt support was inadvertently enabled.
version 1.2.9beta2 [February 21, 2006]
Check for png_rgb_to_gray and png_gray_to_rgb read transformations before
checking for png_read_dither in pngrtran.c
Revised checking of chromaticity limits to accommodate extended RGB
colorspace (John Denker).
Changed line endings in some of the project files to CRLF, even in the
"Unix" tar distributions (Cosmin).
Made png_get_int_32 and png_save_int_32 always available (Cosmin).
Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def
with the newly exported functions.
Eliminated distributions without the "configure" script.
Updated INSTALL instructions.
version 1.2.9beta3 [February 24, 2006]
Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp
Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler)
Removed reference to pngasmrd.h from Makefile.am
Renamed CHANGES to ChangeLog.
Renamed LICENSE to COPYING.
Renamed ANNOUNCE to NEWS.
Created AUTHORS file.
version 1.2.9beta4 [March 3, 2006]
Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac
Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING.
Removed newline from the end of some error and warning messages.
Removed test for sqrt() from configure.ac and configure.
Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix).
Disabled default iTXt support that was inadvertently enabled in
libpng-1.2.9beta1.
Added "OS2" to list of systems that don't need underscores, in pnggccrd.c
Removed libpng version and date from *.c files.
version 1.2.9beta5 [March 4, 2006]
Removed trailing blanks from source files.
Put version and date of latest change in each source file, and changed
copyright year accordingly.
More cleanup of configure.ac, Makefile.ac, and associated scripts.
Restored scripts/makefile.elf which was inadvertently deleted.
version 1.2.9beta6 [March 6, 2006]
Fixed typo (12) in configuration files.
version 1.2.9beta7 [March 7, 2006]
Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am
Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s()
in png.h.
Updated makefile.elf as suggested by debian.
Made cosmetic changes to some makefiles, adding LN_SF and other macros.
Made some makefiles accept "exec_prefix".
version 1.2.9beta8 [March 9, 2006]
Fixed some "#if defined (..." which should be "#if defined(..."
Bug introduced in libpng-1.2.8.
Fixed inconsistency in definition of png_default_read_data()
Restored blank that was lost from makefile.sggcc "clean" target in beta7.
Revised calculation of "current" and "major" for irix in ltmain.sh
Changed "mkdir" to "MKDIR_P" in some makefiles.
Separated PNG_EXPAND and PNG_EXPAND_tRNS.
Added png_set_expand_gray_1_2_4_to_8() and deprecated
png_set_gray_1_2_4_to_8() which also expands tRNS to alpha.
version 1.2.9beta9 [March 10, 2006]
Include "config.h" in pngconf.h when available.
Added some checks for NULL png_ptr or NULL info_ptr (timeless)
version 1.2.9beta10 [March 20, 2006]
Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin)
Made pnggccrd.c PIC-compliant (Christian Aichinger).
Added makefile.mingw (Wolfgang Glas).
Revised pngconf.h MMX checking.
version 1.2.9beta11 [March 22, 2006]
Fixed out-of-order declaration in pngwrite.c that was introduced in beta9
Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros.
version 1.2.9rc1 [March 31, 2006]
Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin).
Removed nonsensical assertion check from pngtest.c (Cosmin).
version 1.2.9 [April 14, 2006]
Revised makefile.beos and added "none" selector in ltmain.sh
version 1.2.10beta1 [April 15, 2006]
Renamed "config.h" to "png_conf.h" and revised Makefile.am to add
-DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h
to include png_conf.h only when PNG_BUILDING_LIBPNG is defined.
version 1.2.10beta2 [April 15, 2006]
Manually updated Makefile.in and configure. Changed png_conf.h.in
back to config.h.
version 1.2.10beta3 [April 15, 2006]
Change png_conf.h back to config.h in pngconf.h.
version 1.2.10beta4 [April 16, 2006]
Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*.
version 1.2.10beta5 [April 16, 2006]
Added a configure check for compiling assembler code in pnggccrd.c
version 1.2.10beta6 [April 17, 2006]
Revised the configure check for pnggccrd.c
Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@
Added @LIBPNG_DEFINES@ to arguments when building libpng.sym
version 1.2.10beta7 [April 18, 2006]
Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles.
version 1.2.10rc1 [April 19, 2006]
Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD
Fixed "LN_FS" typo in makefile.sco and makefile.solaris.
version 1.2.10rc2 [April 20, 2006]
Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE
in configure.ac and configure
Made the configure warning about versioned symbols less arrogant.
version 1.2.10rc3 [April 21, 2006]
Added a note in libpng.txt that png_set_sig_bytes(8) can be used when
writing an embedded PNG without the 8-byte signature.
Revised makefiles and configure to avoid making links to libpng.so.*
version 1.2.10 [April 23, 2006]
Reverted configure to "rc2" state.
version 1.2.11beta1 [May 31, 2006]
scripts/libpng.pc.in contained "configure" style version info and would
not work with makefiles.
The shared-library makefiles were linking to libpng.so.0 instead of
libpng.so.3 compatibility as the library.
version 1.2.11beta2 [June 2, 2006]
Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
buffer overflow.
Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb)
version 1.2.11beta3 [June 5, 2006]
Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin).
Removed the accidental leftover Makefile.in~ (Cosmin).
Avoided potential buffer overflow and optimized buffer in
png_write_sCAL(), png_write_sCAL_s() (Cosmin).
Removed the include directories and libraries from CFLAGS and LDFLAGS
in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin).
version 1.2.11beta4 [June 6, 2006]
Allow zero-length IDAT chunks after the entire zlib datastream, but not
after another intervening chunk type.
version 1.0.19rc1, 1.2.11rc1 [June 13, 2006]
Deleted extraneous square brackets from [config.h] in configure.ac
version 1.0.19rc2, 1.2.11rc2 [June 14, 2006]
Added prototypes for PNG_INCH_CONVERSIONS functions to png.h
Revised INSTALL and autogen.sh
Fixed typo in several makefiles (-W1 should be -Wl)
Added typedef for png_int_32 and png_uint_32 on 64-bit systems.
version 1.0.19rc3, 1.2.11rc3 [June 15, 2006]
Removed the new typedefs for 64-bit systems (delay until version 1.4.0)
Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid
reading out of bounds.
version 1.0.19rc4, 1.2.11rc4 [June 15, 2006]
Really removed the new typedefs for 64-bit systems.
version 1.0.19rc5, 1.2.11rc5 [June 22, 2006]
Removed png_sig_bytes entry from scripts/pngw32.def
version 1.0.19, 1.2.11 [June 26, 2006]
None.
version 1.0.20, 1.2.12 [June 27, 2006]
Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid
buffer overflow.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe)
or to glennrp at users.sourceforge.net
Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu (subscription required; write to
majordomo@ccrc.wustl.edu with "subscribe png-implement" in the message)
or to glennrp@users.sourceforge.net
Glenn R-P

Просмотреть файл

@ -8,8 +8,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.2.6, August 15, 2004, through 1.2.12, June 27, 2006, are
Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
libpng version 1.2.6, September 12, 2004, is
Copyright (c) 2004 Glenn Randers-Pehrson, and is
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@ -105,5 +105,5 @@ Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
June 27, 2006
glennrp@users.sourceforge.net
September 12, 2004

Просмотреть файл

@ -1,8 +1,6 @@
Changes made to pristine png source by mozilla.org developers.
2006/06/27 -- Synced with libpng-1.2.12 tree
2004/10/07 -- Synced with libpng-1.2.7 tree
2004/10/07 -- add mozpngconf.h (bug 208607)

Просмотреть файл

@ -80,6 +80,11 @@ FORCE_USE_PIC = 1
include $(topsrcdir)/config/rules.mk
#ifeq (png,$(filter png,$(MOZ_IMG_ENCODERS)))
ifdef MOZ_IMG_ENCODERS
DEFINES += -DMOZ_PNG_WRITE
endif
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DZLIB_DLL
ifdef BUILD_DEBUG_GC

Просмотреть файл

@ -1,4 +1,4 @@
README for libpng version 1.2.12 - June 27, 2006 (shared library 12.0)
README for libpng version 1.2.7 - September 12, 2004 (shared library 12.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@ -103,18 +103,17 @@ fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG group.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
glennrp@users.sourceforge.net
png-implement@ccrc.wustl.edu (subscription required; write to
majordomo@ccrc.wustl.edu with "subscribe png-implement" in the message).
You can't reach Guy, the original libpng author, at the addresses
given in previous versions of this document. He and Andreas will read mail
addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
the (png-list at ccrc.wustl.edu, subscription required, write to
majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
the (png-list@ccrc.wustl.edu, subscription required, write to
majordomo@ccrc.wustl.edu with "subscribe png-list" in your message).
On the other hand,
please do not send libpng questions to that address, send them to me
or to the png-implement list. I'll
@ -189,12 +188,10 @@ Files in this distribution:
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 libpng12.so.0.1.2.12)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.12)
(gcc, creates libpng12.so.0.1.2.7)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.12,
(gcc, creates libpng12.so.0.1.2.7,
uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
@ -216,12 +213,12 @@ Files in this distribution:
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics
(gcc, creates libpng12.so.0.1.2.12)
(gcc, creates libpng12.so.0.1.2.7)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng12.so.0.1.2.12)
(gcc, creates libpng12.so.0.1.2.7)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng12.so.0.1.2.12)
(gcc, creates libpng12.so.0.1.2.7)
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
@ -252,12 +249,12 @@ Files in this distribution:
Good luck, and happy coding.
-Glenn Randers-Pehrson (current maintainer)
Internet: glennrp at users.sourceforge.net
Internet: glennrp@users.sourceforge.net
-Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca
Internet: adilger@enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc)
Internet: gschal at infinet.com
Internet: gschal@infinet.com

Просмотреть файл

@ -1,9 +1,9 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.2.12 - June 27, 2006
libpng version 1.2.7 - September 12, 2004
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2005 Glenn Randers-Pehrson
<glennrp@users.sourceforge.net>
Copyright (c) 1998-2004 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright
notice in png.h.
@ -771,10 +771,9 @@ in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
is called to insert filler bytes, either before or after each RGB triplet.
16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
byte of the color value first, unless png_set_strip_16() is called to
transform it to regular RGB RGB triplets, or png_set_filler() or
png_set_add alpha() is called to insert filler bytes, either before or
after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
be modified with
transform it to regular RGB RGB triplets, or png_set_filler|add alpha()
is called to insert filler bytes, either before or after each RRGGBB
triplet. Similarly, 8-bit or 16-bit grayscale data can be modified with
png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
The following code transforms grayscale images of less than 8 to 8 bits,
@ -787,7 +786,7 @@ viewing application that wishes to treat all images in the same way.
png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY &&
bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
if (png_get_valid(png_ptr, info_ptr,
PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
@ -797,11 +796,6 @@ in libpng version 1.0.4, with the function names expanded to improve code
readability. In some future version they may actually do different
things.
As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
added. It expands the sample depth without changing tRNS to alpha.
At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it
will be removed from a future version.
PNG can have files with 16 bits per channel. If you only can handle
8 bits per channel, this will strip the pixels down to 8 bit.
@ -873,7 +867,7 @@ to do that, you can add a true alpha channel with
png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
where "filler" contains the alpha value to assign to each pixel.
This function was added in libpng-1.2.7.
This function became available in libpng-1.2.7.
If you are reading an image with an alpha channel, and you need the
data as ARGB instead of the normal PNG format RGBA:
@ -928,7 +922,7 @@ the normalized graylevel is computed:
The default values approximate those recommended in the Charles
Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
@ -1253,8 +1247,8 @@ the second parameter NULL.
Finishing a sequential read
After you are finished reading the image through the
low-level interface, you can finish reading the file. If you are
After you are finished reading the image through either the high- or
low-level interfaces, you can finish reading the file. If you are
interested in comments or time, which may be stored either before or
after the image data, you should pass the separate png_info struct if
you want to keep the comments from before and after the image
@ -1601,14 +1595,6 @@ Libpng section below.
png_init_io(png_ptr, fp);
If you are embedding your PNG into a datastream such as MNG, and don't
want libpng to write the 8-byte signature, or if you have already
written the signature in your application, use
png_set_sig_bytes(png_ptr, 8);
to inform libpng that it should not write a signature.
Write callbacks
At this point, you can set up a callback function that will be
@ -2472,7 +2458,7 @@ Custom chunks
If you need to read or write custom chunks, you may need to get deeper
into the libpng code. The library now has mechanisms for storing
and writing chunks of unknown type; you can even declare callbacks
for custom chunks. However, this may not be good enough if the
for custom chunks. Hoewver, this may not be good enough if the
library code itself needs to know about interactions between your
chunk and existing `intrinsic' chunks.
@ -2823,7 +2809,7 @@ defined:
#if defined(PNG_USE_PNGGCCRD) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) \
&& defined(PNG_THREAD_UNSAFE_OK)
/* Disable thread-unsafe features of pnggccrd */
if (png_access_version_number() >= 10200)
if (png_access_version() >= 10200)
{
png_uint_32 mmx_disable_mask = 0;
png_uint_32 asm_flags;
@ -2917,13 +2903,13 @@ application:
IX. Y2K Compliance in libpng
June 27, 2006
September 12, 2004
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
upward through 1.2.12 are Y2K compliant. It is my belief that earlier
upward through 1.2.7 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that

Просмотреть файл

@ -39,9 +39,7 @@
#define PNG_NO_GLOBAL_ARRAYS
#ifndef MOZ_PNG_READ
#define PNG_NO_READ_SUPPORTED
#endif
#define PNG_NO_INFO_IMAGE
#define PNG_NO_READ_BACKGROUND
#define PNG_NO_READ_DITHER
#define PNG_NO_READ_INVERT
@ -66,14 +64,13 @@
#define PNG_NO_READ_tIME
#define PNG_NO_READ_UNKNOWN_CHUNKS
#define PNG_NO_READ_USER_CHUNKS
#define PNG_NO_USER_MEM
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_NO_READ_OPT_PLTE
#define PNG_NO_READ_STRIP_ALPHA
#define PNG_NO_READ_oFFs
#define PNG_NO_MNG_FEATURES
#ifndef MOZ_PNG_WRITE
#define PNG_NO_WRITE_SUPPORTED
#else
#ifdef MOZ_PNG_WRITE
#define PNG_NO_WRITE_BACKGROUND
#define PNG_NO_WRITE_DITHER
#define PNG_NO_WRITE_INVERT
@ -87,11 +84,8 @@
#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
@ -103,22 +97,20 @@
#define PNG_NO_WRITE_USER_CHUNKS
#define PNG_NO_WRITE_EMPTY_PLTE
#define PNG_NO_WRITE_OPT_PLTE
#define PNG_NO_WRITE_WEIGHTED_FILTER
#define PNG_NO_WRITE_INTERLACING_SUPPORTED /* effective libpng-1.3.0 */
#else
#define PNG_NO_WRITE_SUPPORTED
#endif
#define PNG_NO_INFO_IMAGE
#define PNG_NO_USER_MEM
#define PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_NO_MNG_FEATURES
#define PNG_NO_READ_STRIP_ALPHA
#define PNG_NO_USER_TRANSFORM_PTR
#define PNG_NO_READ_oFFs
#define PNG_NO_HANDLE_AS_UNKNOWN
#define PNG_NO_CONSOLE_IO
#define PNG_NO_ZALLOC_ZERO
#define PNG_NO_ERROR_NUMBERS
#define PNG_NO_EASY_ACCESS
#define PNG_NO_SEQUENTIAL_READ_SUPPORTED
#define PNG_NO_SEQUENTIAL_READ_SUPPORTED
/* Mangle names of exported libpng functions so different libpng versions
can coexist. It is recommended that if you do this, you give your
@ -437,25 +429,6 @@
#define png_write_rows MOZ_PNG_write_rows
#define png_zalloc MOZ_PNG_zalloc
#define png_zfree MOZ_PNG_zfree
#define png_write_data MOZ_PNG_write_data
#define png_default_write_data MOZ_PNG_default_write_data
#define png_flush MOZ_PNG_flush
#define png_write_sig MOZ_PNG_write_sig
#define png_write_IHDR MOZ_PNG_write_IHDR
#define png_write_IDAT MOZ_PNG_write_IDAT
#define png_write_gAMA MOZ_PNG_write_gAMA
#define png_write_sRGB MOZ_PNG_write_sRGB
#define png_write_PLTE MOZ_PNG_write_PLTE
#define png_write_tRNS MOZ_PNG_write_tRNS
#define png_write_oFFs MOZ_PNG_write_oFFs
#define png_write_IEND MOZ_PNG_write_IEND
#define png_write_init MOZ_PNG_write_init
#define png_write_start_row MOZ_PNG_write_trans
#define png_do_write_transformations MOZ_PNG_do_write_trans
#define png_write_find_filter MOZ_PNG_write_find_filter
#define png_write_destroy MOZ_PNG_write_destroy
#define png_write_finish_row MOZ_PNG_write_finish_row
#define png_write_filtered_row MOZ_PNG_write_filtered_row
/* libpng-1.2.6 additions */
#define png_convert_size MOZ_PNG_convert_size
@ -467,10 +440,4 @@
/* 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
#endif

Просмотреть файл

@ -1,9 +1,9 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
@ -13,7 +13,7 @@
#include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_2_12 Your_png_h_is_not_version_1_2_12;
typedef version_1_2_7 Your_png_h_is_not_version_1_2_7;
/* Version information for C files. This had better match the version
* string defined in png.h. */
@ -22,12 +22,9 @@ typedef version_1_2_12 Your_png_h_is_not_version_1_2_12;
/* png_libpng_ver was changed to a function in version 1.0.5c */
const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
#ifdef PNG_READ_SUPPORTED
/* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */
const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
#endif /* PNG_READ_SUPPORTED */
/* Invoke global declarations for constant strings for known chunk types */
PNG_IHDR;
@ -52,7 +49,6 @@ PNG_tIME;
PNG_tRNS;
PNG_zTXt;
#ifdef PNG_READ_SUPPORTED
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
@ -84,8 +80,7 @@ const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
const int FARDATA png_pass_dsp_mask[]
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
#endif /* PNG_READ_SUPPORTED */
#endif /* PNG_USE_GLOBAL_ARRAYS */
#endif
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -93,7 +88,6 @@ const int FARDATA png_pass_dsp_mask[]
* or write any of the magic bytes before it starts on the IHDR.
*/
#ifdef PNG_READ_SUPPORTED
void PNGAPI
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
{
@ -119,10 +113,10 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
if (num_to_check > 8)
num_to_check = 8;
else if (num_to_check < 1)
return (-1);
return (0);
if (start > 7)
return (-1);
return (0);
if (start + num_to_check > 8)
num_to_check = 8 - start;
@ -130,7 +124,6 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
}
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* (Obsolete) function to check signature bytes. It does not allow one
* to check a partial signature. This function might be removed in the
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
@ -140,10 +133,7 @@ png_check_sig(png_bytep sig, int num)
{
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
}
#endif
#endif /* PNG_READ_SUPPORTED */
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Function to allocate memory for zlib and clear it to 0. */
#ifdef PNG_1_0_X
voidpf PNGAPI
@ -289,7 +279,6 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
* and applications using it are urged to use png_create_info_struct()
* instead.
*/
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
#undef png_info_init
void PNGAPI
png_info_init(png_infop info_ptr)
@ -297,7 +286,6 @@ png_info_init(png_infop info_ptr)
/* We only come here via pre-1.0.12-compiled applications */
png_info_init_3(&info_ptr, 0);
}
#endif
void PNGAPI
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
@ -602,7 +590,6 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
png_info_init_3(&info_ptr, png_sizeof(png_info));
}
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
/* This function returns a pointer to the io_ptr associated with the user
* functions. The application should free any memory associated with this
@ -614,7 +601,6 @@ png_get_io_ptr(png_structp png_ptr)
return (png_ptr->io_ptr);
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#if !defined(PNG_NO_STDIO)
/* Initialize the default input/output functions for the PNG file. If you
* use your own read or write routines, you can call either png_set_read_fn()
@ -687,14 +673,13 @@ png_sig_bytes(void)
return ((png_bytep)"\211\120\116\107\015\012\032\012");
}
#endif
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
png_charp PNGAPI
png_get_copyright(png_structp png_ptr)
{
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return ((png_charp) "\n libpng version 1.2.12 - June 27, 2006\n\
Copyright (c) 1998-2006 Glenn Randers-Pehrson\n\
return ((png_charp) "\n libpng version 1.2.7 - September 12, 2004\n\
Copyright (c) 1998-2004 Glenn Randers-Pehrson\n\
Copyright (c) 1996-1997 Andreas Dilger\n\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
return ((png_charp) "");
@ -735,7 +720,6 @@ png_get_header_version(png_structp png_ptr)
return ((png_charp) "");
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int PNGAPI
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
@ -759,7 +743,6 @@ png_reset_zstream(png_structp png_ptr)
{
return (inflateReset(&png_ptr->zstream));
}
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
/* This function was added to libpng-1.0.7 */
png_uint_32 PNGAPI
@ -770,7 +753,6 @@ png_access_version_number(void)
}
#if defined(PNG_READ_SUPPORTED)
#if !defined(PNG_1_0_X)
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
@ -830,9 +812,7 @@ png_mmx_support(void)
}
#endif
#endif /* PNG_1_0_X */
#endif /* PNG_READ_SUPPORTED */
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#ifdef PNG_SIZE_T
/* Added at libpng version 1.2.6 */
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
@ -844,4 +824,3 @@ png_convert_size(size_t size)
return ((png_size_t)size);
}
#endif /* PNG_SIZE_T */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */

Просмотреть файл

@ -1,15 +1,14 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.2.12 - June 27, 2006
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* libpng version 1.2.7 - September 12, 2004
* Copyright (c) 1998-2004 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.)
*
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.2.12 - June 27, 2006: Glenn
* libpng versions 0.97, January 1998, through 1.2.7 - September 12, 2004: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -103,29 +102,10 @@
* 1.0.16 10 10016 10.so.0.1.0.16
* 1.2.6 13 10206 12.so.0.1.2.6
* 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
* 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
* 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
* 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
* 1.0.17 10 10017 10.so.0.1.0.17
* 1.0.17 10 10017 12.so.0.1.0.17
* 1.2.7 13 10207 12.so.0.1.2.7
* 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
* 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
* 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
* 1.0.18 10 10018 10.so.0.1.0.18
* 1.2.8 13 10208 12.so.0.1.2.8
* 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
* 1.2.9beta4-11 13 10209 12.so.0.9[.0]
* 1.2.9rc1 13 10209 12.so.0.9[.0]
* 1.2.9 13 10209 12.so.0.9[.0]
* 1.2.10beta1-8 13 10210 12.so.0.10[.0]
* 1.2.10rc1-3 13 10210 12.so.0.10[.0]
* 1.2.10 13 10210 12.so.0.10[.0]
* 1.2.11beta1-4 13 10211 12.so.0.11[.0]
* 1.0.19rc1-5 10 10019 10.so.0.19[.0]
* 1.2.11rc1-5 13 10211 12.so.0.11[.0]
* 1.0.19 10 10019 10.so.0.19[.0]
* 1.2.11 13 10211 12.so.0.11[.0]
* 1.0.20 10 10020 10.so.0.20[.0]
* 1.2.12 13 10212 12.so.0.12[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -155,8 +135,8 @@
* If you modify libpng you may insert additional notices immediately following
* this sentence.
*
* libpng versions 1.2.6, August 15, 2004, through 1.2.12, June 27, 2006, are
* Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
* libpng versions 1.2.6, August 15, 2004, through 1.2.7, September 12, 2004, are
* Copyright (c) 2004 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:
*
@ -267,13 +247,13 @@
* Y2K compliance in libpng:
* =========================
*
* June 27, 2006
* September 12, 2004
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.2.12 are Y2K compliant. It is my belief that earlier
* upward through 1.2.7 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant.
*
* Libpng only has three year fields. One is a 2-byte unsigned integer
@ -329,81 +309,45 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.12"
#define PNG_LIBPNG_VER_STRING "1.2.7"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.12 - June 27, 2006 (header)\n"
" libpng version 1.2.7 - September 12, 2004 (header)\n"
#define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13
#define PNG_LIBPNG_VER_DLLNUM %DLLNUM%
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 2
#define PNG_LIBPNG_VER_RELEASE 12
#define PNG_LIBPNG_VER_RELEASE 7
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
#define PNG_LIBPNG_VER_BUILD 0
/* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1
#define PNG_LIBPNG_BUILD_BETA 2
#define PNG_LIBPNG_BUILD_RC 3
#define PNG_LIBPNG_BUILD_STABLE 4
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
/* Release-Specific Flags */
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
PNG_LIBPNG_BUILD_STABLE only */
#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_SPECIAL */
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
#define PNG_LIBPNG_BUILD_TYPEMASK 7
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */
#define PNG_LIBPNG_BUILD_TYPE 4
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10212 /* 1.2.12 */
#define PNG_LIBPNG_VER 10207 /* 1.2.7 */
#ifndef PNG_VERSION_INFO_ONLY
/* include the compression library's header */
#include "zlib.h"
#endif
/* include all user configurable info, including optional assembler routines */
#include "pngconf.h"
/*
* Added at libpng-1.2.8 */
/* Ref MSDN: Private as priority over Special
* VS_FF_PRIVATEBUILD File *was not* built using standard release
* procedures. If this value is given, the StringFileInfo block must
* contain a PrivateBuild string.
*
* VS_FF_SPECIALBUILD File *was* built by the original company using
* standard release procedures but is a variation of the standard
* file of the same version number. If this value is given, the
* StringFileInfo block must contain a SpecialBuild string.
*/
#if defined(PNG_USER_PRIVATEBUILD)
# define PNG_LIBPNG_BUILD_TYPE \
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
#else
# if defined(PNG_LIBPNG_SPECIALBUILD)
# define PNG_LIBPNG_BUILD_TYPE \
(PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
# else
# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
# endif
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
#ifdef __cplusplus
extern "C" {
@ -470,7 +414,7 @@ PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
#ifdef PNG_USE_PNGGCCRD
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
#endif
/* This isn't currently used. If you need it, see png.c for more details.
@ -907,12 +851,10 @@ typedef png_info FAR * FAR * png_infopp;
/* Maximum positive integer used in PNG is (2^31)-1 */
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
#define PNG_UINT_32_MAX ((png_uint_32)(-1))
#define PNG_SIZE_MAX ((png_size_t)(-1))
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
#define PNG_UINT_32_MAX (~((png_uint_32)0))
#define PNG_SIZE_MAX (~((png_size_t)0))
/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
#define PNG_MAX_UINT PNG_UINT_31_MAX
#endif
/* These describe the color_type field in png_info. */
/* color type masks */
@ -1373,7 +1315,7 @@ struct png_struct_def
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef png_structp version_1_2_12;
typedef png_structp version_1_2_7;
typedef png_struct FAR * FAR * png_structpp;
@ -1459,14 +1401,11 @@ extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_infop,png_create_info_struct)
PNGARG((png_structp png_ptr));
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Initialize the info structure (old interface - DEPRECATED) */
extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
#undef png_info_init
#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
png_sizeof(png_info));
#endif
extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
png_size_t png_info_struct_size));
@ -1503,16 +1442,9 @@ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
#if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
#if !defined(PNG_1_0_X)
extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
png_ptr));
#endif
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Deprecated */
extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
#endif
#endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
@ -1633,7 +1565,6 @@ extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
#endif
#endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
@ -1641,7 +1572,6 @@ extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
int empty_plte_permitted));
#endif
#endif
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
/* Set how many lines between output flushes - 0 for no flushing */
@ -2356,12 +2286,11 @@ extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
png_infop info_ptr, int unit, double width, double height));
#else
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
#endif
#endif
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
@ -2457,9 +2386,7 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
#define png_debug2(l, m, p1, p2)
#endif
#if 0
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
#endif
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
@ -2604,44 +2531,6 @@ extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
/* Inline macros to do direct reads of bytes from the input buffer. These
* require that you are using an architecture that uses PNG byte ordering
* (MSB first) and supports unaligned data storage. I think that PowerPC
* in big-endian mode and 680x0 are the only ones that will support this.
* The x86 line of processors definitely do not. The png_get_int_32()
* routine also assumes we are using two's complement format for negative
* values, which is almost certainly true.
*/
#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
# define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
# define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
# define png_get_int_32(buf) ( *((png_int_32p) (buf)))
#else
extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));
extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf));
#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
extern PNG_EXPORT(png_uint_32,png_get_uint_31)
PNGARG((png_structp png_ptr, png_bytep buf));
/* No png_get_int_16 -- may be added if there's a real need for it. */
/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
*/
extern PNG_EXPORT(void,png_save_uint_32)
PNGARG((png_bytep buf, png_uint_32 i));
extern PNG_EXPORT(void,png_save_int_32)
PNGARG((png_bytep buf, png_int_32 i));
/* Place a 16-bit number into a buffer in PNG byte order.
* The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers.
*/
extern PNG_EXPORT(void,png_save_uint_16)
PNGARG((png_bytep buf, unsigned int i));
/* No png_save_int_16 -- may be added if there's a real need for it. */
/* ************************************************************************* */
/* These next functions are used internally in the code. They generally
* shouldn't be used unless you are writing code to add or replace some
* functionality in libpng. More information about most functions can
@ -2656,7 +2545,7 @@ extern PNG_EXPORT(void,png_save_uint_16)
#define PNG_HAVE_IHDR 0x01
#define PNG_HAVE_PLTE 0x02
#define PNG_HAVE_IDAT 0x04
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
#define PNG_AFTER_IDAT 0x08
#define PNG_HAVE_IEND 0x10
#define PNG_HAVE_gAMA 0x20
#define PNG_HAVE_cHRM 0x40
@ -2666,7 +2555,6 @@ extern PNG_EXPORT(void,png_save_uint_16)
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
/* flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
@ -2693,14 +2581,7 @@ extern PNG_EXPORT(void,png_save_uint_16)
#define PNG_RGB_TO_GRAY_ERR 0x200000L
#define PNG_RGB_TO_GRAY_WARN 0x400000L
#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
/* 0x800000L Unused */
#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
/* 0x4000000L unused */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
/* 0x40000000L unused */
/* flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
@ -2734,16 +2615,6 @@ extern PNG_EXPORT(void,png_save_uint_16)
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
/* 0x800000L unused */
/* 0x1000000L unused */
/* 0x2000000L unused */
/* 0x4000000L unused */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
/* 0x40000000L unused */
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN)
@ -2779,10 +2650,8 @@ extern PNG_EXPORT(void,png_save_uint_16)
#ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
#else
#if 0
#define png_sig png_sig_bytes(NULL)
#endif
#endif
#endif /* PNG_NO_EXTERN */
/* Constant strings for known chunk types. If you need to add a chunk,
@ -2835,7 +2704,31 @@ PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
#endif /* PNG_USE_GLOBAL_ARRAYS */
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Inline macros to do direct reads of bytes from the input buffer. These
* require that you are using an architecture that uses PNG byte ordering
* (MSB first) and supports unaligned data storage. I think that PowerPC
* in big-endian mode and 680x0 are the only ones that will support this.
* The x86 line of processors definitely do not. The png_get_int_32()
* routine also assumes we are using two's complement format for negative
* values, which is almost certainly true.
*/
#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
# define png_get_int_32(buf) ( *((png_int_32p) (buf)))
# endif
# define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
# define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
#else
# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
# endif
PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
png_bytep buf));
/* Initialize png_ptr struct for reading, and allocate any other memory.
* (old interface - DEPRECATED - use png_create_read_struct instead).
*/
@ -2843,17 +2736,12 @@ extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
#undef png_read_init
#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
#endif
extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size));
#endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Initialize png_ptr struct for writing, and allocate any other memory.
* (old interface - DEPRECATED - use png_create_write_struct instead).
*/
@ -2861,8 +2749,6 @@ extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
#undef png_write_init
#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
#endif
extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
@ -2962,6 +2848,23 @@ PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
#endif
/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
* The only currently known PNG chunks that use signed numbers are
* the ancillary extension chunks, oFFs and pCAL.
*/
PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
#endif
/* Place a 16-bit number into a buffer in PNG byte order.
* The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers.
*/
PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i));
/* simple function to write the signature */
PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
@ -3445,29 +3348,6 @@ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
/* png.c */ /* PRIVATE */
PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
#endif
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
png_infop info_ptr));
PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
png_infop info_ptr));
#if defined(PNG_pHYs_SUPPORTED)
PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
#endif /* PNG_pHYs_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
#endif /* PNG_INTERNAL */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.2.12 - June 27, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2005 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,66 +17,15 @@
#ifndef PNGCONF_H
#define PNGCONF_H
#define PNG_1_2_X
/* This include defines the subset of the libpng library that
* mozilla utilizes.
*/
#include "mozpngconf.h"
/*
* PNG_USER_CONFIG has to be defined on the compiler command line. This
* includes the resource compiler for Windows DLL configurations.
*/
#ifdef PNG_USER_CONFIG
# ifndef PNG_USER_PRIVATEBUILD
# define PNG_USER_PRIVATEBUILD
# endif
#include "pngusr.h"
#endif
/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
#ifdef PNG_CONFIGURE_LIBPNG
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#endif
/*
* Added at libpng-1.2.8
*
* If you create a private DLL you need to define in "pngusr.h" the followings:
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
* the DLL was built>
* e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
* #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
* distinguish your DLL from those of the official release. These
* correspond to the trailing letters that come after the version
* number and must match your private DLL name>
* e.g. // private DLL "libpng13gx.dll"
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
*
* The following macros are also at your disposal if you want to complete the
* DLL VERSIONINFO structure.
* - PNG_USER_VERSIONINFO_COMMENTS
* - PNG_USER_VERSIONINFO_COMPANYNAME
* - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
*/
#ifdef __STDC__
#ifdef SPECIALBUILD
# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
#endif
#ifdef PRIVATEBUILD
# pragma message("PRIVATEBUILD is deprecated.\
Use PNG_USER_PRIVATEBUILD instead.")
# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
#endif
#endif /* __STDC__ */
#ifndef PNG_VERSION_INFO_ONLY
/* End of material added to libpng-1.2.8 */
/* This is the size of the compression buffer, and thus the size of
* an IDAT chunk. Make this whatever size you feel is best for your
* machine. One of these will be allocated per png_struct. When this
@ -465,30 +414,18 @@
*/
/* The size of the png_text structure changed in libpng-1.0.6 when
* iTXt support was added. iTXt support was turned off by default through
* libpng-1.2.x, to support old apps that malloc the png_text structure
* instead of calling png_set_text() and letting libpng malloc it. It
* was turned on by default in libpng-1.3.0.
* iTXt is supported. It is turned off by default, to support old apps
* that malloc the png_text structure instead of calling png_set_text()
* and letting libpng malloc it. It will be turned on by default in
* libpng-1.3.0.
*/
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
# ifndef PNG_NO_iTXt_SUPPORTED
# define PNG_NO_iTXt_SUPPORTED
# endif
# ifndef PNG_NO_READ_iTXt
#ifndef PNG_iTXt_SUPPORTED
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
# define PNG_NO_READ_iTXt
# endif
# ifndef PNG_NO_WRITE_iTXt
# define PNG_NO_WRITE_iTXt
# endif
#endif
#if !defined(PNG_NO_iTXt_SUPPORTED)
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
# define PNG_READ_iTXt
# endif
# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
# define PNG_WRITE_iTXt
# define PNG_NO_WRITE_iTXt
# endif
#endif
@ -609,13 +546,11 @@
# endif
#endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Deprecated, will be removed from version 2.0.0.
Use PNG_MNG_FEATURES_SUPPORTED instead. */
#ifndef PNG_NO_READ_EMPTY_PLTE
# define PNG_READ_EMPTY_PLTE_SUPPORTED
#endif
#endif
#endif /* PNG_READ_SUPPORTED */
@ -659,15 +594,11 @@
# endif
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
!defined(PNG_WRITE_INTERLACING_SUPPORTED)
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
encoders, but can cause trouble
if left undefined */
#endif
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
!defined(PNG_WRITE_WEIGHTED_FILTER) && \
defined(PNG_FLOATING_POINT_SUPPORTED)
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif
@ -676,12 +607,10 @@
# define PNG_WRITE_FLUSH_SUPPORTED
#endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
#ifndef PNG_NO_WRITE_EMPTY_PLTE
# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
#endif
#endif
#endif /* PNG_WRITE_SUPPORTED */
@ -728,14 +657,9 @@
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNG_ASSEMBLER_CODE_SUPPORTED
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \
defined(__MMX__)
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_MMX_CODE_SUPPORTED
# endif
# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \
!defined(PNG_USE_PNGVCRD) && defined(__MMX__)
# define PNG_USE_PNGGCCRD
# endif
#endif
/* If you are sure that you don't need thread safety and you are compiling
@ -1202,9 +1126,6 @@ typedef double FAR * FAR * png_doublepp;
/* Pointers to pointers to pointers; i.e., pointer to array */
typedef char FAR * FAR * FAR * png_charppp;
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* SPC - Is this stuff deprecated? */
/* It'll be removed as of libpng-1.3.0 - GR-P */
/* libpng typedefs for types in zlib. If zlib changes
* or another compression library is used, then change these.
* Eliminates need to change all the source files.
@ -1212,7 +1133,6 @@ typedef char FAR * FAR * FAR * png_charppp;
typedef charf * png_zcharp;
typedef charf * FAR * png_zcharpp;
typedef z_stream FAR * png_zstreamp;
#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */
/*
* Define PNG_BUILD_DLL if the module being built is a Windows
@ -1342,8 +1262,15 @@ typedef z_stream FAR * png_zstreamp;
# endif
# endif /* PNG_IMPEXP */
#else /* !(DLL || non-cygwin WINDOWS) */
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
# ifndef PNGAPI
# if defined(__OS2__)
# if defined(__GNUC__) && defined(__declspec) && defined(PNG_DLL) && !defined(PNG_IMPEXP)
# ifdef PNG_BUILD_DLL
# define PNG_IMPEXP __declspec(dllexport)
# else
# define PNG_IMPEXP __declspec(dllimport)
# endif
# endif /* GNUC & declspec */
# if (defined(__IBMC__) || defined(__IBMCPP__)) && !defined(PNGAPI)
# define PNGAPI _System
# endif
# else
@ -1359,17 +1286,6 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_IMPEXP
#endif
#ifdef PNG_BUILDSYMS
# ifndef PNG_EXPORT
# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
# endif
# ifdef PNG_USE_GLOBAL_ARRAYS
# ifndef PNG_EXPORT_VAR
# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
# endif
# endif
#endif
#ifndef PNG_EXPORT
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
#endif
@ -1468,7 +1384,5 @@ typedef z_stream FAR * png_zstreamp;
#endif /* PNG_INTERNAL */
#endif /* PNG_READ_SUPPORTED */
/* Added at libpng-1.2.8 */
#endif /* PNG_VERSION_INFO_ONLY */
#endif /* PNGCONF_H */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,7 +16,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr,
png_const_charp error_message));
@ -34,37 +33,33 @@ png_error(png_structp png_ptr, png_const_charp error_message)
{
#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 (png_ptr->flags&
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
if (*error_message == '#')
{
if (*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]='\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;
}
}
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]='\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;
}
}
}
#endif
@ -85,23 +80,19 @@ void PNGAPI
png_warning(png_structp png_ptr, png_const_charp warning_message)
{
int offset = 0;
if (png_ptr != NULL)
{
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (png_ptr->flags&
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
#endif
{
if (*warning_message == '#')
{
if (*warning_message == '#')
{
for (offset=1; offset<15; offset++)
if (*(warning_message+offset) == ' ')
break;
}
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);
}
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);
}
@ -155,8 +146,6 @@ void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
{
char msg[18+64];
if (png_ptr == NULL)
png_error(png_ptr, error_message);
png_format_buffer(png_ptr, msg, error_message);
png_error(png_ptr, msg);
}
@ -165,8 +154,6 @@ void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
{
char msg[18+64];
if (png_ptr == NULL)
png_warning(png_ptr, warning_message);
png_format_buffer(png_ptr, msg, warning_message);
png_warning(png_ptr, msg);
}
@ -278,8 +265,6 @@ void PNGAPI
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
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;
png_ptr->warning_fn = warning_fn;
@ -293,8 +278,6 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr)
{
if (png_ptr == NULL)
return NULL;
return ((png_voidp)png_ptr->error_ptr);
}
@ -310,4 +293,3 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
}
}
#endif
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,4 +1,3 @@
/* pnggccrd.c - mixed C/assembler version of utilities to read a PNG file
*
* For Intel x86 CPU (Pentium-MMX or later) and GNU C compiler.
@ -7,9 +6,9 @@
* and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
* for Intel's performance analysis of the MMX vs. non-MMX code.
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation
*
* Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998.
@ -256,10 +255,9 @@ static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
#endif
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables,
/* djgpp, Win32, and Cygwin add their own underscores to global variables,
* so define them without: */
#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \
defined(__OS2__)
#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__)
# define _mmx_supported mmx_supported
# define _const4 const4
# define _const6 const6
@ -1739,7 +1737,6 @@ png_do_read_interlace(png_structp png_ptr)
int dummy_value_c; // fix 'forbidden register spilled'
int dummy_value_S;
int dummy_value_D;
int dummy_value_a;
__asm__ __volatile__ (
"subl $21, %%edi \n\t"
@ -1747,7 +1744,7 @@ png_do_read_interlace(png_structp png_ptr)
".loop3_pass0: \n\t"
"movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0
"pand (%3), %%mm0 \n\t" // z z z z z 2 1 0
"pand _const4, %%mm0 \n\t" // z z z z z 2 1 0
"movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0
"psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z
"movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z
@ -1772,14 +1769,12 @@ png_do_read_interlace(png_structp png_ptr)
: "=c" (dummy_value_c), // output regs (dummy)
"=S" (dummy_value_S),
"=D" (dummy_value_D),
"=a" (dummy_value_a)
"=D" (dummy_value_D)
: "1" (sptr), // esi // input regs
"2" (dp), // edi
"0" (width), // ecx
"3" (&_const4) // %1(?) (0x0000000000FFFFFFLL)
"rim" (_const4) // %1(?) (0x0000000000FFFFFFLL)
#if 0 /* %mm0, ..., %mm4 not supported by gcc 2.7.2.3 or egcs 1.1 */
: "%mm0", "%mm1", "%mm2" // clobber list
@ -1792,7 +1787,6 @@ png_do_read_interlace(png_structp png_ptr)
int dummy_value_c; // fix 'forbidden register spilled'
int dummy_value_S;
int dummy_value_D;
int dummy_value_a;
__asm__ __volatile__ (
"subl $9, %%edi \n\t"
@ -1800,7 +1794,7 @@ png_do_read_interlace(png_structp png_ptr)
".loop3_pass2: \n\t"
"movd (%%esi), %%mm0 \n\t" // x x x x x 2 1 0
"pand (%3), %%mm0 \n\t" // z z z z z 2 1 0
"pand _const4, %%mm0 \n\t" // z z z z z 2 1 0
"movq %%mm0, %%mm1 \n\t" // z z z z z 2 1 0
"psllq $16, %%mm0 \n\t" // z z z 2 1 0 z z
"movq %%mm0, %%mm2 \n\t" // z z z 2 1 0 z z
@ -1819,13 +1813,12 @@ png_do_read_interlace(png_structp png_ptr)
: "=c" (dummy_value_c), // output regs (dummy)
"=S" (dummy_value_S),
"=D" (dummy_value_D),
"=a" (dummy_value_a)
"=D" (dummy_value_D)
: "1" (sptr), // esi // input regs
"2" (dp), // edi
"0" (width), // ecx
"3" (&_const4) // (0x0000000000FFFFFFLL)
"rim" (_const4) // (0x0000000000FFFFFFLL)
#if 0 /* %mm0, ..., %mm2 not supported by gcc 2.7.2.3 or egcs 1.1 */
: "%mm0", "%mm1", "%mm2" // clobber list
@ -1846,8 +1839,6 @@ png_do_read_interlace(png_structp png_ptr)
int dummy_value_c; // fix 'forbidden register spilled'
int dummy_value_S;
int dummy_value_D;
int dummy_value_a;
int dummy_value_d;
__asm__ __volatile__ (
"subl $3, %%esi \n\t"
@ -1859,14 +1850,14 @@ png_do_read_interlace(png_structp png_ptr)
"movq %%mm0, %%mm1 \n\t" // x x 5 4 3 2 1 0
"movq %%mm0, %%mm2 \n\t" // x x 5 4 3 2 1 0
"psllq $24, %%mm0 \n\t" // 4 3 2 1 0 z z z
"pand (%3), %%mm1 \n\t" // z z z z z 2 1 0
"pand _const4, %%mm1 \n\t" // z z z z z 2 1 0
"psrlq $24, %%mm2 \n\t" // z z z x x 5 4 3
"por %%mm1, %%mm0 \n\t" // 4 3 2 1 0 2 1 0
"movq %%mm2, %%mm3 \n\t" // z z z x x 5 4 3
"psllq $8, %%mm2 \n\t" // z z x x 5 4 3 z
"movq %%mm0, (%%edi) \n\t"
"psrlq $16, %%mm3 \n\t" // z z z z z x x 5
"pand (%4), %%mm3 \n\t" // z z z z z z z 5
"pand _const6, %%mm3 \n\t" // z z z z z z z 5
"por %%mm3, %%mm2 \n\t" // z z x x 5 4 3 5
"subl $6, %%esi \n\t"
"movd %%mm2, 8(%%edi) \n\t"
@ -1877,15 +1868,13 @@ png_do_read_interlace(png_structp png_ptr)
: "=c" (dummy_value_c), // output regs (dummy)
"=S" (dummy_value_S),
"=D" (dummy_value_D),
"=a" (dummy_value_a),
"=d" (dummy_value_d)
"=D" (dummy_value_D)
: "1" (sptr), // esi // input regs
"2" (dp), // edi
"0" (width_mmx), // ecx
"3" (&_const4), // 0x0000000000FFFFFFLL
"4" (&_const6) // 0x00000000000000FFLL
"rim" (_const4), // 0x0000000000FFFFFFLL
"rim" (_const6) // 0x00000000000000FFLL
#if 0 /* %mm0, ..., %mm3 not supported by gcc 2.7.2.3 or egcs 1.1 */
: "%mm0", "%mm1" // clobber list
@ -5009,7 +4998,7 @@ png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row,
"jz up_end \n\t"
"cmpl $8, %%edx \n\t" // test for less than 8 bytes
"jb up_lt8 \n\t" // [added by lcreeve at netins.net]
"jb up_lt8 \n\t" // [added by lcreeve@netins.net]
"addl %%edx, %%ecx \n\t"
"andl $0x00000007, %%edx \n\t" // calc bytes over mult of 8
@ -5113,7 +5102,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
case 1: sprintf(filnm, "sub-%s",
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
#if !defined(PNG_1_0_X)
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" :
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" :
#endif
#endif
"x86");
@ -5350,7 +5339,6 @@ int PNGAPI
png_mmx_support(void)
{
#if defined(PNG_MMX_CODE_SUPPORTED)
int result;
__asm__ __volatile__ (
"pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction
"pushl %%ecx \n\t" // so does ecx...
@ -5392,6 +5380,7 @@ png_mmx_support(void)
"0: \n\t" // .NOT_SUPPORTED: target label for jump instructions
"movl $0, %%eax \n\t" // set return value to 0
"1: \n\t" // .RETURN: target label for jump instructions
"movl %%eax, _mmx_supported \n\t" // save in global static variable, too
"popl %%edx \n\t" // restore edx
"popl %%ecx \n\t" // restore ecx
"popl %%ebx \n\t" // restore ebx
@ -5399,17 +5388,16 @@ png_mmx_support(void)
// "ret \n\t" // DONE: no MMX support
// (fall through to standard C "ret")
: "=a" (result) // output list
: // output list (none)
: // any variables used on input (none)
// no clobber list
: "%eax" // clobber list
// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
// , "memory" // if write to a variable gcc thought was in a reg
// , "cc" // "condition codes" (flag bits)
);
_mmx_supported = result;
#else
#else
_mmx_supported = 0;
#endif /* PNG_MMX_CODE_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,8 +11,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
{
@ -559,9 +557,9 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
*interlace_type = info_ptr->interlace_type;
/* check for potential overflow of rowbytes */
if (*width == 0 || *width > PNG_UINT_31_MAX)
if (width == 0 || *width > PNG_UINT_31_MAX)
png_error(png_ptr, "Invalid image width");
if (*height == 0 || *height > PNG_UINT_31_MAX)
if (height == 0 || *height > PNG_UINT_31_MAX)
png_error(png_ptr, "Invalid image height");
if (info_ptr->width > (PNG_UINT_32_MAX
>> 3) /* 8-byte RGBA pixels */
@ -918,7 +916,6 @@ png_get_mmx_rowbytes_threshold (png_structp png_ptr)
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
}
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
#endif /* ?PNG_1_0_X */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* these functions were added to libpng 1.2.6 */
@ -934,4 +931,4 @@ png_get_user_height_max (png_structp png_ptr)
}
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
#endif /* ?PNG_1_0_X */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,8 +17,6 @@
#define PNG_INTERNAL
#include "png.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 */
@ -595,4 +593,3 @@ png_get_mem_ptr(png_structp png_ptr)
return ((png_voidp)png_ptr->mem_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.2.11 - June 7, 2004
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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.)
*/
@ -214,10 +214,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if(png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
@ -285,9 +281,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
if (png_ptr->mode & PNG_HAVE_IDAT)
{
if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
if (png_ptr->push_length == 0)
return;
if (png_ptr->push_length == 0)
return;
if (png_ptr->mode & PNG_AFTER_IDAT)
png_error(png_ptr, "Too many IDAT's found");
@ -619,7 +614,7 @@ png_push_save_buffer(png_structp png_ptr)
png_size_t new_max;
png_bytep old_buffer;
if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
(png_ptr->current_buffer_size + 256))
{
png_error(png_ptr, "Potential overflow of save_buffer");
@ -820,7 +815,7 @@ png_push_process_row(png_structp png_ptr)
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1);
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
if (png_ptr->transformations)
png_do_read_transformations(png_ptr);
#if defined(PNG_READ_INTERLACING_SUPPORTED)

Просмотреть файл

@ -1,9 +1,9 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.2.11 June 7, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -14,8 +14,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED)
/* Create a PNG structure for reading, and allocate any memory needed. */
png_structp PNGAPI
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
@ -77,7 +75,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr,
png_destroy_struct_2((png_voidp)png_ptr,
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
@ -171,10 +169,9 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
return (png_ptr);
}
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* Initialize PNG structure for reading, and allocate any memory needed.
This interface is deprecated in favour of the png_create_read_struct(),
and it will disappear as of libpng-1.3.0. */
and it will eventually disappear. */
#undef png_read_init
void PNGAPI
png_read_init(png_structp png_ptr)
@ -189,7 +186,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
{
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
if(png_sizeof(png_struct) > png_struct_size ||
if(png_sizeof(png_struct) > png_struct_size ||
png_sizeof(png_info) > png_info_size)
{
char msg[80];
@ -225,7 +222,6 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
}
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
}
#endif /* PNG_1_0_X || PNG_1_2_X */
void PNGAPI
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
@ -397,7 +393,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_zTXt_SUPPORTED)
PNG_zTXt;
#endif
#endif /* PNG_USE_LOCAL_ARRAYS */
#endif /* PNG_GLOBAL_ARRAYS */
png_byte chunk_length[4];
png_uint_32 length;
@ -413,10 +409,6 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
/* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search.
*/
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
if(png_ptr->mode & PNG_AFTER_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
@ -742,7 +734,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1);
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
@ -752,8 +744,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
}
#endif
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
if (png_ptr->transformations)
png_do_read_transformations(png_ptr);
#if defined(PNG_READ_INTERLACING_SUPPORTED)
@ -812,7 +803,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it.
*
* [*] png_handle_alpha() does not exist yet, as of this version of libpng
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7
*/
void PNGAPI
@ -862,7 +853,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead.
*
* [*] png_handle_alpha() does not exist yet, as of this version of libpng
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7
*/
void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image)
@ -970,7 +961,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_READ_zTXt_SUPPORTED)
PNG_zTXt;
#endif
#endif /* PNG_USE_LOCAL_ARRAYS */
#endif /* PNG_GLOBAL_ARRAYS */
png_read_data(png_ptr, chunk_length, 4);
length = png_get_uint_31(png_ptr,chunk_length);
@ -989,9 +980,11 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
{
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
{
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
png_error(png_ptr, "Too many IDAT's found");
}
else
png_ptr->mode |= PNG_AFTER_IDAT;
png_handle_unknown(png_ptr, info_ptr, length);
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
png_ptr->mode |= PNG_HAVE_PLTE;
@ -1002,7 +995,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
*/
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
png_error(png_ptr, "Too many IDAT's found");
png_crc_finish(png_ptr, length);
}
@ -1456,6 +1449,5 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* quiet compiler warnings */ return;
}
#endif /* PNG_INFO_IMAGE_SUPPORTED */
#endif
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
#endif /* PNG_READ_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,8 +18,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(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
@ -69,7 +67,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 /* PRIVATE */
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
int check;
@ -161,4 +159,3 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
png_ptr->output_flush_fn = NULL;
#endif
}
#endif /* PNG_READ_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.2.11 June 15, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,8 +16,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED)
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
@ -121,7 +119,7 @@ void PNGAPI
png_set_strip_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_strip_alpha\n");
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
png_ptr->transformations |= PNG_STRIP_ALPHA;
}
#endif
@ -551,7 +549,7 @@ void PNGAPI
png_set_expand(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->transformations |= PNG_EXPAND;
}
/* GRR 19990627: the following three functions currently are identical
@ -566,47 +564,30 @@ png_set_expand(png_structp png_ptr)
*
* More to the point, these functions make it obvious what libpng will be
* doing, whereas "expand" can (and does) mean any number of things.
*
* GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified
* to expand only the sample depth but not to expand the tRNS to alpha.
*/
/* Expand paletted images to RGB. */
void PNGAPI
png_set_palette_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_palette_to_rgb\n");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
#if !defined(PNG_1_0_X)
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
void PNGAPI
png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
{
png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
png_ptr->transformations |= PNG_EXPAND_tRNS;
}
#endif
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* Expand grayscale images of less than 8-bit depth to 8 bits. */
/* Deprecated as of libpng-1.2.9 */
void PNGAPI
png_set_gray_1_2_4_to_8(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_1_2_4_to_8\n");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= PNG_EXPAND;
}
#endif
/* Expand tRNS chunks to alpha channels. */
void PNGAPI
png_set_tRNS_to_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->transformations |= PNG_EXPAND;
}
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
@ -724,41 +705,23 @@ png_init_read_transformations(png_structp png_ptr)
{
if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */
{
/* expand background and tRNS chunks */
/* expand background chunk. */
switch (png_ptr->bit_depth)
{
case 1:
png_ptr->background.gray *= (png_uint_16)0xff;
png_ptr->background.red = png_ptr->background.green
= png_ptr->background.blue = png_ptr->background.gray;
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
{
png_ptr->trans_values.gray *= (png_uint_16)0xff;
png_ptr->trans_values.red = png_ptr->trans_values.green
= png_ptr->trans_values.blue = png_ptr->trans_values.gray;
}
break;
case 2:
png_ptr->background.gray *= (png_uint_16)0x55;
png_ptr->background.red = png_ptr->background.green
= png_ptr->background.blue = png_ptr->background.gray;
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
{
png_ptr->trans_values.gray *= (png_uint_16)0x55;
png_ptr->trans_values.red = png_ptr->trans_values.green
= png_ptr->trans_values.blue = png_ptr->trans_values.gray;
}
break;
case 4:
png_ptr->background.gray *= (png_uint_16)0x11;
png_ptr->background.red = png_ptr->background.green
= png_ptr->background.blue = png_ptr->background.gray;
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
{
png_ptr->trans_values.gray *= (png_uint_16)0x11;
png_ptr->trans_values.red = png_ptr->trans_values.green
= png_ptr->trans_values.blue = png_ptr->trans_values.gray;
}
break;
case 8:
case 16:
@ -780,7 +743,7 @@ png_init_read_transformations(png_structp png_ptr)
if (png_ptr->transformations & PNG_INVERT_ALPHA)
{
#if defined(PNG_READ_EXPAND_SUPPORTED)
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
if (!(png_ptr->transformations & PNG_EXPAND))
#endif
{
/* invert the alpha channel (in tRNS) unless the pixels are
@ -817,8 +780,7 @@ png_init_read_transformations(png_structp png_ptr)
png_ptr->transformations &= (~PNG_GAMMA);
}
if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
png_ptr->gamma != 0.0)
if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY))
{
png_build_gamma_table(png_ptr);
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
@ -826,7 +788,7 @@ png_init_read_transformations(png_structp png_ptr)
{
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
/* could skip if no transparency and
/* could skip if no transparency and
*/
png_color back, back_1;
png_colorp palette = png_ptr->palette;
@ -1080,7 +1042,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
{
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS))
if (png_ptr->num_trans)
info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
else
info_ptr->color_type = PNG_COLOR_TYPE_RGB;
@ -1090,12 +1052,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
else
{
if (png_ptr->num_trans)
{
if (png_ptr->transformations & PNG_EXPAND_tRNS)
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
else
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
}
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
if (info_ptr->bit_depth < 8)
info_ptr->bit_depth = 8;
info_ptr->num_trans = 0;
@ -1129,16 +1086,6 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->bit_depth = 8;
#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR;
#endif
#if defined(PNG_READ_DITHER_SUPPORTED)
if (png_ptr->transformations & PNG_DITHER)
{
@ -1156,6 +1103,16 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->bit_depth = 8;
#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR;
#endif
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
info_ptr->channels = 1;
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
@ -1164,7 +1121,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->channels = 1;
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
if (png_ptr->transformations & PNG_STRIP_ALPHA)
info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
#endif
@ -1241,7 +1198,7 @@ png_do_read_transformations(png_structp png_ptr)
}
else
{
if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS))
if (png_ptr->num_trans)
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->trans_values));
else
@ -1252,9 +1209,9 @@ png_do_read_transformations(png_structp png_ptr)
#endif
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
if (png_ptr->transformations & PNG_STRIP_ALPHA)
png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA));
PNG_FLAG_FILLER_AFTER);
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
@ -2147,7 +2104,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
/* reduce RGB files to grayscale, with or without alpha
* using the equation given in Poynton's ColorFAQ at
* <http://www.inforamp.net/~poynton/>
* Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net
* Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
*
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
*
@ -3644,8 +3601,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
}
/* If the bit depth < 8, it is expanded to 8. Also, if the already
* expanded transparency value is supplied, an alpha channel is built.
/* If the bit depth < 8, it is expanded to 8. Also, if the
* transparency value is supplied, an alpha channel is built.
*/
void /* PRIVATE */
png_do_expand(png_row_infop row_info, png_bytep row,
@ -3938,7 +3895,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
#ifdef PNG_FLOATING_POINT_SUPPORTED
#if defined(PNG_READ_GAMMA_SUPPORTED)
static int png_gamma_shift[] =
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit
* tables, we don't make a full table if we are reducing to 8-bit in
@ -3949,208 +3906,210 @@ void /* PRIVATE */
png_build_gamma_table(png_structp png_ptr)
{
png_debug(1, "in png_build_gamma_table\n");
if (png_ptr->bit_depth <= 8)
if(png_ptr->gamma != 0.0)
{
int i;
double g;
if (png_ptr->bit_depth <= 8)
{
int i;
double g;
if (png_ptr->screen_gamma > .000001)
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
else
g = 1.0;
if (png_ptr->screen_gamma > .000001)
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
else
g = 1.0;
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
for (i = 0; i < 256; i++)
{
png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
}
for (i = 0; i < 256; i++)
{
png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
{
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
{
g = 1.0 / (png_ptr->gamma);
g = 1.0 / (png_ptr->gamma);
png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
for (i = 0; i < 256; i++)
{
png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
}
for (i = 0; i < 256; i++)
{
png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
}
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
if(png_ptr->screen_gamma > 0.000001)
g = 1.0 / png_ptr->screen_gamma;
else
g = png_ptr->gamma; /* probably doing rgb_to_gray */
if(png_ptr->screen_gamma > 0.000001)
g = 1.0 / png_ptr->screen_gamma;
else
g = png_ptr->gamma; /* probably doing rgb_to_gray */
for (i = 0; i < 256; i++)
{
png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
for (i = 0; i < 256; i++)
{
png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0,
g) * 255.0 + .5);
}
}
}
}
#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
}
else
{
double g;
int i, j, shift, num;
int sig_bit;
png_uint_32 ig;
}
else
{
double g;
int i, j, shift, num;
int sig_bit;
png_uint_32 ig;
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
{
sig_bit = (int)png_ptr->sig_bit.red;
if ((int)png_ptr->sig_bit.green > sig_bit)
sig_bit = png_ptr->sig_bit.green;
if ((int)png_ptr->sig_bit.blue > sig_bit)
sig_bit = png_ptr->sig_bit.blue;
}
else
{
sig_bit = (int)png_ptr->sig_bit.gray;
}
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
{
sig_bit = (int)png_ptr->sig_bit.red;
if ((int)png_ptr->sig_bit.green > sig_bit)
sig_bit = png_ptr->sig_bit.green;
if ((int)png_ptr->sig_bit.blue > sig_bit)
sig_bit = png_ptr->sig_bit.blue;
}
else
{
sig_bit = (int)png_ptr->sig_bit.gray;
}
if (sig_bit > 0)
shift = 16 - sig_bit;
else
shift = 0;
if (sig_bit > 0)
shift = 16 - sig_bit;
else
shift = 0;
if (png_ptr->transformations & PNG_16_TO_8)
{
if (shift < (16 - PNG_MAX_GAMMA_8))
shift = (16 - PNG_MAX_GAMMA_8);
}
if (png_ptr->transformations & PNG_16_TO_8)
{
if (shift < (16 - PNG_MAX_GAMMA_8))
shift = (16 - PNG_MAX_GAMMA_8);
}
if (shift > 8)
shift = 8;
if (shift < 0)
shift = 0;
if (shift > 8)
shift = 8;
if (shift < 0)
shift = 0;
png_ptr->gamma_shift = (png_byte)shift;
png_ptr->gamma_shift = (png_byte)shift;
num = (1 << (8 - shift));
num = (1 << (8 - shift));
if (png_ptr->screen_gamma > .000001)
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
else
g = 1.0;
if (png_ptr->screen_gamma > .000001)
g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
else
g = 1.0;
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p)));
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p)));
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
{
double fin, fout;
png_uint_32 last, max;
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
{
double fin, fout;
png_uint_32 last, max;
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
}
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
}
g = 1.0 / g;
last = 0;
for (i = 0; i < 256; i++)
{
fout = ((double)i + 0.5) / 256.0;
fin = pow(fout, g);
max = (png_uint_32)(fin * (double)((png_uint_32)num << 8));
while (last <= max)
{
png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
[(int)(last >> (8 - shift))] = (png_uint_16)(
(png_uint_16)i | ((png_uint_16)i << 8));
last++;
}
}
while (last < ((png_uint_32)num << 8))
{
png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
[(int)(last >> (8 - shift))] = (png_uint_16)65535L;
last++;
}
}
else
{
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
g = 1.0 / g;
last = 0;
for (i = 0; i < 256; i++)
{
fout = ((double)i + 0.5) / 256.0;
fin = pow(fout, g);
max = (png_uint_32)(fin * (double)((png_uint_32)num << 8));
while (last <= max)
{
png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
[(int)(last >> (8 - shift))] = (png_uint_16)(
(png_uint_16)i | ((png_uint_16)i << 8));
last++;
}
}
while (last < ((png_uint_32)num << 8))
{
png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
[(int)(last >> (8 - shift))] = (png_uint_16)65535L;
last++;
}
}
else
{
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_table[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
}
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_table[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
{
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
{
g = 1.0 / (png_ptr->gamma);
g = 1.0 / (png_ptr->gamma);
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p )));
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p )));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_to_1[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_to_1[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
if(png_ptr->screen_gamma > 0.000001)
g = 1.0 / png_ptr->screen_gamma;
else
g = png_ptr->gamma; /* probably doing rgb_to_gray */
if(png_ptr->screen_gamma > 0.000001)
g = 1.0 / png_ptr->screen_gamma;
else
g = png_ptr->gamma; /* probably doing rgb_to_gray */
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p)));
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof (png_uint_16p)));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
for (i = 0; i < num; i++)
{
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(256 * png_sizeof (png_uint_16)));
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_from_1[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
}
ig = (((png_uint_32)i *
(png_uint_32)png_gamma_shift[shift]) >> 4);
for (j = 0; j < 256; j++)
{
png_ptr->gamma_16_from_1[i][j] =
(png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
65535.0, g) * 65535.0 + .5);
}
}
}
#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
}
}
}
}
#endif
/* To do: install integer version of png_build_gamma_table here */
@ -4216,4 +4175,3 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
}
}
#endif /* PNG_MNG_FEATURES_SUPPORTED */
#endif /* PNG_READ_SUPPORTED */

Просмотреть файл

@ -1,9 +1,8 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.2.11 June 4, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -14,8 +13,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED)
#if defined(_WIN32_WCE)
/* strtod() function is not supported on WindowsCE */
# ifdef PNG_FLOATING_POINT_SUPPORTED
@ -40,17 +37,17 @@ __inline double strtod(const char *nptr, char **endptr)
# endif
#endif
png_uint_32 PNGAPI
png_uint_32 /* PRIVATE */
png_get_uint_31(png_structp png_ptr, png_bytep buf)
{
png_uint_32 i = png_get_uint_32(buf);
if (i > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range.");
png_error(png_ptr, "PNG unsigned integer out of range.\n");
return (i);
}
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 PNGAPI
png_uint_32 /* PRIVATE */
png_get_uint_32(png_bytep buf)
{
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
@ -61,10 +58,11 @@ png_get_uint_32(png_bytep buf)
return (i);
}
#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED)
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same. */
png_int_32 PNGAPI
png_int_32 /* PRIVATE */
png_get_int_32(png_bytep buf)
{
png_int_32 i = ((png_int_32)(*buf) << 24) +
@ -74,9 +72,10 @@ png_get_int_32(png_bytep buf)
return (i);
}
#endif /* PNG_READ_pCAL_SUPPORTED */
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 PNGAPI
png_uint_16 /* PRIVATE */
png_get_uint_16(png_bytep buf)
{
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
@ -276,7 +275,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
if (ret != Z_STREAM_END)
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[52];
char umsg[50];
if (ret == Z_BUF_ERROR)
sprintf(umsg,"Buffer error in compressed datastream in %s chunk",
@ -620,7 +619,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
if (info_ptr->valid & PNG_INFO_sRGB)
if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
{
png_warning(png_ptr,
@ -778,7 +777,8 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_read(png_ptr, buf, 4);
uint_y = png_get_uint_32(buf);
if (uint_x + uint_y > 100000L)
if (uint_x > 80000L || uint_y > 80000L ||
uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM red point");
png_crc_finish(png_ptr, 16);
@ -793,7 +793,8 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_read(png_ptr, buf, 4);
uint_y = png_get_uint_32(buf);
if (uint_x + uint_y > 100000L)
if (uint_x > 80000L || uint_y > 80000L ||
uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM green point");
png_crc_finish(png_ptr, 8);
@ -808,7 +809,8 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_read(png_ptr, buf, 4);
uint_y = png_get_uint_32(buf);
if (uint_x + uint_y > 100000L)
if (uint_x > 80000L || uint_y > 80000L ||
uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM blue point");
png_crc_finish(png_ptr, 0);
@ -829,7 +831,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB))
if (info_ptr->valid & PNG_INFO_sRGB)
{
if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) ||
PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) ||
@ -840,6 +842,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) ||
PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000))
{
png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
@ -923,7 +926,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA))
if ((info_ptr->valid & PNG_INFO_gAMA))
{
png_fixed_point igamma;
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -952,7 +955,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#ifdef PNG_READ_cHRM_SUPPORTED
#ifdef PNG_FIXED_POINT_SUPPORTED
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
if (info_ptr->valid & PNG_INFO_cHRM)
if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) ||
PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) ||
PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) ||
@ -1076,7 +1079,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if(profile_size > profile_length)
{
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Ignoring truncated iCCP profile.");
png_warning(png_ptr, "Ignoring truncated iCCP profile.\n");
return;
}
@ -1157,7 +1160,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
new_palette.nentries = (png_int_32) ( data_length / entry_size);
new_palette.nentries = (png_uint_32) (data_length / entry_size);
if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX /
png_sizeof(png_sPLT_entry)))
{
@ -2167,8 +2170,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
(png_ptr->read_user_chunk_fn != NULL))
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
{
png_unknown_chunk chunk;
@ -3104,7 +3106,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
png_error(png_ptr, "This image requires a row greater than 64KB");
#endif
if ((png_uint_32)png_ptr->rowbytes > PNG_SIZE_MAX - 1)
if ((png_uint_32)png_ptr->rowbytes + 1 > PNG_SIZE_MAX)
png_error(png_ptr, "Row has too many bytes to allocate in memory.");
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
@ -3120,4 +3122,3 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}
#endif /* PNG_READ_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,8 +16,6 @@
#define PNG_INTERNAL
#include "png.h"
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
#if defined(PNG_bKGD_SUPPORTED)
void PNGAPI
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
@ -102,7 +100,6 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
if (white_x > (double) PNG_UINT_31_MAX ||
white_y > (double) PNG_UINT_31_MAX ||
red_x > (double) PNG_UINT_31_MAX ||
@ -111,16 +108,6 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
green_y > (double) PNG_UINT_31_MAX ||
blue_x > (double) PNG_UINT_31_MAX ||
blue_y > (double) PNG_UINT_31_MAX)
#else
if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L)
#endif
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
@ -222,21 +209,19 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
png_debug1(1, "in %s storage function\n", "hIST");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette <= 0 || info_ptr->num_palette
> PNG_MAX_PALETTE_LENGTH)
if (info_ptr->num_palette == 0)
{
png_warning(png_ptr,
"Invalid palette size, hIST allocation skipped.");
"Palette size 0, hIST allocation skipped.");
return;
}
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
#endif
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version
1.2.1 */
/* Changed from info->num_palette to 256 in version 1.2.1 */
png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
(png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16)));
(png_uint_32)(256 * png_sizeof (png_uint_16)));
if (png_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
@ -318,13 +303,13 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
* 5. The color_type is RGB or RGBA
*/
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream");
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
if(filter_type != PNG_FILTER_TYPE_BASE)
{
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB ||
(color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
png_error(png_ptr, "Unknown filter method in IHDR");
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
@ -532,17 +517,6 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
{
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_error(png_ptr, "Invalid palette length");
else
{
png_warning(png_ptr, "Invalid palette length");
return;
}
}
/*
* It may not actually be necessary to set png_ptr->palette here;
* we do it for backward compatibility with the way the png_handle_tRNS
@ -552,13 +526,11 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
#endif
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
of num_palette entries,
/* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries,
in case of an invalid PNG file that has too-large sample values. */
png_ptr->palette = (png_colorp)png_malloc(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH *
png_sizeof(png_color));
256 * png_sizeof(png_color));
png_memset(png_ptr->palette, 0, 256 * png_sizeof(png_color));
png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color));
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@ -918,11 +890,10 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
#endif
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
/* Changed from num_trans to 256 in version 1.2.1 */
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
(png_uint_32)PNG_MAX_PALETTE_LENGTH);
if (num_trans <= PNG_MAX_PALETTE_LENGTH)
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
(png_uint_32)256);
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TRNS;
#else
@ -950,9 +921,6 @@ png_set_sPLT(png_structp png_ptr,
png_sPLT_tp np;
int i;
if (png_ptr == NULL || info_ptr == NULL)
return;
np = (png_sPLT_tp)png_malloc_warn(png_ptr,
(info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
if (np == NULL)
@ -1055,14 +1023,13 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
}
#endif
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
void PNGAPI
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{
/* This function is deprecated in favor of png_permit_mng_features()
and will be removed from libpng-1.3.0 */
and will be removed from libpng-2.0.0 */
png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
if (png_ptr == NULL)
return;
@ -1071,7 +1038,6 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
}
#endif
#endif
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_uint_32 PNGAPI
@ -1093,8 +1059,6 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
{
png_bytep new_list, p;
int i, old_num_chunks;
if (png_ptr == NULL)
return;
if (num_chunks == 0)
{
if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
@ -1138,8 +1102,6 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
png_user_chunk_ptr read_user_chunk_fn)
{
png_debug(1, "in png_set_read_user_chunk_fn\n");
if (png_ptr == NULL)
return;
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
png_ptr->user_chunk_ptr = user_chunk_ptr;
}
@ -1166,8 +1128,6 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
void PNGAPI
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
{
if (png_ptr == NULL)
return;
if(png_ptr->zbuf)
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf_size = (png_size_t)size;
@ -1194,9 +1154,6 @@ png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
png_uint_32 settable_asm_flags;
png_uint_32 settable_mmx_flags;
if (png_ptr == NULL)
return;
settable_mmx_flags =
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
@ -1239,8 +1196,6 @@ png_set_mmx_thresholds (png_structp png_ptr,
png_byte mmx_bitdepth_threshold,
png_uint_32 mmx_rowbytes_threshold)
{
if (png_ptr == NULL)
return;
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
}
@ -1262,4 +1217,3 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
#endif /* ?PNG_1_0_X */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,9 +1,9 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/
@ -11,7 +11,6 @@
#define PNG_INTERNAL
#include "png.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
@ -242,7 +241,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
static PNG_CONST png_byte onebppswaptable[256] = {
static png_byte onebppswaptable[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@ -277,7 +276,7 @@ static PNG_CONST png_byte onebppswaptable[256] = {
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
};
static PNG_CONST png_byte twobppswaptable[256] = {
static png_byte twobppswaptable[256] = {
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@ -312,7 +311,7 @@ static PNG_CONST png_byte twobppswaptable[256] = {
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
};
static PNG_CONST png_byte fourbppswaptable[256] = {
static png_byte fourbppswaptable[256] = {
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
@ -363,11 +362,11 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
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;
@ -393,9 +392,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
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))) &&
if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
row_info->channels == 4)
{
if (row_info->bit_depth == 8)
@ -474,9 +471,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
row_info->channels = 3;
}
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
(flags & PNG_FLAG_STRIP_ALPHA))) &&
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY &&
row_info->channels == 2)
{
if (row_info->bit_depth == 8)
@ -530,8 +525,6 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
}
row_info->channels = 1;
}
if (flags & PNG_FLAG_STRIP_ALPHA)
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
}
}
#endif
@ -649,4 +642,3 @@ png_get_user_transform_ptr(png_structp png_ptr)
return (NULL);
#endif
}
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

Просмотреть файл

@ -1,9 +1,8 @@
/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file
*
* For Intel x86 CPU and Microsoft Visual C++ compiler
*
* Last changed in libpng 1.2.6 - August 15, 2004
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation
@ -3633,7 +3632,7 @@ duploop:
jz dupend
// 2 lines added by lcreeve at netins.net
// 2 lines added by lcreeve@netins.net
// (mail 11 Jul 98 in png-implement list)
cmp edx, 8 //test for less than 8 bytes
jb duplt8

Просмотреть файл

@ -1,9 +1,9 @@
/* pngwio.c - functions for data output
*
* Last changed in libpng 1.2.3 - May 21, 2002
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2002 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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.)
*

Просмотреть файл

@ -1,9 +1,9 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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.)
*/
@ -26,15 +26,13 @@ void PNGAPI
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_info_before_PLTE\n");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
{
png_write_sig(png_ptr); /* write PNG signature */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted))
{
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream");
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
png_ptr->mng_features_permitted=0;
}
#endif
@ -130,16 +128,13 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
png_debug(1, "in png_write_info\n");
if (png_ptr == NULL || info_ptr == NULL)
return;
png_write_info_before_PLTE(png_ptr, info_ptr);
if (info_ptr->valid & PNG_INFO_PLTE)
png_write_PLTE(png_ptr, info_ptr->palette,
(png_uint_32)info_ptr->num_palette);
else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_error(png_ptr, "Valid palette required for paletted images");
png_error(png_ptr, "Valid palette required for paletted images\n");
#if defined(PNG_WRITE_tRNS_SUPPORTED)
if (info_ptr->valid & PNG_INFO_tRNS)
@ -188,7 +183,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->scal_s_width, info_ptr->scal_s_height);
#else
png_warning(png_ptr,
"png_write_sCAL not supported; sCAL chunk not written.");
"png_write_sCAL not supported; sCAL chunk not written.\n");
#endif
#endif
#endif
@ -227,7 +222,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
#else
png_warning(png_ptr, "Unable to write international text");
png_warning(png_ptr, "Unable to write international text\n");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
@ -241,7 +236,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].text, 0,
info_ptr->text[i].compression);
#else
png_warning(png_ptr, "Unable to write compressed text");
png_warning(png_ptr, "Unable to write compressed text\n");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
@ -254,7 +249,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].text,
0);
#else
png_warning(png_ptr, "Unable to write uncompressed text");
png_warning(png_ptr, "Unable to write uncompressed text\n");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
@ -295,8 +290,6 @@ void PNGAPI
png_write_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_end\n");
if (png_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_HAVE_IDAT))
png_error(png_ptr, "No IDATs written into file");
@ -330,7 +323,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
#else
png_warning(png_ptr, "Unable to write international text");
png_warning(png_ptr, "Unable to write international text\n");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
@ -343,7 +336,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
info_ptr->text[i].text, 0,
info_ptr->text[i].compression);
#else
png_warning(png_ptr, "Unable to write compressed text");
png_warning(png_ptr, "Unable to write compressed text\n");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
@ -355,7 +348,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
png_write_tEXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text, 0);
#else
png_warning(png_ptr, "Unable to write uncompressed text");
png_warning(png_ptr, "Unable to write uncompressed text\n");
#endif
/* Mark this chunk as written */
@ -561,8 +554,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
}
/* Initialize png_ptr structure, and allocate any memory needed */
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* Deprecated. */
#undef png_write_init
void PNGAPI
png_write_init(png_structp png_ptr)
@ -613,7 +604,6 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
}
png_write_init_3(&png_ptr, user_png_ver, png_struct_size);
}
#endif /* PNG_1_0_X || PNG_1_2_X */
void PNGAPI
@ -624,12 +614,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
#ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */
#endif
int i = 0;
if (png_ptr == NULL)
return;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
@ -706,10 +691,6 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
png_bytepp rp; /* row pointer */
png_debug(1, "in png_write_rows\n");
if (png_ptr == NULL)
return;
/* loop through the rows */
for (i = 0, rp = row; i < num_rows; i++, rp++)
{
@ -727,9 +708,6 @@ png_write_image(png_structp png_ptr, png_bytepp image)
int pass, num_pass; /* pass variables */
png_bytepp rp; /* points to current row */
if (png_ptr == NULL)
return;
png_debug(1, "in png_write_image\n");
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* intialize interlace handling. If image is not interlaced,
@ -753,11 +731,8 @@ png_write_image(png_structp png_ptr, png_bytepp image)
void PNGAPI
png_write_row(png_structp png_ptr, png_bytep row)
{
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
png_ptr->row_number, png_ptr->pass);
/* initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
@ -931,8 +906,6 @@ void PNGAPI
png_set_flush(png_structp png_ptr, int nrows)
{
png_debug(1, "in png_set_flush\n");
if (png_ptr == NULL)
return;
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
}
@ -943,8 +916,6 @@ png_write_flush(png_structp png_ptr)
int wrote_IDAT;
png_debug(1, "in png_write_flush\n");
if (png_ptr == NULL)
return;
/* We have already written out all of the data */
if (png_ptr->row_number >= png_ptr->num_rows)
return;
@ -1121,8 +1092,6 @@ void PNGAPI
png_set_filter(png_structp png_ptr, int method, int filters)
{
png_debug(1, "in png_set_filter\n");
if (png_ptr == NULL)
return;
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(method == PNG_INTRAPIXEL_DIFFERENCING))
@ -1231,8 +1200,6 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
int i;
png_debug(1, "in png_set_filter_heuristics\n");
if (png_ptr == NULL)
return;
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
{
png_warning(png_ptr, "Unknown filter heuristic method");
@ -1345,8 +1312,6 @@ void PNGAPI
png_set_compression_level(png_structp png_ptr, int level)
{
png_debug(1, "in png_set_compression_level\n");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
png_ptr->zlib_level = level;
}
@ -1355,8 +1320,6 @@ void PNGAPI
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
{
png_debug(1, "in png_set_compression_mem_level\n");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
png_ptr->zlib_mem_level = mem_level;
}
@ -1365,8 +1328,6 @@ void PNGAPI
png_set_compression_strategy(png_structp png_ptr, int strategy)
{
png_debug(1, "in png_set_compression_strategy\n");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
png_ptr->zlib_strategy = strategy;
}
@ -1374,8 +1335,6 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
void PNGAPI
png_set_compression_window_bits(png_structp png_ptr, int window_bits)
{
if (png_ptr == NULL)
return;
if (window_bits > 15)
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
else if (window_bits < 8)
@ -1396,8 +1355,6 @@ void PNGAPI
png_set_compression_method(png_structp png_ptr, int method)
{
png_debug(1, "in png_set_compression_method\n");
if (png_ptr == NULL)
return;
if (method != 8)
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
@ -1407,8 +1364,6 @@ png_set_compression_method(png_structp png_ptr, int method)
void PNGAPI
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
{
if (png_ptr == NULL)
return;
png_ptr->write_row_fn = write_row_fn;
}
@ -1418,8 +1373,6 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
write_user_transform_fn)
{
png_debug(1, "in png_set_write_user_transform_fn\n");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_USER_TRANSFORM;
png_ptr->write_user_transform_fn = write_user_transform_fn;
}
@ -1431,8 +1384,6 @@ void PNGAPI
png_write_png(png_structp png_ptr, png_infop info_ptr,
int transforms, voidp params)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
/* invert the alpha channel from opacity to transparency */
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)

Просмотреть файл

@ -1,9 +1,9 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.2.9 April 14, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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.)
*/
@ -60,14 +60,14 @@ png_do_write_transformations(png_structp png_ptr)
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->shift));
#endif
#if defined(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);
#endif
#if defined(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);
#endif
#if defined(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);
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR)
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
@ -439,12 +439,9 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
png_uint_32 row_width = row_info->width;
for (i = 0, sp = dp = row; i < row_width; i++)
{
/* does nothing
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*/
sp+=3; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
}
}
@ -457,15 +454,12 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row; i < row_width; i++)
{
/* does nothing
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*/
sp+=6; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
}
@ -495,11 +489,8 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
for (i = 0, sp = dp = row; i < row_width; i++)
{
/* does nothing
*(dp++) = *(sp++);
*(dp++) = *(sp++);
*/
sp+=2; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
}

Просмотреть файл

@ -1,9 +1,9 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.2.11 June 4, 2006
* libpng version 1.2.7 - September 12, 2004
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
* Copyright (c) 1998-2004 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,7 +16,7 @@
* with unsigned numbers for convenience, although one supported
* ancillary chunk uses signed (two's complement) numbers.
*/
void PNGAPI
void /* PRIVATE */
png_save_uint_32(png_bytep buf, png_uint_32 i)
{
buf[0] = (png_byte)((i >> 24) & 0xff);
@ -25,11 +25,12 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
buf[3] = (png_byte)(i & 0xff);
}
#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
/* The png_save_int_32 function assumes integers are stored in two's
* complement format. If this isn't the case, then this routine needs to
* be modified to write data in two's complement format.
*/
void PNGAPI
void /* PRIVATE */
png_save_int_32(png_bytep buf, png_int_32 i)
{
buf[0] = (png_byte)((i >> 24) & 0xff);
@ -37,12 +38,13 @@ png_save_int_32(png_bytep buf, png_int_32 i)
buf[2] = (png_byte)((i >> 8) & 0xff);
buf[3] = (png_byte)(i & 0xff);
}
#endif
/* Place a 16-bit number into a buffer in PNG byte order.
* The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers.
*/
void PNGAPI
void /* PRIVATE */
png_save_uint_16(png_bytep buf, unsigned int i)
{
buf[0] = (png_byte)((i >> 8) & 0xff);
@ -159,11 +161,9 @@ png_text_compress(png_structp png_ptr,
{
int ret;
comp->num_output_ptr = 0;
comp->max_output_ptr = 0;
comp->num_output_ptr = comp->max_output_ptr = 0;
comp->output_ptr = NULL;
comp->input = NULL;
comp->input_len = 0;
/* we may just want to pass the text right through */
if (compression == PNG_TEXT_COMPRESSION_NONE)
@ -219,7 +219,7 @@ png_text_compress(png_structp png_ptr,
png_error(png_ptr, "zlib error");
}
/* check to see if we need more room */
if (!(png_ptr->zstream.avail_out))
if (!png_ptr->zstream.avail_out && png_ptr->zstream.avail_in)
{
/* make sure the output array has room */
if (comp->num_output_ptr >= comp->max_output_ptr)
@ -357,9 +357,9 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
png_write_chunk_data(png_ptr, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
/* reset zlib for another zTXt/iTXt or image data */
/* reset zlib for another zTXt/iTXt or the image data */
deflateReset(&png_ptr->zstream);
png_ptr->zstream.data_type = Z_BINARY;
}
#endif
@ -523,9 +523,6 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
/* libpng is not interested in zstream.data_type */
/* set it to a predefined value, to avoid its evaluation inside zlib */
png_ptr->zstream.data_type = Z_BINARY;
png_ptr->mode = PNG_HAVE_IHDR;
}
@ -730,13 +727,6 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
compression_state comp;
png_debug(1, "in png_write_iCCP\n");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
comp.output_ptr = NULL;
comp.input = NULL;
comp.input_len = 0;
if (name == NULL || (name_len = png_check_keyword(png_ptr, name,
&new_name)) == 0)
{
@ -937,7 +927,8 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
itemp = (png_uint_32)(white_y * 100000.0 + 0.5);
png_save_uint_32(buf + 4, itemp);
if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0)
if (red_x < 0 || red_x > 0.8 || red_y < 0 || red_y > 0.8 ||
red_x + red_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM red point specified");
return;
@ -947,7 +938,8 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
itemp = (png_uint_32)(red_y * 100000.0 + 0.5);
png_save_uint_32(buf + 12, itemp);
if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0)
if (green_x < 0 || green_x > 0.8 || green_y < 0 || green_y > 0.8 ||
green_x + green_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM green point specified");
return;
@ -957,7 +949,8 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
itemp = (png_uint_32)(green_y * 100000.0 + 0.5);
png_save_uint_32(buf + 20, itemp);
if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0)
if (blue_x < 0 || blue_x > 0.8 || blue_y < 0 || blue_y > 0.8 ||
blue_x + blue_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM blue point specified");
return;
@ -995,7 +988,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_save_uint_32(buf, (png_uint_32)white_x);
png_save_uint_32(buf + 4, (png_uint_32)white_y);
if (red_x + red_y > 100000L)
if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM fixed red point specified");
return;
@ -1003,7 +996,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_save_uint_32(buf + 8, (png_uint_32)red_x);
png_save_uint_32(buf + 12, (png_uint_32)red_y);
if (green_x + green_y > 100000L)
if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L)
{
png_warning(png_ptr, "Invalid fixed cHRM green point specified");
return;
@ -1011,7 +1004,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_save_uint_32(buf + 16, (png_uint_32)green_x);
png_save_uint_32(buf + 20, (png_uint_32)green_y);
if (blue_x + blue_y > 100000L)
if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L)
{
png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
return;
@ -1348,12 +1341,6 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_debug(1, "in png_write_zTXt\n");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
comp.output_ptr = NULL;
comp.input = NULL;
comp.input_len = 0;
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
{
png_warning(png_ptr, "Empty keyword in zTXt chunk");
@ -1407,11 +1394,6 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
png_debug(1, "in png_write_iTXt\n");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
comp.output_ptr = NULL;
comp.input = NULL;
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
{
png_warning(png_ptr, "Empty keyword in iTXt chunk");
@ -1567,41 +1549,39 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
/* write the sCAL chunk */
#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
void /* PRIVATE */
png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_sCAL;
#endif
char buf[64];
png_size_t total_len;
char wbuf[32], hbuf[32];
png_byte bunit = unit;
png_debug(1, "in png_write_sCAL\n");
buf[0] = (char)unit;
#if defined(_WIN32_WCE)
/* sprintf() function is not supported on WindowsCE */
{
wchar_t wc_buf[32];
size_t wc_len;
swprintf(wc_buf, TEXT("%12.12e"), width);
wc_len = wcslen(wc_buf);
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL);
total_len = wc_len + 2;
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL);
swprintf(wc_buf, TEXT("%12.12e"), height);
wc_len = wcslen(wc_buf);
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len,
NULL, NULL);
total_len += wc_len;
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL);
}
#else
sprintf(buf + 1, "%12.12e", width);
total_len = 1 + png_strlen(buf + 1) + 1;
sprintf(buf + total_len, "%12.12e", height);
total_len += png_strlen(buf + total_len);
sprintf(wbuf, "%12.12e", width);
sprintf(hbuf, "%12.12e", height);
#endif
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
png_debug1(3, "sCAL total length = %d\n", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);
png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
png_write_chunk_end(png_ptr);
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -1612,26 +1592,23 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_sCAL;
#endif
png_byte buf[64];
png_size_t wlen, hlen, total_len;
png_size_t total_len;
char wbuf[32], hbuf[32];
png_byte bunit = unit;
png_debug(1, "in png_write_sCAL_s\n");
wlen = png_strlen(width);
hlen = png_strlen(height);
total_len = wlen + hlen + 2;
if (total_len > 64)
{
png_warning(png_ptr, "Can't write sCAL (buffer too small)");
return;
}
png_strcpy(wbuf,(const char *)width);
png_strcpy(hbuf,(const char *)height);
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
buf[0] = (png_byte)unit;
png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
png_debug1(3, "sCAL total length = %d\n", total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)&bunit, 1);
png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
png_write_chunk_end(png_ptr);
}
#endif
#endif
@ -1894,7 +1871,6 @@ png_write_finish_row(png_structp png_ptr)
}
deflateReset(&png_ptr->zstream);
png_ptr->zstream.data_type = Z_BINARY;
}
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
@ -2072,7 +2048,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
* been specified by the application, and then writes the row out with the
* chosen filter.
*/
#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)
#define PNG_MAXSUM (~((png_uint_32)0) >> 1)
#define PNG_HISHIFT 10
#define PNG_LOMASK ((png_uint_32)0xffffL)
#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))

Просмотреть файл

@ -136,7 +136,7 @@ NS_IMETHODIMP nsPNGDecoder::Init(imgILoad *aLoad)
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* Ignore unused chunks */
png_set_keep_unknown_chunks(mPNG, 1, unused_chunks,
png_set_keep_unknown_chunks(mPNG, 0, unused_chunks,
(int)sizeof(unused_chunks)/5);
#endif