Updated the bundled libpng to v1.2.35 (released 18 Feb. 2009)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6684 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2009-03-14 14:37:51 +00:00
parent 26c355b6a0
commit 7c32ec2b94
27 changed files with 1217 additions and 1039 deletions

View File

@ -1,5 +1,6 @@
CHANGES IN FLTK 1.3.0
- Updated the bundled libpng to v1.2.35 (released 18 Feb. 2009)
- Fl_Preferences.H now doesn't include windows.h any more
(Windows only, STR #2173).
- Fl_Window::draw() now doesn't reset its x/y-coordinates to 0
@ -26,7 +27,6 @@ CHANGES IN FLTK 1.3.0
- Added sorting to Fl_Browser_ (STR #2113)
- Added utf8 support for OS X copy and paste
- Improved handling of composed keys in OS X 10.5 and up
- Updated the bundled libpng to v1.2.33.
- Fixed callback would not be called when shortcut was used with
radio and toggle buttons in default FL_RELEASE mode.
- Fixed a problem with TrackMouseEvent() (Windows only) that would

View File

@ -1,5 +1,5 @@
Libpng 1.2.33 - October 31, 2008
Libpng 1.2.35 - February 14, 2009
This is a public release of libpng, intended for use in production codes.
@ -8,47 +8,45 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.2.33.tar.gz
libpng-1.2.33.tar.lzma
libpng-1.2.35.tar.gz
libpng-1.2.35.tar.lzma
(Get the lzma codec from <http://tukaani.org/lzma>).
libpng-1.2.33.tar.bz2
libpng-1.2.35.tar.bz2
Source files with LF line endings (for Unix/Linux) without the
"configure" script
libpng-1.2.33-no-config.tar.gz
libpng-1.2.33-no-config.tar.lzma
libpng-1.2.33-no-config.tar.bz2
libpng-1.2.35-no-config.tar.gz
libpng-1.2.35-no-config.tar.lzma
libpng-1.2.35-no-config.tar.bz2
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1233.zip
lpng1233.7z
lpng1233.tar.bz2
lpng1235.zip
lpng1235.7z
lpng1235.tar.bz2
Project files
libpng-1.2.33-project-netware.zip
libpng-1.2.33-project-wince.zip
libpng-1.2.35-project-netware.zip
libpng-1.2.35-project-wince.zip
Other information:
libpng-1.2.33-README.txt
libpng-1.2.33-KNOWNBUGS.txt
libpng-1.2.33-LICENSE.txt
libpng-1.2.33-Y2K-compliance.txt
libpng-1.2.33-[previous version]-diff.txt
libpng-1.2.35-README.txt
libpng-1.2.35-KNOWNBUGS.txt
libpng-1.2.35-LICENSE.txt
libpng-1.2.35-Y2K-compliance.txt
libpng-1.2.35-[previous version]-diff.txt
Changes since the last public release (1.2.32):
Changes since the last public release (1.2.34):
version 1.2.33 [October 31, 2008]
version 1.2.35 [February 14, 2009]
Revised makefile.darwin to fix shared library numbering.
Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8()
in example.c (debian bug report)
Changed remaining "key" to "png_ptr->chunkdata" in png_handle_tEXt()
to avoid memory leak after memory failure while reading tEXt chunk.`
Zero out all arrays of pointers after png_malloc(). (Tavis Ormandy)
Use png_memset() instead of a loop to intialize pointers. We realize
this will not work on platforms where the NULL pointer is not all zeroes.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -2186,7 +2186,7 @@ version 1.2.30beta03 [July 6, 2008]
version 1.2.30beta04 [July 10, 2008]
Merged more cosmetic whitespace changes from libpng-1.4.0beta19.
version 1.0.38rc01, 1.2.30rc01 [October 31, 2008]
version 1.0.38rc01, 1.2.30rc01 [February 14, 2009]
No changes.
version 1.0.38rc02, 1.2.30rc02 [July 21, 2008]
@ -2257,10 +2257,75 @@ version 1.2.33beta01 [October 6, 2008]
version 1.2.33rc01 [October 15, 2008]
No changes.
version 1.0.41rc01, version 1.2.33rc02 [October 31, 2008]
version 1.0.41rc01, version 1.2.33rc02 [October 23, 2008]
Changed remaining "key" to "png_ptr->chunkdata" in png_handle_tEXt()
to avoid memory leak after memory failure while reading tEXt chunk.`
version 1.2.33 [October 31, 2008]
No changes.
version 1.2.34beta01 [November 27, 2008]
Revised png_warning() to write its message on standard output by default
when warning_fn is NULL. This was the behavior prior to libpng-1.2.9beta9.
Fixed string vs pointer-to-string error in png_check_keyword().
Added png_check_cHRM_fixed() in png.c and moved checking from pngget.c,
pngrutil.c, and pngwrite.c, and eliminated floating point cHRM checking.
Added check for zero-area RGB cHRM triangle in png_check_cHRM_fixed().
In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant
check for all-zero coordinates that is detected by the triangle check.
Revised png_warning() to write its message on standard output by default
when warning_fn is NULL.
version 1.2.34beta02 [November 28, 2008]
Corrected off-by-one error in bKGD validity check in png_write_bKGD()
and in png_handle_bKGD().
version 1.2.34beta03 [December 1, 2008]
Revised bKGD validity check to use >= x instead of > x + 1
Merged with png_debug from libpng-1.4.0 to remove newlines.
version 1.2.34beta04 [December 2, 2008]
More merging with png_debug from libpng-1.4.0 to remove newlines.
version 1.2.34beta05 [December 5, 2008]
Removed redundant check for key==NULL before calling png_check_keyword()
to ensure that new_key gets initialized and removed extra warning
(Arvan Pritchard).
version 1.2.34beta06 [December 9, 2008]
In png_write_png(), respect the placement of the filler bytes in an earlier
call to png_set_filler() (Jim Barry).
version 1.2.34beta07 [December 9, 2008]
Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and
PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated
PNG_TRANSFORM_STRIP_FILLER (Jim Barry).
version 1.0.42rc01, 1.2.34rc01 [December 11, 2008]
No changes.
version 1.0.42, 1.2.34 [December 18, 2008]
No changes.
version 1.2.35beta01 [February 4, 2009]
Zero out some arrays of pointers after png_malloc(). (Tavis Ormandy)
version 1.2.35beta02 [Feburary 4, 2009]
Zero out more arrays of pointers after png_malloc().
version 1.2.35beta03 [February 5, 2009]
Use png_memset() instead of a loop to intialize pointers. We realize
this will not work on platforms where the NULL pointer is not all zeroes.
version 1.2.35rc01 [February 11, 2009]
No changes.
version 1.2.35rc02 [February 12, 2009]
Fix typo in new png_memset call in pngset.c (png_color should be png_charp)
version 1.0.43 and 1.2.35 [February 14, 2009]
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

View File

@ -1,5 +1,5 @@
Installing libpng version 1.2.33 - October 31, 2008
Installing libpng version 1.2.35 - February 14, 2009
On Unix/Linux and similar systems, you can simply type
@ -44,7 +44,7 @@ to have access to the zlib.h and zconf.h include files that
correspond to the version of zlib that's installed.
You can rename the directories that you downloaded (they
might be called "libpng-1.2.33" or "lpng109" and "zlib-1.2.1"
might be called "libpng-1.2.35" or "lpng109" and "zlib-1.2.1"
or "zlib121") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
@ -101,9 +101,9 @@ include
CMakeLists.txt => "cmake" script
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.elf => Linux/ELF makefile symbol versioning,
gcc, creates libpng12.so.0.1.2.33)
gcc, creates libpng12.so.0.1.2.35)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.33)
(gcc, creates libpng12.so.0.1.2.35)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from
@ -125,14 +125,14 @@ include
makefile.openbsd => OpenBSD makefile
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc,
creates libpng12.so.0.1.2.33)
creates libpng12.so.0.1.2.35)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng12.so.0.1.2.33)
creates libpng12.so.0.1.2.35)
makefile.solaris-x86 => Solaris/intelMMX 2.X makefile (gcc,
creates libpng12.so.0.1.2.33)
creates libpng12.so.0.1.2.35)
makefile.so9 => Solaris 9 makefile (gcc,
creates libpng12.so.0.1.2.33)
creates libpng12.so.0.1.2.35)
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

View File

@ -1,5 +1,5 @@
Known bugs in libpng version 1.2.33
Known bugs in libpng version 1.2.35
1. February 23, 2006: The custom makefiles don't build libpng with -lz.

View File

@ -8,7 +8,7 @@ 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.33, October 31, 2008, are
libpng versions 1.2.6, August 15, 2004, through 1.2.35, February 14, 2009, 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
October 31, 2008
February 14, 2009

View File

@ -1,4 +1,4 @@
README for libpng version 1.2.33 - October 31, 2008 (shared library 12.0)
README for libpng version 1.2.35 - February 14, 2009 (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.
@ -194,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.33)
gcc, creates libpng12.so.0.1.2.35)
makefile.linux => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.33)
(gcc, creates libpng12.so.0.1.2.35)
makefile.gcmmx => Linux/ELF makefile
(gcc, creates libpng12.so.0.1.2.33,
(gcc, creates libpng12.so.0.1.2.35,
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
@ -220,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.33)
(gcc, creates libpng12.so.0.1.2.35)
makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng12.so.0.1.2.33)
(gcc, creates libpng12.so.0.1.2.35)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng12.so.0.1.2.33)
(gcc, creates libpng12.so.0.1.2.35)
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

View File

@ -1,13 +1,13 @@
Y2K compliance in libpng:
=========================
October 31, 2008
February 14, 2009
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.33 are Y2K compliant. It is my belief that earlier
upward through 1.2.35 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

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "October 31, 2008"
.TH LIBPNG 3 "February 14, 2009"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.33
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.35
.SH SYNOPSIS
\fI\fB
@ -821,7 +821,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng.txt - A description on how to use and modify libpng
libpng version 1.2.33 - October 31, 2008
libpng version 1.2.35 - February 14, 2009
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2008 Glenn Randers-Pehrson
@ -830,7 +830,7 @@ libpng.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.2.33 - October 31, 2008
libpng versions 0.97, January 1998, through 1.2.35 - February 14, 2009
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2008 Glenn Randers-Pehrson
@ -1293,6 +1293,8 @@ row_pointers prior to calling png_read_png() with
"Image is too wide to process in memory");
row_pointers = png_malloc(png_ptr,
height*png_sizeof(png_bytep));
for (int i=0; i<height, i++)
row_pointers[i]=NULL; /* security precaution */
for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr,
width*pixel_size);
@ -3673,13 +3675,13 @@ application:
.SH IX. Y2K Compliance in libpng
October 31, 2008
February 14, 2009
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.33 are Y2K compliant. It is my belief that earlier
upward through 1.2.35 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
@ -3931,6 +3933,16 @@ the first widely used release:
1.0.41rc01 10 10041 10.so.0.41[.0]
1.2.33 13 10233 12.so.0.33[.0]
1.0.41 10 10041 10.so.0.41[.0]
1.2.34beta01-07 13 10234 12.so.0.34[.0]
1.0.42rc01 10 10042 10.so.0.42[.0]
1.2.34rc01 13 10234 12.so.0.34[.0]
1.0.42 10 10042 10.so.0.42[.0]
1.2.34 13 10234 12.so.0.34[.0]
1.2.35beta01-03 13 10235 12.so.0.35[.0]
1.0.43rc01-02 10 10043 10.so.0.43[.0]
1.2.35rc01-02 13 10235 12.so.0.35[.0]
1.0.43 10 10043 10.so.0.43[.0]
1.2.35 13 10235 12.so.0.35[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@ -3986,7 +3998,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.2.33 - October 31, 2008:
Libpng version 1.2.35 - February 14, 2009:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -4007,7 +4019,7 @@ included in the libpng distribution, the latter shall prevail.)
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.2.6, August 15, 2004, through 1.2.33, October 31, 2008, are
libpng versions 1.2.6, August 15, 2004, through 1.2.35, February 14, 2009, 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
@ -4106,7 +4118,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
October 31, 2008
February 14, 2009
.\" end of man page

View File

@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.2.33 - October 31, 2008
libpng version 1.2.35 - February 14, 2009
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2008 Glenn Randers-Pehrson
@ -9,7 +9,7 @@ libpng.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.2.33 - October 31, 2008
libpng versions 0.97, January 1998, through 1.2.35 - February 14, 2009
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2008 Glenn Randers-Pehrson
@ -472,6 +472,8 @@ row_pointers prior to calling png_read_png() with
"Image is too wide to process in memory");
row_pointers = png_malloc(png_ptr,
height*png_sizeof(png_bytep));
for (int i=0; i<height, i++)
row_pointers[i]=NULL; /* security precaution */
for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr,
width*pixel_size);
@ -2852,13 +2854,13 @@ application:
IX. Y2K Compliance in libpng
October 31, 2008
February 14, 2009
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.33 are Y2K compliant. It is my belief that earlier
upward through 1.2.35 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

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "October 31, 2008"
.TH LIBPNGPF 3 "February 14, 2009"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.33
libpng \- Portable Network Graphics (PNG) Reference Library 1.2.35
(private functions)
.SH SYNOPSIS
\fB#include <png.h>\fP

View File

@ -1,4 +1,4 @@
.TH PNG 5 "October 31, 2008"
.TH PNG 5 "February 14, 2009"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION

186
png/png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.34 [December 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -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_33 Your_png_h_is_not_version_1_2_33;
typedef version_1_2_35 Your_png_h_is_not_version_1_2_35;
/* Version information for C files. This had better match the version
* string defined in png.h. */
@ -92,8 +92,8 @@ 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;
png_debug(1, "in png_set_sig_bytes\n");
if (png_ptr == NULL) return;
png_debug(1, "in png_set_sig_bytes");
if (num_bytes > 8)
png_error(png_ptr, "Too many bytes for PNG signature.");
@ -153,7 +153,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()");
@ -240,8 +240,8 @@ 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);
png_debug(1, "in png_create_info_struct");
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);
@ -263,9 +263,9 @@ 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");
png_debug(1, "in png_destroy_info_struct");
if (info_ptr_ptr != NULL)
info_ptr = *info_ptr_ptr;
@ -302,11 +302,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");
png_debug(1, "in png_info_init_3");
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);
@ -314,7 +314,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
@ -322,12 +322,12 @@ void PNGAPI
png_data_freer(png_structp png_ptr, png_infop info_ptr,
int freer, png_uint_32 mask)
{
png_debug(1, "in png_data_freer\n");
png_debug(1, "in png_data_freer");
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,
@ -339,7 +339,7 @@ void PNGAPI
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
int num)
{
png_debug(1, "in png_free_data\n");
png_debug(1, "in png_free_data");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -459,7 +459,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);
@ -469,7 +469,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++)
@ -485,7 +485,7 @@ 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;
@ -499,7 +499,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;
@ -509,7 +509,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);
@ -563,7 +563,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++)
@ -579,7 +579,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);
@ -593,7 +593,7 @@ if (mask & PNG_FREE_ROWS)
void /* PRIVATE */
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_info_destroy\n");
png_debug(1, "in png_info_destroy");
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
@ -602,7 +602,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
@ -617,7 +617,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);
}
@ -632,8 +632,8 @@ png_get_io_ptr(png_structp png_ptr)
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;
png_debug(1, "in png_init_io");
if (png_ptr == NULL) return;
png_ptr->io_ptr = (png_voidp)fp;
}
#endif
@ -649,7 +649,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*
@ -670,7 +670,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);
@ -678,7 +678,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);
@ -694,7 +694,7 @@ 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.33 - October 31, 2008\n\
return ((png_charp) "\n libpng version 1.2.35 - February 14, 2009\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");
@ -744,12 +744,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
@ -796,4 +796,116 @@ png_convert_size(size_t size)
return ((png_size_t)size);
}
#endif /* PNG_SIZE_T */
/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
#if defined(PNG_cHRM_SUPPORTED)
#if !defined(PNG_NO_CHECK_cHRM)
/*
Multiply two 32-bit numbers, V1 and V2, using 32-bit
arithmetic, to produce a 64 bit result in the HI/LO words.
A B
x C D
------
AD || BD
AC || CB || 0
where A and B are the high and low 16-bit words of V1,
C and D are the 16-bit words of V2, AD is the product of
A and D, and X || Y is (X << 16) + Y.
*/
void png_64bit_product (long v1, long v2, unsigned long *hi_product,
unsigned long *lo_product)
{
int a, b, c, d;
long lo, hi, x, y;
a = (v1 >> 16) & 0xffff;
b = v1 & 0xffff;
c = (v2 >> 16) & 0xffff;
d = v2 & 0xffff;
lo = b * d; /* BD */
x = a * d + c * b; /* AD + CB */
y = ((lo >> 16) & 0xffff) + x;
lo = (lo & 0xffff) | ((y & 0xffff) << 16);
hi = (y >> 16) & 0xffff;
hi += a * c; /* AC */
*hi_product = (unsigned long)hi;
*lo_product = (unsigned long)lo;
}
int /* private */
png_check_cHRM_fixed(png_structp png_ptr,
png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
png_fixed_point blue_x, png_fixed_point blue_y)
{
int ret = 1;
unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
png_debug(1, "in function png_check_cHRM_fixed");
if (png_ptr == NULL)
return 0;
if (white_x < 0 || white_y <= 0 ||
red_x < 0 || red_y < 0 ||
green_x < 0 || green_y < 0 ||
blue_x < 0 || blue_y < 0)
{
png_warning(png_ptr,
"Ignoring attempt to set negative chromaticity value");
ret = 0;
}
if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
white_y > (png_fixed_point) PNG_UINT_31_MAX ||
red_x > (png_fixed_point) PNG_UINT_31_MAX ||
red_y > (png_fixed_point) PNG_UINT_31_MAX ||
green_x > (png_fixed_point) PNG_UINT_31_MAX ||
green_y > (png_fixed_point) PNG_UINT_31_MAX ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX )
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
ret = 0;
}
if (white_x > 100000L - white_y)
{
png_warning(png_ptr, "Invalid cHRM white point");
ret = 0;
}
if (red_x > 100000L - red_y)
{
png_warning(png_ptr, "Invalid cHRM red point");
ret = 0;
}
if (green_x > 100000L - green_y)
{
png_warning(png_ptr, "Invalid cHRM green point");
ret = 0;
}
if (blue_x > 100000L - blue_y)
{
png_warning(png_ptr, "Invalid cHRM blue point");
ret = 0;
}
png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);
png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);
if (xy_hi == yx_hi && xy_lo == yx_lo)
{
png_warning(png_ptr,
"Ignoring attempt to set cHRM RGB triangle with zero area");
ret = 0;
}
return ret;
}
#endif /* NO_PNG_CHECK_cHRM */
#endif /* PNG_cHRM_SUPPORTED */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */

105
png/png.h
View File

@ -1,14 +1,14 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.2.33 - October 31, 2008
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* libpng version 1.2.35 - February 14, 2009
* Copyright (c) 1998-2009 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.33 - October 31, 2008: Glenn
* libpng versions 0.97, January 1998, through 1.2.35 - February 14, 2009: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -212,6 +212,16 @@
* 1.0.41rc01 10 10041 10.so.0.41[.0]
* 1.2.33 13 10233 12.so.0.33[.0]
* 1.0.41 10 10041 10.so.0.41[.0]
* 1.2.34beta01-07 13 10234 12.so.0.34[.0]
* 1.0.42rc01 10 10042 10.so.0.42[.0]
* 1.2.34rc01 13 10234 12.so.0.34[.0]
* 1.0.42 10 10042 10.so.0.42[.0]
* 1.2.34 13 10234 12.so.0.34[.0]
* 1.2.35beta01-03 13 10235 12.so.0.35[.0]
* 1.0.43rc01-02 10 10043 10.so.0.43[.0]
* 1.2.35rc01-02 13 10235 12.so.0.35[.0]
* 1.0.43 10 10043 10.so.0.43[.0]
* 1.2.35 13 10235 12.so.0.35[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -241,7 +251,7 @@
* If you modify libpng you may insert additional notices immediately following
* this sentence.
*
* libpng versions 1.2.6, August 15, 2004, through 1.2.33, October 31, 2008, are
* libpng versions 1.2.6, August 15, 2004, through 1.2.35, February 14, 2009, 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:
@ -353,13 +363,13 @@
* Y2K compliance in libpng:
* =========================
*
* October 31, 2008
* February 14, 2009
*
* 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.33 are Y2K compliant. It is my belief that earlier
* upward through 1.2.35 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
@ -415,9 +425,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.33"
#define PNG_LIBPNG_VER_STRING "1.2.35"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.33 - October 31, 2008\n"
" libpng version 1.2.35 - February 14, 2009\n"
#define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13
@ -425,7 +435,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 33
#define PNG_LIBPNG_VER_RELEASE 35
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
@ -453,7 +463,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 10233 /* 1.2.33 */
#define PNG_LIBPNG_VER 10235 /* 1.2.35 */
#ifndef PNG_VERSION_INFO_ONLY
/* include the compression library's header */
@ -1154,7 +1164,10 @@ typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */
/* Added to libpng-1.2.34 */
#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* WRITE only */
#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */
/* Flags for MNG supported features */
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
@ -1474,7 +1487,7 @@ struct png_struct_def
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef png_structp version_1_2_33;
typedef png_structp version_1_2_35;
typedef png_struct FAR * FAR * png_structpp;
@ -2526,33 +2539,80 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
#include <crtdbg.h>
#if (PNG_DEBUG > 1)
#define png_debug(l,m) _RPT0(_CRT_WARN,m)
#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1)
#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2)
#ifndef _DEBUG
# define _DEBUG
#endif
#ifndef png_debug
#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
#endif
#ifndef png_debug1
#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
#endif
#ifndef png_debug2
#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
#endif
#endif
#else /* PNG_DEBUG_FILE || !_MSC_VER */
#ifndef PNG_DEBUG_FILE
#define PNG_DEBUG_FILE stderr
#endif /* PNG_DEBUG_FILE */
#if (PNG_DEBUG > 1)
#ifndef png_debug
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
* non-ISO compilers */
#ifdef __STDC__
#define png_debug(l,m) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
}
#endif
#ifndef png_debug1
#define png_debug1(l,m,p1) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
}
#endif
#ifndef png_debug2
#define png_debug2(l,m,p1,p2) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
}
#endif
#else /* __STDC __ */
#ifndef png_debug
#define png_debug(l,m) \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format);
#endif
#ifndef png_debug1
#define png_debug1(l,m,p1) \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1);
#endif
#ifndef png_debug2
#define png_debug2(l,m,p1,p2) \
int num_tabs=l; \
char format[256]; \
snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
m,PNG_STRING_NEWLINE); \
fprintf(PNG_DEBUG_FILE,format,p1,p2);
#endif
#endif /* __STDC __ */
#endif /* (PNG_DEBUG > 1) */
#endif /* _MSC_VER */
#endif /* (PNG_DEBUG > 0) */
@ -3584,6 +3644,15 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
/* Read the chunk header (length + type name) */
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
/* Added at libpng version 1.2.34 */
#if defined(PNG_cHRM_SUPPORTED)
PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
png_fixed_point int_white_x, png_fixed_point int_white_y,
png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
png_fixed_point int_blue_y));
#endif
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
#endif /* PNG_INTERNAL */

View File

@ -1,9 +1,9 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.2.33 - October 31, 2008
* libpng version 1.2.35 - February 14, 2009
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* Copyright (c) 1998-2009 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.)
*/
@ -233,6 +233,8 @@
# include <windows.h>
/* Console I/O functions are not supported on WindowsCE */
# define PNG_NO_CONSOLE_IO
/* abort() may not be supported on some/all Windows CE platforms */
# define PNG_ABORT() exit(-1)
# ifdef PNG_DEBUG
# undef PNG_DEBUG
# endif
@ -798,6 +800,12 @@
# define PNG_USER_HEIGHT_MAX 1000000L
#endif
/* Added at libpng-1.2.34 and 1.4.0 */
#ifndef PNG_STRING_NEWLINE
#define PNG_STRING_NEWLINE "\n"
#endif
/* These are currently experimental features, define them if you want */
/* very little testing */
@ -1123,10 +1131,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

View File

@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.34 [December 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -46,27 +46,27 @@ png_error(png_structp png_ptr, png_const_charp error_message)
{
/* Strip "#nnnn " from beginning of error message. */
int offset;
for (offset=1; offset<15; 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];
for (i = 0; i < offset - 1; i++)
msg[i] = error_message[i + 1];
msg[i - 1] = '\0';
error_message=msg;
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;
}
}
}
@ -111,16 +111,16 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
{
if (*warning_message == '#')
{
for (offset=1; offset<15; 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);
}
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
else
png_default_warning(png_ptr, warning_message+offset);
png_default_warning(png_ptr, warning_message + offset);
}
#endif /* PNG_NO_WARNINGS */
@ -168,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';
}
}
@ -220,20 +220,20 @@ png_default_error(png_structp png_ptr, png_const_charp 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] == ' ')
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 + 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
@ -276,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] == ' ')
break;
}
if((offset > 1) && (offset < 15))
if ((offset > 1) && (offset < 15))
{
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);
@ -335,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);

View File

@ -120,8 +120,8 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_pHYs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0);
else return (info_ptr->x_pixels_per_unit);
}
@ -138,8 +138,8 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_pHYs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0);
else return (info_ptr->y_pixels_per_unit);
}
@ -156,8 +156,8 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_pHYs_SUPPORTED)
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 ||
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_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);
@ -176,7 +176,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_pHYs_SUPPORTED)
if (info_ptr->valid & PNG_INFO_pHYs)
{
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0)
return ((float)0.0);
else
@ -197,8 +197,8 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_oFFs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0);
else return (info_ptr->x_offset);
}
@ -215,8 +215,8 @@ png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_oFFs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0);
else return (info_ptr->y_offset);
}
@ -233,8 +233,8 @@ png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_oFFs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0);
else return (info_ptr->x_offset);
}
@ -251,8 +251,8 @@ png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_oFFs_SUPPORTED)
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)
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0);
else return (info_ptr->y_offset);
}
@ -307,7 +307,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
png_debug1(1, "in %s retrieval function", "pHYs");
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
@ -322,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);
@ -364,7 +364,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
&& background != NULL)
{
png_debug1(1, "in %s retrieval function\n", "bKGD");
png_debug1(1, "in %s retrieval function", "bKGD");
*background = &(info_ptr->background);
return (PNG_INFO_bKGD);
}
@ -381,7 +381,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
{
png_debug1(1, "in %s retrieval function\n", "cHRM");
png_debug1(1, "in %s retrieval function", "cHRM");
if (white_x != NULL)
*white_x = (double)info_ptr->x_white;
if (white_y != NULL)
@ -412,7 +412,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
{
png_debug1(1, "in %s retrieval function\n", "cHRM");
png_debug1(1, "in %s retrieval function", "cHRM");
if (white_x != NULL)
*white_x = info_ptr->int_x_white;
if (white_y != NULL)
@ -444,7 +444,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& file_gamma != NULL)
{
png_debug1(1, "in %s retrieval function\n", "gAMA");
png_debug1(1, "in %s retrieval function", "gAMA");
*file_gamma = (double)info_ptr->gamma;
return (PNG_INFO_gAMA);
}
@ -459,7 +459,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
&& int_file_gamma != NULL)
{
png_debug1(1, "in %s retrieval function\n", "gAMA");
png_debug1(1, "in %s retrieval function", "gAMA");
*int_file_gamma = info_ptr->int_gamma;
return (PNG_INFO_gAMA);
}
@ -475,7 +475,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
&& file_srgb_intent != NULL)
{
png_debug1(1, "in %s retrieval function\n", "sRGB");
png_debug1(1, "in %s retrieval function", "sRGB");
*file_srgb_intent = (int)info_ptr->srgb_intent;
return (PNG_INFO_sRGB);
}
@ -492,7 +492,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
&& name != NULL && profile != NULL && proflen != NULL)
{
png_debug1(1, "in %s retrieval function\n", "iCCP");
png_debug1(1, "in %s retrieval function", "iCCP");
*name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile;
/* compression_type is a dummy so the API won't have to change
@ -526,7 +526,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
&& hist != NULL)
{
png_debug1(1, "in %s retrieval function\n", "hIST");
png_debug1(1, "in %s retrieval function", "hIST");
*hist = info_ptr->hist;
return (PNG_INFO_hIST);
}
@ -544,7 +544,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
bit_depth != NULL && color_type != NULL)
{
png_debug1(1, "in %s retrieval function\n", "IHDR");
png_debug1(1, "in %s retrieval function", "IHDR");
*width = info_ptr->width;
*height = info_ptr->height;
*bit_depth = info_ptr->bit_depth;
@ -588,7 +588,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
{
png_debug1(1, "in %s retrieval function\n", "oFFs");
png_debug1(1, "in %s retrieval function", "oFFs");
*offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset;
*unit_type = (int)info_ptr->offset_unit_type;
@ -608,7 +608,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
nparams != NULL && units != NULL && params != NULL)
{
png_debug1(1, "in %s retrieval function\n", "pCAL");
png_debug1(1, "in %s retrieval function", "pCAL");
*purpose = info_ptr->pcal_purpose;
*X0 = info_ptr->pcal_X0;
*X1 = info_ptr->pcal_X1;
@ -668,7 +668,7 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs))
{
png_debug1(1, "in %s retrieval function\n", "pHYs");
png_debug1(1, "in %s retrieval function", "pHYs");
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
@ -696,10 +696,10 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
&& palette != NULL)
{
png_debug1(1, "in %s retrieval function\n", "PLTE");
png_debug1(1, "in %s retrieval function", "PLTE");
*palette = info_ptr->palette;
*num_palette = info_ptr->num_palette;
png_debug1(3, "num_palette = %d\n", *num_palette);
png_debug1(3, "num_palette = %d", *num_palette);
return (PNG_INFO_PLTE);
}
return (0);
@ -712,7 +712,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
&& sig_bit != NULL)
{
png_debug1(1, "in %s retrieval function\n", "sBIT");
png_debug1(1, "in %s retrieval function", "sBIT");
*sig_bit = &(info_ptr->sig_bit);
return (PNG_INFO_sBIT);
}
@ -727,7 +727,7 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
png_debug1(1, "in %s retrieval function\n",
png_debug1(1, "in %s retrieval function",
(png_ptr->chunk_name[0] == '\0' ? "text"
: (png_const_charp)png_ptr->chunk_name));
if (text_ptr != NULL)
@ -749,7 +749,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
&& mod_time != NULL)
{
png_debug1(1, "in %s retrieval function\n", "tIME");
png_debug1(1, "in %s retrieval function", "tIME");
*mod_time = &(info_ptr->mod_time);
return (PNG_INFO_tIME);
}
@ -765,7 +765,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_uint_32 retval = 0;
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
{
png_debug1(1, "in %s retrieval function\n", "tRNS");
png_debug1(1, "in %s retrieval function", "tRNS");
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (trans != NULL)
@ -783,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;
@ -883,7 +883,7 @@ png_get_mmx_rowbytes_threshold (png_structp png_ptr)
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* these functions were added to libpng 1.2.6 */
/* These functions were added to libpng 1.2.6 */
png_uint_32 PNGAPI
png_get_user_width_max (png_structp png_ptr)
{

View File

@ -1,9 +1,9 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.35 [February 14, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* Copyright (c) 1998-2009 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.)
*
@ -47,7 +47,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
int i;
png_debug(1, "in png_create_read_struct\n");
png_debug(1, "in png_create_read_struct");
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
@ -71,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);
@ -81,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
@ -91,12 +91,12 @@ 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);
if(user_png_ver)
if (user_png_ver)
{
i=0;
i = 0;
do
{
if(user_png_ver[i] != png_libpng_ver[i])
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
@ -130,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");
@ -166,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();
@ -192,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,
@ -212,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.");
@ -242,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;
@ -263,26 +263,26 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
}
} while (png_libpng_ver[i++]);
png_debug(1, "in png_read_init_3\n");
png_debug(1, "in png_read_init_3");
#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 */
@ -326,8 +326,8 @@ 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 || info_ptr == NULL) return;
png_debug(1, "in png_read_info\n");
if (png_ptr == NULL || info_ptr == NULL) return;
png_debug(1, "in png_read_info");
/* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8)
{
@ -349,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;
@ -415,7 +415,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
* matching the chunk name rather than a linear search.
*/
if (!png_memcmp(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(chunk_name, png_IHDR, 4))
@ -533,8 +533,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
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;
png_debug(1, "in png_read_update_info");
if (png_ptr == NULL) return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
else
@ -552,8 +552,8 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI
png_start_read_image(png_structp png_ptr)
{
png_debug(1, "in png_start_read_image\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_start_read_image");
if (png_ptr == NULL) return;
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
}
@ -566,12 +566,12 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_CONST PNG_IDAT;
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;
png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
if (png_ptr == NULL) return;
png_debug2(1, "in png_read_row (row %lu, pass %d)",
png_ptr->row_number, png_ptr->pass);
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr);
@ -734,7 +734,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]));
@ -743,7 +743,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 */
@ -822,8 +822,8 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp rp;
png_bytepp dp;
png_debug(1, "in png_read_rows\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_read_rows");
if (png_ptr == NULL) return;
rp = row;
dp = display_row;
if (rp != NULL && dp != NULL)
@ -834,14 +834,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;
@ -867,12 +867,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;
png_debug(1, "in png_read_image");
if (png_ptr == NULL) return;
#ifdef PNG_READ_INTERLACING_SUPPORTED
pass = png_set_interlace_handling(png_ptr);
@ -907,8 +907,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_debug(1, "in png_read_end\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_read_end");
if (png_ptr == NULL) return;
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
do
@ -1087,7 +1087,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_voidp mem_ptr = NULL;
#endif
png_debug(1, "in png_destroy_read_struct\n");
png_debug(1, "in png_destroy_read_struct");
if (png_ptr_ptr != NULL)
png_ptr = *png_ptr_ptr;
if (png_ptr == NULL)
@ -1138,13 +1138,13 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
if (png_ptr != NULL)
{
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
png_destroy_struct((png_voidp)png_ptr);
#endif
*png_ptr_ptr = NULL;
}
*png_ptr_ptr = NULL;
}
}
/* free all memory used by the read (old method) */
@ -1161,7 +1161,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_free_ptr free_fn;
#endif
png_debug(1, "in png_read_destroy\n");
png_debug(1, "in png_read_destroy");
if (info_ptr != NULL)
png_info_destroy(png_ptr, info_ptr);
@ -1268,7 +1268,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;
@ -1278,7 +1278,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;
@ -1288,7 +1288,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
}
@ -1296,7 +1296,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;
}
@ -1310,7 +1310,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
*/
@ -1323,7 +1323,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 ------------------- */
@ -1430,18 +1430,18 @@ 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));
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ROWS;
#endif
png_memset(info_ptr->row_pointers, 0, info_ptr->height
* png_sizeof(png_bytep));
for (row = 0; row < (int)info_ptr->height; row++)
{
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));
}
}
png_read_image(png_ptr, info_ptr->row_pointers);

View File

@ -27,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", (int)length);
if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length);
else
@ -45,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.
*/
@ -76,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);
@ -105,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;
@ -137,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)

View File

@ -1,9 +1,9 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.35 [February 14, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* Copyright (c) 1998-2009 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.)
*
@ -21,9 +21,9 @@
void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
{
png_debug(1, "in png_set_crc_action\n");
png_debug(1, "in png_set_crc_action");
/* 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 */
@ -80,8 +80,8 @@ png_set_background(png_structp png_ptr,
png_color_16p background_color, int background_gamma_code,
int need_expand, double background_gamma)
{
png_debug(1, "in png_set_background\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_background");
if (png_ptr == NULL) return;
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
{
png_warning(png_ptr, "Application must supply a known background gamma");
@ -102,8 +102,8 @@ png_set_background(png_structp png_ptr,
void PNGAPI
png_set_strip_16(png_structp png_ptr)
{
png_debug(1, "in png_set_strip_16\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_strip_16");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_16_TO_8;
}
#endif
@ -112,8 +112,8 @@ png_set_strip_16(png_structp png_ptr)
void PNGAPI
png_set_strip_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_strip_alpha\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_strip_alpha");
if (png_ptr == NULL) return;
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
}
#endif
@ -142,8 +142,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
int num_palette, int maximum_colors, png_uint_16p histogram,
int full_dither)
{
png_debug(1, "in png_set_dither\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_dither");
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,8 @@ 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)));
for (i = 0; i < 769; i++)
hash[i] = NULL;
/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */
png_sizeof(png_dsortp)));
png_memset(hash, 0, 769 * png_sizeof(png_dsortp));
num_new_palette = num_palette;
@ -436,8 +434,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 +457,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)));
@ -526,8 +524,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
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;
png_debug(1, "in png_set_gamma");
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))
@ -545,8 +543,8 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
void PNGAPI
png_set_expand(png_structp png_ptr)
{
png_debug(1, "in png_set_expand\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_expand");
if (png_ptr == NULL) return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -572,8 +570,8 @@ png_set_expand(png_structp png_ptr)
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;
png_debug(1, "in png_set_palette_to_rgb");
if (png_ptr == NULL) return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -583,8 +581,8 @@ png_set_palette_to_rgb(png_structp png_ptr)
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;
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_EXPAND;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -596,8 +594,8 @@ png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
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;
png_debug(1, "in png_set_gray_1_2_4_to_8");
if (png_ptr == NULL) return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
}
#endif
@ -607,7 +605,7 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
void PNGAPI
png_set_tRNS_to_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_tRNS_to_alpha\n");
png_debug(1, "in png_set_tRNS_to_alpha");
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -617,7 +615,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
void PNGAPI
png_set_gray_to_rgb(png_structp png_ptr)
{
png_debug(1, "in png_set_gray_to_rgb\n");
png_debug(1, "in png_set_gray_to_rgb");
png_ptr->transformations |= PNG_GRAY_TO_RGB;
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
@ -635,7 +633,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
@ -644,8 +642,8 @@ void PNGAPI
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;
png_debug(1, "in png_set_rgb_to_gray");
if (png_ptr == NULL) return;
switch(error_action)
{
case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
@ -666,12 +664,12 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
#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);
@ -684,7 +682,7 @@ 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_ptr->rgb_to_gray_blue_coeff =
(png_uint_16)(32768 - red_int - green_int);
}
}
@ -697,14 +695,14 @@ void PNGAPI
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;
png_debug(1, "in png_set_read_user_transform_fn");
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
@ -717,9 +715,9 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
void /* PRIVATE */
png_init_read_transformations(png_structp png_ptr)
{
png_debug(1, "in png_init_read_transformations\n");
png_debug(1, "in png_init_read_transformations");
#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) \
@ -820,7 +818,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]);
@ -841,7 +839,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++)
{
@ -1112,7 +1110,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
}
@ -1124,7 +1122,7 @@ png_init_read_transformations(png_structp png_ptr)
void /* PRIVATE */
png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_read_transform_info\n");
png_debug(1, "in png_read_transform_info");
#if defined(PNG_READ_EXPAND_SUPPORTED)
if (png_ptr->transformations & PNG_EXPAND)
{
@ -1241,11 +1239,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
@ -1253,10 +1251,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
}
@ -1268,7 +1266,7 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
void /* PRIVATE */
png_do_read_transformations(png_structp png_ptr)
{
png_debug(1, "in png_do_read_transformations\n");
png_debug(1, "in png_do_read_transformations");
if (png_ptr->row_buf == NULL)
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
@ -1326,13 +1324,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");
}
@ -1416,7 +1414,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
@ -1478,7 +1476,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: */
@ -1490,9 +1488,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 *
@ -1514,7 +1512,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
void /* PRIVATE */
png_do_unpack(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_unpack\n");
png_debug(1, "in png_do_unpack");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL && row_info->bit_depth < 8)
#else
@ -1604,7 +1602,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
{
png_debug(1, "in png_do_unshift\n");
png_debug(1, "in png_do_unshift");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL && sig_bits != NULL &&
@ -1710,7 +1708,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
void /* PRIVATE */
png_do_chop(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_chop\n");
png_debug(1, "in png_do_chop");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL && row_info->bit_depth == 16)
#else
@ -1764,7 +1762,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_swap_alpha\n");
png_debug(1, "in png_do_read_swap_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -1856,7 +1854,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_invert_alpha\n");
png_debug(1, "in png_do_read_invert_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -1962,14 +1960,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_byte hi_filler = (png_byte)((filler>>8) & 0xff);
png_byte lo_filler = (png_byte)(filler & 0xff);
png_debug(1, "in png_do_read_filler\n");
png_debug(1, "in png_do_read_filler");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
#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)
@ -2001,7 +1999,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)
@ -2041,7 +2039,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)
@ -2077,7 +2075,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)
@ -2134,7 +2132,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
png_uint_32 i;
png_uint_32 row_width = row_info->width;
png_debug(1, "in png_do_gray_to_rgb\n");
png_debug(1, "in png_do_gray_to_rgb");
if (row_info->bit_depth >= 8 &&
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -2204,7 +2202,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
@ -2240,7 +2238,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_uint_32 row_width = row_info->width;
int rgb_error = 0;
png_debug(1, "in png_do_rgb_to_gray\n");
png_debug(1, "in png_do_rgb_to_gray");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -2266,14 +2264,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
@ -2286,13 +2284,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);
}
}
}
@ -2313,7 +2311,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
{
@ -2347,7 +2345,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);
@ -2370,7 +2368,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];
@ -2387,7 +2385,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 */
@ -2410,7 +2408,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
{
@ -2444,7 +2442,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);
@ -2459,7 +2457,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;
}
@ -2478,7 +2476,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
int i;
int v;
png_debug(1, "in png_do_build_grayscale_palette\n");
png_debug(1, "in png_do_build_grayscale_palette");
if (palette == NULL)
return;
@ -2520,7 +2518,7 @@ void /* PRIVATE */
png_correct_palette(png_structp png_ptr, png_colorp palette,
int num_palette)
{
png_debug(1, "in png_correct_palette\n");
png_debug(1, "in png_correct_palette");
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
@ -2717,7 +2715,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
png_uint_32 row_width=row_info->width;
int shift;
png_debug(1, "in png_do_background\n");
png_debug(1, "in png_do_background");
if (background != NULL &&
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -3377,7 +3375,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);
}
}
}
@ -3399,7 +3397,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
png_uint_32 i;
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_gamma\n");
png_debug(1, "in png_do_gamma");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -3581,7 +3579,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
png_uint_32 i;
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_expand_palette\n");
png_debug(1, "in png_do_expand_palette");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -3724,7 +3722,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_uint_32 i;
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_expand\n");
png_debug(1, "in png_do_expand");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -3836,7 +3834,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;
@ -3915,7 +3913,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);
}
}
}
@ -3930,7 +3928,7 @@ png_do_dither(png_row_infop row_info, png_bytep row,
png_uint_32 i;
png_uint_32 row_width=row_info->width;
png_debug(1, "in png_do_dither\n");
png_debug(1, "in png_do_dither");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -3968,7 +3966,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)
@ -3997,7 +3995,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)
@ -4025,7 +4023,7 @@ static PNG_CONST int png_gamma_shift[] =
void /* PRIVATE */
png_build_gamma_table(png_structp png_ptr)
{
png_debug(1, "in png_build_gamma_table\n");
png_debug(1, "in png_build_gamma_table");
if (png_ptr->bit_depth <= 8)
{
@ -4066,7 +4064,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 */
@ -4126,17 +4124,19 @@ 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))
{
double fin, fout;
png_uint_32 last, max;
png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p));
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;
@ -4166,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++)
@ -4186,12 +4186,14 @@ 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 )));
png_memset(png_ptr->gamma_16_to_1, 0, 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);
@ -4203,18 +4205,21 @@ 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)));
png_memset(png_ptr->gamma_16_from_1, 0,
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);
@ -4238,7 +4243,7 @@ png_build_gamma_table(png_structp png_ptr)
void /* PRIVATE */
png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_intrapixel\n");
png_debug(1, "in png_do_read_intrapixel");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -4279,11 +4284,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);

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.2.33 [October 31, 2008]
* Last changed in libpng 1.2.34 [December 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -115,7 +115,7 @@ png_read_chunk_header(png_structp png_ptr)
/* put the chunk name into png_ptr->chunk_name */
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
png_debug2(0, "Reading %s chunk, length = %lu\n",
png_debug2(0, "Reading %s chunk, length = %lu",
png_ptr->chunk_name, length);
/* reset the crc and run it over the chunk name */
@ -132,7 +132,7 @@ png_read_chunk_header(png_structp png_ptr)
void /* PRIVATE */
png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
{
if(png_ptr == NULL) return;
if (png_ptr == NULL) return;
png_read_data(png_ptr, buf, length);
png_calculate_crc(png_ptr, buf, length);
}
@ -256,7 +256,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
png_error(png_ptr,"Not enough memory to decompress chunk");
png_error(png_ptr, "Not enough memory to decompress chunk");
}
png_memcpy(text, png_ptr->chunkdata, prefix_size);
}
@ -279,12 +279,12 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_ptr->zbuf_size - png_ptr->zstream.avail_out;
text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
if (text == NULL)
{
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
png_error(png_ptr,
"Not enough memory to decompress chunk.");
}
}
png_memcpy(text + prefix_size, png_ptr->zbuf,
text_size - prefix_size);
png_memcpy(text, png_ptr->chunkdata, prefix_size);
@ -344,7 +344,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_warning(png_ptr,
"Incomplete compressed datastream in chunk other than IDAT");
#endif
text_size=prefix_size;
text_size = prefix_size;
if (text == NULL)
{
text = (png_charp)png_malloc_warn(png_ptr, text_size+1);
@ -352,7 +352,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
png_error(png_ptr,"Not enough memory for text.");
png_error(png_ptr, "Not enough memory for text.");
}
png_memcpy(text, png_ptr->chunkdata, prefix_size);
}
@ -378,7 +378,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
#endif
*(png_ptr->chunkdata + prefix_size) = 0x00;
*newlength=prefix_size;
*newlength = prefix_size;
}
}
#endif
@ -392,7 +392,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int bit_depth, color_type, compression_type, filter_type;
int interlace_type;
png_debug(1, "in png_handle_IHDR\n");
png_debug(1, "in png_handle_IHDR");
if (png_ptr->mode & PNG_HAVE_IHDR)
png_error(png_ptr, "Out of place IHDR");
@ -446,10 +446,10 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* set up other useful info */
png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
png_ptr->channels);
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
png_debug1(3,"channels = %d\n", png_ptr->channels);
png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes);
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
png_debug1(3, "channels = %d", png_ptr->channels);
png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes);
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
}
@ -464,7 +464,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_colorp pal_ptr;
#endif
png_debug(1, "in png_handle_PLTE\n");
png_debug(1, "in png_handle_PLTE");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before PLTE");
@ -596,7 +596,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void /* PRIVATE */
png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_debug(1, "in png_handle_IEND\n");
png_debug(1, "in png_handle_IEND");
if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
{
@ -611,7 +611,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
png_crc_finish(png_ptr, length);
info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */
info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
}
#if defined(PNG_READ_gAMA_SUPPORTED)
@ -624,7 +624,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
png_byte buf[4];
png_debug(1, "in png_handle_gAMA\n");
png_debug(1, "in png_handle_gAMA");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before gAMA");
@ -676,7 +676,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma);
fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
#endif
return;
}
@ -702,7 +702,7 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t truelen;
png_byte buf[4];
png_debug(1, "in png_handle_sBIT\n");
png_debug(1, "in png_handle_sBIT");
buf[0] = buf[1] = buf[2] = buf[3] = 0;
@ -774,7 +774,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 uint_x, uint_y;
png_debug(1, "in png_handle_cHRM\n");
png_debug(1, "in png_handle_cHRM");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before cHRM");
@ -812,42 +812,21 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
uint_x = png_get_uint_32(buf);
uint_y = png_get_uint_32(buf + 4);
if (uint_x > 80000L || uint_y > 80000L ||
uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM white point");
return;
}
int_x_white = (png_fixed_point)uint_x;
int_y_white = (png_fixed_point)uint_y;
uint_x = png_get_uint_32(buf + 8);
uint_y = png_get_uint_32(buf + 12);
if (uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM red point");
return;
}
int_x_red = (png_fixed_point)uint_x;
int_y_red = (png_fixed_point)uint_y;
uint_x = png_get_uint_32(buf + 16);
uint_y = png_get_uint_32(buf + 20);
if (uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM green point");
return;
}
int_x_green = (png_fixed_point)uint_x;
int_y_green = (png_fixed_point)uint_y;
uint_x = png_get_uint_32(buf + 24);
uint_y = png_get_uint_32(buf + 28);
if (uint_x + uint_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM blue point");
return;
}
int_x_blue = (png_fixed_point)uint_x;
int_y_blue = (png_fixed_point)uint_y;
@ -878,14 +857,14 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
"Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
#ifdef PNG_FLOATING_POINT_SUPPORTED
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n",
white_x, white_y, red_x, red_y);
fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",
fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n",
green_x, green_y, blue_x, blue_y);
#else
fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
int_x_white, int_y_white, int_x_red, int_y_red);
fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
int_x_green, int_y_green, int_x_blue, int_y_blue);
#endif
#endif /* PNG_NO_CONSOLE_IO */
@ -913,7 +892,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int intent;
png_byte buf[1];
png_debug(1, "in png_handle_sRGB\n");
png_debug(1, "in png_handle_sRGB");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before sRGB");
@ -974,7 +953,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
(int)png_ptr->int_gamma);
# else
# ifdef PNG_FLOATING_POINT_SUPPORTED
fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma);
fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma);
# endif
# endif
#endif
@ -1016,7 +995,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 profile_size, profile_length;
png_size_t slength, prefix_length, data_length;
png_debug(1, "in png_handle_iCCP\n");
png_debug(1, "in png_handle_iCCP");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before iCCP");
@ -1080,13 +1059,13 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (compression_type)
{
png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk");
compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8
compression_type = 0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8
wrote nonzero) */
}
prefix_length = profile - png_ptr->chunkdata;
png_decompress_chunk(png_ptr, compression_type,
slength, prefix_length, &data_length);
slength, prefix_length, &data_length);
profile_length = data_length - prefix_length;
@ -1100,15 +1079,15 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Check the profile_size recorded in the first 32 bits of the ICC profile */
pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
profile_size = ((*(pC ))<<24) |
((*(pC+1))<<16) |
((*(pC+2))<< 8) |
((*(pC+3)) );
profile_size = ((*(pC ))<<24) |
((*(pC + 1))<<16) |
((*(pC + 2))<< 8) |
((*(pC + 3)) );
if(profile_size < profile_length)
if (profile_size < profile_length)
profile_length = profile_size;
if(profile_size > profile_length)
if (profile_size > profile_length)
{
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
@ -1137,7 +1116,8 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 skip = 0;
png_size_t slength;
png_debug(1, "in png_handle_sPLT\n");
png_debug(1, "in png_handle_sPLT");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before sPLT");
@ -1273,7 +1253,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
png_debug(1, "in png_handle_tRNS\n");
png_debug(1, "in png_handle_tRNS");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before tRNS");
@ -1369,7 +1349,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t truelen;
png_byte buf[6];
png_debug(1, "in png_handle_bKGD\n");
png_debug(1, "in png_handle_bKGD");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before bKGD");
@ -1420,7 +1400,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->background.index = buf[0];
if (info_ptr && info_ptr->num_palette)
{
if(buf[0] > info_ptr->num_palette)
if (buf[0] >= info_ptr->num_palette)
{
png_warning(png_ptr, "Incorrect bKGD chunk index value");
return;
@ -1458,7 +1438,7 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
unsigned int num, i;
png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
png_debug(1, "in png_handle_hIST\n");
png_debug(1, "in png_handle_hIST");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before hIST");
@ -1513,7 +1493,7 @@ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_uint_32 res_x, res_y;
int unit_type;
png_debug(1, "in png_handle_pHYs\n");
png_debug(1, "in png_handle_pHYs");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before pHYs");
@ -1556,7 +1536,7 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_int_32 offset_x, offset_y;
int unit_type;
png_debug(1, "in png_handle_oFFs\n");
png_debug(1, "in png_handle_oFFs");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before oFFs");
@ -1603,7 +1583,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t slength;
int i;
png_debug(1, "in png_handle_pCAL\n");
png_debug(1, "in png_handle_pCAL");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before pCAL");
@ -1620,7 +1600,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
length + 1);
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
@ -1641,7 +1621,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */
png_debug(3, "Finding end of pCAL purpose string\n");
png_debug(3, "Finding end of pCAL purpose string");
for (buf = png_ptr->chunkdata; *buf; buf++)
/* empty loop */ ;
@ -1657,14 +1637,14 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n");
png_debug(3, "Reading pCAL X0, X1, type, nparams, and units");
X0 = png_get_int_32((png_bytep)buf+1);
X1 = png_get_int_32((png_bytep)buf+5);
type = buf[9];
nparams = buf[10];
units = buf + 11;
png_debug(3, "Checking pCAL equation type and number of parameters\n");
png_debug(3, "Checking pCAL equation type and number of parameters");
/* Check that we have the right number of parameters for known
equation types. */
if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||
@ -1685,7 +1665,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
for (buf = units; *buf; buf++)
/* Empty loop to move past the units string. */ ;
png_debug(3, "Allocating pCAL parameters array\n");
png_debug(3, "Allocating pCAL parameters array");
params = (png_charpp)png_malloc_warn(png_ptr,
(png_uint_32)(nparams * png_sizeof(png_charp))) ;
if (params == NULL)
@ -1701,7 +1681,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
buf++; /* Skip the null string terminator from previous parameter. */
png_debug1(3, "Reading pCAL parameter %d\n", i);
png_debug1(3, "Reading pCAL parameter %d", i);
for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
/* Empty loop to move past each parameter string */ ;
@ -1741,7 +1721,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
png_size_t slength;
png_debug(1, "in png_handle_sCAL\n");
png_debug(1, "in png_handle_sCAL");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before sCAL");
@ -1758,14 +1738,14 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
length + 1);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk");
return;
}
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk");
return;
}
slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
@ -1784,17 +1764,17 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
width = png_strtod(png_ptr, ep, &vp);
if (*vp)
{
png_warning(png_ptr, "malformed width string in sCAL chunk");
return;
png_warning(png_ptr, "malformed width string in sCAL chunk");
return;
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
if (swidth == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
return;
}
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
return;
}
png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
#endif
#endif
@ -1805,31 +1785,31 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_ptr->chunkdata + slength < ep)
{
png_warning(png_ptr, "Truncated sCAL chunk");
png_warning(png_ptr, "Truncated sCAL chunk");
#if defined(PNG_FIXED_POINT_SUPPORTED) && \
!defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, swidth);
png_free(png_ptr, swidth);
#endif
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
return;
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
height = png_strtod(png_ptr, ep, &vp);
if (*vp)
{
png_warning(png_ptr, "malformed height string in sCAL chunk");
return;
png_warning(png_ptr, "malformed height string in sCAL chunk");
return;
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
if (sheight == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
return;
}
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
return;
}
png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
#endif
#endif
@ -1875,7 +1855,7 @@ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_byte buf[7];
png_time mod_time;
png_debug(1, "in png_handle_tIME\n");
png_debug(1, "in png_handle_tIME");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Out of place tIME chunk");
@ -1923,7 +1903,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_size_t slength;
int ret;
png_debug(1, "in png_handle_tEXt\n");
png_debug(1, "in png_handle_tEXt");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before tEXt");
@ -1941,6 +1922,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
{
@ -1958,6 +1940,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
key = png_ptr->chunkdata;
key[slength] = 0x00;
for (text = key; *text; text++)
@ -1985,7 +1968,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->text = text;
text_ptr->text_length = png_strlen(text);
ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
@ -2006,7 +1989,9 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int ret;
png_size_t slength, prefix_len, data_len;
png_debug(1, "in png_handle_zTXt\n");
png_debug(1, "in png_handle_zTXt");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before zTXt");
@ -2018,7 +2003,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
there is no hard and fast rule to tell us where to stop. */
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr,"zTXt chunk too large to fit in memory");
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
png_crc_finish(png_ptr, length);
return;
}
@ -2028,7 +2013,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (png_ptr->chunkdata == NULL)
{
png_warning(png_ptr,"Out of memory processing zTXt chunk.");
png_warning(png_ptr, "Out of memory processing zTXt chunk.");
return;
}
slength = (png_size_t)length;
@ -2066,13 +2051,13 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
prefix_len = text - png_ptr->chunkdata;
png_decompress_chunk(png_ptr, comp_type,
(png_size_t)length, prefix_len, &data_len);
(png_size_t)length, prefix_len, &data_len);
text_ptr = (png_textp)png_malloc_warn(png_ptr,
(png_uint_32)png_sizeof(png_text));
(png_uint_32)png_sizeof(png_text));
if (text_ptr == NULL)
{
png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
png_warning(png_ptr, "Not enough memory to process zTXt chunk.");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
return;
@ -2087,7 +2072,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->text = png_ptr->chunkdata + prefix_len;
text_ptr->text_length = data_len;
ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
png_free(png_ptr, png_ptr->chunkdata);
@ -2109,7 +2094,8 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
int ret;
png_size_t slength, prefix_len, data_len;
png_debug(1, "in png_handle_iTXt\n");
png_debug(1, "in png_handle_iTXt");
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before iTXt");
@ -2122,7 +2108,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
there is no hard and fast rule to tell us where to stop. */
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr,"iTXt chunk too large to fit in memory");
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
png_crc_finish(png_ptr, length);
return;
}
@ -2195,14 +2181,14 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
key=png_ptr->chunkdata;
if (comp_flag)
png_decompress_chunk(png_ptr, comp_type,
(size_t)length, prefix_len, &data_len);
(size_t)length, prefix_len, &data_len);
else
data_len = png_strlen(png_ptr->chunkdata + prefix_len);
text_ptr = (png_textp)png_malloc_warn(png_ptr,
(png_uint_32)png_sizeof(png_text));
if (text_ptr == NULL)
{
png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
png_warning(png_ptr, "Not enough memory to process iTXt chunk.");
png_free(png_ptr, png_ptr->chunkdata);
png_ptr->chunkdata = NULL;
return;
@ -2215,7 +2201,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->key = png_ptr->chunkdata;
text_ptr->text = png_ptr->chunkdata + prefix_len;
ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr);
png_free(png_ptr, png_ptr->chunkdata);
@ -2235,7 +2221,8 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{
png_uint_32 skip = 0;
png_debug(1, "in png_handle_unknown\n");
png_debug(1, "in png_handle_unknown");
if (png_ptr->mode & PNG_HAVE_IDAT)
{
@ -2249,7 +2236,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
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) !=
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
@ -2281,10 +2268,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
else
{
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, 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;
@ -2295,7 +2282,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
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,
@ -2304,7 +2291,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
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;
}
@ -2330,7 +2317,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void /* PRIVATE */
png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
{
png_debug(1, "in png_check_chunk_name\n");
png_debug(1, "in png_check_chunk_name");
if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) ||
isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3]))
{
@ -2352,7 +2339,7 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
void /* PRIVATE */
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
{
png_debug(1,"in png_combine_row\n");
png_debug(1, "in png_combine_row");
if (mask == 0xff)
{
png_memcpy(row, png_ptr->row_buf + 1,
@ -2568,7 +2555,7 @@ png_do_read_interlace(png_structp png_ptr)
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
png_debug(1,"in png_do_read_interlace\n");
png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL)
{
png_uint_32 final_width;
@ -2769,7 +2756,7 @@ png_do_read_interlace(png_structp png_ptr)
}
}
row_info->width = final_width;
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
}
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
transformations = transformations; /* silence compiler warning */
@ -2781,8 +2768,8 @@ void /* PRIVATE */
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
png_bytep prev_row, int filter)
{
png_debug(1, "in png_read_filter_row\n");
png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter);
png_debug(1, "in png_read_filter_row");
png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
@ -2886,7 +2873,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
p = c;
*/
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
*rp = (png_byte)(((int)(*rp) + p) & 0xff);
rp++;
@ -2895,7 +2882,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
}
default:
png_warning(png_ptr, "Ignoring bad adaptive filter type");
*row=0;
*row = 0;
break;
}
}
@ -2921,7 +2908,7 @@ png_read_finish_row(png_structp png_ptr)
#endif /* PNG_READ_INTERLACING_SUPPORTED */
#endif
png_debug(1, "in png_read_finish_row\n");
png_debug(1, "in png_read_finish_row");
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
return;
@ -2973,7 +2960,7 @@ png_read_finish_row(png_structp png_ptr)
png_ptr->zstream.next_out = (Byte *)&extra;
png_ptr->zstream.avail_out = (uInt)1;
for(;;)
for (;;)
{
if (!(png_ptr->zstream.avail_in))
{
@ -3056,7 +3043,7 @@ png_read_start_row(png_structp png_ptr)
int max_pixel_depth;
png_size_t row_bytes;
png_debug(1, "in png_read_start_row\n");
png_debug(1, "in png_read_start_row");
png_ptr->zstream.avail_in = 0;
png_init_read_transformations(png_ptr);
#ifdef PNG_READ_INTERLACING_SUPPORTED
@ -3176,11 +3163,11 @@ png_read_start_row(png_structp png_ptr)
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if(png_ptr->transformations & PNG_USER_TRANSFORM)
if (png_ptr->transformations & PNG_USER_TRANSFORM)
{
int user_pixel_depth=png_ptr->user_transform_depth*
int user_pixel_depth = png_ptr->user_transform_depth*
png_ptr->user_transform_channels;
if(user_pixel_depth > max_pixel_depth)
if (user_pixel_depth > max_pixel_depth)
max_pixel_depth=user_pixel_depth;
}
#endif
@ -3190,7 +3177,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
/* calculate the maximum bytes needed, adding a byte and a pixel
for safety's sake */
row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) +
row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
1 + ((max_pixel_depth + 7) >> 3);
#ifdef PNG_MAX_MALLOC_64K
if (row_bytes > (png_uint_32)65536L)
@ -3200,8 +3187,8 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
{
png_free(png_ptr, png_ptr->big_row_buf);
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32;
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32;
png_ptr->old_big_row_buf_size = row_bytes+64;
}
@ -3215,19 +3202,19 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (png_ptr->rowbytes+1 > png_ptr->old_prev_row_size)
{
png_free(png_ptr, png_ptr->prev_row);
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
png_ptr->rowbytes + 1));
png_ptr->old_prev_row_size = png_ptr->rowbytes+1;
}
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %lu,\n", png_ptr->width);
png_debug1(3, "height = %lu,\n", png_ptr->height);
png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth);
png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes);
png_debug1(3, "width = %lu,", png_ptr->width);
png_debug1(3, "height = %lu,", png_ptr->height);
png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %lu", png_ptr->irowbytes);
png_ptr->flags |= PNG_FLAG_ROW_INIT;
}

View File

@ -1,9 +1,9 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.35 [February 14, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* Copyright (c) 1998-2009 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.)
*
@ -21,7 +21,7 @@
void PNGAPI
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
{
png_debug1(1, "in %s storage function\n", "bKGD");
png_debug1(1, "in %s storage function", "bKGD");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -37,34 +37,9 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double white_x, double white_y, double red_x, double red_y,
double green_x, double green_y, double blue_x, double blue_y)
{
png_debug1(1, "in %s storage function\n", "cHRM");
png_debug1(1, "in %s storage function", "cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0.0 || white_y < 0.0 ||
red_x < 0.0 || red_y < 0.0 ||
green_x < 0.0 || green_y < 0.0 ||
blue_x < 0.0 || blue_y < 0.0)
{
png_warning(png_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
if (white_x > 21474.83 || white_y > 21474.83 ||
red_x > 21474.83 || red_y > 21474.83 ||
green_x > 21474.83 || green_y > 21474.83 ||
blue_x > 21474.83 || blue_y > 21474.83)
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
return;
}
info_ptr->x_white = (float)white_x;
info_ptr->y_white = (float)white_y;
@ -86,7 +61,8 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
#endif
info_ptr->valid |= PNG_INFO_cHRM;
}
#endif
#endif /* PNG_FLOATING_POINT_SUPPORTED */
#ifdef PNG_FIXED_POINT_SUPPORTED
void PNGAPI
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
@ -94,61 +70,38 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
png_fixed_point blue_x, png_fixed_point blue_y)
{
png_debug1(1, "in %s storage function\n", "cHRM");
png_debug1(1, "in %s storage function", "cHRM fixed");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
blue_x || blue_y))
#if !defined(PNG_NO_CHECK_cHRM)
if (png_check_cHRM_fixed(png_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
#endif
{
png_warning(png_ptr,
"Ignoring attempt to set all-zero chromaticity values");
return;
}
if (white_x < 0 || white_y < 0 ||
red_x < 0 || red_y < 0 ||
green_x < 0 || green_y < 0 ||
blue_x < 0 || blue_y < 0)
{
png_warning(png_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
white_y > (png_fixed_point) PNG_UINT_31_MAX ||
red_x > (png_fixed_point) PNG_UINT_31_MAX ||
red_y > (png_fixed_point) PNG_UINT_31_MAX ||
green_x > (png_fixed_point) PNG_UINT_31_MAX ||
green_y > (png_fixed_point) PNG_UINT_31_MAX ||
blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
blue_y > (png_fixed_point) PNG_UINT_31_MAX )
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
return;
}
info_ptr->int_x_white = white_x;
info_ptr->int_y_white = white_y;
info_ptr->int_x_red = red_x;
info_ptr->int_y_red = red_y;
info_ptr->int_x_green = green_x;
info_ptr->int_y_green = green_y;
info_ptr->int_x_blue = blue_x;
info_ptr->int_y_blue = blue_y;
info_ptr->int_x_white = white_x;
info_ptr->int_y_white = white_y;
info_ptr->int_x_red = red_x;
info_ptr->int_y_red = red_y;
info_ptr->int_x_green = green_x;
info_ptr->int_y_green = green_y;
info_ptr->int_x_blue = blue_x;
info_ptr->int_y_blue = blue_y;
#ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->x_white = (float)(white_x/100000.);
info_ptr->y_white = (float)(white_y/100000.);
info_ptr->x_red = (float)( red_x/100000.);
info_ptr->y_red = (float)( red_y/100000.);
info_ptr->x_green = (float)(green_x/100000.);
info_ptr->y_green = (float)(green_y/100000.);
info_ptr->x_blue = (float)( blue_x/100000.);
info_ptr->y_blue = (float)( blue_y/100000.);
info_ptr->x_white = (float)(white_x/100000.);
info_ptr->y_white = (float)(white_y/100000.);
info_ptr->x_red = (float)( red_x/100000.);
info_ptr->y_red = (float)( red_y/100000.);
info_ptr->x_green = (float)(green_x/100000.);
info_ptr->y_green = (float)(green_y/100000.);
info_ptr->x_blue = (float)( blue_x/100000.);
info_ptr->y_blue = (float)( blue_y/100000.);
#endif
info_ptr->valid |= PNG_INFO_cHRM;
info_ptr->valid |= PNG_INFO_cHRM;
}
}
#endif
#endif
#endif /* PNG_FIXED_POINT_SUPPORTED */
#endif /* PNG_cHRM_SUPPORTED */
#if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED
@ -156,7 +109,7 @@ void PNGAPI
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{
double gamma;
png_debug1(1, "in %s storage function\n", "gAMA");
png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -167,13 +120,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
@ -183,7 +136,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
{
png_fixed_point gamma;
png_debug1(1, "in %s storage function\n", "gAMA");
png_debug1(1, "in %s storage function", "gAMA");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -197,10 +150,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.);
@ -209,7 +162,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
@ -220,7 +173,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
{
int i;
png_debug1(1, "in %s storage function\n", "hIST");
png_debug1(1, "in %s storage function", "hIST");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->num_palette == 0 || info_ptr->num_palette
@ -237,7 +190,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.");
@ -263,7 +216,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type)
{
png_debug1(1, "in %s storage function\n", "IHDR");
png_debug1(1, "in %s storage function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -318,21 +271,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
@ -362,7 +315,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_oFFs_SUPPORTED)
@ -370,7 +323,7 @@ void PNGAPI
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
png_int_32 offset_x, png_int_32 offset_y, int unit_type)
{
png_debug1(1, "in %s storage function\n", "oFFs");
png_debug1(1, "in %s storage function", "oFFs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -390,66 +343,67 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_uint_32 length;
int i;
png_debug1(1, "in %s storage function\n", "pCAL");
png_debug1(1, "in %s storage function", "pCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
length = png_strlen(purpose) + 1;
png_debug1(3, "allocating purpose for info (%lu bytes)\n",
png_debug1(3, "allocating purpose for info (%lu bytes)",
(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");
png_debug(3, "storing X0, X1, type, and nparams in info");
info_ptr->pcal_X0 = X0;
info_ptr->pcal_X1 = X1;
info_ptr->pcal_type = (png_byte)type;
info_ptr->pcal_nparams = (png_byte)nparams;
length = png_strlen(units) + 1;
png_debug1(3, "allocating units for info (%lu bytes)\n",
png_debug1(3, "allocating units for info (%lu bytes)",
(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;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_PCAL;
#endif
png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
for (i = 0; i < nparams; i++)
{
length = png_strlen(params[i]) + 1;
png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i,
png_debug2(3, "allocating parameter %d for info (%lu bytes)", 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);
}
info_ptr->valid |= PNG_INFO_pCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_PCAL;
#endif
}
#endif
@ -459,7 +413,7 @@ void PNGAPI
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
int unit, double width, double height)
{
png_debug1(1, "in %s storage function\n", "sCAL");
png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -477,14 +431,14 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
{
png_uint_32 length;
png_debug1(1, "in %s storage function\n", "sCAL");
png_debug1(1, "in %s storage function", "sCAL");
if (png_ptr == NULL || info_ptr == NULL)
return;
info_ptr->scal_unit = (png_byte)unit;
length = png_strlen(swidth) + 1;
png_debug1(3, "allocating unit for info (%u bytes)\n",
png_debug1(3, "allocating unit for info (%u bytes)",
(unsigned int)length);
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->scal_s_width == NULL)
@ -496,7 +450,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
length = png_strlen(sheight) + 1;
png_debug1(3, "allocating unit for info (%u bytes)\n",
png_debug1(3, "allocating unit for info (%u bytes)",
(unsigned int)length);
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
if (info_ptr->scal_s_height == NULL)
@ -522,7 +476,7 @@ void PNGAPI
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type)
{
png_debug1(1, "in %s storage function\n", "pHYs");
png_debug1(1, "in %s storage function", "pHYs");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -538,7 +492,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
png_colorp palette, int num_palette)
{
png_debug1(1, "in %s storage function\n", "PLTE");
png_debug1(1, "in %s storage function", "PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -569,7 +523,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;
@ -587,11 +541,11 @@ void PNGAPI
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit)
{
png_debug1(1, "in %s storage function\n", "sBIT");
png_debug1(1, "in %s storage function", "sBIT");
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
@ -600,7 +554,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
void PNGAPI
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{
png_debug1(1, "in %s storage function\n", "sRGB");
png_debug1(1, "in %s storage function", "sRGB");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -624,12 +578,10 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
int_green_y, int_blue_x, int_blue_y;
#endif
#endif
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -647,7 +599,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
#endif
#if defined(PNG_cHRM_SUPPORTED)
#ifdef PNG_FIXED_POINT_SUPPORTED
int_white_x = 31270L;
int_white_y = 32900L;
int_red_x = 64000L;
@ -657,10 +608,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int_blue_x = 15000L;
int_blue_y = 6000L;
png_set_cHRM_fixed(png_ptr, info_ptr,
int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
int_blue_x, int_blue_y);
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
white_x = (float).3127;
white_y = (float).3290;
@ -670,13 +617,27 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
green_y = (float).60;
blue_x = (float).15;
blue_y = (float).06;
#endif
png_set_cHRM(png_ptr, info_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
#if !defined(PNG_NO_CHECK_cHRM)
if (png_check_cHRM_fixed(png_ptr,
int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
int_green_y, int_blue_x, int_blue_y))
#endif
{
#ifdef PNG_FIXED_POINT_SUPPORTED
png_set_cHRM_fixed(png_ptr, info_ptr,
int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
int_green_y, int_blue_x, int_blue_y);
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
png_set_cHRM(png_ptr, info_ptr,
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
#endif
}
#endif /* cHRM */
}
#endif
#endif /* sRGB */
#if defined(PNG_iCCP_SUPPORTED)
@ -689,7 +650,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charp new_iccp_profile;
png_uint_32 length;
png_debug1(1, "in %s storage function\n", "iCCP");
png_debug1(1, "in %s storage function", "iCCP");
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return;
@ -732,7 +693,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");
}
@ -743,7 +704,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
{
int i;
png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ?
"text" : (png_const_charp)png_ptr->chunk_name));
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
@ -763,7 +724,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);
@ -778,20 +739,20 @@ 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
info_ptr->free_me |= PNG_FREE_TEXT;
#endif
}
png_debug1(3, "allocated %d entries for info_ptr->text\n",
png_debug1(3, "allocated %d entries for info_ptr->text",
info_ptr->max_text);
}
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)
@ -799,7 +760,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;
@ -828,7 +789,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
@ -845,24 +806,24 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
(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_debug2(2, "Allocated %lu bytes at %x in png_set_text",
(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
@ -871,15 +832,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;
@ -893,7 +854,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
#endif
}
info_ptr->num_text++;
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
}
return(0);
}
@ -903,12 +864,12 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
void PNGAPI
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{
png_debug1(1, "in %s storage function\n", "tIME");
png_debug1(1, "in %s storage function", "tIME");
if (png_ptr == NULL || info_ptr == NULL ||
(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
@ -918,7 +879,7 @@ void PNGAPI
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values)
{
png_debug1(1, "in %s storage function\n", "tRNS");
png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -961,7 +922,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
info_ptr->num_trans = (png_uint_16)num_trans;
if (num_trans != 0)
{
info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->valid |= PNG_INFO_tRNS;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TRNS;
#else
@ -1000,6 +961,7 @@ png_set_sPLT(png_structp png_ptr,
png_memcpy(np, info_ptr->splt_palettes,
info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes=NULL;
@ -1024,7 +986,7 @@ png_set_sPLT(png_structp png_ptr,
{
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;
}
@ -1071,13 +1033,13 @@ 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);
@ -1088,15 +1050,15 @@ png_set_unknown_chunks(png_structp png_ptr,
{
to->data = (png_bytep)png_malloc_warn(png_ptr,
(png_uint_32)from->size);
if (to->data == NULL)
{
png_warning(png_ptr,
if (to->data == NULL)
{
png_warning(png_ptr,
"Out of memory while processing unknown chunk.");
to->size = 0;
}
else
png_memcpy(to->data, from->data, from->size);
}
}
else
png_memcpy(to->data, from->data, from->size);
}
}
info_ptr->unknown_chunks = np;
@ -1109,7 +1071,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;
}
@ -1123,7 +1085,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{
/* This function is deprecated in favor of png_permit_mng_features()
and will be removed from libpng-1.3.0 */
png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
png_debug(1, "in png_permit_empty_plte, DEPRECATED.");
if (png_ptr == NULL)
return;
png_ptr->mng_features_permitted = (png_byte)
@ -1137,7 +1099,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
png_uint_32 PNGAPI
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
{
png_debug(1, "in png_permit_mng_features\n");
png_debug(1, "in png_permit_mng_features");
if (png_ptr == NULL)
return (png_uint_32)0;
png_ptr->mng_features_permitted =
@ -1157,12 +1119,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;
@ -1170,23 +1132,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)
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
@ -1198,7 +1160,7 @@ void PNGAPI
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
png_user_chunk_ptr read_user_chunk_fn)
{
png_debug(1, "in png_set_read_user_chunk_fn\n");
png_debug(1, "in png_set_read_user_chunk_fn");
if (png_ptr == NULL)
return;
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
@ -1210,15 +1172,15 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
void PNGAPI
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
{
png_debug1(1, "in %s storage function\n", "rows");
png_debug1(1, "in %s storage function", "rows");
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
@ -1230,7 +1192,7 @@ png_set_compression_buffer_size(png_structp png_ptr,
{
if (png_ptr == NULL)
return;
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;
@ -1283,7 +1245,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;
}

View File

@ -17,8 +17,8 @@
void PNGAPI
png_set_bgr(png_structp png_ptr)
{
png_debug(1, "in png_set_bgr\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_bgr");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_BGR;
}
#endif
@ -28,8 +28,8 @@ png_set_bgr(png_structp png_ptr)
void PNGAPI
png_set_swap(png_structp png_ptr)
{
png_debug(1, "in png_set_swap\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_swap");
if (png_ptr == NULL) return;
if (png_ptr->bit_depth == 16)
png_ptr->transformations |= PNG_SWAP_BYTES;
}
@ -40,8 +40,8 @@ png_set_swap(png_structp png_ptr)
void PNGAPI
png_set_packing(png_structp png_ptr)
{
png_debug(1, "in png_set_packing\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_packing");
if (png_ptr == NULL) return;
if (png_ptr->bit_depth < 8)
{
png_ptr->transformations |= PNG_PACK;
@ -55,8 +55,8 @@ png_set_packing(png_structp png_ptr)
void PNGAPI
png_set_packswap(png_structp png_ptr)
{
png_debug(1, "in png_set_packswap\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_packswap");
if (png_ptr == NULL) return;
if (png_ptr->bit_depth < 8)
png_ptr->transformations |= PNG_PACKSWAP;
}
@ -66,8 +66,8 @@ png_set_packswap(png_structp png_ptr)
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;
png_debug(1, "in png_set_shift");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_SHIFT;
png_ptr->shift = *true_bits;
}
@ -78,7 +78,7 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
int PNGAPI
png_set_interlace_handling(png_structp png_ptr)
{
png_debug(1, "in png_set_interlace handling\n");
png_debug(1, "in png_set_interlace handling");
if (png_ptr && png_ptr->interlaced)
{
png_ptr->transformations |= PNG_INTERLACE;
@ -98,8 +98,8 @@ png_set_interlace_handling(png_structp png_ptr)
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;
png_debug(1, "in png_set_filler");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_FILLER;
png_ptr->filler = (png_byte)filler;
if (filler_loc == PNG_FILLER_AFTER)
@ -131,8 +131,8 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
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;
png_debug(1, "in png_set_add_alpha");
if (png_ptr == NULL) return;
png_set_filler(png_ptr, filler, filler_loc);
png_ptr->transformations |= PNG_ADD_ALPHA;
}
@ -145,8 +145,8 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
void PNGAPI
png_set_swap_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_swap_alpha\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_swap_alpha");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_SWAP_ALPHA;
}
#endif
@ -156,8 +156,8 @@ png_set_swap_alpha(png_structp png_ptr)
void PNGAPI
png_set_invert_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_invert_alpha\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_invert_alpha");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_INVERT_ALPHA;
}
#endif
@ -166,8 +166,8 @@ png_set_invert_alpha(png_structp png_ptr)
void PNGAPI
png_set_invert_mono(png_structp png_ptr)
{
png_debug(1, "in png_set_invert_mono\n");
if(png_ptr == NULL) return;
png_debug(1, "in png_set_invert_mono");
if (png_ptr == NULL) return;
png_ptr->transformations |= PNG_INVERT_MONO;
}
@ -175,7 +175,7 @@ png_set_invert_mono(png_structp png_ptr)
void /* PRIVATE */
png_do_invert(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_invert\n");
png_debug(1, "in png_do_invert");
/* This test removed from libpng version 1.0.13 and 1.2.0:
* if (row_info->bit_depth == 1 &&
*/
@ -230,7 +230,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_swap\n");
png_debug(1, "in png_do_swap");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -361,7 +361,7 @@ static PNG_CONST png_byte fourbppswaptable[256] = {
void /* PRIVATE */
png_do_packswap(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_packswap\n");
png_debug(1, "in png_do_packswap");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -393,7 +393,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
{
png_debug(1, "in png_do_strip_filler\n");
png_debug(1, "in png_do_strip_filler");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -551,7 +551,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
void /* PRIVATE */
png_do_bgr(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_bgr\n");
png_debug(1, "in png_do_bgr");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -630,14 +630,14 @@ void PNGAPI
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;
png_debug(1, "in png_set_user_transform_info");
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

View File

@ -1,9 +1,9 @@
/* pngwio.c - functions for data output
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.35 [February 14, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* Copyright (c) 1998-2009 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,10 +134,10 @@ 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)
if (io_ptr != NULL && fileno(io_ptr) != -1)
fflush(io_ptr);
#endif
}
@ -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

View File

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.2.31 [August 19, 2008]
* Last changed in libpng 1.2.34 [December 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -25,16 +25,16 @@
void PNGAPI
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_info_before_PLTE\n");
png_debug(1, "in png_write_info_before_PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
{
png_write_sig(png_ptr); /* write PNG signature */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted))
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
@ -99,7 +99,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{
png_unknown_chunk *up;
png_debug(5, "writing extra chunks\n");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
@ -130,7 +130,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
int i;
#endif
png_debug(1, "in png_write_info\n");
png_debug(1, "in png_write_info");
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -215,7 +215,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
/* Check to see if we need to write text chunks */
for (i = 0; i < info_ptr->num_text; i++)
{
png_debug2(2, "Writing header text chunk %d, type %d\n", i,
png_debug2(2, "Writing header text chunk %d, type %d", i,
info_ptr->text[i].compression);
/* an internationalized chunk? */
if (info_ptr->text[i].compression > 0)
@ -268,7 +268,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
{
png_unknown_chunk *up;
png_debug(5, "writing extra chunks\n");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
@ -296,7 +296,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
void PNGAPI
png_write_end(png_structp png_ptr, png_infop info_ptr)
{
png_debug(1, "in png_write_end\n");
png_debug(1, "in png_write_end");
if (png_ptr == NULL)
return;
if (!(png_ptr->mode & PNG_HAVE_IDAT))
@ -318,7 +318,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
/* loop through comment chunks */
for (i = 0; i < info_ptr->num_text; i++)
{
png_debug2(2, "Writing trailer text chunk %d, type %d\n", i,
png_debug2(2, "Writing trailer text chunk %d, type %d", i,
info_ptr->text[i].compression);
/* an internationalized chunk? */
if (info_ptr->text[i].compression > 0)
@ -370,7 +370,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
{
png_unknown_chunk *up;
png_debug(5, "writing extra chunks\n");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
@ -413,7 +413,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
void PNGAPI
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
{
png_debug(1, "in png_convert_from_struct_tm\n");
png_debug(1, "in png_convert_from_struct_tm");
ptime->year = (png_uint_16)(1900 + ttime->tm_year);
ptime->month = (png_byte)(ttime->tm_mon + 1);
ptime->day = (png_byte)ttime->tm_mday;
@ -427,7 +427,7 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
{
struct tm *tbuf;
png_debug(1, "in png_convert_from_time_t\n");
png_debug(1, "in png_convert_from_time_t");
tbuf = gmtime(&ttime);
png_convert_from_struct_tm(ptime, tbuf);
}
@ -454,14 +454,14 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef PNG_SETJMP_SUPPORTED
volatile
#endif
png_structp png_ptr;
png_structp png_ptr;
#ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD
jmp_buf jmpbuf;
#endif
#endif
int i;
png_debug(1, "in png_create_write_struct\n");
png_debug(1, "in png_create_write_struct");
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
@ -485,12 +485,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
@ -499,12 +499,12 @@ 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);
if(user_png_ver)
if (user_png_ver)
{
i=0;
do
{
if(user_png_ver[i] != png_libpng_ver[i])
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
@ -562,7 +562,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();
@ -587,9 +587,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];
@ -607,7 +607,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
@ -616,7 +616,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
@ -653,17 +653,17 @@ 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
}
} while (png_libpng_ver[i++]);
png_debug(1, "in png_write_init_3\n");
png_debug(1, "in png_write_init_3");
#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)
@ -674,7 +674,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
@ -684,7 +684,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,
@ -713,7 +713,7 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
png_uint_32 i; /* row counter */
png_bytepp rp; /* row pointer */
png_debug(1, "in png_write_rows\n");
png_debug(1, "in png_write_rows");
if (png_ptr == NULL)
return;
@ -738,7 +738,7 @@ png_write_image(png_structp png_ptr, png_bytepp image)
if (png_ptr == NULL)
return;
png_debug(1, "in png_write_image\n");
png_debug(1, "in png_write_image");
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* intialize interlace handling. If image is not interlaced,
this will set pass to 1 */
@ -763,7 +763,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
{
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
png_debug2(1, "in png_write_row (row %ld, pass %d)",
png_ptr->row_number, png_ptr->pass);
/* initialize transformations and other stuff if first time */
@ -877,12 +877,12 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
png_ptr->row_info.width);
png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes);
png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row,
@ -918,7 +918,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 */
@ -938,7 +938,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
void PNGAPI
png_set_flush(png_structp png_ptr, int nrows)
{
png_debug(1, "in png_set_flush\n");
png_debug(1, "in png_set_flush");
if (png_ptr == NULL)
return;
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
@ -950,7 +950,7 @@ png_write_flush(png_structp png_ptr)
{
int wrote_IDAT;
png_debug(1, "in png_write_flush\n");
png_debug(1, "in png_write_flush");
if (png_ptr == NULL)
return;
/* We have already written out all of the data */
@ -1010,7 +1010,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_voidp mem_ptr = NULL;
#endif
png_debug(1, "in png_destroy_write_struct\n");
png_debug(1, "in png_destroy_write_struct");
if (png_ptr_ptr != NULL)
{
png_ptr = *png_ptr_ptr;
@ -1042,7 +1042,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_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
}
@ -1084,7 +1084,7 @@ png_write_destroy(png_structp png_ptr)
png_free_ptr free_fn;
#endif
png_debug(1, "in png_write_destroy\n");
png_debug(1, "in png_write_destroy");
/* free any memory zlib uses */
deflateEnd(&png_ptr->zstream);
@ -1113,7 +1113,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;
@ -1123,7 +1123,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;
@ -1133,7 +1133,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
}
@ -1141,11 +1141,11 @@ png_write_destroy(png_structp png_ptr)
void PNGAPI
png_set_filter(png_structp png_ptr, int method, int filters)
{
png_debug(1, "in png_set_filter\n");
png_debug(1, "in png_set_filter");
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
@ -1264,7 +1264,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
{
int i;
png_debug(1, "in png_set_filter_heuristics\n");
png_debug(1, "in png_set_filter_heuristics");
if (png_ptr == NULL)
return;
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
@ -1378,7 +1378,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
void PNGAPI
png_set_compression_level(png_structp png_ptr, int level)
{
png_debug(1, "in png_set_compression_level\n");
png_debug(1, "in png_set_compression_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
@ -1388,7 +1388,7 @@ png_set_compression_level(png_structp png_ptr, int level)
void PNGAPI
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
{
png_debug(1, "in png_set_compression_mem_level\n");
png_debug(1, "in png_set_compression_mem_level");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
@ -1398,7 +1398,7 @@ png_set_compression_mem_level(png_structp png_ptr, int mem_level)
void PNGAPI
png_set_compression_strategy(png_structp png_ptr, int strategy)
{
png_debug(1, "in png_set_compression_strategy\n");
png_debug(1, "in png_set_compression_strategy");
if (png_ptr == NULL)
return;
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
@ -1429,7 +1429,7 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
void PNGAPI
png_set_compression_method(png_structp png_ptr, int method)
{
png_debug(1, "in png_set_compression_method\n");
png_debug(1, "in png_set_compression_method");
if (png_ptr == NULL)
return;
if (method != 8)
@ -1451,7 +1451,7 @@ void PNGAPI
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
write_user_transform_fn)
{
png_debug(1, "in png_set_write_user_transform_fn\n");
png_debug(1, "in png_set_write_user_transform_fn");
if (png_ptr == NULL)
return;
png_ptr->transformations |= PNG_USER_TRANSFORM;
@ -1506,11 +1506,11 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED)
/* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
* RGB (4 channels -> 3 channels). The second parameter is not used.
*/
if (transforms & PNG_TRANSFORM_STRIP_FILLER)
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
/* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED)

View File

@ -18,14 +18,14 @@
void /* PRIVATE */
png_do_write_transformations(png_structp png_ptr)
{
png_debug(1, "in png_do_write_transformations\n");
png_debug(1, "in png_do_write_transformations");
if (png_ptr == NULL)
return;
#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: */
@ -86,7 +86,7 @@ png_do_write_transformations(png_structp png_ptr)
void /* PRIVATE */
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
{
png_debug(1, "in png_do_pack\n");
png_debug(1, "in png_do_pack");
if (row_info->bit_depth == 8 &&
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -212,7 +212,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
void /* PRIVATE */
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
{
png_debug(1, "in png_do_shift\n");
png_debug(1, "in png_do_shift");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL &&
#else
@ -336,7 +336,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
void /* PRIVATE */
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_write_swap_alpha\n");
png_debug(1, "in png_do_write_swap_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -424,7 +424,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_write_invert_alpha\n");
png_debug(1, "in png_do_write_invert_alpha");
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL)
#endif
@ -514,7 +514,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_write_intrapixel\n");
png_debug(1, "in png_do_write_intrapixel");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
@ -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);

View File

@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.2.30 [August 15, 2008]
* Last changed in libpng 1.2.34 [December 18, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -80,7 +80,7 @@ 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, (png_size_t)length);
png_write_chunk_end(png_ptr);
@ -96,9 +96,9 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
{
png_byte buf[8];
png_debug2(0, "Writing %s chunk, length = %lu\n", chunk_name,
png_debug2(0, "Writing %s chunk, length = %lu", chunk_name,
(unsigned long)length);
if(png_ptr == NULL) return;
if (png_ptr == NULL) return;
/* write the length and the chunk name */
png_save_uint_32(buf, length);
@ -120,7 +120,7 @@ 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_write_data(png_ptr, data, length);
@ -137,7 +137,7 @@ 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 in a single operation */
png_save_uint_32(buf, png_ptr->crc);
@ -248,7 +248,7 @@ png_text_compress(png_structp png_ptr,
(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
@ -300,13 +300,13 @@ png_text_compress(png_structp png_ptr,
(png_uint_32)(comp->max_output_ptr *
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 */
@ -357,14 +357,14 @@ 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_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,
@ -392,7 +392,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_byte buf[13]; /* buffer to store the IHDR info */
png_debug(1, "in png_write_IHDR\n");
png_debug(1, "in png_write_IHDR");
/* Check that we have valid input data from the application info */
switch (color_type)
{
@ -404,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:
@ -534,7 +534,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
png_ptr->zlib_method = 8;
ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
png_ptr->zlib_method, png_ptr->zlib_window_bits,
png_ptr->zlib_method, png_ptr->zlib_window_bits,
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
if (ret != Z_OK)
{
@ -544,7 +544,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
"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_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;
@ -569,7 +569,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_colorp pal_ptr;
png_byte buf[3];
png_debug(1, "in png_write_PLTE\n");
png_debug(1, "in png_write_PLTE");
if ((
#if defined(PNG_MNG_FEATURES_SUPPORTED)
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
@ -595,7 +595,7 @@ 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_debug1(3, "num_palette = %d", png_ptr->num_palette);
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE,
(png_uint_32)(num_pal * 3));
@ -629,7 +629,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IDAT;
#endif
png_debug(1, "in png_write_IDAT\n");
png_debug(1, "in png_write_IDAT");
/* Optimize the CMF field in the zlib stream. */
/* This hack of the zlib stream is compliant to the stream specification. */
@ -681,7 +681,7 @@ png_write_IEND(png_structp png_ptr)
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_IEND;
#endif
png_debug(1, "in png_write_IEND\n");
png_debug(1, "in png_write_IEND");
png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
(png_size_t)0);
png_ptr->mode |= PNG_HAVE_IEND;
@ -699,7 +699,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
png_uint_32 igamma;
png_byte buf[4];
png_debug(1, "in png_write_gAMA\n");
png_debug(1, "in png_write_gAMA");
/* file_gamma is saved in 1/100,000ths */
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
png_save_uint_32(buf, igamma);
@ -715,7 +715,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
#endif
png_byte buf[4];
png_debug(1, "in png_write_gAMA\n");
png_debug(1, "in png_write_gAMA");
/* file_gamma is saved in 1/100,000ths */
png_save_uint_32(buf, (png_uint_32)file_gamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
@ -733,8 +733,8 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
#endif
png_byte buf[1];
png_debug(1, "in png_write_sRGB\n");
if(srgb_intent >= PNG_sRGB_INTENT_LAST)
png_debug(1, "in png_write_sRGB");
if (srgb_intent >= PNG_sRGB_INTENT_LAST)
png_warning(png_ptr,
"Invalid sRGB rendering intent specified");
buf[0]=(png_byte)srgb_intent;
@ -756,7 +756,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
compression_state comp;
int embedded_profile_len = 0;
png_debug(1, "in png_write_iCCP\n");
png_debug(1, "in png_write_iCCP");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
@ -764,12 +764,9 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
comp.input = NULL;
comp.input_len = 0;
if (name == NULL || (name_len = png_check_keyword(png_ptr, name,
if ((name_len = png_check_keyword(png_ptr, name,
&new_name)) == 0)
{
png_warning(png_ptr, "Empty keyword in iCCP chunk");
return;
}
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
png_warning(png_ptr, "Unknown compression type in iCCP chunk");
@ -779,24 +776,24 @@ 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,
@ -805,7 +802,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
/* make sure we include the NULL after the name and the compression type */
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
(png_uint_32)(name_len + profile_len + 2));
new_name[name_len+1]=0x00;
new_name[name_len + 1] = 0x00;
png_write_chunk_data(png_ptr, (png_bytep)new_name,
(png_size_t)(name_len + 2));
@ -835,63 +832,60 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
int i;
#endif
png_debug(1, "in png_write_sPLT\n");
if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr,
png_debug(1, "in png_write_sPLT");
if ((name_len = png_check_keyword(png_ptr,
spalette->name, &new_name))==0)
{
png_warning(png_ptr, "Empty keyword in sPLT chunk");
return;
}
return;
/* make sure we include the NULL after the name */
png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
(png_uint_32)(name_len + 2 + palette_size));
(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);
}
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
@ -912,7 +906,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
png_byte buf[4];
png_size_t size;
png_debug(1, "in png_write_sBIT\n");
png_debug(1, "in png_write_sBIT");
/* make sure we don't depend upon the order of PNG_COLOR_8 */
if (color_type & PNG_COLOR_MASK_COLOR)
{
@ -969,55 +963,42 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
PNG_cHRM;
#endif
png_byte buf[32];
png_uint_32 itemp;
png_debug(1, "in png_write_cHRM\n");
/* each value is saved in 1/100,000ths */
if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
white_x + white_y > 1.0)
{
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);
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y,
int_green_x, int_green_y, int_blue_x, int_blue_y;
png_debug(1, "in png_write_cHRM");
int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5);
int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5);
int_red_x = (png_uint_32)(red_x * 100000.0 + 0.5);
int_red_y = (png_uint_32)(red_y * 100000.0 + 0.5);
int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5);
int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5);
int_blue_x = (png_uint_32)(blue_x * 100000.0 + 0.5);
int_blue_y = (png_uint_32)(blue_y * 100000.0 + 0.5);
#if !defined(PNG_NO_CHECK_cHRM)
if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y,
int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y))
#endif
return;
}
itemp = (png_uint_32)(white_x * 100000.0 + 0.5);
png_save_uint_32(buf, itemp);
itemp = (png_uint_32)(white_y * 100000.0 + 0.5);
png_save_uint_32(buf + 4, itemp);
if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM red point specified");
return;
}
itemp = (png_uint_32)(red_x * 100000.0 + 0.5);
png_save_uint_32(buf + 8, itemp);
itemp = (png_uint_32)(red_y * 100000.0 + 0.5);
png_save_uint_32(buf + 12, itemp);
/* each value is saved in 1/100,000ths */
png_save_uint_32(buf, int_white_x);
png_save_uint_32(buf + 4, int_white_y);
if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM green point specified");
return;
}
itemp = (png_uint_32)(green_x * 100000.0 + 0.5);
png_save_uint_32(buf + 16, itemp);
itemp = (png_uint_32)(green_y * 100000.0 + 0.5);
png_save_uint_32(buf + 20, itemp);
png_save_uint_32(buf + 8, int_red_x);
png_save_uint_32(buf + 12, int_red_y);
if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0)
{
png_warning(png_ptr, "Invalid cHRM blue point specified");
return;
}
itemp = (png_uint_32)(blue_x * 100000.0 + 0.5);
png_save_uint_32(buf + 24, itemp);
itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
png_save_uint_32(buf + 28, itemp);
png_save_uint_32(buf + 16, int_green_x);
png_save_uint_32(buf + 20, int_green_y);
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
png_save_uint_32(buf + 24, int_blue_x);
png_save_uint_32(buf + 28, int_blue_y);
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
}
}
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
@ -1032,45 +1013,27 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
#endif
png_byte buf[32];
png_debug(1, "in png_write_cHRM\n");
png_debug(1, "in png_write_cHRM");
/* each value is saved in 1/100,000ths */
if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
{
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", (unsigned long)white_x,
(unsigned long)white_y);
#if !defined(PNG_NO_CHECK_cHRM)
if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
green_x, green_y, blue_x, blue_y))
#endif
return;
}
{
png_save_uint_32(buf, (png_uint_32)white_x);
png_save_uint_32(buf + 4, (png_uint_32)white_y);
if (red_x + red_y > 100000L)
{
png_warning(png_ptr, "Invalid cHRM fixed red point specified");
return;
}
png_save_uint_32(buf + 8, (png_uint_32)red_x);
png_save_uint_32(buf + 12, (png_uint_32)red_y);
if (green_x + green_y > 100000L)
{
png_warning(png_ptr, "Invalid fixed cHRM green point specified");
return;
}
png_save_uint_32(buf + 16, (png_uint_32)green_x);
png_save_uint_32(buf + 20, (png_uint_32)green_y);
if (blue_x + blue_y > 100000L)
{
png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
return;
}
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_bytep)png_cHRM, buf, (png_size_t)32);
}
}
#endif
#endif
@ -1086,12 +1049,12 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
#endif
png_byte buf[6];
png_debug(1, "in png_write_tRNS\n");
png_debug(1, "in png_write_tRNS");
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
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 */
@ -1101,7 +1064,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
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");
@ -1116,12 +1079,12 @@ 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;
}
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
@ -1141,7 +1104,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
#endif
png_byte buf[6];
png_debug(1, "in png_write_bKGD\n");
png_debug(1, "in png_write_bKGD");
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
if (
@ -1149,7 +1112,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
(png_ptr->num_palette ||
(!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
#endif
back->index > png_ptr->num_palette)
back->index >= png_ptr->num_palette)
{
png_warning(png_ptr, "Invalid background palette index");
return;
@ -1162,17 +1125,17 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
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;
}
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");
@ -1195,10 +1158,10 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
int i;
png_byte buf[3];
png_debug(1, "in png_write_hIST\n");
png_debug(1, "in png_write_hIST");
if (num_hist > (int)png_ptr->num_palette)
{
png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist,
png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
png_ptr->num_palette);
png_warning(png_ptr, "Invalid number of histogram entries specified");
return;
@ -1235,7 +1198,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
int kflag;
int kwarn=0;
png_debug(1, "in png_check_keyword\n");
png_debug(1, "in png_check_keyword");
*new_key = NULL;
if (key == NULL || (key_len = png_strlen(key)) == 0)
@ -1244,7 +1207,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
return ((png_size_t)0);
}
png_debug1(2, "Keyword to be checked is '%s'\n", key);
png_debug1(2, "Keyword to be checked is '%s'", key);
*new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2));
if (*new_key == NULL)
@ -1303,7 +1266,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
}
}
png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp);
png_debug1(2, "Checking for multiple internal spaces in '%s'", kp);
/* Remove multiple internal spaces. */
for (kflag = 0, dp = *new_key; *kp != '\0'; kp++)
@ -1325,20 +1288,20 @@ 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");
}
if (key_len > 79)
{
png_warning(png_ptr, "keyword length must be 1 - 79 characters");
new_key[79] = '\0';
(*new_key)[79] = '\0';
key_len = 79;
}
@ -1358,12 +1321,9 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
png_size_t key_len;
png_charp new_key;
png_debug(1, "in png_write_tEXt\n");
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
{
png_warning(png_ptr, "Empty keyword in tEXt chunk");
png_debug(1, "in png_write_tEXt");
if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
return;
}
if (text == NULL || *text == '\0')
text_len = 0;
@ -1403,7 +1363,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_charp new_key;
compression_state comp;
png_debug(1, "in png_write_zTXt\n");
png_debug(1, "in png_write_zTXt");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
@ -1411,9 +1371,8 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
comp.input = NULL;
comp.input_len = 0;
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
if ((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;
}
@ -1460,23 +1419,22 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
PNG_iTXt;
#endif
png_size_t lang_len, key_len, lang_key_len, text_len;
png_charp new_lang, new_key;
png_charp new_lang;
png_charp new_key = NULL;
png_byte cbuf[2];
compression_state comp;
png_debug(1, "in png_write_iTXt\n");
png_debug(1, "in png_write_iTXt");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
comp.output_ptr = NULL;
comp.input = NULL;
if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
{
png_warning(png_ptr, "Empty keyword in iTXt chunk");
if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
return;
}
if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)
if ((lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)
{
png_warning(png_ptr, "Empty language field in iTXt chunk");
new_lang = NULL;
@ -1537,7 +1495,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
png_write_chunk_end(png_ptr);
png_free(png_ptr, new_key);
png_free(png_ptr, new_lang);
png_free(png_ptr, new_lang);
}
#endif
@ -1552,7 +1510,7 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
#endif
png_byte buf[9];
png_debug(1, "in png_write_oFFs\n");
png_debug(1, "in png_write_oFFs");
if (unit_type >= PNG_OFFSET_LAST)
png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
@ -1578,14 +1536,14 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
png_charp new_purpose;
int i;
png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams);
png_debug1(1, "in png_write_pCAL (%d parameters)", nparams);
if (type >= PNG_EQUATION_LAST)
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;
png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len);
png_debug1(3, "pCAL purpose length = %d", (int)purpose_len);
units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);
png_debug1(3, "pCAL units length = %d\n", (int)units_len);
png_debug1(3, "pCAL units length = %d", (int)units_len);
total_len = purpose_len + units_len + 10;
params_len = (png_uint_32p)png_malloc(png_ptr,
@ -1596,12 +1554,12 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
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,
png_debug2(3, "pCAL parameter %d length = %lu", 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_debug1(3, "pCAL total length = %d", (int)total_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);
@ -1637,7 +1595,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
char buf[64];
png_size_t total_len;
png_debug(1, "in png_write_sCAL\n");
png_debug(1, "in png_write_sCAL");
buf[0] = (char)unit;
#if defined(_WIN32_WCE)
@ -1662,7 +1620,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
total_len += png_strlen(buf + total_len);
#endif
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
}
#else
@ -1677,7 +1635,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
png_byte buf[64];
png_size_t wlen, hlen, total_len;
png_debug(1, "in png_write_sCAL_s\n");
png_debug(1, "in png_write_sCAL_s");
wlen = png_strlen(width);
hlen = png_strlen(height);
@ -1692,7 +1650,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
}
#endif
@ -1711,7 +1669,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
#endif
png_byte buf[9];
png_debug(1, "in png_write_pHYs\n");
png_debug(1, "in png_write_pHYs");
if (unit_type >= PNG_RESOLUTION_LAST)
png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
@ -1735,7 +1693,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
#endif
png_byte buf[7];
png_debug(1, "in png_write_tIME\n");
png_debug(1, "in png_write_tIME");
if (mod_time->month > 12 || mod_time->month < 1 ||
mod_time->day > 31 || mod_time->day < 1 ||
mod_time->hour > 23 || mod_time->second > 60)
@ -1779,9 +1737,9 @@ png_write_start_row(png_structp png_ptr)
png_size_t buf_size;
png_debug(1, "in png_write_start_row\n");
png_debug(1, "in png_write_start_row");
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,
@ -1879,7 +1837,7 @@ png_write_finish_row(png_structp png_ptr)
int ret;
png_debug(1, "in png_write_finish_row\n");
png_debug(1, "in png_write_finish_row");
/* next row */
png_ptr->row_number++;
@ -1924,7 +1882,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;
}
}
@ -1988,7 +1946,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
#endif
png_debug(1, "in png_do_write_interlace\n");
png_debug(1, "in png_do_write_interlace");
/* we don't have to do anything on the last pass (6) */
#if defined(PNG_USELESS_TESTS_SUPPORTED)
if (row != NULL && row_info != NULL && pass < 6)
@ -2159,7 +2117,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
int num_p_filters = (int)png_ptr->num_prev_filters;
#endif
png_debug(1, "in png_write_find_filter\n");
png_debug(1, "in png_write_find_filter");
/* find out how many bytes offset each pixel is */
bpp = (row_info->pixel_depth + 7) >> 3;
@ -2768,8 +2726,8 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
void /* PRIVATE */
png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
{
png_debug(1, "in png_write_filtered_row\n");
png_debug1(2, "filter = %d\n", filtered_row[0]);
png_debug(1, "in png_write_filtered_row");
png_debug1(2, "filter = %d", filtered_row[0]);
/* set up the zlib input buffer */
png_ptr->zstream.next_in = filtered_row;