зеркало из https://github.com/mozilla/pjs.git
Update trunk to libpng-1.2.31 - bug 418900 r=joe sr=tor
This commit is contained in:
Родитель
350709e326
Коммит
9ada44ec8b
|
@ -2032,6 +2032,215 @@ version 1.2.24 [December 14, 2007]
|
|||
Revised gather.sh and makefile.std in contrib/pngminim to avoid compiling
|
||||
unused files.
|
||||
|
||||
version 1.2.25beta01 [January 7, 2008]
|
||||
Fixed bug with unknown chunk handling, introduced in version 1.2.17rc2
|
||||
|
||||
version 1.2.25beta02 [January 10, 2008]
|
||||
Prevent gamma from being applied twice.
|
||||
|
||||
version 1.2.25rc01 [January 17, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.2.25beta03 [January 22, 2008]
|
||||
Fixed some continue-after-malloc-failure errors in pngset.c (David Hill)
|
||||
Check for info_ptr == NULL in png_read_info() and png_process_data().
|
||||
Check for possible use of NULL user_png_ver[] in png_create_read_struct().
|
||||
Change "if (swidth == NULL)" to "if (sheight == NULL)" in png_handle_sCAL
|
||||
(bug introduced in libpng-1.2.4/1.0.13).
|
||||
Return from png_destroy_read_struct() if png_ptr_ptr is NULL.
|
||||
Fix overflow of "msg" in png_decompress_chunk().
|
||||
|
||||
version 1.2.25beta04 [January 26, 2008]
|
||||
Work around Coverity bug report by slightly refactoring
|
||||
png_read_push_finish_row()
|
||||
|
||||
version 1.2.25beta05 [January 31, 2008]
|
||||
Added libpng-1.2.25beta05.tar.lzma to distribution. Get the lzma codec
|
||||
from <http://tukaani.org/lzma>.
|
||||
Added lp1225b05.7z to distribution. Get the 7-zip decoder from
|
||||
from <http://www.7-zip.org>.
|
||||
Fixed some broken links in the README file.
|
||||
|
||||
version 1.2.25beta06 [February 6, 2008]
|
||||
Refactored png_read_push_finish_row() again, trying to satisfy Coverity.
|
||||
Fixed potential NULL dereference of png_ptr in png_destroy_write_struct();
|
||||
clarified potential NULL dereference of png_ptr in png_destroy_read_struct();
|
||||
fixed potential NULL dereference of info_ptr in png_handle_bKGD();
|
||||
fixed potential NULL dereference of user_png_ver[] in
|
||||
png_create_write_struct_2(). (Coverity)
|
||||
|
||||
version 1.2.25rc02 [February 10, 2008]
|
||||
Reset png_ptr->pass in png_read_push_finish_row() before break.
|
||||
Changed "pass" from png_byte to int.
|
||||
|
||||
version 1.2.25 and 1.0.31 [February 18, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.2.26beta01 [February 21, 2008]
|
||||
Added missing "(" in pngmem.c. Bug introduced in libpng-1.2.2/1.0.13
|
||||
|
||||
version 1.2.26beta02 [March 12, 2008]
|
||||
Refined error message returned from deflateInit2 in pngwutil.c
|
||||
Check IHDR length in png_push_read_chunk() before saving it.
|
||||
|
||||
version 1.2.26beta03 [March 16, 2008]
|
||||
Revised contrib/gregbook to handle premature end-of-file and file
|
||||
read errors correctly.
|
||||
|
||||
version 1.2.26beta04 [March 18, 2008]
|
||||
Free png_ptr->big_row_buf and png_ptr->prev_row before allocating
|
||||
new copies in png_read_start_row(). Bug introduced in libpng-1.2.22.
|
||||
|
||||
version 1.2.26beta05 [March 19, 2008]
|
||||
Removed extra png_free() added in libpng-1.2.26beta04.
|
||||
|
||||
version 1.2.26beta06 [March 19, 2008]
|
||||
Avoid reallocating big_row_buf and prev_row when the size does not increase.
|
||||
|
||||
version 1.2.26rc01 [March 26, 2008]
|
||||
Ifdef out some code that is unused when interlacing is not supported.
|
||||
|
||||
versions 1.0.32 and 1.2.26 [April 2, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.2.27beta01 [April 12, 2008]
|
||||
Fixed bug (introduced in libpng-1.0.5h) with handling zero-length
|
||||
unknown chunks.
|
||||
Added more information about png_set_keep_unknown_chunks() to the
|
||||
documentation.
|
||||
Reject tRNS chunk with out-of-range samples instead of masking off
|
||||
the invalid high bits as done in since libpng-1.2.19beta5.
|
||||
|
||||
version 1.2.27beta02 [April 13, 2008]
|
||||
Revised documentation about unknown chunk and user chunk handling.
|
||||
Keep tRNS chunk with out-of-range samples and issue a png_warning().
|
||||
|
||||
version 1.2.27beta03 [April 14, 2008]
|
||||
Added check for NULL ptr in TURBOC version of png_free_default().
|
||||
Removed several unnecessary checks for NULL before calling png_free().
|
||||
Revised png_set_tRNS() so that calling it twice removes and invalidates
|
||||
the previous call.
|
||||
Revised pngtest to check for out-of-range tRNS samples.
|
||||
|
||||
version 1.2.27beta04 [April 18, 2008]
|
||||
Added AC_LIBTOOL_WIN32_DLL to configure.ac
|
||||
Rebuilt Makefile.in, aclocal.m4, and configure with autoconf-2.62
|
||||
|
||||
version 1.2.27beta05 [April 19, 2008]
|
||||
Added MAINTAINERCLEANFILES variable to Makefile.am
|
||||
|
||||
version 1.2.27beta06 [April 21, 2008]
|
||||
Avoid changing color_type from GRAY to RGB by
|
||||
png_set_expand_gray_1_2_4_to_8().
|
||||
|
||||
version 1.2.27rc01 [April 23, 2008]
|
||||
Fix broken URL for rfc2083 in png.5 and libpng-*.txt
|
||||
|
||||
version 1.0.33 and 1.2.27 [April 30, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.0.34 and 1.2.28 [April 30, 2008]
|
||||
Rebuilt Makefile.in, aclocal.m4, and configure with autoconf-2.61
|
||||
due to backward incompatibilities.
|
||||
Removed a stray object file from contrib/gregbook
|
||||
|
||||
version 1.2.29beta01 [May 1, 2008]
|
||||
Removed some stray *.diff and *.orig files
|
||||
|
||||
version 1.2.29beta02 [May 1, 2008]
|
||||
Reverted Makefile.in, aclocal.m4, and configure to the libpng-1.2.26
|
||||
versions.
|
||||
|
||||
version 1.2.29beta03 [May 2, 2008]
|
||||
Added --force to autogen libtoolize options and --force-missing to
|
||||
automake options.
|
||||
Changed $(ECHO) to echo in Makefile.am and Makefile.in
|
||||
Updated all configure files to autoconf-2.62
|
||||
#ifdef out pnggcrd.c code if using MSC_VER
|
||||
|
||||
version 1.2.29rc01 [May 4, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.0.35 and 1.2.29 [May 8, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.0.37 [May 9, 2008]
|
||||
Updated Makefile.in and configure (omitted version 1.0.36).
|
||||
|
||||
version 1.2.30beta01 [May 29, 2008]
|
||||
Updated libpng.pc-configure.in and libpng-config.in per debian bug reports.
|
||||
|
||||
version 1.2.30beta02 [June 25, 2008]
|
||||
Restored png_flush(png_ptr) at the end of png_write_end(), that was
|
||||
removed from libpng-1.0.9beta03.
|
||||
|
||||
version 1.2.30beta03 [July 6, 2008]
|
||||
Merged some cosmetic whitespace changes from libpng-1.4.0beta19.
|
||||
Inline call of png_get_uint_32() in png_get_uint_31(), as in 1.4.0beta19.
|
||||
Added demo of decoding vpAg and sTER chunks to pngtest.c, from 1.4.0beta19.
|
||||
Changed PNGMAJ from 0 to 12 in makefile.darwin, which does not like 0.
|
||||
Added new private function png_read_chunk_header() from 1.4.0beta19.
|
||||
Merge reading of chunk length and chunk type into a single 8-byte read.
|
||||
Merge writing of chunk length and chunk type into a single 8-byte write.
|
||||
|
||||
version 1.2.30beta04 [July 10, 2008]
|
||||
Merged more cosmetic whitespace changes from libpng-1.4.0beta19.
|
||||
|
||||
version 1.0.38rc01, 1.2.30rc01 [August 13, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.0.38rc02, 1.2.30rc02 [July 21, 2008]
|
||||
Moved local array "chunkdata" from pngrutil.c to the png_struct, so
|
||||
it will be freed by png_read_destroy() in case of a read error (Kurt
|
||||
Christensen).
|
||||
|
||||
version 1.0.38rc03, 1.2.30rc03 [July 21, 2008]
|
||||
Changed "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking.
|
||||
|
||||
version 1.0.38rc04, 1.2.30rc04 [July 22, 2008]
|
||||
Changed "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in
|
||||
png_decompress_chunk().
|
||||
|
||||
version 1.0.38rc05, 1.2.30rc05 [July 25, 2008]
|
||||
Changed all remaining "chunkdata" to "png_ptr->chunkdata" in
|
||||
png_decompress_chunk() and remove chunkdata from parameter list.
|
||||
Put a call to png_check_chunk_name() in png_read_chunk_header().
|
||||
Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
|
||||
Removed two calls to png_check_chunk_name() occuring later in the process.
|
||||
|
||||
version 1.0.38rc06, 1.2.30rc06 [July 29, 2008]
|
||||
Added a call to png_check_chunk_name() in pngpread.c
|
||||
Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte.
|
||||
|
||||
version 1.0.38r07, 1.2.30r07 [August 2, 2008]
|
||||
Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta)
|
||||
Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings.
|
||||
Added code in pngset.c to quiet compiler warnings.
|
||||
Updated contrib/visupng/cexcept.h to version 2.0.1
|
||||
Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c
|
||||
|
||||
version 1.0.38r08, 1.2.30r08 [August 2, 2008]
|
||||
Enclose "volatile" declarations in #ifdef PNG_SETJMP_SUPPORTED (Cosmin).
|
||||
|
||||
version 1.0.38, 1.2.30 [August 13, 2008]
|
||||
|
||||
version 1.0.38, 1.2.30 [August 14, 2008]
|
||||
No changes.
|
||||
|
||||
version 1.2.31rc01 [August 19, 2008]
|
||||
Removed extra crc check at the end of png_handle_cHRM(). Bug introduced
|
||||
in libpng-1.2.30beta03 (Heiko Nitzsche).
|
||||
|
||||
version 1.2.31rc02 [August 19, 2008]
|
||||
Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call.
|
||||
|
||||
version 1.2.31rc03 [August 19, 2008]
|
||||
Added PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED block, off by default, around
|
||||
new png_flush().
|
||||
|
||||
version 1.0.39, 1.2.31 [August 21, 2008]
|
||||
No changes.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
|
|
@ -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.24, December 14, 2007, are
|
||||
Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.2.31, August 21, 2008, are
|
||||
Copyright (c) 2004, 2006-2008 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
|
||||
|
||||
|
@ -106,4 +106,4 @@ certification mark of the Open Source Initiative.
|
|||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 14, 2007
|
||||
August 21, 2008
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
Changes made to pristine png source by mozilla.org developers.
|
||||
|
||||
2008/08/21 -- Synced with libpng-1.2.31 (bug #418900).
|
||||
|
||||
2008/03/29 -- Initialize prev_row for each APNG frame, only when
|
||||
the frame size increases (bug #420416)
|
||||
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
README for libpng version 1.2.24 - December 14, 2007 (shared library 12.0)
|
||||
README for libpng version 1.2.31 - August 21, 2008 (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.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz
|
||||
or libpng-*.tar.bz2 if you want UNIX-style line endings in the text
|
||||
files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.lzma, or libpng-*.tar.bz2 if you want UNIX-style line
|
||||
endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style
|
||||
line endings. You can get UNIX-style line endings from the *.zip file
|
||||
by using "unzip -a" but there seems to be no simple way to recover
|
||||
UNIX-style line endings from the *.7z file. The *.tar.lzma file is
|
||||
recommended for *NIX users instead.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
|
@ -54,7 +58,7 @@ to set different actions based on whether the CRC error occurred in a
|
|||
critical or an ancillary chunk.
|
||||
|
||||
The changes made to the library, and bugs fixed are based on discussions
|
||||
on the PNG-implement mailing list
|
||||
on the png-mng-implement mailing list
|
||||
and not on material submitted privately to Guy, Andreas, or Glenn. They will
|
||||
forward any good suggestions to the list.
|
||||
|
||||
|
@ -77,12 +81,12 @@ compression library that is useful for more things than just PNG files.
|
|||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at
|
||||
ftp://ftp.simplesystems.org/pub/png/src/
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
|
@ -110,14 +114,14 @@ to subscribe) or to glennrp at users.sourceforge.net
|
|||
|
||||
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.
|
||||
addressed to the png-mng-implement list, however.
|
||||
|
||||
Please do not send general questions about PNG. Send them to
|
||||
the (png-mng-misc at lists.sourceforge.net, subscription required, visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement to subscribe)
|
||||
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
|
||||
or to the png-mng-implement list. I'll
|
||||
get them in the end anyway. If you have a question about something
|
||||
in the PNG specification that is related to using libpng, send it
|
||||
to me. Send me any questions that start with "I was using libpng,
|
||||
|
@ -190,11 +194,11 @@ Files in this distribution:
|
|||
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.24)
|
||||
gcc, creates libpng12.so.0.1.2.31)
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng12.so.0.1.2.24)
|
||||
(gcc, creates libpng12.so.0.1.2.31)
|
||||
makefile.gcmmx => Linux/ELF makefile
|
||||
(gcc, creates libpng12.so.0.1.2.24,
|
||||
(gcc, creates libpng12.so.0.1.2.31,
|
||||
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 +220,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.24)
|
||||
(gcc, creates libpng12.so.0.1.2.31)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.solaris => Solaris 2.X makefile
|
||||
(gcc, creates libpng12.so.0.1.2.24)
|
||||
(gcc, creates libpng12.so.0.1.2.31)
|
||||
makefile.so9 => Solaris 9 makefile
|
||||
(gcc, creates libpng12.so.0.1.2.24)
|
||||
(gcc, creates libpng12.so.0.1.2.31)
|
||||
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
|
||||
|
@ -256,7 +260,7 @@ Good luck, and happy coding.
|
|||
|
||||
-Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||
Internet: adilger at enel.ucalgary.ca
|
||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
||||
Web: http://members.shaw.ca/adilger/
|
||||
|
||||
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||
(formerly of Group 42, Inc)
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.2.24 - December 14, 2007
|
||||
libpng version 1.2.31 - August 21, 2008
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||
For conditions of distribution and use, see copyright
|
||||
notice in png.h.
|
||||
|
||||
based on:
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.2.31 - August 21, 2008
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
|
@ -47,12 +51,14 @@ a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
|
|||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
The PNG-1.2 specification is available at
|
||||
<http://www.libpng.org/pub/png/documents/>
|
||||
<http://www.libpng.org/pub/png/documents/>. It is technically equivalent
|
||||
to the PNG specification (second edition) but has some additional material.
|
||||
|
||||
The PNG-1.0 specification is available
|
||||
as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
|
||||
W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
|
||||
additional chunks are described in the special-purpose public chunks
|
||||
W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
|
||||
|
||||
Some additional chunks are described in the special-purpose public chunks
|
||||
documents at <http://www.libpng.org/pub/png/documents/>.
|
||||
|
||||
Other information
|
||||
|
@ -260,15 +266,19 @@ input stream. You must supply the function
|
|||
png_unknown_chunkp chunk);
|
||||
{
|
||||
/* The unknown chunk structure contains your
|
||||
chunk data: */
|
||||
chunk data, along with similar data for any other
|
||||
unknown chunks: */
|
||||
|
||||
png_byte name[5];
|
||||
png_byte *data;
|
||||
png_size_t size;
|
||||
|
||||
/* Note that libpng has already taken care of
|
||||
the CRC handling */
|
||||
|
||||
/* put your code here. Return one of the
|
||||
following: */
|
||||
/* put your code here. Search for your chunk in the
|
||||
unknown chunk structure, process it, and return one
|
||||
of the following: */
|
||||
|
||||
return (-n); /* chunk had an error */
|
||||
return (0); /* did not recognize */
|
||||
|
@ -288,6 +298,11 @@ you can retrieve with
|
|||
|
||||
png_get_user_chunk_ptr(png_ptr);
|
||||
|
||||
If you call the png_set_read_user_chunk_fn() function, then all unknown
|
||||
chunks will be saved when read, in case your callback function will need
|
||||
one or more of them. This behavior can be changed with the
|
||||
png_set_keep_unknown_chunks() function, described below.
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been read, which you can use to control
|
||||
a progress meter or the like. It's demonstrated in pngtest.c.
|
||||
|
@ -332,13 +347,13 @@ Unknown-chunk handling
|
|||
Now you get to set the way the library processes unknown chunks in the
|
||||
input PNG stream. Both known and unknown chunks will be read. Normal
|
||||
behavior is that known chunks will be parsed into information in
|
||||
various info_ptr members; unknown chunks will be discarded. To change
|
||||
various info_ptr members while unknown chunks will be discarded. To change
|
||||
this, you can call:
|
||||
|
||||
png_set_keep_unknown_chunks(png_ptr, keep,
|
||||
chunk_list, num_chunks);
|
||||
keep - 0: do not handle as unknown
|
||||
1: do not keep
|
||||
keep - 0: default unknown chunk handling
|
||||
1: ignore; do not keep
|
||||
2: keep only if safe-to-copy
|
||||
3: keep even if unsafe-to-copy
|
||||
You can use these definitions:
|
||||
|
@ -361,6 +376,37 @@ instances of png_set_keep_unknown_chunks(), the final instance will
|
|||
take precedence. The IHDR and IEND chunks should not be named in
|
||||
chunk_list; if they are, libpng will process them normally anyway.
|
||||
|
||||
Here is an example of the usage of png_set_keep_unknown_chunks(),
|
||||
where the private "vpAg" chunk will later be processed by a user chunk
|
||||
callback function:
|
||||
|
||||
png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'};
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_byte unused_chunks[]=
|
||||
{
|
||||
104, 73, 83, 84, (png_byte) '\0', /* hIST */
|
||||
105, 84, 88, 116, (png_byte) '\0', /* iTXt */
|
||||
112, 67, 65, 76, (png_byte) '\0', /* pCAL */
|
||||
115, 67, 65, 76, (png_byte) '\0', /* sCAL */
|
||||
115, 80, 76, 84, (png_byte) '\0', /* sPLT */
|
||||
116, 73, 77, 69, (png_byte) '\0', /* tIME */
|
||||
};
|
||||
#endif
|
||||
|
||||
...
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* ignore all unknown chunks: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
|
||||
/* except for vpAg: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
|
||||
/* also ignore unused known chunks: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
|
||||
(int)sizeof(unused_chunks)/5);
|
||||
#endif
|
||||
|
||||
|
||||
The high-level read interface
|
||||
|
||||
At this point there are two ways to proceed; through the high-level
|
||||
|
@ -804,6 +850,7 @@ 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.
|
||||
|
||||
|
@ -1743,6 +1790,11 @@ Some of the more important parts of the png_info are:
|
|||
can also be
|
||||
PNG_INTRAPIXEL_DIFFERENCING)
|
||||
|
||||
If you call png_set_IHDR(), the call must appear before any of the
|
||||
other png_set_*() functions, which might require access to some of
|
||||
the IHDR settings. The remaining png_set_*() functions can be called
|
||||
in any order.
|
||||
|
||||
png_set_PLTE(png_ptr, info_ptr, palette,
|
||||
num_palette);
|
||||
palette - the palette for the file
|
||||
|
@ -2391,6 +2443,9 @@ Your malloc_fn() must return NULL in case of failure. The png_malloc()
|
|||
function will normally call png_error() if it receives a NULL from the
|
||||
system memory allocator or from your replacement malloc_fn().
|
||||
|
||||
Your free_fn() will never be called with a NULL ptr, since libpng's
|
||||
png_free() checks for NULL before calling free_fn().
|
||||
|
||||
Input/Output in libpng is done through png_read() and png_write(),
|
||||
which currently just call fread() and fwrite(). The FILE * is stored in
|
||||
png_struct and is initialized via png_init_io(). If you wish to change
|
||||
|
@ -2796,13 +2851,13 @@ application:
|
|||
|
||||
IX. Y2K Compliance in libpng
|
||||
|
||||
December 14, 2007
|
||||
August 21, 2008
|
||||
|
||||
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.24 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.2.31 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
|
||||
|
|
|
@ -477,6 +477,40 @@
|
|||
/* libpng-1.2.22 addition */
|
||||
#define png_err MOZ_PNG_err
|
||||
|
||||
/* APNG additions */
|
||||
#define png_handle_acTL MOZ_APNG_handle_acTL
|
||||
#define png_handle_fcTL MOZ_APNG_handle_fcTL
|
||||
#define png_handle_fdAT MOZ_APNG_handle_fdAT
|
||||
#define png_have_info MOZ_APNG_have_info
|
||||
#define png_progressive_read_reset MOZ_APNG_prog_read_reset
|
||||
#define png_read_reinit MOZ_APNG_read_reinit
|
||||
#define png_read_reset MOZ_APNG_read_reset
|
||||
#define png_ensure_sequence_number MOZ_APNG_ensure_seqno
|
||||
#define png_write_frame_head MOZ_APNG_write_frame_head
|
||||
#define png_write_frame_tail MOZ_APNG_write_frame_tail
|
||||
#define png_set_progressive_frame_fn MOZ_APNG_set_prog_frame_fn
|
||||
#define png_set_acTL MOZ_APNG_set_acTL
|
||||
#define png_get_num_frames MOZ_APNG_set_num_frames
|
||||
#define png_get_num_plays MOZ_APNG_set_num_plays
|
||||
#define png_get_next_frame_fcTL MOZ_APNG_get_next_frame_fcTL
|
||||
#define png_set_next_frame_fcTL MOZ_APNG_set_next_frame_fcTL
|
||||
#define png_ensure_fcTL_is_valid MOZ_APNG_ensure_fcTL_is_valid
|
||||
#define png_get_next_frame_width MOZ_APNG_get_next_frame_width
|
||||
#define png_get_next_frame_height MOZ_APNG_get_next_frame_height
|
||||
#define png_get_next_frame_x_offset MOZ_APNG_get_next_frame_x_offset
|
||||
#define png_get_next_frame_y_offset MOZ_APNG_get_next_frame_y_offset
|
||||
#define png_get_next_frame_delay_num MOZ_APNG_get_next_frame_delay_num
|
||||
#define png_get_next_frame_delay_den MOZ_APNG_get_next_frame_delay_den
|
||||
#define png_get_next_frame_dispose_op MOZ_APNG_get_next_frame_dispose_op
|
||||
#define png_get_next_frame_blend_op MOZ_APNG_get_next_frame_blend_op
|
||||
#define png_get_first_frame_is_hidden MOZ_APNG_get_first_frame_is_hidden
|
||||
#define png_set_first_frame_is_hidden MOZ_APNG_set_first_frame_is_hidden
|
||||
#define png_write_acTL MOZ_APNG_write_acTL
|
||||
#define png_write_reset MOZ_APNG_write_reset
|
||||
#define png_write_reinit MOZ_APNG_write_reinit
|
||||
#define png_write_fcTL MOZ_APNG_write_fcTL
|
||||
#define png_read_frame_head MOZ_APNG_read_frame_head
|
||||
|
||||
#ifndef PR_LOGGING
|
||||
#define MOZ_PNG_warning(s1,s2) ""
|
||||
#define MOZ_PNG_chunk_warn(s1,s2) ""
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.2.21 October 4, 2007
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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_24 Your_png_h_is_not_version_1_2_24;
|
||||
typedef version_1_2_31 Your_png_h_is_not_version_1_2_31;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h. */
|
||||
|
@ -95,7 +95,7 @@ PNG_CONST int FARDATA png_pass_dsp_mask[]
|
|||
void PNGAPI
|
||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_debug(1, "in png_set_sig_bytes\n");
|
||||
if (num_bytes > 8)
|
||||
png_error(png_ptr, "Too many bytes for PNG signature.");
|
||||
|
@ -156,7 +156,7 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
|||
png_uint_32 save_flags=p->flags;
|
||||
png_uint_32 num_bytes;
|
||||
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
if (items > PNG_UINT_32_MAX/size)
|
||||
{
|
||||
png_warning (p, "Potential overflow in png_zalloc()");
|
||||
|
@ -244,7 +244,7 @@ png_create_info_struct(png_structp png_ptr)
|
|||
png_infop info_ptr;
|
||||
|
||||
png_debug(1, "in png_create_info_struct\n");
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
||||
png_ptr->malloc_fn, png_ptr->mem_ptr);
|
||||
|
@ -266,7 +266,7 @@ void PNGAPI
|
|||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||
{
|
||||
png_infop info_ptr = NULL;
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
|
||||
png_debug(1, "in png_destroy_info_struct\n");
|
||||
if (info_ptr_ptr != NULL)
|
||||
|
@ -305,11 +305,11 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
|||
{
|
||||
png_infop info_ptr = *ptr_ptr;
|
||||
|
||||
if(info_ptr == NULL) return;
|
||||
if (info_ptr == NULL) return;
|
||||
|
||||
png_debug(1, "in png_info_init_3\n");
|
||||
|
||||
if(png_sizeof(png_info) > png_info_struct_size)
|
||||
if (png_sizeof(png_info) > png_info_struct_size)
|
||||
{
|
||||
png_destroy_struct(info_ptr);
|
||||
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
|
||||
|
@ -317,7 +317,7 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
|||
}
|
||||
|
||||
/* set everything to 0 */
|
||||
png_memset(info_ptr, 0, png_sizeof (png_info));
|
||||
png_memset(info_ptr, 0, png_sizeof(png_info));
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
|
@ -328,9 +328,9 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
|||
png_debug(1, "in png_data_freer\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if(freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
if (freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||
info_ptr->free_me |= mask;
|
||||
else if(freer == PNG_USER_WILL_FREE_DATA)
|
||||
else if (freer == PNG_USER_WILL_FREE_DATA)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
|
@ -383,11 +383,11 @@ if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
|
|||
#endif
|
||||
{
|
||||
png_free(png_ptr, info_ptr->trans);
|
||||
info_ptr->trans = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
#ifndef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
info_ptr->trans = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -462,7 +462,7 @@ if (mask & PNG_FREE_SPLT)
|
|||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->splt_palettes)
|
||||
if (info_ptr->splt_palettes)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].name);
|
||||
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
|
||||
|
@ -472,7 +472,7 @@ if (mask & PNG_FREE_SPLT)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(info_ptr->splt_palettes_num)
|
||||
if (info_ptr->splt_palettes_num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
|
||||
|
@ -488,11 +488,12 @@ if (mask & PNG_FREE_SPLT)
|
|||
#endif
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_ptr->unknown_chunk.data)
|
||||
if (png_ptr->unknown_chunk.data)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||
#else
|
||||
|
@ -501,7 +502,7 @@ if (mask & PNG_FREE_UNKN)
|
|||
{
|
||||
if (num != -1)
|
||||
{
|
||||
if(info_ptr->unknown_chunks)
|
||||
if (info_ptr->unknown_chunks)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
|
||||
info_ptr->unknown_chunks[num].data = NULL;
|
||||
|
@ -511,7 +512,7 @@ if (mask & PNG_FREE_UNKN)
|
|||
{
|
||||
int i;
|
||||
|
||||
if(info_ptr->unknown_chunks_num)
|
||||
if (info_ptr->unknown_chunks_num)
|
||||
{
|
||||
for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
|
||||
|
@ -565,7 +566,7 @@ if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
|||
if (mask & PNG_FREE_ROWS)
|
||||
#endif
|
||||
{
|
||||
if(info_ptr->row_pointers)
|
||||
if (info_ptr->row_pointers)
|
||||
{
|
||||
int row;
|
||||
for (row = 0; row < (int)info_ptr->height; row++)
|
||||
|
@ -581,7 +582,7 @@ if (mask & PNG_FREE_ROWS)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
if(num == -1)
|
||||
if (num == -1)
|
||||
info_ptr->free_me &= ~mask;
|
||||
else
|
||||
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
|
||||
|
@ -604,7 +605,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
png_ptr->num_chunk_list=0;
|
||||
png_ptr->num_chunk_list = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -619,7 +620,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||
png_voidp PNGAPI
|
||||
png_get_io_ptr(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
return (png_ptr->io_ptr);
|
||||
}
|
||||
|
||||
|
@ -635,7 +636,7 @@ void PNGAPI
|
|||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||
{
|
||||
png_debug(1, "in png_init_io\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->io_ptr = (png_voidp)fp;
|
||||
}
|
||||
#endif
|
||||
|
@ -651,7 +652,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
if (png_ptr->time_buffer == NULL)
|
||||
{
|
||||
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||
|
@ -672,7 +673,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||
#ifdef USE_FAR_KEYWORD
|
||||
{
|
||||
char near_time_buf[29];
|
||||
png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||
png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
|
@ -680,7 +681,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||
29*png_sizeof(char));
|
||||
}
|
||||
#else
|
||||
png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||
png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
|
||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||
ptime->second % 61);
|
||||
|
@ -696,8 +697,8 @@ png_charp PNGAPI
|
|||
png_get_copyright(png_structp png_ptr)
|
||||
{
|
||||
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||
return ((png_charp) "\n libpng version 1.2.24 - December 14, 2007\n\
|
||||
Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\
|
||||
return ((png_charp) "\n libpng version 1.2.31 - August 21, 2008\n\
|
||||
Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\n\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||
}
|
||||
|
@ -746,12 +747,12 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
|||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||
int i;
|
||||
png_bytep p;
|
||||
if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
|
||||
if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
|
||||
return 0;
|
||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||
p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
|
||||
for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
|
||||
if (!png_memcmp(chunk_name, p, 4))
|
||||
return ((int)*(p+4));
|
||||
return ((int)*(p + 4));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.2.24 - December 14, 2007
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* libpng version 1.2.31 - August 21, 2008
|
||||
* Copyright (c) 1998-2008 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.24 - December 14, 2007: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.2.31 - August 21, 2008: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
|
@ -175,6 +174,34 @@
|
|||
* 1.2.24beta01-02 13 10224 12.so.0.24[.0]
|
||||
* 1.2.24rc01 13 10224 12.so.0.24[.0]
|
||||
* 1.2.24 13 10224 12.so.0.24[.0]
|
||||
* 1.2.25beta01-06 13 10225 12.so.0.25[.0]
|
||||
* 1.2.25rc01-02 13 10225 12.so.0.25[.0]
|
||||
* 1.0.31 10 10031 10.so.0.31[.0]
|
||||
* 1.2.25 13 10225 12.so.0.25[.0]
|
||||
* 1.2.26beta01-06 13 10226 12.so.0.26[.0]
|
||||
* 1.2.26rc01 13 10226 12.so.0.26[.0]
|
||||
* 1.2.26 13 10226 12.so.0.26[.0]
|
||||
* 1.0.32 10 10032 10.so.0.32[.0]
|
||||
* 1.2.27beta01-06 13 10227 12.so.0.27[.0]
|
||||
* 1.2.27rc01 13 10227 12.so.0.27[.0]
|
||||
* 1.0.33 10 10033 10.so.0.33[.0]
|
||||
* 1.2.27 13 10227 12.so.0.27[.0]
|
||||
* 1.0.34 10 10034 10.so.0.34[.0]
|
||||
* 1.2.28 13 10228 12.so.0.28[.0]
|
||||
* 1.2.29beta01-03 13 10229 12.so.0.29[.0]
|
||||
* 1.2.29rc01 13 10229 12.so.0.29[.0]
|
||||
* 1.0.35 10 10035 10.so.0.35[.0]
|
||||
* 1.2.29 13 10229 12.so.0.29[.0]
|
||||
* 1.0.37 10 10037 10.so.0.37[.0]
|
||||
* 1.2.31beta01-04 13 10230 12.so.0.30[.0]
|
||||
* 1.0.38rc01-08 10 10038 10.so.0.38[.0]
|
||||
* 1.2.30rc01-08 13 10230 12.so.0.30[.0]
|
||||
* 1.0.38 10 10038 10.so.0.38[.0]
|
||||
* 1.2.30 13 10230 12.so.0.30[.0]
|
||||
* 1.0.39rc01-03 10 10039 10.so.0.39[.0]
|
||||
* 1.2.31rc01-03 13 10231 12.so.0.31[.0]
|
||||
* 1.0.39 10 10039 10.so.0.39[.0]
|
||||
* 1.2.31 13 10231 12.so.0.31[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -184,7 +211,7 @@
|
|||
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||
* were given the previous public release number plus a letter, until
|
||||
* version 1.0.6j; from then on they were given the upcoming public
|
||||
* release number plus "betaNN" or "rcN".
|
||||
* release number plus "betaNN" or "rcNN".
|
||||
*
|
||||
* Binary incompatibility exists only when applications make direct access
|
||||
* to the info_ptr or png_ptr members through png.h, and the compiled
|
||||
|
@ -204,8 +231,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.24, December 14, 2007, are
|
||||
* Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.2.31, August 21, 2008, are
|
||||
* Copyright (c) 2004, 2006-2008 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:
|
||||
*
|
||||
|
@ -316,13 +343,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* December 14, 2007
|
||||
* August 21, 2008
|
||||
*
|
||||
* 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.24 are Y2K compliant. It is my belief that earlier
|
||||
* upward through 1.2.31 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
|
||||
|
@ -378,9 +405,9 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.2.24"
|
||||
#define PNG_LIBPNG_VER_STRING "1.2.31"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.2.24 - December 14, 2007\n"
|
||||
" libpng version 1.2.31 - August 21, 2008\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 0
|
||||
#define PNG_LIBPNG_VER_DLLNUM 13
|
||||
|
@ -388,7 +415,7 @@
|
|||
/* 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 24
|
||||
#define PNG_LIBPNG_VER_RELEASE 31
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
|
||||
|
||||
|
@ -416,7 +443,7 @@
|
|||
* 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 10224 /* 1.2.24 */
|
||||
#define PNG_LIBPNG_VER 10231 /* 1.2.31 */
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* include the compression library's header */
|
||||
|
@ -1206,7 +1233,7 @@ struct png_struct_def
|
|||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row */
|
||||
#ifndef PNG_NO_WRITE_FILTERING
|
||||
#ifndef PNG_NO_WRITE_FILTER
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
|
@ -1479,13 +1506,17 @@ struct png_struct_def
|
|||
|
||||
/* New members added in libpng-1.2.26 */
|
||||
png_uint_32 old_big_row_buf_size, old_prev_row_size;
|
||||
|
||||
/* New member added in libpng-1.2.31 */
|
||||
png_charp chunkdata; /* buffer for reading chunk data */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* 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_24;
|
||||
typedef png_structp version_1_2_31;
|
||||
|
||||
typedef png_struct FAR * FAR * png_structpp;
|
||||
|
||||
|
@ -2750,6 +2781,7 @@ extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
|
|||
png_ptr));
|
||||
#endif
|
||||
|
||||
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
|
@ -3139,8 +3171,8 @@ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
|
|||
/* Decompress data in a chunk that uses compression */
|
||||
#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
|
||||
defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
|
||||
PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
|
||||
int comp_type, png_charp chunkdata, png_size_t chunklength,
|
||||
PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
|
||||
int comp_type, png_size_t chunklength,
|
||||
png_size_t prefix_length, png_size_t *data_length));
|
||||
#endif
|
||||
|
||||
|
@ -3706,6 +3738,9 @@ 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 */
|
||||
|
||||
/* Read the chunk header (length + type name) */
|
||||
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
||||
|
||||
/* 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.24 - December 14, 2007
|
||||
* libpng version 1.2.31 - August 21, 2008
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
@ -1135,10 +1135,10 @@ typedef unsigned char png_byte;
|
|||
change (I'm not sure if you will or not, so I thought I'd be safe) */
|
||||
#ifdef PNG_SIZE_T
|
||||
typedef PNG_SIZE_T png_size_t;
|
||||
# define png_sizeof(x) png_convert_size(sizeof (x))
|
||||
# define png_sizeof(x) png_convert_size(sizeof(x))
|
||||
#else
|
||||
typedef size_t png_size_t;
|
||||
# define png_sizeof(x) sizeof (x)
|
||||
# define png_sizeof(x) sizeof(x)
|
||||
#endif
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.2.22 [October 13, 2007]
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*
|
||||
|
@ -15,8 +15,8 @@
|
|||
|
||||
#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));
|
||||
|
@ -44,28 +44,29 @@ png_error(png_structp png_ptr, png_const_charp error_message)
|
|||
{
|
||||
if (*error_message == '#')
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of error message. */
|
||||
int offset;
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(error_message+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;
|
||||
for (i = 0; i < offset - 1; i++)
|
||||
msg[i] = error_message[i + 1];
|
||||
msg[i - 1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
else
|
||||
error_message+=offset;
|
||||
error_message += offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||
{
|
||||
msg[0]='0';
|
||||
msg[1]='\0';
|
||||
error_message=msg;
|
||||
msg[0] = '0';
|
||||
msg[1] = '\0';
|
||||
error_message = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,16 +111,16 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
{
|
||||
if (*warning_message == '#')
|
||||
{
|
||||
for (offset=1; offset<15; offset++)
|
||||
if (*(warning_message+offset) == ' ')
|
||||
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);
|
||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||
}
|
||||
else
|
||||
png_default_warning(png_ptr, warning_message+offset);
|
||||
png_default_warning(png_ptr, warning_message + offset);
|
||||
}
|
||||
#endif /* PNG_NO_WARNINGS */
|
||||
|
||||
|
@ -167,8 +168,8 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
|||
{
|
||||
buffer[iout++] = ':';
|
||||
buffer[iout++] = ' ';
|
||||
png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||
buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0';
|
||||
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,22 +217,23 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
|
|||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
if (*error_message == '#')
|
||||
{
|
||||
/* Strip "#nnnn " from beginning of warning message. */
|
||||
int offset;
|
||||
char error_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
for (offset = 0; offset<15; offset++)
|
||||
{
|
||||
error_number[offset] = *(error_message+offset+1);
|
||||
if (*(error_message+offset) == ' ')
|
||||
error_number[offset] = error_message[offset + 1];
|
||||
if (error_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
error_number[offset-1]='\0';
|
||||
error_number[offset - 1] = '\0';
|
||||
fprintf(stderr, "libpng error no. %s: %s\n", error_number,
|
||||
error_message+offset);
|
||||
error_message + offset + 1);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
|
||||
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -274,17 +276,17 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||
{
|
||||
int offset;
|
||||
char warning_number[16];
|
||||
for (offset=0; offset<15; offset++)
|
||||
for (offset = 0; offset < 15; offset++)
|
||||
{
|
||||
warning_number[offset]=*(warning_message+offset+1);
|
||||
if (*(warning_message+offset) == ' ')
|
||||
warning_number[offset] = warning_message[offset + 1];
|
||||
if (warning_message[offset] == ' ')
|
||||
break;
|
||||
}
|
||||
if((offset > 1) && (offset < 15))
|
||||
if ((offset > 1) && (offset < 15))
|
||||
{
|
||||
warning_number[offset-1]='\0';
|
||||
warning_number[offset + 1] = '\0';
|
||||
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
|
||||
warning_message+offset);
|
||||
warning_message + offset);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
||||
|
@ -333,7 +335,7 @@ png_get_error_ptr(png_structp png_ptr)
|
|||
void PNGAPI
|
||||
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||
{
|
||||
if(png_ptr != NULL)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->flags &=
|
||||
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.2.15 January 5, 2007
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
|
@ -122,7 +121,7 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||
return (0);
|
||||
else return (info_ptr->y_pixels_per_unit);
|
||||
}
|
||||
|
@ -158,7 +157,7 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
||||
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
||||
return (0);
|
||||
else return (info_ptr->x_pixels_per_unit);
|
||||
|
@ -199,7 +198,7 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
|
@ -217,7 +216,7 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
|
@ -235,7 +234,7 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->x_offset);
|
||||
}
|
||||
|
@ -253,7 +252,7 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
|||
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
||||
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||
return (0);
|
||||
else return (info_ptr->y_offset);
|
||||
}
|
||||
|
@ -323,7 +322,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
|
|||
{
|
||||
*unit_type = (int)info_ptr->phys_unit_type;
|
||||
retval |= PNG_INFO_pHYs;
|
||||
if(*unit_type == 1)
|
||||
if (*unit_type == 1)
|
||||
{
|
||||
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
|
||||
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
|
||||
|
@ -784,10 +783,10 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||
*trans_values = &(info_ptr->trans_values);
|
||||
retval |= PNG_INFO_tRNS;
|
||||
}
|
||||
if(trans != NULL)
|
||||
if (trans != NULL)
|
||||
*trans = NULL;
|
||||
}
|
||||
if(num_trans != NULL)
|
||||
if (num_trans != NULL)
|
||||
{
|
||||
*num_trans = info_ptr->num_trans;
|
||||
retval |= PNG_INFO_tRNS;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.2.13 November 13, 2006
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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)
|
||||
|
||||
/* Borland DOS special memory handler */
|
||||
|
@ -48,7 +47,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
|||
return (png_get_copyright(NULL));
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
|
@ -80,7 +79,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(free_fn != NULL)
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
|
@ -122,7 +121,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
@ -171,7 +170,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||
ret = NULL;
|
||||
}
|
||||
|
||||
if(png_ptr->zlib_window_bits > 14)
|
||||
if (png_ptr->zlib_window_bits > 14)
|
||||
num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
|
||||
else
|
||||
num_blocks = 1;
|
||||
|
@ -210,7 +209,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||
|
||||
png_ptr->offset_table = table;
|
||||
png_ptr->offset_table_ptr = farmalloc(num_blocks *
|
||||
png_sizeof (png_bytep));
|
||||
png_sizeof(png_bytep));
|
||||
|
||||
if (png_ptr->offset_table_ptr == NULL)
|
||||
{
|
||||
|
@ -273,6 +272,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||
/* free a pointer allocated by png_malloc(). In the default
|
||||
configuration, png_ptr is not used, but is passed in case it
|
||||
is needed. If ptr is NULL, return without taking any action. */
|
||||
|
||||
void PNGAPI
|
||||
png_free(png_structp png_ptr, png_voidp ptr)
|
||||
{
|
||||
|
@ -293,7 +293,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
|||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL || ptr == NULL) return;
|
||||
|
||||
if (png_ptr->offset_table != NULL)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
|||
return (NULL);
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(malloc_fn != NULL)
|
||||
if (malloc_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
|
@ -369,7 +369,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
|
|||
struct_ptr = (png_voidp)farmalloc(size);
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
struct_ptr = (png_voidp)halloc(size,1);
|
||||
struct_ptr = (png_voidp)halloc(size, 1);
|
||||
# else
|
||||
struct_ptr = (png_voidp)malloc(size);
|
||||
# endif
|
||||
|
@ -398,7 +398,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
|||
if (struct_ptr != NULL)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if(free_fn != NULL)
|
||||
if (free_fn != NULL)
|
||||
{
|
||||
png_struct dummy_struct;
|
||||
png_structp png_ptr = &dummy_struct;
|
||||
|
@ -434,7 +434,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
|
|||
if (png_ptr == NULL || size == 0)
|
||||
return (NULL);
|
||||
|
||||
if(png_ptr->malloc_fn != NULL)
|
||||
if (png_ptr->malloc_fn != NULL)
|
||||
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
|
||||
else
|
||||
ret = (png_malloc_default(png_ptr, size));
|
||||
|
@ -456,7 +456,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||
if (size > (png_uint_32)65536L)
|
||||
{
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||
else
|
||||
#endif
|
||||
|
@ -542,9 +542,9 @@ png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
|||
{
|
||||
png_voidp ptr;
|
||||
png_uint_32 save_flags;
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
|
||||
save_flags=png_ptr->flags;
|
||||
save_flags = png_ptr->flags;
|
||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||
png_ptr->flags=save_flags;
|
||||
|
@ -560,7 +560,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
|
|||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memcpy_check.");
|
||||
png_error(png_ptr, "Overflow in png_memcpy_check.");
|
||||
|
||||
return(png_memcpy (s1, s2, size));
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
|||
|
||||
size = (png_size_t)length;
|
||||
if ((png_uint_32)size != length)
|
||||
png_error(png_ptr,"Overflow in png_memset_check.");
|
||||
png_error(png_ptr, "Overflow in png_memset_check.");
|
||||
|
||||
return (png_memset (s1, value, size));
|
||||
|
||||
|
@ -587,10 +587,11 @@ void PNGAPI
|
|||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||
malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
if(png_ptr != NULL) {
|
||||
png_ptr->mem_ptr = mem_ptr;
|
||||
png_ptr->malloc_fn = malloc_fn;
|
||||
png_ptr->free_fn = free_fn;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->mem_ptr = mem_ptr;
|
||||
png_ptr->malloc_fn = malloc_fn;
|
||||
png_ptr->free_fn = free_fn;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,7 +602,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
|||
png_voidp PNGAPI
|
||||
png_get_mem_ptr(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
return ((png_voidp)png_ptr->mem_ptr);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.2.23 [November 6, 2007]
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
|
||||
/* push model modes */
|
||||
|
@ -28,7 +27,7 @@ void PNGAPI
|
|||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||
png_bytep buffer, png_size_t buffer_size)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL || info_ptr == NULL) return;
|
||||
png_push_restore_buffer(png_ptr, buffer, buffer_size);
|
||||
|
||||
while (png_ptr->buffer_size)
|
||||
|
@ -43,7 +42,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
|||
void /* PRIVATE */
|
||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
switch (png_ptr->process_mode)
|
||||
{
|
||||
case PNG_READ_SIG_MODE:
|
||||
|
@ -114,7 +113,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
|
||||
num_to_check);
|
||||
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check);
|
||||
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
|
@ -215,9 +214,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||
}
|
||||
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
|
@ -319,13 +319,17 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||
#endif /* PNG_READ_APNG_SUPPORTED */
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
if(png_ptr->mode & PNG_AFTER_IDAT)
|
||||
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 != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||
{
|
||||
if (png_ptr->push_length != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
png_push_save_buffer(png_ptr);
|
||||
return;
|
||||
}
|
||||
|
@ -697,7 +701,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
|||
{
|
||||
png_bytep ptr;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
ptr = buffer;
|
||||
if (png_ptr->save_buffer_size)
|
||||
{
|
||||
|
@ -738,7 +742,7 @@ png_push_save_buffer(png_structp png_ptr)
|
|||
{
|
||||
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
|
||||
{
|
||||
png_size_t i,istop;
|
||||
png_size_t i, istop;
|
||||
png_bytep sp;
|
||||
png_bytep dp;
|
||||
|
||||
|
@ -811,7 +815,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||
}
|
||||
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
|
@ -863,7 +867,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||
png_ptr->idat_size = png_ptr->push_length;
|
||||
|
||||
#if defined(PNG_READ_APNG_SUPPORTED)
|
||||
if(png_ptr->num_frames_read > 0)
|
||||
if (png_ptr->num_frames_read > 0)
|
||||
{
|
||||
png_ensure_sequence_number(png_ptr, 4);
|
||||
png_ptr->idat_size -= 4;
|
||||
|
@ -878,7 +882,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||
{
|
||||
save_size = (png_size_t)png_ptr->idat_size;
|
||||
/* check for overflow */
|
||||
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||
if ((png_uint_32)save_size != png_ptr->idat_size)
|
||||
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||
}
|
||||
else
|
||||
|
@ -900,7 +904,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||
{
|
||||
save_size = (png_size_t)png_ptr->idat_size;
|
||||
/* check for overflow */
|
||||
if((png_uint_32)save_size != png_ptr->idat_size)
|
||||
if ((png_uint_32)save_size != png_ptr->idat_size)
|
||||
png_error(png_ptr, "save_size overflowed in pngpread");
|
||||
}
|
||||
else
|
||||
|
@ -940,7 +944,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
|||
|
||||
png_ptr->zstream.next_in = buffer;
|
||||
png_ptr->zstream.avail_in = (uInt)buffer_length;
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
||||
if (ret != Z_OK)
|
||||
|
@ -1254,7 +1258,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
(png_uint_32)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
|
@ -1352,7 +1356,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
(png_uint_32)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
|
@ -1443,8 +1447,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||
if (text == NULL)
|
||||
{
|
||||
text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||
+ key_size + 1));
|
||||
(png_uint_32)(png_ptr->zbuf_size
|
||||
- png_ptr->zstream.avail_out + key_size + 1));
|
||||
png_memcpy(text + key_size, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
png_memcpy(text, key, key_size);
|
||||
|
@ -1458,8 +1462,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
tmp = text;
|
||||
text = (png_charp)png_malloc(png_ptr, text_size +
|
||||
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
|
||||
+ 1));
|
||||
(png_uint_32)(png_ptr->zbuf_size
|
||||
- png_ptr->zstream.avail_out));
|
||||
png_memcpy(text, tmp, text_size);
|
||||
png_free(png_ptr, tmp);
|
||||
png_memcpy(text + text_size, png_ptr->zbuf,
|
||||
|
@ -1542,7 +1546,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||
#endif
|
||||
|
||||
png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)(length+1));
|
||||
(png_uint_32)(length + 1));
|
||||
png_ptr->current_text[length] = '\0';
|
||||
png_ptr->current_text_ptr = png_ptr->current_text;
|
||||
png_ptr->current_text_size = (png_size_t)length;
|
||||
|
@ -1643,22 +1647,21 @@ void /* PRIVATE */
|
|||
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
||||
length)
|
||||
{
|
||||
png_uint_32 skip=0;
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
png_uint_32 skip = 0;
|
||||
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
{
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS
|
||||
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
&& png_ptr->read_user_chunk_fn == NULL
|
||||
&& png_ptr->read_user_chunk_fn == NULL
|
||||
#endif
|
||||
)
|
||||
)
|
||||
#endif
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
|
||||
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
|
@ -1675,13 +1678,20 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
|
||||
(png_charp)png_ptr->chunk_name,
|
||||
png_sizeof(png_ptr->unknown_chunk.name));
|
||||
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0';
|
||||
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
|
||||
= '\0';
|
||||
|
||||
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
||||
png_ptr->unknown_chunk.size = (png_size_t)length;
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
||||
if (length == 0)
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
else
|
||||
{
|
||||
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)length);
|
||||
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
||||
}
|
||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||
if(png_ptr->read_user_chunk_fn != NULL)
|
||||
if (png_ptr->read_user_chunk_fn != NULL)
|
||||
{
|
||||
/* callback to user unknown chunk handler */
|
||||
int ret;
|
||||
|
@ -1692,16 +1702,16 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||
if (ret == 0)
|
||||
{
|
||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||
PNG_HANDLE_CHUNK_ALWAYS)
|
||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||
png_set_unknown_chunks(png_ptr, info_ptr,
|
||||
&png_ptr->unknown_chunk, 1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
||||
else
|
||||
#endif
|
||||
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
@ -1741,7 +1751,7 @@ png_progressive_combine_row (png_structp png_ptr,
|
|||
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
|
||||
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||
#endif
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||
}
|
||||
|
@ -1751,7 +1761,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
|||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||
png_progressive_end_ptr end_fn)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->info_fn = info_fn;
|
||||
png_ptr->row_fn = row_fn;
|
||||
png_ptr->end_fn = end_fn;
|
||||
|
@ -1773,7 +1783,7 @@ png_set_progressive_frame_fn(png_structp png_ptr,
|
|||
png_voidp PNGAPI
|
||||
png_get_progressive_ptr(png_structp png_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return (NULL);
|
||||
if (png_ptr == NULL) return (NULL);
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.2.24 December 14, 2007
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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,6 @@
|
|||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED)
|
||||
|
||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||
|
@ -35,6 +34,9 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
volatile
|
||||
#endif
|
||||
png_structp png_ptr;
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
|
@ -69,7 +71,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
#endif
|
||||
{
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf=NULL;
|
||||
png_ptr->zbuf = NULL;
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)png_ptr,
|
||||
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
|
||||
|
@ -79,7 +81,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
return (NULL);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -89,12 +91,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
i=0;
|
||||
do
|
||||
if (user_png_ver)
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
}
|
||||
else
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||
{
|
||||
|
@ -122,7 +130,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
png_warning(png_ptr, msg);
|
||||
#endif
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
png_ptr->flags=0;
|
||||
png_ptr->flags = 0;
|
||||
#endif
|
||||
png_error(png_ptr,
|
||||
"Incompatible libpng version in application and library");
|
||||
|
@ -158,7 +166,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
PNG_ABORT();
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
||||
#else
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
PNG_ABORT();
|
||||
|
@ -184,13 +192,13 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
/* We only come here via pre-1.0.12-compiled applications */
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#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];
|
||||
png_ptr->warning_fn=NULL;
|
||||
png_ptr->warning_fn = NULL;
|
||||
if (user_png_ver)
|
||||
{
|
||||
png_snprintf(msg, 80,
|
||||
|
@ -204,20 +212,20 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif
|
||||
if(png_sizeof(png_struct) > png_struct_size)
|
||||
if (png_sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
png_ptr->error_fn = NULL;
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
png_ptr->flags=0;
|
||||
png_ptr->flags = 0;
|
||||
#endif
|
||||
png_error(png_ptr,
|
||||
"The png struct allocated by the application for reading is too small.");
|
||||
}
|
||||
if(png_sizeof(png_info) > png_info_size)
|
||||
if (png_sizeof(png_info) > png_info_size)
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
png_ptr->error_fn = NULL;
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
png_ptr->flags=0;
|
||||
png_ptr->flags = 0;
|
||||
#endif
|
||||
png_error(png_ptr,
|
||||
"The info struct allocated by application for reading is too small.");
|
||||
|
@ -234,20 +242,20 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
png_structp png_ptr=*ptr_ptr;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
|
||||
do
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
{
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
#else
|
||||
png_ptr->warning_fn=NULL;
|
||||
png_ptr->warning_fn = NULL;
|
||||
png_warning(png_ptr,
|
||||
"Application uses deprecated png_read_init() and should be recompiled.");
|
||||
break;
|
||||
|
@ -259,22 +267,22 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
if(png_sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_destroy_struct(png_ptr);
|
||||
*ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
|
||||
png_ptr = *ptr_ptr;
|
||||
}
|
||||
if (png_sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_destroy_struct(png_ptr);
|
||||
*ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
|
||||
png_ptr = *ptr_ptr;
|
||||
}
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, png_sizeof (png_struct));
|
||||
png_memset(png_ptr, 0, png_sizeof(png_struct));
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
/* added at libpng-1.2.6 */
|
||||
|
@ -318,7 +326,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
void PNGAPI
|
||||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL || info_ptr == NULL) return;
|
||||
png_debug(1, "in png_read_info\n");
|
||||
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
||||
if (png_ptr->sig_bytes < 8)
|
||||
|
@ -341,7 +349,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_CONST PNG_IHDR;
|
||||
|
@ -405,38 +413,29 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||
PNG_CONST PNG_fdAT;
|
||||
#endif
|
||||
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||
png_byte chunk_length[4];
|
||||
png_uint_32 length;
|
||||
|
||||
png_read_data(png_ptr, chunk_length, 4);
|
||||
length = png_get_uint_31(png_ptr,chunk_length);
|
||||
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
|
||||
png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
|
||||
length);
|
||||
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
||||
|
||||
/* 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_IDAT, 4))
|
||||
if(png_ptr->mode & PNG_AFTER_IDAT)
|
||||
if (!png_memcmp(chunk_name, 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_memcmp(chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
else if (!png_memcmp(chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
else if (png_handle_as_unknown(png_ptr, chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
|
@ -447,16 +446,15 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
!(png_ptr->mode & PNG_HAVE_PLTE))
|
||||
png_error(png_ptr, "Missing PLTE before IDAT");
|
||||
|
||||
#if defined(PNG_READ_APNG_SUPPORTED)
|
||||
png_have_info(png_ptr, info_ptr);
|
||||
#endif
|
||||
|
@ -465,79 +463,79 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||
break;
|
||||
}
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
||||
else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
||||
else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
||||
else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
||||
else if (!png_memcmp(chunk_name, png_hIST, 4))
|
||||
png_handle_hIST(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
||||
else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
||||
else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tIME, 4))
|
||||
png_handle_tIME(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_APNG_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_acTL, 4))
|
||||
png_handle_acTL(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_fcTL, 4))
|
||||
png_handle_fcTL(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_fdAT, 4))
|
||||
png_handle_fdAT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
else
|
||||
|
@ -628,8 +626,9 @@ void PNGAPI
|
|||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_update_info\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
|
||||
png_read_start_row(png_ptr);
|
||||
else
|
||||
png_warning(png_ptr,
|
||||
|
@ -647,7 +646,7 @@ void PNGAPI
|
|||
png_start_read_image(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_start_read_image\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
}
|
||||
|
@ -664,11 +663,11 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
PNG_CONST PNG_IEND;
|
||||
#endif
|
||||
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
||||
0xff};
|
||||
0xff};
|
||||
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
#endif
|
||||
int ret;
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
|
||||
png_ptr->row_number, png_ptr->pass);
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
|
@ -796,16 +795,10 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
|
||||
while (!png_ptr->idat_size || bytes_to_skip != 0)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
|
||||
png_crc_finish(png_ptr, bytes_to_skip);
|
||||
bytes_to_skip = 0;
|
||||
|
||||
png_read_data(png_ptr, chunk_length, 4);
|
||||
png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
|
||||
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||
|
||||
#if defined(PNG_READ_APNG_SUPPORTED)
|
||||
if (png_ptr->num_frames_read == 0)
|
||||
|
@ -857,7 +850,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
if (ret != Z_OK)
|
||||
png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
|
||||
"Decompression error");
|
||||
|
||||
|
||||
} while (png_ptr->zstream.avail_out);
|
||||
|
||||
png_ptr->row_info.color_type = png_ptr->color_type;
|
||||
|
@ -868,7 +861,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
|
||||
png_ptr->row_info.width);
|
||||
|
||||
if(png_ptr->row_buf[0])
|
||||
if (png_ptr->row_buf[0])
|
||||
png_read_filter_row(png_ptr, &(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1, png_ptr->prev_row + 1,
|
||||
(int)(png_ptr->row_buf[0]));
|
||||
|
@ -877,7 +870,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
png_ptr->rowbytes + 1);
|
||||
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
|
@ -957,7 +950,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||
png_bytepp dp;
|
||||
|
||||
png_debug(1, "in png_read_rows\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
rp = row;
|
||||
dp = display_row;
|
||||
if (rp != NULL && dp != NULL)
|
||||
|
@ -968,14 +961,14 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
}
|
||||
else if(rp != NULL)
|
||||
else if (rp != NULL)
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr = *rp;
|
||||
png_read_row(png_ptr, rptr, png_bytep_NULL);
|
||||
rp++;
|
||||
}
|
||||
else if(dp != NULL)
|
||||
else if (dp != NULL)
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep dptr = *dp;
|
||||
|
@ -1001,12 +994,12 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||
void PNGAPI
|
||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_uint_32 i,image_height;
|
||||
png_uint_32 i, image_height;
|
||||
int pass, j;
|
||||
png_bytepp rp;
|
||||
|
||||
png_debug(1, "in png_read_image\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
pass = png_set_interlace_handling(png_ptr);
|
||||
|
@ -1041,11 +1034,8 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
|||
void PNGAPI
|
||||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_uint_32 length;
|
||||
|
||||
png_debug(1, "in png_read_end\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
||||
|
||||
do
|
||||
|
@ -1112,33 +1102,27 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
|||
PNG_CONST PNG_fdAT;
|
||||
#endif
|
||||
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
||||
|
||||
png_read_data(png_ptr, chunk_length, 4);
|
||||
length = png_get_uint_31(png_ptr,chunk_length);
|
||||
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
|
||||
png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
|
||||
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
||||
if (!png_memcmp(chunk_name, png_IHDR, 4))
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
||||
else if (!png_memcmp(chunk_name, png_IEND, 4))
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
||||
else if (png_handle_as_unknown(png_ptr, chunk_name))
|
||||
{
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||
{
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||
png_error(png_ptr, "Too many IDAT's found");
|
||||
}
|
||||
png_handle_unknown(png_ptr, info_ptr, length);
|
||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||
}
|
||||
#endif
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||
{
|
||||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
* read, but not after other chunks have been read.
|
||||
|
@ -1147,74 +1131,74 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
|||
png_error(png_ptr, "Too many IDAT's found");
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
||||
else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
||||
else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
||||
else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
||||
else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
||||
else if (!png_memcmp(chunk_name, png_hIST, 4))
|
||||
png_handle_hIST(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
||||
else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
||||
else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
||||
else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
||||
else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tIME, 4))
|
||||
png_handle_tIME(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
||||
else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
||||
else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
#if defined(PNG_READ_APNG_SUPPORTED)
|
||||
|
@ -1245,13 +1229,14 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||
|
||||
png_debug(1, "in png_destroy_read_struct\n");
|
||||
if (png_ptr_ptr != NULL)
|
||||
{
|
||||
png_ptr = *png_ptr_ptr;
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
free_fn = png_ptr->free_fn;
|
||||
mem_ptr = png_ptr->mem_ptr;
|
||||
free_fn = png_ptr->free_fn;
|
||||
mem_ptr = png_ptr->mem_ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (info_ptr_ptr != NULL)
|
||||
info_ptr = *info_ptr_ptr;
|
||||
|
@ -1326,6 +1311,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->palette_lookup);
|
||||
png_free(png_ptr, png_ptr->dither_index);
|
||||
|
@ -1422,7 +1408,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||
* being used again.
|
||||
*/
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
|
@ -1432,7 +1418,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||
free_fn = png_ptr->free_fn;
|
||||
#endif
|
||||
|
||||
png_memset(png_ptr, 0, png_sizeof (png_struct));
|
||||
png_memset(png_ptr, 0, png_sizeof(png_struct));
|
||||
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
|
@ -1442,7 +1428,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1450,7 +1436,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||
void PNGAPI
|
||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->read_row_fn = read_row_fn;
|
||||
}
|
||||
|
||||
|
@ -1464,7 +1450,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||
{
|
||||
int row;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel from opacity to transparency
|
||||
*/
|
||||
|
@ -1477,7 +1463,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||
*/
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
|
||||
png_error(png_ptr,"Image is too high to process with png_read_png()");
|
||||
png_error(png_ptr, "Image is too high to process with png_read_png()");
|
||||
|
||||
/* -------------- image transformations start here ------------------- */
|
||||
|
||||
|
@ -1584,7 +1570,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
#endif
|
||||
if(info_ptr->row_pointers == NULL)
|
||||
if (info_ptr->row_pointers == NULL)
|
||||
{
|
||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||
info_ptr->height * png_sizeof(png_bytep));
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.2.13 November 13, 2006
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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,7 +17,6 @@
|
|||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED)
|
||||
|
||||
/* Read the data from whatever input you are using. The default routine
|
||||
|
@ -28,7 +27,7 @@
|
|||
void /* PRIVATE */
|
||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4,"reading %d bytes\n", (int)length);
|
||||
png_debug1(4, "reading %d bytes\n", (int)length);
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
|
@ -46,7 +45,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
{
|
||||
png_size_t check;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
|
@ -77,7 +76,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
png_byte *n_data;
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
@ -106,7 +105,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
err = fread(buf, (png_size_t)1, read, io_ptr);
|
||||
#endif
|
||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
||||
if(err != read)
|
||||
if (err != read)
|
||||
break;
|
||||
else
|
||||
check += err;
|
||||
|
@ -138,7 +137,7 @@ void PNGAPI
|
|||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr read_data_fn)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.2.22 [October 13, 2007]
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*
|
||||
|
@ -15,7 +15,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. */
|
||||
|
@ -24,7 +23,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
|||
{
|
||||
png_debug(1, "in png_set_crc_action\n");
|
||||
/* Tell libpng how we react to CRC errors in critical chunks */
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
switch (crit_action)
|
||||
{
|
||||
case PNG_CRC_NO_CHANGE: /* leave setting as is */
|
||||
|
@ -39,7 +38,8 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
|||
PNG_FLAG_CRC_CRITICAL_IGNORE;
|
||||
break;
|
||||
case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */
|
||||
png_warning(png_ptr, "Can't discard critical data on CRC error.");
|
||||
png_warning(png_ptr,
|
||||
"Can't discard critical data on CRC error.");
|
||||
case PNG_CRC_ERROR_QUIT: /* error/quit */
|
||||
case PNG_CRC_DEFAULT:
|
||||
default:
|
||||
|
@ -81,7 +81,7 @@ png_set_background(png_structp png_ptr,
|
|||
int need_expand, double background_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_background\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
{
|
||||
png_warning(png_ptr, "Application must supply a known background gamma");
|
||||
|
@ -103,7 +103,7 @@ void PNGAPI
|
|||
png_set_strip_16(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
}
|
||||
#endif
|
||||
|
@ -113,7 +113,7 @@ void PNGAPI
|
|||
png_set_strip_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
@ -143,7 +143,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
int full_dither)
|
||||
{
|
||||
png_debug(1, "in png_set_dither\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_DITHER;
|
||||
|
||||
if (!full_dither)
|
||||
|
@ -151,7 +151,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
int i;
|
||||
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = (png_byte)i;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
|
||||
/* initialize an array to sort colors */
|
||||
png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
|
||||
/* initialize the dither_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
|
@ -274,7 +274,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
}
|
||||
}
|
||||
png_free(png_ptr, png_ptr->dither_sort);
|
||||
png_ptr->dither_sort=NULL;
|
||||
png_ptr->dither_sort = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -292,13 +292,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
png_dsortp t;
|
||||
png_dsortpp hash;
|
||||
|
||||
t=NULL;
|
||||
t = NULL;
|
||||
|
||||
/* initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof(png_byte)));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
|
@ -308,10 +308,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
}
|
||||
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
|
||||
png_sizeof (png_dsortp)));
|
||||
png_sizeof(png_dsortp)));
|
||||
for (i = 0; i < 769; i++)
|
||||
hash[i] = NULL;
|
||||
/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */
|
||||
/* png_memset(hash, 0, 769 * png_sizeof(png_dsortp)); */
|
||||
|
||||
num_new_palette = num_palette;
|
||||
|
||||
|
@ -436,8 +436,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
png_free(png_ptr, hash);
|
||||
png_free(png_ptr, png_ptr->palette_to_index);
|
||||
png_free(png_ptr, png_ptr->index_to_palette);
|
||||
png_ptr->palette_to_index=NULL;
|
||||
png_ptr->index_to_palette=NULL;
|
||||
png_ptr->palette_to_index = NULL;
|
||||
png_ptr->index_to_palette = NULL;
|
||||
}
|
||||
num_palette = maximum_colors;
|
||||
}
|
||||
|
@ -459,10 +459,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
|
||||
(png_uint_32)(num_entries * png_sizeof (png_byte)));
|
||||
(png_uint_32)(num_entries * png_sizeof(png_byte)));
|
||||
|
||||
png_memset(png_ptr->palette_lookup, 0, num_entries *
|
||||
png_sizeof (png_byte));
|
||||
png_sizeof(png_byte));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
png_sizeof(png_byte)));
|
||||
|
@ -527,7 +527,7 @@ void PNGAPI
|
|||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_gamma\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
|
@ -546,11 +546,9 @@ void PNGAPI
|
|||
png_set_expand(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* GRR 19990627: the following three functions currently are identical
|
||||
|
@ -575,11 +573,9 @@ void PNGAPI
|
|||
png_set_palette_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_palette_to_rgb\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(PNG_1_0_X)
|
||||
|
@ -588,11 +584,9 @@ 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");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -603,7 +597,7 @@ 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");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
}
|
||||
#endif
|
||||
|
@ -615,9 +609,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_tRNS_to_alpha\n");
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
#endif
|
||||
}
|
||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||
|
||||
|
@ -627,9 +619,7 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb\n");
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -645,7 +635,7 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
|||
{
|
||||
int red_fixed = (int)((float)red*100000.0 + 0.5);
|
||||
int green_fixed = (int)((float)green*100000.0 + 0.5);
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
|
||||
}
|
||||
#endif
|
||||
|
@ -655,7 +645,7 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||
png_fixed_point red, png_fixed_point green)
|
||||
{
|
||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
switch(error_action)
|
||||
{
|
||||
case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
|
||||
|
@ -669,18 +659,19 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||
png_ptr->transformations |= PNG_EXPAND;
|
||||
#else
|
||||
{
|
||||
png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
|
||||
png_warning(png_ptr,
|
||||
"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
|
||||
png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
png_uint_16 red_int, green_int;
|
||||
if(red < 0 || green < 0)
|
||||
if (red < 0 || green < 0)
|
||||
{
|
||||
red_int = 6968; /* .212671 * 32768 + .5 */
|
||||
green_int = 23434; /* .715160 * 32768 + .5 */
|
||||
}
|
||||
else if(red + green < 100000L)
|
||||
else if (red + green < 100000L)
|
||||
{
|
||||
red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
|
||||
green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
|
||||
|
@ -693,7 +684,8 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||
}
|
||||
png_ptr->rgb_to_gray_red_coeff = red_int;
|
||||
png_ptr->rgb_to_gray_green_coeff = green_int;
|
||||
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int);
|
||||
png_ptr->rgb_to_gray_blue_coeff =
|
||||
(png_uint_16)(32768 - red_int - green_int);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -706,13 +698,13 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
|||
read_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||
#endif
|
||||
#ifdef PNG_LEGACY_SUPPORTED
|
||||
if(read_user_transform_fn)
|
||||
if (read_user_transform_fn)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transforms");
|
||||
#endif
|
||||
|
@ -727,7 +719,7 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
{
|
||||
png_debug(1, "in png_init_read_transformations\n");
|
||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||
if(png_ptr != NULL)
|
||||
if (png_ptr != NULL)
|
||||
#endif
|
||||
{
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \
|
||||
|
@ -828,7 +820,7 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
{
|
||||
/* invert the alpha channel (in tRNS) unless the pixels are
|
||||
going to be expanded, in which case leave it for later */
|
||||
int i,istop;
|
||||
int i, istop;
|
||||
istop=(int)png_ptr->num_trans;
|
||||
for (i=0; i<istop; i++)
|
||||
png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]);
|
||||
|
@ -849,7 +841,7 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
&& (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0)
|
||||
< PNG_GAMMA_THRESHOLD))
|
||||
{
|
||||
int i,k;
|
||||
int i, k;
|
||||
k=0;
|
||||
for (i=0; i<png_ptr->num_trans; i++)
|
||||
{
|
||||
|
@ -964,6 +956,14 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
||||
}
|
||||
}
|
||||
/* Prevent the transformations being done again, and make sure
|
||||
* that the now spurious alpha channel is stripped - the code
|
||||
* has just reduced background composition and gamma correction
|
||||
* to a simple alpha channel strip.
|
||||
*/
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||
png_ptr->transformations &= ~PNG_GAMMA;
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
}
|
||||
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
|
||||
else
|
||||
|
@ -1038,6 +1038,9 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
palette[i].green = png_ptr->gamma_table[palette[i].green];
|
||||
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
||||
}
|
||||
|
||||
/* Done the gamma correction. */
|
||||
png_ptr->transformations &= ~PNG_GAMMA;
|
||||
}
|
||||
}
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
|
@ -1075,6 +1078,10 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
png_ptr->trans[i], back.blue);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handled alpha, still need to strip the channel. */
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
}
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
|
||||
|
@ -1105,7 +1112,7 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
}
|
||||
#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
|
||||
&& !defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if(png_ptr)
|
||||
if (png_ptr)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
@ -1123,7 +1130,8 @@ 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 &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
else
|
||||
info_ptr->color_type = PNG_COLOR_TYPE_RGB;
|
||||
|
@ -1136,8 +1144,10 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||
{
|
||||
if (png_ptr->transformations & PNG_EXPAND_tRNS)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
#if 0 /* Removed from libpng-1.2.27 */
|
||||
else
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
#endif
|
||||
}
|
||||
if (info_ptr->bit_depth < 8)
|
||||
info_ptr->bit_depth = 8;
|
||||
|
@ -1231,11 +1241,11 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if(png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if(info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
info_ptr->bit_depth = png_ptr->user_transform_depth;
|
||||
if(info_ptr->channels < png_ptr->user_transform_channels)
|
||||
if (info_ptr->channels < png_ptr->user_transform_channels)
|
||||
info_ptr->channels = png_ptr->user_transform_channels;
|
||||
}
|
||||
#endif
|
||||
|
@ -1243,10 +1253,10 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
|||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width);
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
|
||||
|
||||
#if !defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if(png_ptr)
|
||||
if (png_ptr)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
@ -1265,7 +1275,7 @@ png_do_read_transformations(png_structp png_ptr)
|
|||
char msg[50];
|
||||
|
||||
png_snprintf2(msg, 50,
|
||||
"NULL row buffer for row %ld, pass %d", png_ptr->row_number,
|
||||
"NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number,
|
||||
png_ptr->pass);
|
||||
png_error(png_ptr, msg);
|
||||
#else
|
||||
|
@ -1316,13 +1326,13 @@ png_do_read_transformations(png_structp png_ptr)
|
|||
{
|
||||
int rgb_error =
|
||||
png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
if(rgb_error)
|
||||
if (rgb_error)
|
||||
{
|
||||
png_ptr->rgb_to_gray_status=1;
|
||||
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||
PNG_RGB_TO_GRAY_WARN)
|
||||
png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
||||
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||
PNG_RGB_TO_GRAY_ERR)
|
||||
png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
||||
}
|
||||
|
@ -1406,7 +1416,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
|||
{
|
||||
png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->dither_index);
|
||||
if(png_ptr->row_info.rowbytes == (png_uint_32)0)
|
||||
if (png_ptr->row_info.rowbytes == (png_uint_32)0)
|
||||
png_error(png_ptr, "png_do_dither returned rowbytes=0");
|
||||
}
|
||||
#endif
|
||||
|
@ -1468,7 +1478,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
|||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
{
|
||||
if(png_ptr->read_user_transform_fn != NULL)
|
||||
if (png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* user read transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
|
@ -1480,9 +1490,9 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
|||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if(png_ptr->user_transform_depth)
|
||||
if (png_ptr->user_transform_depth)
|
||||
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
|
||||
if(png_ptr->user_transform_channels)
|
||||
if (png_ptr->user_transform_channels)
|
||||
png_ptr->row_info.channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
|
||||
|
@ -1959,7 +1969,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
#endif
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
if(row_info->bit_depth == 8)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This changes the data from G to GX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
|
@ -1991,7 +2001,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
row_info->rowbytes = row_width * 2;
|
||||
}
|
||||
}
|
||||
else if(row_info->bit_depth == 16)
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
/* This changes the data from GG to GGXX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
|
@ -2031,7 +2041,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
} /* COLOR_TYPE == GRAY */
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
if(row_info->bit_depth == 8)
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
/* This changes the data from RGB to RGBX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
|
@ -2067,7 +2077,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
row_info->rowbytes = row_width * 4;
|
||||
}
|
||||
}
|
||||
else if(row_info->bit_depth == 16)
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
/* This changes the data from RRGGBB to RRGGBBXX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
|
@ -2194,7 +2204,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
|||
row_info->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2202,8 +2212,10 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
|||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
/* 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
|
||||
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008)
|
||||
* New link:
|
||||
* <http://www.poynton.com/notes/colour_and_gamma/>
|
||||
* Charles Poynton poynton at poynton.com
|
||||
*
|
||||
* Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
|
||||
*
|
||||
|
@ -2254,14 +2266,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
png_byte red = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte green = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte blue = png_ptr->gamma_to_1[*(sp++)];
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1[
|
||||
(rc*red+gc*green+bc*blue)>>15];
|
||||
(rc*red + gc*green + bc*blue)>>15];
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
*(dp++) = *(sp - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2274,13 +2286,13 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
{
|
||||
rgb_error |= 1;
|
||||
*(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
}
|
||||
else
|
||||
*(dp++) = *(sp-1);
|
||||
*(dp++) = *(sp - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2301,7 +2313,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
|
||||
if(red == green && red == blue)
|
||||
if (red == green && red == blue)
|
||||
w = red;
|
||||
else
|
||||
{
|
||||
|
@ -2335,7 +2347,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
|
@ -2358,7 +2370,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
png_byte red = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte green = png_ptr->gamma_to_1[*(sp++)];
|
||||
png_byte blue = png_ptr->gamma_to_1[*(sp++)];
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
*(dp++) = png_ptr->gamma_from_1
|
||||
[(rc*red + gc*green + bc*blue)>>15];
|
||||
|
@ -2375,7 +2387,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
png_byte red = *(sp++);
|
||||
png_byte green = *(sp++);
|
||||
png_byte blue = *(sp++);
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = *(sp++); /* alpha */
|
||||
|
@ -2398,7 +2410,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
|
||||
|
||||
if(red == green && red == blue)
|
||||
if (red == green && red == blue)
|
||||
w = red;
|
||||
else
|
||||
{
|
||||
|
@ -2432,7 +2444,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
||||
green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
||||
blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
|
||||
if(red != green || red != blue)
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
|
@ -2447,7 +2459,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
row_info->color_type &= ~PNG_COLOR_MASK_COLOR;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
return rgb_error;
|
||||
}
|
||||
|
@ -3365,7 +3377,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
|||
row_info->channels--;
|
||||
row_info->pixel_depth = (png_byte)(row_info->channels *
|
||||
row_info->bit_depth);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3824,7 +3836,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
dp = row + (row_info->rowbytes << 1) - 1;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*(sp-1) == gray_high && *(sp) == gray_low)
|
||||
if (*(sp - 1) == gray_high && *(sp) == gray_low)
|
||||
{
|
||||
*dp-- = 0;
|
||||
*dp-- = 0;
|
||||
|
@ -3903,7 +3915,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3956,7 +3968,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
|||
row_info->color_type = PNG_COLOR_TYPE_PALETTE;
|
||||
row_info->channels = 1;
|
||||
row_info->pixel_depth = row_info->bit_depth;
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||
palette_lookup != NULL && row_info->bit_depth == 8)
|
||||
|
@ -3985,7 +3997,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
|||
row_info->color_type = PNG_COLOR_TYPE_PALETTE;
|
||||
row_info->channels = 1;
|
||||
row_info->pixel_depth = row_info->bit_depth;
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
|
||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
dither_lookup && row_info->bit_depth == 8)
|
||||
|
@ -4054,7 +4066,7 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
if(png_ptr->screen_gamma > 0.000001)
|
||||
if (png_ptr->screen_gamma > 0.000001)
|
||||
g = 1.0 / png_ptr->screen_gamma;
|
||||
else
|
||||
g = png_ptr->gamma; /* probably doing rgb_to_gray */
|
||||
|
@ -4114,7 +4126,7 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
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_uint_32)(num * png_sizeof(png_uint_16p)));
|
||||
|
||||
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
|
||||
{
|
||||
|
@ -4124,7 +4136,7 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
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)));
|
||||
(png_uint_32)(256 * png_sizeof(png_uint_16)));
|
||||
}
|
||||
|
||||
g = 1.0 / g;
|
||||
|
@ -4154,7 +4166,7 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
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)));
|
||||
(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++)
|
||||
|
@ -4174,12 +4186,12 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
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_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)));
|
||||
(png_uint_32)(256 * png_sizeof(png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
|
@ -4191,18 +4203,18 @@ png_build_gamma_table(png_structp png_ptr)
|
|||
}
|
||||
}
|
||||
|
||||
if(png_ptr->screen_gamma > 0.000001)
|
||||
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_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)));
|
||||
(png_uint_32)(256 * png_sizeof(png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
|
@ -4267,11 +4279,11 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp+1);
|
||||
png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3);
|
||||
png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5);
|
||||
png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL);
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp+1) = (png_byte)(red & 0xff);
|
||||
*(rp+4) = (png_byte)((blue >> 8) & 0xff);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.2.24 [December 14, 2007]
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*
|
||||
|
@ -15,7 +15,6 @@
|
|||
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED)
|
||||
|
@ -168,13 +167,13 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
|||
gamma=21474.83;
|
||||
}
|
||||
else
|
||||
gamma=file_gamma;
|
||||
gamma = file_gamma;
|
||||
info_ptr->gamma = (float)gamma;
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
info_ptr->int_gamma = (int)(gamma*100000.+.5);
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
if(gamma == 0.0)
|
||||
if (gamma == 0.0)
|
||||
png_warning(png_ptr, "Setting gamma=0");
|
||||
}
|
||||
#endif
|
||||
|
@ -198,10 +197,10 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
|||
if (int_gamma < 0)
|
||||
{
|
||||
png_warning(png_ptr, "Setting negative gamma to zero");
|
||||
gamma=0;
|
||||
gamma = 0;
|
||||
}
|
||||
else
|
||||
gamma=int_gamma;
|
||||
gamma = int_gamma;
|
||||
}
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
info_ptr->gamma = (float)(gamma/100000.);
|
||||
|
@ -210,7 +209,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
|||
info_ptr->int_gamma = gamma;
|
||||
#endif
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
if(gamma == 0)
|
||||
if (gamma == 0)
|
||||
png_warning(png_ptr, "Setting gamma=0");
|
||||
}
|
||||
#endif
|
||||
|
@ -238,7 +237,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
|||
/* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH 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)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
|
||||
if (png_ptr->hist == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
|
||||
|
@ -319,21 +318,21 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||
* 4. The filter_method is 64 and
|
||||
* 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");
|
||||
if(filter_type != PNG_FILTER_TYPE_BASE)
|
||||
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");
|
||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
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_ALPHA)))
|
||||
png_error(png_ptr, "Unknown filter method in IHDR");
|
||||
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
|
||||
if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
|
||||
png_warning(png_ptr, "Invalid filter method in IHDR");
|
||||
}
|
||||
#else
|
||||
if(filter_type != PNG_FILTER_TYPE_BASE)
|
||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
||||
png_error(png_ptr, "Unknown filter method in IHDR");
|
||||
#endif
|
||||
|
||||
|
@ -363,7 +362,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||
- 8) /* extra max_pixel_depth pad */
|
||||
info_ptr->rowbytes = (png_size_t)0;
|
||||
else
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width);
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
|
||||
#if defined(PNG_APNG_SUPPORTED)
|
||||
/* for non-animated png. this may be overritten from an acTL chunk later */
|
||||
|
@ -401,13 +400,14 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||
return;
|
||||
|
||||
length = png_strlen(purpose) + 1;
|
||||
png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
|
||||
png_debug1(3, "allocating purpose for info (%lu bytes)\n",
|
||||
(unsigned long)length);
|
||||
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
|
||||
|
||||
png_debug(3, "storing X0, X1, type, and nparams in info\n");
|
||||
|
@ -417,35 +417,37 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
|||
info_ptr->pcal_nparams = (png_byte)nparams;
|
||||
|
||||
length = png_strlen(units) + 1;
|
||||
png_debug1(3, "allocating units for info (%lu bytes)\n", length);
|
||||
png_debug1(3, "allocating units for info (%lu bytes)\n",
|
||||
(unsigned long)length);
|
||||
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
if (info_ptr->pcal_units == NULL)
|
||||
{
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL units.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
|
||||
|
||||
info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
|
||||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL params.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr->pcal_params[nparams] = NULL;
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
length = png_strlen(params[i]) + 1;
|
||||
png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
|
||||
png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i,
|
||||
(unsigned long)length);
|
||||
info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
if (info_ptr->pcal_params[i] == NULL)
|
||||
{
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
|
||||
}
|
||||
|
||||
|
@ -487,26 +489,30 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
|||
info_ptr->scal_unit = (png_byte)unit;
|
||||
|
||||
length = png_strlen(swidth) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
png_debug1(3, "allocating unit for info (%u bytes)\n",
|
||||
(unsigned int)length);
|
||||
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
if (info_ptr->scal_s_width == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Memory allocation failed while processing sCAL.");
|
||||
return;
|
||||
}
|
||||
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
||||
|
||||
length = png_strlen(sheight) + 1;
|
||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
||||
png_debug1(3, "allocating unit for info (%u bytes)\n",
|
||||
(unsigned int)length);
|
||||
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
|
||||
if (info_ptr->scal_s_height == NULL)
|
||||
{
|
||||
png_free (png_ptr, info_ptr->scal_s_width);
|
||||
info_ptr->scal_s_width = NULL;
|
||||
png_warning(png_ptr,
|
||||
"Memory allocation failed while processing sCAL.");
|
||||
return;
|
||||
}
|
||||
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
|
@ -568,7 +574,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
|||
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
|
||||
png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH *
|
||||
png_sizeof(png_color));
|
||||
png_memcpy(png_ptr->palette, palette, num_palette * 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;
|
||||
|
||||
|
@ -590,7 +596,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8));
|
||||
png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));
|
||||
info_ptr->valid |= PNG_INFO_sBIT;
|
||||
}
|
||||
#endif
|
||||
|
@ -704,7 +710,8 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
|||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
png_free (png_ptr, new_iccp_name);
|
||||
png_warning(png_ptr, "Insufficient memory to process iCCP profile.");
|
||||
png_warning(png_ptr,
|
||||
"Insufficient memory to process iCCP profile.");
|
||||
return;
|
||||
}
|
||||
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
||||
|
@ -730,7 +737,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
int num_text)
|
||||
{
|
||||
int ret;
|
||||
ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
|
||||
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
|
||||
if (ret)
|
||||
png_error(png_ptr, "Insufficient memory to store text");
|
||||
}
|
||||
|
@ -761,7 +768,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
||||
old_text = info_ptr->text;
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
|
||||
(png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
|
||||
if (info_ptr->text == NULL)
|
||||
{
|
||||
png_free(png_ptr, old_text);
|
||||
|
@ -776,7 +783,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
info_ptr->max_text = num_text + 8;
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
|
||||
(png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
|
||||
if (info_ptr->text == NULL)
|
||||
return(1);
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
|
@ -788,8 +795,8 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
}
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_size_t text_length,key_len;
|
||||
png_size_t lang_len,lang_key_len;
|
||||
png_size_t text_length, key_len;
|
||||
png_size_t lang_len, lang_key_len;
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
|
||||
if (text_ptr[i].key == NULL)
|
||||
|
@ -797,7 +804,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
|
||||
key_len = png_strlen(text_ptr[i].key);
|
||||
|
||||
if(text_ptr[i].compression <= 0)
|
||||
if (text_ptr[i].compression <= 0)
|
||||
{
|
||||
lang_len = 0;
|
||||
lang_key_len = 0;
|
||||
|
@ -826,7 +833,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
{
|
||||
text_length = 0;
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(text_ptr[i].compression > 0)
|
||||
if (text_ptr[i].compression > 0)
|
||||
textp->compression = PNG_ITXT_COMPRESSION_NONE;
|
||||
else
|
||||
#endif
|
||||
|
@ -839,26 +846,28 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
}
|
||||
|
||||
textp->key = (png_charp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
(png_uint_32)
|
||||
(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
if (textp->key == NULL)
|
||||
return(1);
|
||||
png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
|
||||
(png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
(png_uint_32)
|
||||
(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
(int)textp->key);
|
||||
|
||||
png_memcpy(textp->key, text_ptr[i].key,
|
||||
(png_size_t)(key_len));
|
||||
*(textp->key+key_len) = '\0';
|
||||
*(textp->key + key_len) = '\0';
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if (text_ptr[i].compression > 0)
|
||||
{
|
||||
textp->lang=textp->key + key_len + 1;
|
||||
textp->lang = textp->key + key_len + 1;
|
||||
png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
|
||||
*(textp->lang+lang_len) = '\0';
|
||||
textp->lang_key=textp->lang + lang_len + 1;
|
||||
*(textp->lang + lang_len) = '\0';
|
||||
textp->lang_key = textp->lang + lang_len + 1;
|
||||
png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
|
||||
*(textp->lang_key+lang_key_len) = '\0';
|
||||
textp->text=textp->lang_key + lang_key_len + 1;
|
||||
*(textp->lang_key + lang_key_len) = '\0';
|
||||
textp->text = textp->lang_key + lang_key_len + 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -867,15 +876,15 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
textp->lang=NULL;
|
||||
textp->lang_key=NULL;
|
||||
#endif
|
||||
textp->text=textp->key + key_len + 1;
|
||||
textp->text = textp->key + key_len + 1;
|
||||
}
|
||||
if(text_length)
|
||||
if (text_length)
|
||||
png_memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
*(textp->text+text_length) = '\0';
|
||||
*(textp->text + text_length) = '\0';
|
||||
|
||||
#ifdef PNG_iTXt_SUPPORTED
|
||||
if(textp->compression > 0)
|
||||
if (textp->compression > 0)
|
||||
{
|
||||
textp->text_length = 0;
|
||||
textp->itxt_length = text_length;
|
||||
|
@ -904,7 +913,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
|||
(png_ptr->mode & PNG_WROTE_tIME))
|
||||
return;
|
||||
|
||||
png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time));
|
||||
png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
|
||||
info_ptr->valid |= PNG_INFO_tIME;
|
||||
}
|
||||
#endif
|
||||
|
@ -925,30 +934,45 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*/
|
||||
|
||||
#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 */
|
||||
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)
|
||||
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (trans_values != NULL)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
(int)trans_values->gray > sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
((int)trans_values->red > sample_max ||
|
||||
(int)trans_values->green > sample_max ||
|
||||
(int)trans_values->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
png_memcpy(&(info_ptr->trans_values), trans_values,
|
||||
png_sizeof(png_color_16));
|
||||
if (num_trans == 0)
|
||||
num_trans = 1;
|
||||
}
|
||||
|
||||
info_ptr->num_trans = (png_uint_16)num_trans;
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
if (num_trans != 0)
|
||||
{
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
#else
|
||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -956,6 +980,13 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||
void PNGAPI
|
||||
png_set_sPLT(png_structp png_ptr,
|
||||
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||
/*
|
||||
* entries - array of png_sPLT_t structures
|
||||
* to be added to the list of palettes
|
||||
* in the info structure.
|
||||
* nentries - number of palette structures to be
|
||||
* added.
|
||||
*/
|
||||
{
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
@ -964,7 +995,8 @@ png_set_sPLT(png_structp png_ptr,
|
|||
return;
|
||||
|
||||
np = (png_sPLT_tp)png_malloc_warn(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
|
||||
(info_ptr->splt_palettes_num + nentries) *
|
||||
(png_uint_32)png_sizeof(png_sPLT_t));
|
||||
if (np == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "No memory for sPLT palettes.");
|
||||
|
@ -988,16 +1020,18 @@ png_set_sPLT(png_structp png_ptr,
|
|||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing sPLT chunk");
|
||||
continue;
|
||||
}
|
||||
png_memcpy(to->name, from->name, length);
|
||||
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||
from->nentries * png_sizeof(png_sPLT_entry));
|
||||
(png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry)));
|
||||
if (to->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing sPLT chunk");
|
||||
png_free(png_ptr,to->name);
|
||||
png_free(png_ptr, to->name);
|
||||
to->name = NULL;
|
||||
continue;
|
||||
}
|
||||
png_memcpy(to->entries, from->entries,
|
||||
from->nentries * png_sizeof(png_sPLT_entry));
|
||||
|
@ -1161,8 +1195,8 @@ png_set_unknown_chunks(png_structp png_ptr,
|
|||
return;
|
||||
|
||||
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
png_sizeof(png_unknown_chunk));
|
||||
(png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) *
|
||||
png_sizeof(png_unknown_chunk)));
|
||||
if (np == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
|
@ -1177,28 +1211,32 @@ png_set_unknown_chunks(png_structp png_ptr,
|
|||
|
||||
for (i = 0; i < num_unknowns; i++)
|
||||
{
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_unknown_chunkp from = unknowns + i;
|
||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||
png_unknown_chunkp from = unknowns + i;
|
||||
|
||||
png_memcpy((png_charp)to->name,
|
||||
(png_charp)from->name,
|
||||
png_sizeof(from->name));
|
||||
to->name[png_sizeof(to->name)-1] = '\0';
|
||||
png_memcpy((png_charp)to->name,
|
||||
(png_charp)from->name,
|
||||
png_sizeof(from->name));
|
||||
to->name[png_sizeof(to->name)-1] = '\0';
|
||||
to->size = from->size;
|
||||
/* note our location in the read or write sequence */
|
||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||
|
||||
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
|
||||
if (to->data == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
if (from->size == 0)
|
||||
to->data=NULL;
|
||||
else
|
||||
{
|
||||
to->data = (png_bytep)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)from->size);
|
||||
if (to->data == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing unknown chunk.");
|
||||
}
|
||||
else
|
||||
{
|
||||
png_memcpy(to->data, from->data, from->size);
|
||||
to->size = from->size;
|
||||
|
||||
/* note our location in the read or write sequence */
|
||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||
}
|
||||
to->size = 0;
|
||||
}
|
||||
else
|
||||
png_memcpy(to->data, from->data, from->size);
|
||||
}
|
||||
}
|
||||
|
||||
info_ptr->unknown_chunks = np;
|
||||
|
@ -1211,7 +1249,7 @@ void PNGAPI
|
|||
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||
int chunk, int location)
|
||||
{
|
||||
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||
if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
|
||||
(int)info_ptr->unknown_chunks_num)
|
||||
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
|
||||
}
|
||||
|
@ -1259,12 +1297,12 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
|||
return;
|
||||
if (num_chunks == 0)
|
||||
{
|
||||
if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
|
||||
|
||||
if(keep == PNG_HANDLE_CHUNK_ALWAYS)
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS)
|
||||
png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
else
|
||||
png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
|
||||
|
@ -1272,22 +1310,23 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
|||
}
|
||||
if (chunk_list == NULL)
|
||||
return;
|
||||
old_num_chunks=png_ptr->num_chunk_list;
|
||||
old_num_chunks = png_ptr->num_chunk_list;
|
||||
new_list=(png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(5*(num_chunks+old_num_chunks)));
|
||||
if(png_ptr->chunk_list != NULL)
|
||||
(png_uint_32)
|
||||
(5*(num_chunks + old_num_chunks)));
|
||||
if (png_ptr->chunk_list != NULL)
|
||||
{
|
||||
png_memcpy(new_list, png_ptr->chunk_list,
|
||||
(png_size_t)(5*old_num_chunks));
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
}
|
||||
png_memcpy(new_list+5*old_num_chunks, chunk_list,
|
||||
png_memcpy(new_list + 5*old_num_chunks, chunk_list,
|
||||
(png_size_t)(5*num_chunks));
|
||||
for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
|
||||
for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
|
||||
*p=(png_byte)keep;
|
||||
png_ptr->num_chunk_list=old_num_chunks+num_chunks;
|
||||
png_ptr->chunk_list=new_list;
|
||||
png_ptr->num_chunk_list = old_num_chunks + num_chunks;
|
||||
png_ptr->chunk_list = new_list;
|
||||
#ifdef PNG_FREE_ME_SUPPORTED
|
||||
png_ptr->free_me |= PNG_FREE_LIST;
|
||||
#endif
|
||||
|
@ -1316,22 +1355,22 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
|
||||
info_ptr->row_pointers = row_pointers;
|
||||
if(row_pointers)
|
||||
if (row_pointers)
|
||||
info_ptr->valid |= PNG_INFO_IDAT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
||||
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_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf_size = (png_size_t)size;
|
||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
|
@ -1356,6 +1395,7 @@ png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
|||
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->asm_flags = 0;
|
||||
asm_flags = asm_flags; /* Quiet the compiler */
|
||||
}
|
||||
|
||||
/* this function was added to libpng 1.2.0 */
|
||||
|
@ -1367,6 +1407,9 @@ png_set_mmx_thresholds (png_structp png_ptr,
|
|||
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
/* Quiet the compiler */
|
||||
mmx_bitdepth_threshold = mmx_bitdepth_threshold;
|
||||
mmx_rowbytes_threshold = mmx_rowbytes_threshold;
|
||||
}
|
||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||
|
||||
|
@ -1380,7 +1423,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
|||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||
* regardless of dimensions, set both limits to 0x7ffffffL.
|
||||
*/
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->user_width_max = user_width_max;
|
||||
png_ptr->user_height_max = user_height_max;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.2.17 May 15, 2007
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
||||
#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
|
||||
png_set_bgr(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_bgr\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_BGR;
|
||||
}
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@ void PNGAPI
|
|||
png_set_swap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (png_ptr->bit_depth == 16)
|
||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void PNGAPI
|
|||
png_set_packing(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packing\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
|
@ -56,7 +56,7 @@ void PNGAPI
|
|||
png_set_packswap(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_packswap\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (png_ptr->bit_depth < 8)
|
||||
png_ptr->transformations |= PNG_PACKSWAP;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void PNGAPI
|
|||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_shift\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_SHIFT;
|
||||
png_ptr->shift = *true_bits;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void PNGAPI
|
|||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_filler\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_FILLER;
|
||||
png_ptr->filler = (png_byte)filler;
|
||||
if (filler_loc == PNG_FILLER_AFTER)
|
||||
|
@ -132,7 +132,7 @@ void PNGAPI
|
|||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||
{
|
||||
png_debug(1, "in png_set_add_alpha\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_set_filler(png_ptr, filler, filler_loc);
|
||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void PNGAPI
|
|||
png_set_swap_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_swap_alpha\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
@ -157,7 +157,7 @@ void PNGAPI
|
|||
png_set_invert_alpha(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_alpha\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
@ -167,7 +167,7 @@ void PNGAPI
|
|||
png_set_invert_mono(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_invert_mono\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||
}
|
||||
|
||||
|
@ -631,13 +631,13 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
|||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||
{
|
||||
png_debug(1, "in png_set_user_transform_info\n");
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
#else
|
||||
if(user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
if (user_transform_ptr || user_transform_depth || user_transform_channels)
|
||||
png_warning(png_ptr,
|
||||
"This version of libpng does not support user transform info");
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.2.13 November 13, 2006
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*
|
||||
|
@ -45,7 +45,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
{
|
||||
png_uint_32 check;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#if defined(_WIN32_WCE)
|
||||
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||
check = 0;
|
||||
|
@ -71,7 +71,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||
png_FILE_p io_ptr;
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
|
@ -134,7 +134,7 @@ png_default_flush(png_structp png_ptr)
|
|||
#if !defined(_WIN32_WCE)
|
||||
png_FILE_p io_ptr;
|
||||
#endif
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#if !defined(_WIN32_WCE)
|
||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||
if (io_ptr != NULL)
|
||||
|
@ -170,7 +170,7 @@ void PNGAPI
|
|||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_ptr->io_ptr = io_ptr;
|
||||
|
||||
#if !defined(PNG_NO_STDIO)
|
||||
|
@ -206,27 +206,27 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
|||
|
||||
#if defined(USE_FAR_KEYWORD)
|
||||
#if defined(_MSC_VER)
|
||||
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
if(check != 0)
|
||||
if(FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||
png_error(png_ptr,"segment lost in conversion");
|
||||
if (check != 0)
|
||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
return(near_ptr);
|
||||
}
|
||||
# else
|
||||
void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||
void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
|
||||
{
|
||||
void *near_ptr;
|
||||
void FAR *far_ptr;
|
||||
near_ptr = (void FAR *)ptr;
|
||||
far_ptr = (void FAR *)near_ptr;
|
||||
if(check != 0)
|
||||
if(far_ptr != ptr)
|
||||
png_error(png_ptr,"segment lost in conversion");
|
||||
if (check != 0)
|
||||
if (far_ptr != ptr)
|
||||
png_error(png_ptr, "segment lost in conversion");
|
||||
return(near_ptr);
|
||||
}
|
||||
# endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.2.24 December 14, 2007
|
||||
* Last changed in libpng 1.2.31 [August 21, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
@ -32,9 +32,9 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
|||
{
|
||||
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))
|
||||
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");
|
||||
png_ptr->mng_features_permitted=0;
|
||||
}
|
||||
#endif
|
||||
|
@ -112,6 +112,8 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
|||
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||
{
|
||||
if (up->size == 0)
|
||||
png_warning(png_ptr, "Writing zero-length unknown chunk");
|
||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||
}
|
||||
}
|
||||
|
@ -399,6 +401,18 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
|||
|
||||
/* write end of PNG file */
|
||||
png_write_IEND(png_ptr);
|
||||
/* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
|
||||
* and restored again in libpng-1.2.30, may cause some applications that
|
||||
* do not set png_ptr->output_flush_fn to crash. If your application
|
||||
* experiences a problem, please try building libpng with
|
||||
* PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to
|
||||
* png-mng-implement at lists.sf.net . This kludge will be removed
|
||||
* from libpng-1.4.0.
|
||||
*/
|
||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED) && \
|
||||
defined(PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED)
|
||||
png_flush(png_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||
|
@ -445,7 +459,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
{
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_structp png_ptr;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
volatile
|
||||
#endif
|
||||
png_structp png_ptr;
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
jmp_buf jmpbuf;
|
||||
|
@ -476,12 +493,12 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
#endif
|
||||
{
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_ptr->zbuf=NULL;
|
||||
png_ptr->zbuf=NULL;
|
||||
png_destroy_struct(png_ptr);
|
||||
return (NULL);
|
||||
}
|
||||
#ifdef USE_FAR_KEYWORD
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -490,12 +507,15 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
i=0;
|
||||
do
|
||||
if (user_png_ver)
|
||||
{
|
||||
if(user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
i=0;
|
||||
do
|
||||
{
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
}
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||
{
|
||||
|
@ -550,7 +570,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
#ifdef USE_FAR_KEYWORD
|
||||
if (setjmp(jmpbuf))
|
||||
PNG_ABORT();
|
||||
png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
|
||||
#else
|
||||
if (setjmp(png_ptr->jmpbuf))
|
||||
PNG_ABORT();
|
||||
|
@ -575,9 +595,9 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||
png_size_t png_struct_size, png_size_t png_info_size)
|
||||
{
|
||||
/* We only come here via pre-1.0.12-compiled applications */
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
#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];
|
||||
|
@ -595,7 +615,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||
png_warning(png_ptr, msg);
|
||||
}
|
||||
#endif
|
||||
if(png_sizeof(png_struct) > png_struct_size)
|
||||
if (png_sizeof(png_struct) > png_struct_size)
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
|
@ -604,7 +624,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||
png_error(png_ptr,
|
||||
"The png struct allocated by the application for writing is too small.");
|
||||
}
|
||||
if(png_sizeof(png_info) > png_info_size)
|
||||
if (png_sizeof(png_info) > png_info_size)
|
||||
{
|
||||
png_ptr->error_fn=NULL;
|
||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||
|
@ -641,7 +661,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
#else
|
||||
png_ptr->warning_fn=NULL;
|
||||
png_warning(png_ptr,
|
||||
"Application uses deprecated png_write_init() and should be recompiled.");
|
||||
"Application uses deprecated png_write_init() and should be recompiled.");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -651,7 +671,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* save jump buffer and error functions */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
if (png_sizeof(png_struct) > png_struct_size)
|
||||
|
@ -662,7 +682,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
}
|
||||
|
||||
/* reset all variables to 0 */
|
||||
png_memset(png_ptr, 0, png_sizeof (png_struct));
|
||||
png_memset(png_ptr, 0, png_sizeof(png_struct));
|
||||
|
||||
/* added at libpng-1.2.6 */
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
@ -672,7 +692,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* restore jump buffer */
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
|
||||
|
@ -906,7 +926,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
|
|||
* 4. The filter_method is 64 and
|
||||
* 5. The color_type is RGB or RGBA
|
||||
*/
|
||||
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
{
|
||||
/* Intrapixel differencing */
|
||||
|
@ -1008,21 +1028,32 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
free_fn = png_ptr->free_fn;
|
||||
mem_ptr = png_ptr->mem_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (info_ptr_ptr != NULL)
|
||||
info_ptr = *info_ptr_ptr;
|
||||
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
|
||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
png_ptr->num_chunk_list=0;
|
||||
}
|
||||
if (png_ptr->num_chunk_list)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->chunk_list);
|
||||
png_ptr->chunk_list=NULL;
|
||||
png_ptr->num_chunk_list = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
|
||||
|
@ -1068,7 +1099,7 @@ png_write_destroy(png_structp png_ptr)
|
|||
/* free our memory. png_free checks NULL for us. */
|
||||
png_free(png_ptr, png_ptr->zbuf);
|
||||
png_free(png_ptr, png_ptr->row_buf);
|
||||
#ifndef PNG_NO_WRITE_FILTERING
|
||||
#ifndef PNG_NO_WRITE_FILTER
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->sub_row);
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
|
@ -1090,7 +1121,7 @@ png_write_destroy(png_structp png_ptr)
|
|||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
/* reset structure */
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
|
||||
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
|
||||
error_fn = png_ptr->error_fn;
|
||||
|
@ -1100,7 +1131,7 @@ png_write_destroy(png_structp png_ptr)
|
|||
free_fn = png_ptr->free_fn;
|
||||
#endif
|
||||
|
||||
png_memset(png_ptr, 0, png_sizeof (png_struct));
|
||||
png_memset(png_ptr, 0, png_sizeof(png_struct));
|
||||
|
||||
png_ptr->error_fn = error_fn;
|
||||
png_ptr->warning_fn = warning_fn;
|
||||
|
@ -1110,7 +1141,7 @@ png_write_destroy(png_structp png_ptr)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1153,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||
if (png_ptr == NULL)
|
||||
return;
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(method == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
method = PNG_FILTER_TYPE_BASE;
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,7 @@ png_do_write_transformations(png_structp png_ptr)
|
|||
|
||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if(png_ptr->write_user_transform_fn != NULL)
|
||||
if (png_ptr->write_user_transform_fn != NULL)
|
||||
(*(png_ptr->write_user_transform_fn)) /* user write transform function */
|
||||
(png_ptr, /* png_ptr */
|
||||
&(png_ptr->row_info), /* row_info: */
|
||||
|
@ -558,8 +558,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
png_uint_32 s0 = (*(rp ) << 8) | *(rp+1);
|
||||
png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3);
|
||||
png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5);
|
||||
png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp+1) = (png_byte)(red & 0xff);
|
||||
*(rp+4) = (png_byte)((blue >> 8) & 0xff);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.2.20 Septhember 3, 2007
|
||||
* Last changed in libpng 1.2.30 [August 13, 2008]
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2008 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.)
|
||||
*/
|
||||
|
@ -49,6 +49,24 @@ png_save_uint_16(png_bytep buf, unsigned int i)
|
|||
buf[1] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
/* Simple function to write the signature. If we have already written
|
||||
* the magic bytes of the signature, or more likely, the PNG stream is
|
||||
* being embedded into another stream and doesn't need its own signature,
|
||||
* we should call png_set_sig_bytes() to tell libpng how many of the
|
||||
* bytes have already been written.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_write_sig(png_structp png_ptr)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
/* write the rest of the 8 byte signature */
|
||||
png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
|
||||
(png_size_t)(8 - png_ptr->sig_bytes));
|
||||
if (png_ptr->sig_bytes < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
/* Write a PNG chunk all at once. The type is an array of ASCII characters
|
||||
* representing the chunk name. The array must be at least 4 bytes in
|
||||
* length, and does not need to be null terminated. To be safe, pass the
|
||||
|
@ -62,9 +80,9 @@ void PNGAPI
|
|||
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_bytep data, png_size_t length)
|
||||
{
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
|
||||
png_write_chunk_data(png_ptr, data, length);
|
||||
png_write_chunk_data(png_ptr, data, (png_size_t)length);
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
|
||||
|
@ -76,16 +94,18 @@ void PNGAPI
|
|||
png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
||||
png_uint_32 length)
|
||||
{
|
||||
png_byte buf[4];
|
||||
png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
|
||||
if(png_ptr == NULL) return;
|
||||
png_byte buf[8];
|
||||
|
||||
/* write the length */
|
||||
png_debug2(0, "Writing %s chunk, length = %lu\n", chunk_name,
|
||||
(unsigned long)length);
|
||||
if (png_ptr == NULL) return;
|
||||
|
||||
/* write the length and the chunk name */
|
||||
png_save_uint_32(buf, length);
|
||||
png_write_data(png_ptr, buf, (png_size_t)4);
|
||||
|
||||
/* write the chunk name */
|
||||
png_write_data(png_ptr, chunk_name, (png_size_t)4);
|
||||
png_memcpy(buf + 4, chunk_name, 4);
|
||||
png_write_data(png_ptr, buf, (png_size_t)8);
|
||||
/* put the chunk name into png_ptr->chunk_name */
|
||||
png_memcpy(png_ptr->chunk_name, chunk_name, 4);
|
||||
/* reset the crc and run it over the chunk name */
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, chunk_name, (png_size_t)4);
|
||||
|
@ -100,11 +120,14 @@ void PNGAPI
|
|||
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
/* write the data, and run the CRC over it */
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
if (data != NULL && length > 0)
|
||||
{
|
||||
png_calculate_crc(png_ptr, data, length);
|
||||
png_write_data(png_ptr, data, length);
|
||||
/* update the CRC after writing the data,
|
||||
* in case that the user I/O routine alters it.
|
||||
*/
|
||||
png_calculate_crc(png_ptr, data, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,31 +137,14 @@ png_write_chunk_end(png_structp png_ptr)
|
|||
{
|
||||
png_byte buf[4];
|
||||
|
||||
if(png_ptr == NULL) return;
|
||||
if (png_ptr == NULL) return;
|
||||
|
||||
/* write the crc */
|
||||
/* write the crc in a single operation */
|
||||
png_save_uint_32(buf, png_ptr->crc);
|
||||
|
||||
png_write_data(png_ptr, buf, (png_size_t)4);
|
||||
}
|
||||
|
||||
/* Simple function to write the signature. If we have already written
|
||||
* the magic bytes of the signature, or more likely, the PNG stream is
|
||||
* being embedded into another stream and doesn't need its own signature,
|
||||
* we should call png_set_sig_bytes() to tell libpng how many of the
|
||||
* bytes have already been written.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_write_sig(png_structp png_ptr)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
/* write the rest of the 8 byte signature */
|
||||
png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
|
||||
(png_size_t)8 - png_ptr->sig_bytes);
|
||||
if(png_ptr->sig_bytes < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)
|
||||
/*
|
||||
* This pair of functions encapsulates the operation of (a) compressing a
|
||||
|
@ -239,20 +245,21 @@ png_text_compress(png_structp png_ptr,
|
|||
|
||||
old_ptr = comp->output_ptr;
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
(png_uint_32)(comp->max_output_ptr *
|
||||
png_sizeof (png_charpp)));
|
||||
(png_uint_32)
|
||||
(comp->max_output_ptr * png_sizeof(png_charpp)));
|
||||
png_memcpy(comp->output_ptr, old_ptr, old_max
|
||||
* png_sizeof (png_charp));
|
||||
* png_sizeof(png_charp));
|
||||
png_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
(png_uint_32)(comp->max_output_ptr *
|
||||
png_sizeof (png_charp)));
|
||||
(png_uint_32)
|
||||
(comp->max_output_ptr * png_sizeof(png_charp)));
|
||||
}
|
||||
|
||||
/* save the data */
|
||||
comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
|
||||
comp->output_ptr[comp->num_output_ptr] =
|
||||
(png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
|
@ -291,20 +298,21 @@ png_text_compress(png_structp png_ptr,
|
|||
/* This could be optimized to realloc() */
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
(png_uint_32)(comp->max_output_ptr *
|
||||
png_sizeof (png_charpp)));
|
||||
png_sizeof(png_charp)));
|
||||
png_memcpy(comp->output_ptr, old_ptr,
|
||||
old_max * png_sizeof (png_charp));
|
||||
old_max * png_sizeof(png_charp));
|
||||
png_free(png_ptr, old_ptr);
|
||||
}
|
||||
else
|
||||
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
|
||||
(png_uint_32)(comp->max_output_ptr *
|
||||
png_sizeof (png_charp)));
|
||||
png_sizeof(png_charp)));
|
||||
}
|
||||
|
||||
/* save off the data */
|
||||
comp->output_ptr[comp->num_output_ptr] =
|
||||
(png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size);
|
||||
(png_charp)png_malloc(png_ptr,
|
||||
(png_uint_32)png_ptr->zbuf_size);
|
||||
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
|
||||
png_ptr->zbuf_size);
|
||||
comp->num_output_ptr++;
|
||||
|
@ -349,18 +357,18 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
|
|||
/* write saved output buffers, if any */
|
||||
for (i = 0; i < comp->num_output_ptr; i++)
|
||||
{
|
||||
png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],
|
||||
png_ptr->zbuf_size);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i],
|
||||
(png_size_t)png_ptr->zbuf_size);
|
||||
png_free(png_ptr, comp->output_ptr[i]);
|
||||
comp->output_ptr[i]=NULL;
|
||||
comp->output_ptr[i]=NULL;
|
||||
}
|
||||
if (comp->max_output_ptr != 0)
|
||||
png_free(png_ptr, comp->output_ptr);
|
||||
comp->output_ptr=NULL;
|
||||
comp->output_ptr=NULL;
|
||||
/* write anything left in zbuf */
|
||||
if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
|
||||
png_write_chunk_data(png_ptr, png_ptr->zbuf,
|
||||
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
||||
(png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out));
|
||||
|
||||
/* reset zlib for another zTXt/iTXt or image data */
|
||||
deflateReset(&png_ptr->zstream);
|
||||
|
@ -380,6 +388,8 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||
PNG_IHDR;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
png_byte buf[13]; /* buffer to store the IHDR info */
|
||||
|
||||
png_debug(1, "in png_write_IHDR\n");
|
||||
|
@ -394,7 +404,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||
case 4:
|
||||
case 8:
|
||||
case 16: png_ptr->channels = 1; break;
|
||||
default: png_error(png_ptr,"Invalid bit depth for grayscale image");
|
||||
default: png_error(png_ptr, "Invalid bit depth for grayscale image");
|
||||
}
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
|
@ -494,7 +504,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||
buf[12] = (png_byte)interlace_type;
|
||||
|
||||
/* write the chunk */
|
||||
png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
|
||||
|
||||
#if defined(PNG_WRITE_APNG_SUPPORTED)
|
||||
png_ptr->first_frame_width = width;
|
||||
|
@ -528,10 +538,19 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||
png_ptr->zlib_window_bits = 15;
|
||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
|
||||
png_ptr->zlib_method = 8;
|
||||
if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
|
||||
png_ptr->zlib_method, png_ptr->zlib_window_bits,
|
||||
png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK)
|
||||
png_error(png_ptr, "zlib failed to initialize compressor");
|
||||
ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
|
||||
png_ptr->zlib_method, png_ptr->zlib_window_bits,
|
||||
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
|
||||
if (ret != Z_OK)
|
||||
{
|
||||
if (ret == Z_VERSION_ERROR) png_error(png_ptr,
|
||||
"zlib failed to initialize compressor -- version error");
|
||||
if (ret == Z_STREAM_ERROR) png_error(png_ptr,
|
||||
"zlib failed to initialize compressor -- stream error");
|
||||
if (ret == Z_MEM_ERROR) png_error(png_ptr,
|
||||
"zlib failed to initialize compressor -- mem error");
|
||||
png_error(png_ptr, "zlib failed to initialize compressor");
|
||||
}
|
||||
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 */
|
||||
|
@ -583,7 +602,8 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
|||
png_ptr->num_palette = (png_uint_16)num_pal;
|
||||
png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
|
||||
|
||||
png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE,
|
||||
(png_uint_32)(num_pal * 3));
|
||||
#ifndef PNG_NO_POINTER_INDEXING
|
||||
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
|
||||
{
|
||||
|
@ -712,7 +732,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
|
|||
/* file_gamma is saved in 1/100,000ths */
|
||||
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
|
||||
png_save_uint_32(buf, igamma);
|
||||
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
|
@ -727,7 +747,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
|
|||
png_debug(1, "in png_write_gAMA\n");
|
||||
/* file_gamma is saved in 1/100,000ths */
|
||||
png_save_uint_32(buf, (png_uint_32)file_gamma);
|
||||
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -743,11 +763,11 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
|||
png_byte buf[1];
|
||||
|
||||
png_debug(1, "in png_write_sRGB\n");
|
||||
if(srgb_intent >= PNG_sRGB_INTENT_LAST)
|
||||
if (srgb_intent >= PNG_sRGB_INTENT_LAST)
|
||||
png_warning(png_ptr,
|
||||
"Invalid sRGB rendering intent specified");
|
||||
buf[0]=(png_byte)srgb_intent;
|
||||
png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -788,34 +808,35 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
|||
|
||||
if (profile_len > 3)
|
||||
embedded_profile_len =
|
||||
((*( (png_bytep)profile ))<<24) |
|
||||
((*( (png_bytep)profile+1))<<16) |
|
||||
((*( (png_bytep)profile+2))<< 8) |
|
||||
((*( (png_bytep)profile+3)) );
|
||||
((*( (png_bytep)profile ))<<24) |
|
||||
((*( (png_bytep)profile + 1))<<16) |
|
||||
((*( (png_bytep)profile + 2))<< 8) |
|
||||
((*( (png_bytep)profile + 3)) );
|
||||
|
||||
if (profile_len < embedded_profile_len)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Embedded profile length too large in iCCP chunk");
|
||||
return;
|
||||
}
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Embedded profile length too large in iCCP chunk");
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile_len > embedded_profile_len)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Truncating profile to actual length in iCCP chunk");
|
||||
profile_len = embedded_profile_len;
|
||||
}
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Truncating profile to actual length in iCCP chunk");
|
||||
profile_len = embedded_profile_len;
|
||||
}
|
||||
|
||||
if (profile_len)
|
||||
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
||||
PNG_COMPRESSION_TYPE_BASE, &comp);
|
||||
profile_len = png_text_compress(png_ptr, profile,
|
||||
(png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);
|
||||
|
||||
/* make sure we include the NULL after the name and the compression type */
|
||||
png_write_chunk_start(png_ptr, png_iCCP,
|
||||
(png_uint_32)name_len+profile_len+2);
|
||||
new_name[name_len+1]=0x00;
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
|
||||
(png_uint_32)(name_len + profile_len + 2));
|
||||
new_name[name_len + 1] = 0x00;
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name,
|
||||
(png_size_t)(name_len + 2));
|
||||
|
||||
if (profile_len)
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
|
@ -852,54 +873,55 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
|||
}
|
||||
|
||||
/* make sure we include the NULL after the name */
|
||||
png_write_chunk_start(png_ptr, png_sPLT,
|
||||
(png_uint_32)(name_len + 2 + palette_size));
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
|
||||
(png_uint_32)(name_len + 2 + palette_size));
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_name,
|
||||
(png_size_t)(name_len + 1));
|
||||
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1);
|
||||
|
||||
/* loop through each palette entry, writing appropriately */
|
||||
#ifndef PNG_NO_POINTER_INDEXING
|
||||
for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++)
|
||||
for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)
|
||||
{
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep->red;
|
||||
entrybuf[1] = (png_byte)ep->green;
|
||||
entrybuf[2] = (png_byte)ep->blue;
|
||||
entrybuf[3] = (png_byte)ep->alpha;
|
||||
png_save_uint_16(entrybuf + 4, ep->frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_save_uint_16(entrybuf + 0, ep->red);
|
||||
png_save_uint_16(entrybuf + 2, ep->green);
|
||||
png_save_uint_16(entrybuf + 4, ep->blue);
|
||||
png_save_uint_16(entrybuf + 6, ep->alpha);
|
||||
png_save_uint_16(entrybuf + 8, ep->frequency);
|
||||
}
|
||||
png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep->red;
|
||||
entrybuf[1] = (png_byte)ep->green;
|
||||
entrybuf[2] = (png_byte)ep->blue;
|
||||
entrybuf[3] = (png_byte)ep->alpha;
|
||||
png_save_uint_16(entrybuf + 4, ep->frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_save_uint_16(entrybuf + 0, ep->red);
|
||||
png_save_uint_16(entrybuf + 2, ep->green);
|
||||
png_save_uint_16(entrybuf + 4, ep->blue);
|
||||
png_save_uint_16(entrybuf + 6, ep->alpha);
|
||||
png_save_uint_16(entrybuf + 8, ep->frequency);
|
||||
}
|
||||
png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
|
||||
}
|
||||
#else
|
||||
ep=spalette->entries;
|
||||
for (i=0; i>spalette->nentries; i++)
|
||||
{
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep[i].red;
|
||||
entrybuf[1] = (png_byte)ep[i].green;
|
||||
entrybuf[2] = (png_byte)ep[i].blue;
|
||||
entrybuf[3] = (png_byte)ep[i].alpha;
|
||||
png_save_uint_16(entrybuf + 4, ep[i].frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_save_uint_16(entrybuf + 0, ep[i].red);
|
||||
png_save_uint_16(entrybuf + 2, ep[i].green);
|
||||
png_save_uint_16(entrybuf + 4, ep[i].blue);
|
||||
png_save_uint_16(entrybuf + 6, ep[i].alpha);
|
||||
png_save_uint_16(entrybuf + 8, ep[i].frequency);
|
||||
}
|
||||
png_write_chunk_data(png_ptr, entrybuf, entry_size);
|
||||
if (spalette->depth == 8)
|
||||
{
|
||||
entrybuf[0] = (png_byte)ep[i].red;
|
||||
entrybuf[1] = (png_byte)ep[i].green;
|
||||
entrybuf[2] = (png_byte)ep[i].blue;
|
||||
entrybuf[3] = (png_byte)ep[i].alpha;
|
||||
png_save_uint_16(entrybuf + 4, ep[i].frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
png_save_uint_16(entrybuf + 0, ep[i].red);
|
||||
png_save_uint_16(entrybuf + 2, ep[i].green);
|
||||
png_save_uint_16(entrybuf + 4, ep[i].blue);
|
||||
png_save_uint_16(entrybuf + 6, ep[i].alpha);
|
||||
png_save_uint_16(entrybuf + 8, ep[i].frequency);
|
||||
}
|
||||
png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -960,7 +982,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
|||
buf[size++] = sbit->alpha;
|
||||
}
|
||||
|
||||
png_write_chunk(png_ptr, png_sBIT, buf, size);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -985,7 +1007,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
|||
{
|
||||
png_warning(png_ptr, "Invalid cHRM white point specified");
|
||||
#if !defined(PNG_NO_CONSOLE_IO)
|
||||
fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y);
|
||||
fprintf(stderr, "white_x=%f, white_y=%f\n", white_x, white_y);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1024,7 +1046,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
|||
itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
|
||||
png_save_uint_32(buf + 28, itemp);
|
||||
|
||||
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
|
@ -1045,7 +1067,8 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
|||
{
|
||||
png_warning(png_ptr, "Invalid fixed cHRM white point specified");
|
||||
#if !defined(PNG_NO_CONSOLE_IO)
|
||||
fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y);
|
||||
fprintf(stderr, "white_x=%ld, white_y=%ld\n", (unsigned long)white_x,
|
||||
(unsigned long)white_y);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1076,7 +1099,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
|||
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
|
||||
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
|
||||
|
||||
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1097,23 +1120,24 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
|||
{
|
||||
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
|
||||
{
|
||||
png_warning(png_ptr,"Invalid number of transparent colors specified");
|
||||
png_warning(png_ptr, "Invalid number of transparent colors specified");
|
||||
return;
|
||||
}
|
||||
/* write the chunk out as it is */
|
||||
png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans,
|
||||
(png_size_t)num_trans);
|
||||
}
|
||||
else if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
/* one 16 bit value */
|
||||
if(tran->gray >= (1 << png_ptr->bit_depth))
|
||||
if (tran->gray >= (1 << png_ptr->bit_depth))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
|
||||
return;
|
||||
}
|
||||
png_save_uint_16(buf, tran->gray);
|
||||
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
|
||||
}
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
{
|
||||
|
@ -1121,13 +1145,13 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
|||
png_save_uint_16(buf, tran->red);
|
||||
png_save_uint_16(buf + 2, tran->green);
|
||||
png_save_uint_16(buf + 4, tran->blue);
|
||||
if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1160,31 +1184,31 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
|||
return;
|
||||
}
|
||||
buf[0] = back->index;
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);
|
||||
}
|
||||
else if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_save_uint_16(buf, back->red);
|
||||
png_save_uint_16(buf + 2, back->green);
|
||||
png_save_uint_16(buf + 4, back->blue);
|
||||
if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
|
||||
if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(back->gray >= (1 << png_ptr->bit_depth))
|
||||
if (back->gray >= (1 << png_ptr->bit_depth))
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
|
||||
return;
|
||||
}
|
||||
png_save_uint_16(buf, back->gray);
|
||||
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1209,7 +1233,8 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
|||
return;
|
||||
}
|
||||
|
||||
png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_hIST,
|
||||
(png_uint_32)(num_hist * 2));
|
||||
for (i = 0; i < num_hist; i++)
|
||||
{
|
||||
png_save_uint_16(buf, hist[i]);
|
||||
|
@ -1329,13 +1354,13 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||
}
|
||||
}
|
||||
*dp = '\0';
|
||||
if(kwarn)
|
||||
if (kwarn)
|
||||
png_warning(png_ptr, "extra interior spaces removed from keyword");
|
||||
|
||||
if (key_len == 0)
|
||||
{
|
||||
png_free(png_ptr, *new_key);
|
||||
*new_key=NULL;
|
||||
*new_key=NULL;
|
||||
png_warning(png_ptr, "Zero length keyword");
|
||||
}
|
||||
|
||||
|
@ -1375,16 +1400,18 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
|||
text_len = png_strlen(text);
|
||||
|
||||
/* make sure we include the 0 after the key */
|
||||
png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_tEXt,
|
||||
(png_uint_32)(key_len + text_len + 1));
|
||||
/*
|
||||
* We leave it to the application to meet PNG-1.0 requirements on the
|
||||
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
|
||||
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
|
||||
* The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
|
||||
*/
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key,
|
||||
(png_size_t)(key_len + 1));
|
||||
if (text_len)
|
||||
png_write_chunk_data(png_ptr, (png_bytep)text, text_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
png_free(png_ptr, new_key);
|
||||
|
@ -1416,6 +1443,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
|||
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
|
||||
{
|
||||
png_warning(png_ptr, "Empty keyword in zTXt chunk");
|
||||
png_free(png_ptr, new_key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1433,10 +1461,11 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
|||
&comp);
|
||||
|
||||
/* write start of chunk */
|
||||
png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32)
|
||||
(key_len+text_len+2));
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt,
|
||||
(png_uint_32)(key_len+text_len + 2));
|
||||
/* write key */
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key,
|
||||
(png_size_t)(key_len + 1));
|
||||
png_free(png_ptr, new_key);
|
||||
|
||||
buf[0] = (png_byte)compression;
|
||||
|
@ -1501,7 +1530,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
|||
/* make sure we include the compression flag, the compression byte,
|
||||
* and the NULs after the key, lang, and lang_key parts */
|
||||
|
||||
png_write_chunk_start(png_ptr, png_iTXt,
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
|
||||
(png_uint_32)(
|
||||
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
|
||||
+ key_len
|
||||
|
@ -1515,7 +1544,8 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
|||
* any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them.
|
||||
* The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
|
||||
*/
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_key,
|
||||
(png_size_t)(key_len + 1));
|
||||
|
||||
/* set the compression flag */
|
||||
if (compression == PNG_ITXT_COMPRESSION_NONE || \
|
||||
|
@ -1525,17 +1555,18 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
|||
cbuf[0] = 1;
|
||||
/* set the compression method */
|
||||
cbuf[1] = 0;
|
||||
png_write_chunk_data(png_ptr, cbuf, 2);
|
||||
png_write_chunk_data(png_ptr, cbuf, (png_size_t)2);
|
||||
|
||||
cbuf[0] = 0;
|
||||
png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1);
|
||||
png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1);
|
||||
png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf),
|
||||
(png_size_t)(lang_len + 1));
|
||||
png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf),
|
||||
(png_size_t)(lang_key_len + 1));
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
png_free(png_ptr, new_key);
|
||||
if (new_lang)
|
||||
png_free(png_ptr, new_lang);
|
||||
png_free(png_ptr, new_lang);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1558,7 +1589,7 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
|
|||
png_save_int_32(buf + 4, y_offset);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
|
||||
}
|
||||
#endif
|
||||
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||
|
@ -1586,21 +1617,23 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
|||
png_debug1(3, "pCAL units length = %d\n", (int)units_len);
|
||||
total_len = purpose_len + units_len + 10;
|
||||
|
||||
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
|
||||
*png_sizeof(png_uint_32)));
|
||||
params_len = (png_uint_32p)png_malloc(png_ptr,
|
||||
(png_uint_32)(nparams * png_sizeof(png_uint_32)));
|
||||
|
||||
/* Find the length of each parameter, making sure we don't count the
|
||||
null terminator for the last parameter. */
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
|
||||
png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]);
|
||||
png_debug2(3, "pCAL parameter %d length = %lu\n", i,
|
||||
(unsigned long) params_len[i]);
|
||||
total_len += (png_size_t)params_len[i];
|
||||
}
|
||||
|
||||
png_debug1(3, "pCAL total length = %d\n", (int)total_len);
|
||||
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
|
||||
png_write_chunk_data(png_ptr, (png_bytep)new_purpose,
|
||||
(png_size_t)purpose_len);
|
||||
png_save_int_32(buf, X0);
|
||||
png_save_int_32(buf + 4, X1);
|
||||
buf[8] = (png_byte)type;
|
||||
|
@ -1659,7 +1692,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
|
|||
#endif
|
||||
|
||||
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
||||
png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
|
||||
}
|
||||
#else
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
|
@ -1689,7 +1722,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
|
|||
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
|
||||
|
||||
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
||||
png_write_chunk(png_ptr, png_sCAL, buf, total_len);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1715,7 +1748,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
|||
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
||||
buf[8] = (png_byte)unit_type;
|
||||
|
||||
png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1747,7 +1780,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
|||
buf[5] = mod_time->minute;
|
||||
buf[6] = mod_time->second;
|
||||
|
||||
png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||
png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1841,18 +1874,19 @@ png_write_start_row(png_structp png_ptr)
|
|||
|
||||
png_debug(1, "in png_write_start_row\n");
|
||||
buf_size = (png_size_t)(PNG_ROWBYTES(
|
||||
png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1);
|
||||
png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1);
|
||||
|
||||
/* set up row buffer */
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)buf_size);
|
||||
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
|
||||
|
||||
#ifndef PNG_NO_WRITE_FILTERING
|
||||
#ifndef PNG_NO_WRITE_FILTER
|
||||
/* set up filtering buffer, if using this filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
(png_uint_32)(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
|
@ -1860,31 +1894,32 @@ png_write_start_row(png_structp png_ptr)
|
|||
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
{
|
||||
/* set up previous row buffer */
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)buf_size);
|
||||
png_memset(png_ptr->prev_row, 0, buf_size);
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
(png_uint_32)(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG)
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
(png_uint_32)(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
(png_uint_32)(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
#endif /* PNG_NO_WRITE_FILTERING */
|
||||
}
|
||||
#endif /* PNG_NO_WRITE_FILTER */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* if interlaced, we need to set up width and height of pass */
|
||||
|
@ -1982,7 +2017,7 @@ png_write_finish_row(png_structp png_ptr)
|
|||
if (png_ptr->prev_row != NULL)
|
||||
png_memset(png_ptr->prev_row, 0,
|
||||
(png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
|
||||
png_ptr->usr_bit_depth,png_ptr->width))+1);
|
||||
png_ptr->usr_bit_depth, png_ptr->width)) + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче