mirror of https://github.com/PCSX2/pcsx2.git
Update libpng.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1789 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
4b4422d2dc
commit
eec90508ff
|
@ -4270,40 +4270,6 @@
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\png\pnggccrd.c"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Devel|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\png\pngget.c"
|
RelativePath="..\..\src\png\pngget.c"
|
||||||
>
|
>
|
||||||
|
@ -4644,40 +4610,6 @@
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\png\pngvcrd.c"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Devel|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
PrecompiledHeaderThrough=""
|
|
||||||
PrecompiledHeaderFile=""
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\png\pngwio.c"
|
RelativePath="..\..\src\png\pngwio.c"
|
||||||
>
|
>
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
|
||||||
|
This copy of the libpng notices is provided for your convenience. In case of
|
||||||
|
any discrepancy between this copy and the notices in the file png.h that is
|
||||||
|
included in the libpng distribution, the latter shall prevail.
|
||||||
|
|
||||||
|
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||||
|
|
||||||
|
If you modify libpng you may insert additional notices immediately following
|
||||||
|
this sentence.
|
||||||
|
|
||||||
|
This code is released under the libpng license.
|
||||||
|
|
||||||
|
libpng versions 1.2.6, August 15, 2004, through 1.2.39, August 13, 2009, are
|
||||||
|
Copyright (c) 2004, 2006-2009 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
|
||||||
|
|
||||||
|
Cosmin Truta
|
||||||
|
|
||||||
|
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
||||||
|
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
||||||
|
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
|
with the following individuals added to the list of Contributing Authors
|
||||||
|
|
||||||
|
Simon-Pierre Cadieux
|
||||||
|
Eric S. Raymond
|
||||||
|
Gilles Vollant
|
||||||
|
|
||||||
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
|
There is no warranty against interference with your enjoyment of the
|
||||||
|
library or against infringement. There is no warranty that our
|
||||||
|
efforts or the library will fulfill any of your particular purposes
|
||||||
|
or needs. This library is provided with all faults, and the entire
|
||||||
|
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||||
|
the user.
|
||||||
|
|
||||||
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
|
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||||
|
distributed according to the same disclaimer and license as libpng-0.96,
|
||||||
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
Tom Lane
|
||||||
|
Glenn Randers-Pehrson
|
||||||
|
Willem van Schaik
|
||||||
|
|
||||||
|
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
|
Copyright (c) 1996, 1997 Andreas Dilger
|
||||||
|
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
John Bowler
|
||||||
|
Kevin Bracey
|
||||||
|
Sam Bushell
|
||||||
|
Magnus Holmgren
|
||||||
|
Greg Roelofs
|
||||||
|
Tom Tanner
|
||||||
|
|
||||||
|
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
|
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
|
||||||
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
|
is defined as the following set of individuals:
|
||||||
|
|
||||||
|
Andreas Dilger
|
||||||
|
Dave Martindale
|
||||||
|
Guy Eric Schalnat
|
||||||
|
Paul Schmidt
|
||||||
|
Tim Wegner
|
||||||
|
|
||||||
|
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||||
|
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||||
|
including, without limitation, the warranties of merchantability and of
|
||||||
|
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||||
|
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||||
|
or consequential damages, which may result from the use of the PNG
|
||||||
|
Reference Library, even if advised of the possibility of such damage.
|
||||||
|
|
||||||
|
Permission is hereby granted to use, copy, modify, and distribute this
|
||||||
|
source code, or portions hereof, for any purpose, without fee, subject
|
||||||
|
to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this source code must not be misrepresented.
|
||||||
|
|
||||||
|
2. Altered versions must be plainly marked as such and must not
|
||||||
|
be misrepresented as being the original source.
|
||||||
|
|
||||||
|
3. This Copyright notice may not be removed or altered from any
|
||||||
|
source or altered source distribution.
|
||||||
|
|
||||||
|
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
|
fee, and encourage the use of this source code as a component to
|
||||||
|
supporting the PNG file format in commercial products. If you use this
|
||||||
|
source code in a product, acknowledgment is not required but would be
|
||||||
|
appreciated.
|
||||||
|
|
||||||
|
|
||||||
|
A "png_get_copyright" function is available, for convenient use in "about"
|
||||||
|
boxes and the like:
|
||||||
|
|
||||||
|
printf("%s",png_get_copyright(NULL));
|
||||||
|
|
||||||
|
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||||
|
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||||
|
|
||||||
|
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||||
|
certification mark of the Open Source Initiative.
|
||||||
|
|
||||||
|
Glenn Randers-Pehrson
|
||||||
|
glennrp at users.sourceforge.net
|
||||||
|
August 13, 2009
|
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* libpng version 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.39 [August 13, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
|
@ -13,18 +16,21 @@
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef version_1_2_7 Your_png_h_is_not_version_1_2_7;
|
typedef version_1_2_39 Your_png_h_is_not_version_1_2_39;
|
||||||
|
|
||||||
/* Version information for C files. This had better match the version
|
/* Version information for C files. This had better match the version
|
||||||
* string defined in png.h. */
|
* string defined in png.h. */
|
||||||
|
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||||
const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
|
PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
/* png_sig was changed to a function in version 1.0.5c */
|
/* png_sig was changed to a function in version 1.0.5c */
|
||||||
/* Place to hold the signature string for a PNG file. */
|
/* Place to hold the signature string for a PNG file. */
|
||||||
const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
||||||
/* Invoke global declarations for constant strings for known chunk types */
|
/* Invoke global declarations for constant strings for known chunk types */
|
||||||
PNG_IHDR;
|
PNG_IHDR;
|
||||||
|
@ -49,38 +55,35 @@ PNG_tIME;
|
||||||
PNG_tRNS;
|
PNG_tRNS;
|
||||||
PNG_zTXt;
|
PNG_zTXt;
|
||||||
|
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* start of interlace block */
|
/* Start of interlace block */
|
||||||
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* offset to next interlace block */
|
/* Offset to next interlace block */
|
||||||
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* start of interlace block in the y direction */
|
/* Start of interlace block in the y direction */
|
||||||
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* Offset to next interlace block in the y direction */
|
||||||
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
/* width of interlace block (used in assembler routines only) */
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Height of interlace block. This is not currently used - if you need
|
/* Height of interlace block. This is not currently used - if you need
|
||||||
* it, uncomment it here and in png.h
|
* it, uncomment it here and in png.h
|
||||||
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Mask to determine which pixels are valid in a pass */
|
/* Mask to determine which pixels are valid in a pass */
|
||||||
const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
|
|
||||||
/* Mask to determine which pixels to overwrite while displaying */
|
/* Mask to determine which pixels to overwrite while displaying */
|
||||||
const int FARDATA png_pass_dsp_mask[]
|
PNG_CONST int FARDATA png_pass_dsp_mask[]
|
||||||
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||||
|
|
||||||
#endif
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
#endif /* PNG_USE_GLOBAL_ARRAYS */
|
||||||
|
|
||||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||||
* of the PNG file signature. If the PNG data is embedded into another
|
* of the PNG file signature. If the PNG data is embedded into another
|
||||||
|
@ -88,10 +91,13 @@ const int FARDATA png_pass_dsp_mask[]
|
||||||
* or write any of the magic bytes before it starts on the IHDR.
|
* or write any of the magic bytes before it starts on the IHDR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||||
{
|
{
|
||||||
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)
|
if (num_bytes > 8)
|
||||||
png_error(png_ptr, "Too many bytes for PNG signature.");
|
png_error(png_ptr, "Too many bytes for PNG signature.");
|
||||||
|
|
||||||
|
@ -113,10 +119,10 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||||
if (num_to_check > 8)
|
if (num_to_check > 8)
|
||||||
num_to_check = 8;
|
num_to_check = 8;
|
||||||
else if (num_to_check < 1)
|
else if (num_to_check < 1)
|
||||||
return (0);
|
return (-1);
|
||||||
|
|
||||||
if (start > 7)
|
if (start > 7)
|
||||||
return (0);
|
return (-1);
|
||||||
|
|
||||||
if (start + num_to_check > 8)
|
if (start + num_to_check > 8)
|
||||||
num_to_check = 8 - start;
|
num_to_check = 8 - start;
|
||||||
|
@ -124,32 +130,38 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
||||||
return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
|
return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
/* (Obsolete) function to check signature bytes. It does not allow one
|
/* (Obsolete) function to check signature bytes. It does not allow one
|
||||||
* to check a partial signature. This function might be removed in the
|
* to check a partial signature. This function might be removed in the
|
||||||
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
|
* future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG.
|
||||||
*/
|
*/
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_check_sig(png_bytep sig, int num)
|
png_check_sig(png_bytep sig, int num)
|
||||||
{
|
{
|
||||||
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
/* Function to allocate memory for zlib and clear it to 0. */
|
/* Function to allocate memory for zlib and clear it to 0. */
|
||||||
#ifdef PNG_1_0_X
|
#ifdef PNG_1_0_X
|
||||||
voidpf PNGAPI
|
voidpf PNGAPI
|
||||||
#else
|
#else
|
||||||
voidpf /* private */
|
voidpf /* PRIVATE */
|
||||||
#endif
|
#endif
|
||||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
png_voidp ptr;
|
png_voidp ptr;
|
||||||
png_structp p=(png_struct*)png_ptr;
|
png_structp p=(png_structp)png_ptr;
|
||||||
png_uint_32 save_flags=p->flags;
|
png_uint_32 save_flags=p->flags;
|
||||||
png_uint_32 num_bytes;
|
png_uint_32 num_bytes;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
if (items > PNG_UINT_32_MAX/size)
|
if (items > PNG_UINT_32_MAX/size)
|
||||||
{
|
{
|
||||||
png_warning (png_ptr, "Potential overflow in png_zalloc()");
|
png_warning (p, "Potential overflow in png_zalloc()");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
num_bytes = (png_uint_32)items * size;
|
num_bytes = (png_uint_32)items * size;
|
||||||
|
@ -176,11 +188,11 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||||
return ((voidpf)ptr);
|
return ((voidpf)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function to free memory for zlib */
|
/* Function to free memory for zlib */
|
||||||
#ifdef PNG_1_0_X
|
#ifdef PNG_1_0_X
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
#else
|
#else
|
||||||
void /* private */
|
void /* PRIVATE */
|
||||||
#endif
|
#endif
|
||||||
png_zfree(voidpf png_ptr, voidpf ptr)
|
png_zfree(voidpf png_ptr, voidpf ptr)
|
||||||
{
|
{
|
||||||
|
@ -233,8 +245,9 @@ png_create_info_struct(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
|
|
||||||
png_debug(1, "in png_create_info_struct\n");
|
png_debug(1, "in png_create_info_struct");
|
||||||
if(png_ptr == NULL) return (NULL);
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
|
||||||
png_ptr->malloc_fn, png_ptr->mem_ptr);
|
png_ptr->malloc_fn, png_ptr->mem_ptr);
|
||||||
|
@ -256,8 +269,10 @@ void PNGAPI
|
||||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||||
{
|
{
|
||||||
png_infop info_ptr = NULL;
|
png_infop info_ptr = NULL;
|
||||||
|
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)
|
if (info_ptr_ptr != NULL)
|
||||||
info_ptr = *info_ptr_ptr;
|
info_ptr = *info_ptr_ptr;
|
||||||
|
|
||||||
|
@ -279,6 +294,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||||
* and applications using it are urged to use png_create_info_struct()
|
* and applications using it are urged to use png_create_info_struct()
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
#undef png_info_init
|
#undef png_info_init
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_info_init(png_infop info_ptr)
|
png_info_init(png_infop info_ptr)
|
||||||
|
@ -286,13 +302,17 @@ png_info_init(png_infop info_ptr)
|
||||||
/* We only come here via pre-1.0.12-compiled applications */
|
/* We only come here via pre-1.0.12-compiled applications */
|
||||||
png_info_init_3(&info_ptr, 0);
|
png_info_init_3(&info_ptr, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
||||||
{
|
{
|
||||||
png_infop info_ptr = *ptr_ptr;
|
png_infop info_ptr = *ptr_ptr;
|
||||||
|
|
||||||
png_debug(1, "in png_info_init_3\n");
|
if (info_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
@ -301,7 +321,7 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
||||||
*ptr_ptr = info_ptr;
|
*ptr_ptr = info_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set everything to 0 */
|
/* Set everything to 0 */
|
||||||
png_memset(info_ptr, 0, png_sizeof(png_info));
|
png_memset(info_ptr, 0, png_sizeof(png_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +330,7 @@ void PNGAPI
|
||||||
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
png_data_freer(png_structp png_ptr, png_infop info_ptr,
|
||||||
int freer, png_uint_32 mask)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
if (freer == PNG_DESTROY_WILL_FREE_DATA)
|
if (freer == PNG_DESTROY_WILL_FREE_DATA)
|
||||||
|
@ -327,12 +347,12 @@ void PNGAPI
|
||||||
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
|
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
|
||||||
int num)
|
int num)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_free_data\n");
|
png_debug(1, "in png_free_data");
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(PNG_TEXT_SUPPORTED)
|
#if defined(PNG_TEXT_SUPPORTED)
|
||||||
/* free text item num or (if num == -1) all text items */
|
/* Free text item num or (if num == -1) all text items */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
|
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -360,7 +380,7 @@ if (mask & PNG_FREE_TEXT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_tRNS_SUPPORTED)
|
#if defined(PNG_tRNS_SUPPORTED)
|
||||||
/* free any tRNS entry */
|
/* Free any tRNS entry */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
|
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -368,16 +388,16 @@ if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
png_free(png_ptr, info_ptr->trans);
|
png_free(png_ptr, info_ptr->trans);
|
||||||
|
info_ptr->trans = NULL;
|
||||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||||
#ifndef PNG_FREE_ME_SUPPORTED
|
#ifndef PNG_FREE_ME_SUPPORTED
|
||||||
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
|
||||||
#endif
|
#endif
|
||||||
info_ptr->trans = NULL;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_sCAL_SUPPORTED)
|
#if defined(PNG_sCAL_SUPPORTED)
|
||||||
/* free any sCAL entry */
|
/* Free any sCAL entry */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
|
if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -395,7 +415,7 @@ if (mask & PNG_FREE_SCAL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_pCAL_SUPPORTED)
|
#if defined(PNG_pCAL_SUPPORTED)
|
||||||
/* free any pCAL entry */
|
/* Free any pCAL entry */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
|
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -422,7 +442,7 @@ if (mask & PNG_FREE_PCAL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_iCCP_SUPPORTED)
|
#if defined(PNG_iCCP_SUPPORTED)
|
||||||
/* free any iCCP entry */
|
/* Free any iCCP entry */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
|
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -438,7 +458,7 @@ if (mask & PNG_FREE_ICCP)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_sPLT_SUPPORTED)
|
#if defined(PNG_sPLT_SUPPORTED)
|
||||||
/* free a given sPLT entry, or (if num == -1) all sPLT entries */
|
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
|
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -473,6 +493,12 @@ if (mask & PNG_FREE_SPLT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if (png_ptr->unknown_chunk.data)
|
||||||
|
{
|
||||||
|
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||||
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -505,7 +531,7 @@ if (mask & PNG_FREE_UNKN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_hIST_SUPPORTED)
|
#if defined(PNG_hIST_SUPPORTED)
|
||||||
/* free any hIST entry */
|
/* Free any hIST entry */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
|
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -521,7 +547,7 @@ if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* free any PLTE entry that was internally allocated */
|
/* Free any PLTE entry that was internally allocated */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
|
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -538,7 +564,7 @@ if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
#if defined(PNG_INFO_IMAGE_SUPPORTED)
|
||||||
/* free any image bits attached to the info structure */
|
/* Free any image bits attached to the info structure */
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
|
@ -575,11 +601,11 @@ if (mask & PNG_FREE_ROWS)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
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);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||||
if (png_ptr->num_chunk_list)
|
if (png_ptr->num_chunk_list)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->chunk_list);
|
png_free(png_ptr, png_ptr->chunk_list);
|
||||||
|
@ -590,6 +616,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
|
||||||
png_info_init_3(&info_ptr, png_sizeof(png_info));
|
png_info_init_3(&info_ptr, png_sizeof(png_info));
|
||||||
}
|
}
|
||||||
|
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||||
|
|
||||||
/* This function returns a pointer to the io_ptr associated with the user
|
/* This function returns a pointer to the io_ptr associated with the user
|
||||||
* functions. The application should free any memory associated with this
|
* functions. The application should free any memory associated with this
|
||||||
|
@ -598,9 +625,12 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_io_ptr(png_structp png_ptr)
|
png_get_io_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
return (png_ptr->io_ptr);
|
return (png_ptr->io_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
/* Initialize the default input/output functions for the PNG file. If you
|
/* Initialize the default input/output functions for the PNG file. If you
|
||||||
* use your own read or write routines, you can call either png_set_read_fn()
|
* use your own read or write routines, you can call either png_set_read_fn()
|
||||||
|
@ -611,7 +641,9 @@ png_get_io_ptr(png_structp png_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_init_io\n");
|
png_debug(1, "in png_init_io");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->io_ptr = (png_voidp)fp;
|
png_ptr->io_ptr = (png_voidp)fp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -627,6 +659,8 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
if (png_ptr->time_buffer == NULL)
|
if (png_ptr->time_buffer == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||||
|
@ -647,7 +681,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
{
|
{
|
||||||
char near_time_buf[29];
|
char near_time_buf[29];
|
||||||
sprintf(near_time_buf, "%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->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
ptime->second % 61);
|
ptime->second % 61);
|
||||||
|
@ -655,7 +689,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||||
29*png_sizeof(char));
|
29*png_sizeof(char));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sprintf(png_ptr->time_buffer, "%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->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
ptime->second % 61);
|
ptime->second % 61);
|
||||||
|
@ -665,24 +699,16 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
||||||
}
|
}
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
|
||||||
#if 0
|
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||||
/* Signature string for a PNG file. */
|
|
||||||
png_bytep PNGAPI
|
|
||||||
png_sig_bytes(void)
|
|
||||||
{
|
|
||||||
return ((png_bytep)"\211\120\116\107\015\012\032\012");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_copyright(png_structp png_ptr)
|
png_get_copyright(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) "\n libpng version 1.2.7 - September 12, 2004\n\
|
return ((png_charp) "\n libpng version 1.2.39 - August 13, 2009\n\
|
||||||
Copyright (c) 1998-2004 Glenn Randers-Pehrson\n\
|
Copyright (c) 1998-2009 Glenn Randers-Pehrson\n\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\n\
|
Copyright (c) 1996-1997 Andreas Dilger\n\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following return the library version as a short string in the
|
/* The following return the library version as a short string in the
|
||||||
|
@ -697,37 +723,39 @@ png_charp PNGAPI
|
||||||
png_get_libpng_ver(png_structp png_ptr)
|
png_get_libpng_ver(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Version of *.c files used when building libpng */
|
/* Version of *.c files used when building libpng */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_header_ver(png_structp png_ptr)
|
png_get_header_ver(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Version of *.h files used when building libpng */
|
/* Version of *.h files used when building libpng */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_header_version(png_structp png_ptr)
|
png_get_header_version(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Returns longer string containing both version and date */
|
/* Returns longer string containing both version and date */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_HEADER_VERSION_STRING);
|
return ((png_charp) PNG_HEADER_VERSION_STRING
|
||||||
return ((png_charp) "");
|
#ifndef PNG_READ_SUPPORTED
|
||||||
|
" (NO READ SUPPORT)"
|
||||||
|
#endif
|
||||||
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
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 */
|
/* Check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||||
int i;
|
int i;
|
||||||
png_bytep p;
|
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;
|
return 0;
|
||||||
p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
|
p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
|
||||||
for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
|
for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
|
||||||
|
@ -741,8 +769,11 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_reset_zstream(png_structp png_ptr)
|
png_reset_zstream(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
return (inflateReset(&png_ptr->zstream));
|
return (inflateReset(&png_ptr->zstream));
|
||||||
}
|
}
|
||||||
|
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||||
|
|
||||||
/* This function was added to libpng-1.0.7 */
|
/* This function was added to libpng-1.0.7 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
|
@ -753,66 +784,19 @@ png_access_version_number(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
/* This function was added to libpng 1.2.0 */
|
||||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
|
||||||
/* this INTERNAL function was added to libpng 1.2.0 */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_init_mmx_flags (png_structp png_ptr)
|
|
||||||
{
|
|
||||||
png_ptr->mmx_rowbytes_threshold = 0;
|
|
||||||
png_ptr->mmx_bitdepth_threshold = 0;
|
|
||||||
|
|
||||||
# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD))
|
|
||||||
|
|
||||||
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED;
|
|
||||||
|
|
||||||
if (png_mmx_support() > 0) {
|
|
||||||
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
|
|
||||||
# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
|
|
||||||
# endif
|
|
||||||
# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_INTERLACE
|
|
||||||
# endif
|
|
||||||
# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
;
|
|
||||||
# else
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_UP
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
|
|
||||||
png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT;
|
|
||||||
png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT;
|
|
||||||
# endif
|
|
||||||
} else {
|
|
||||||
png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
|
|
||||||
| PNG_MMX_READ_FLAGS
|
|
||||||
| PNG_MMX_WRITE_FLAGS );
|
|
||||||
}
|
|
||||||
|
|
||||||
# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */
|
|
||||||
|
|
||||||
/* clear all MMX flags; no support is compiled in */
|
|
||||||
png_ptr->asm_flags &= ~( PNG_MMX_FLAGS );
|
|
||||||
|
|
||||||
# endif /* ?(PNGVCRD || PNGGCCRD) */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */
|
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
|
||||||
#if !defined(PNG_USE_PNGGCCRD) && \
|
|
||||||
!(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
|
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_mmx_support(void)
|
png_mmx_support(void)
|
||||||
{
|
{
|
||||||
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
#endif /* PNG_1_0_X */
|
||||||
|
#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
#ifdef PNG_SIZE_T
|
#ifdef PNG_SIZE_T
|
||||||
/* Added at libpng version 1.2.6 */
|
/* Added at libpng version 1.2.6 */
|
||||||
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
|
PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
|
||||||
|
@ -824,3 +808,119 @@ png_convert_size(size_t size)
|
||||||
return ((png_size_t)size);
|
return ((png_size_t)size);
|
||||||
}
|
}
|
||||||
#endif /* PNG_SIZE_T */
|
#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 /* PRIVATE */
|
||||||
|
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) */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.2.7 - September 12, 2004
|
* libpng version 1.2.39 - August 13, 2009
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Any machine specific code is near the front of this file, so if you
|
/* Any machine specific code is near the front of this file, so if you
|
||||||
|
@ -17,10 +20,72 @@
|
||||||
#ifndef PNGCONF_H
|
#ifndef PNGCONF_H
|
||||||
#define PNGCONF_H
|
#define PNGCONF_H
|
||||||
|
|
||||||
|
#define PNG_1_2_X
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PNG_USER_CONFIG has to be defined on the compiler command line. This
|
||||||
|
* includes the resource compiler for Windows DLL configurations.
|
||||||
|
*/
|
||||||
#ifdef PNG_USER_CONFIG
|
#ifdef PNG_USER_CONFIG
|
||||||
|
# ifndef PNG_USER_PRIVATEBUILD
|
||||||
|
# define PNG_USER_PRIVATEBUILD
|
||||||
|
# endif
|
||||||
#include "pngusr.h"
|
#include "pngusr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
|
||||||
|
#ifdef PNG_CONFIGURE_LIBPNG
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Added at libpng-1.2.8
|
||||||
|
*
|
||||||
|
* If you create a private DLL you need to define in "pngusr.h" the followings:
|
||||||
|
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
|
||||||
|
* the DLL was built>
|
||||||
|
* e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
|
||||||
|
* #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
|
||||||
|
* distinguish your DLL from those of the official release. These
|
||||||
|
* correspond to the trailing letters that come after the version
|
||||||
|
* number and must match your private DLL name>
|
||||||
|
* e.g. // private DLL "libpng13gx.dll"
|
||||||
|
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
|
||||||
|
*
|
||||||
|
* The following macros are also at your disposal if you want to complete the
|
||||||
|
* DLL VERSIONINFO structure.
|
||||||
|
* - PNG_USER_VERSIONINFO_COMMENTS
|
||||||
|
* - PNG_USER_VERSIONINFO_COMPANYNAME
|
||||||
|
* - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __STDC__
|
||||||
|
#ifdef SPECIALBUILD
|
||||||
|
# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
|
||||||
|
are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PRIVATEBUILD
|
||||||
|
# pragma message("PRIVATEBUILD is deprecated.\
|
||||||
|
Use PNG_USER_PRIVATEBUILD instead.")
|
||||||
|
# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
|
||||||
|
#endif
|
||||||
|
#endif /* __STDC__ */
|
||||||
|
|
||||||
|
#ifndef PNG_VERSION_INFO_ONLY
|
||||||
|
|
||||||
|
/* End of material added to libpng-1.2.8 */
|
||||||
|
|
||||||
|
/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble
|
||||||
|
Restored at libpng-1.2.21 */
|
||||||
|
#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \
|
||||||
|
!defined(PNG_WARN_UNINITIALIZED_ROW)
|
||||||
|
# define PNG_WARN_UNINITIALIZED_ROW 1
|
||||||
|
#endif
|
||||||
|
/* End of material added at libpng-1.2.19/1.2.21 */
|
||||||
|
|
||||||
/* This is the size of the compression buffer, and thus the size of
|
/* This is the size of the compression buffer, and thus the size of
|
||||||
* an IDAT chunk. Make this whatever size you feel is best for your
|
* an IDAT chunk. Make this whatever size you feel is best for your
|
||||||
* machine. One of these will be allocated per png_struct. When this
|
* machine. One of these will be allocated per png_struct. When this
|
||||||
|
@ -171,6 +236,8 @@
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
/* Console I/O functions are not supported on WindowsCE */
|
/* Console I/O functions are not supported on WindowsCE */
|
||||||
# define PNG_NO_CONSOLE_IO
|
# define PNG_NO_CONSOLE_IO
|
||||||
|
/* abort() may not be supported on some/all Windows CE platforms */
|
||||||
|
# define PNG_ABORT() exit(-1)
|
||||||
# ifdef PNG_DEBUG
|
# ifdef PNG_DEBUG
|
||||||
# undef PNG_DEBUG
|
# undef PNG_DEBUG
|
||||||
# endif
|
# endif
|
||||||
|
@ -222,6 +289,7 @@
|
||||||
# define PNGARG(arglist) arglist
|
# define PNGARG(arglist) arglist
|
||||||
#endif /* _NO_PROTO */
|
#endif /* _NO_PROTO */
|
||||||
|
|
||||||
|
|
||||||
#endif /* OF */
|
#endif /* OF */
|
||||||
|
|
||||||
#endif /* PNGARG */
|
#endif /* PNGARG */
|
||||||
|
@ -232,7 +300,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef MACOS
|
#ifndef MACOS
|
||||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||||
defined(THINK_C) || (defined(__SC__) && !defined(__DMC__))|| defined(TARGET_OS_MAC)
|
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||||
# define MACOS
|
# define MACOS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -249,8 +317,15 @@
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* This is an attempt to force a single setjmp behaviour on Linux. If
|
/* This is an attempt to force a single setjmp behaviour on Linux. If
|
||||||
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
|
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
|
||||||
|
*
|
||||||
|
* You can bypass this test if you know that your application uses exactly
|
||||||
|
* the same setjmp.h that was included when libpng was built. Only define
|
||||||
|
* PNG_SKIP_SETJMP_CHECK while building your application, prior to the
|
||||||
|
* application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
|
||||||
|
* while building a separate libpng library for general use.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
# ifndef PNG_SKIP_SETJMP_CHECK
|
||||||
# ifdef __linux__
|
# ifdef __linux__
|
||||||
# ifdef _BSD_SOURCE
|
# ifdef _BSD_SOURCE
|
||||||
# define PNG_SAVE_BSD_SOURCE
|
# define PNG_SAVE_BSD_SOURCE
|
||||||
|
@ -260,17 +335,20 @@
|
||||||
/* If you encounter a compiler error here, see the explanation
|
/* If you encounter a compiler error here, see the explanation
|
||||||
* near the end of INSTALL.
|
* near the end of INSTALL.
|
||||||
*/
|
*/
|
||||||
__png.h__ already includes setjmp.h;
|
__pngconf.h__ in libpng already includes setjmp.h;
|
||||||
__dont__ include it again.;
|
__dont__ include it again.;
|
||||||
# endif
|
# endif
|
||||||
# endif /* __linux__ */
|
# endif /* __linux__ */
|
||||||
|
# endif /* PNG_SKIP_SETJMP_CHECK */
|
||||||
|
|
||||||
/* include setjmp.h for error handling */
|
/* include setjmp.h for error handling */
|
||||||
# include <setjmp.h>
|
# include <setjmp.h>
|
||||||
|
|
||||||
# ifdef __linux__
|
# ifdef __linux__
|
||||||
# ifdef PNG_SAVE_BSD_SOURCE
|
# ifdef PNG_SAVE_BSD_SOURCE
|
||||||
|
# ifndef _BSD_SOURCE
|
||||||
# define _BSD_SOURCE
|
# define _BSD_SOURCE
|
||||||
|
# endif
|
||||||
# undef PNG_SAVE_BSD_SOURCE
|
# undef PNG_SAVE_BSD_SOURCE
|
||||||
# endif
|
# endif
|
||||||
# endif /* __linux__ */
|
# endif /* __linux__ */
|
||||||
|
@ -409,21 +487,33 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The size of the png_text structure changed in libpng-1.0.6 when
|
/* The size of the png_text structure changed in libpng-1.0.6 when
|
||||||
* iTXt is supported. It is turned off by default, to support old apps
|
* iTXt support was added. iTXt support was turned off by default through
|
||||||
* that malloc the png_text structure instead of calling png_set_text()
|
* libpng-1.2.x, to support old apps that malloc the png_text structure
|
||||||
* and letting libpng malloc it. It will be turned on by default in
|
* instead of calling png_set_text() and letting libpng malloc it. It
|
||||||
* libpng-1.3.0.
|
* will be turned on by default in libpng-1.4.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PNG_iTXt_SUPPORTED
|
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
|
||||||
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
|
# ifndef PNG_NO_iTXt_SUPPORTED
|
||||||
|
# define PNG_NO_iTXt_SUPPORTED
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_NO_READ_iTXt
|
||||||
# define PNG_NO_READ_iTXt
|
# define PNG_NO_READ_iTXt
|
||||||
# endif
|
# endif
|
||||||
# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
|
# ifndef PNG_NO_WRITE_iTXt
|
||||||
# define PNG_NO_WRITE_iTXt
|
# define PNG_NO_WRITE_iTXt
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_iTXt_SUPPORTED)
|
||||||
|
# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
|
||||||
|
# define PNG_READ_iTXt
|
||||||
|
# endif
|
||||||
|
# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
|
||||||
|
# define PNG_WRITE_iTXt
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following support, added after version 1.0.0, can be turned off here en
|
/* The following support, added after version 1.0.0, can be turned off here en
|
||||||
* masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
|
* masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
|
||||||
* with old applications that require the length of png_struct and png_info
|
* with old applications that require the length of png_struct and png_info
|
||||||
|
@ -434,6 +524,7 @@
|
||||||
# define PNG_NO_FREE_ME
|
# define PNG_NO_FREE_ME
|
||||||
# define PNG_NO_READ_UNKNOWN_CHUNKS
|
# define PNG_NO_READ_UNKNOWN_CHUNKS
|
||||||
# define PNG_NO_WRITE_UNKNOWN_CHUNKS
|
# define PNG_NO_WRITE_UNKNOWN_CHUNKS
|
||||||
|
# define PNG_NO_HANDLE_AS_UNKNOWN
|
||||||
# define PNG_NO_READ_USER_CHUNKS
|
# define PNG_NO_READ_USER_CHUNKS
|
||||||
# define PNG_NO_READ_iCCP
|
# define PNG_NO_READ_iCCP
|
||||||
# define PNG_NO_WRITE_iCCP
|
# define PNG_NO_WRITE_iCCP
|
||||||
|
@ -463,7 +554,7 @@
|
||||||
# define PNG_FREE_ME_SUPPORTED
|
# define PNG_FREE_ME_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED)
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
|
||||||
!defined(PNG_NO_READ_TRANSFORMS)
|
!defined(PNG_NO_READ_TRANSFORMS)
|
||||||
|
@ -528,12 +619,12 @@
|
||||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||||
|
|
||||||
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
|
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
|
||||||
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
|
!defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */
|
||||||
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
||||||
#endif /* about interlacing capability! You'll */
|
#endif /* about interlacing capability! You'll */
|
||||||
/* still have interlacing unless you change the following line: */
|
/* still have interlacing unless you change the following line: */
|
||||||
|
|
||||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */
|
||||||
|
|
||||||
#ifndef PNG_NO_READ_COMPOSITE_NODIV
|
#ifndef PNG_NO_READ_COMPOSITE_NODIV
|
||||||
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
|
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
|
||||||
|
@ -541,15 +632,17 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
|
||||||
/* Deprecated, will be removed from version 2.0.0.
|
/* Deprecated, will be removed from version 2.0.0.
|
||||||
Use PNG_MNG_FEATURES_SUPPORTED instead. */
|
Use PNG_MNG_FEATURES_SUPPORTED instead. */
|
||||||
#ifndef PNG_NO_READ_EMPTY_PLTE
|
#ifndef PNG_NO_READ_EMPTY_PLTE
|
||||||
# define PNG_READ_EMPTY_PLTE_SUPPORTED
|
# define PNG_READ_EMPTY_PLTE_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
||||||
#if defined(PNG_WRITE_SUPPORTED)
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
|
||||||
# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
|
# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
|
||||||
!defined(PNG_NO_WRITE_TRANSFORMS)
|
!defined(PNG_NO_WRITE_TRANSFORMS)
|
||||||
|
@ -589,11 +682,15 @@
|
||||||
# endif
|
# endif
|
||||||
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
|
||||||
|
!defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
|
||||||
encoders, but can cause trouble
|
encoders, but can cause trouble
|
||||||
if left undefined */
|
if left undefined */
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
|
#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
|
||||||
|
!defined(PNG_WRITE_WEIGHTED_FILTER) && \
|
||||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
@ -602,10 +699,12 @@
|
||||||
# define PNG_WRITE_FLUSH_SUPPORTED
|
# define PNG_WRITE_FLUSH_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
|
||||||
/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
|
/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
|
||||||
#ifndef PNG_NO_WRITE_EMPTY_PLTE
|
#ifndef PNG_NO_WRITE_EMPTY_PLTE
|
||||||
# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
|
# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_WRITE_SUPPORTED */
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
||||||
|
@ -647,21 +746,46 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
|
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
|
||||||
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
|
* and removed from version 1.2.20. The following will be removed
|
||||||
|
* from libpng-1.4.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE)
|
||||||
|
# ifndef PNG_OPTIMIZED_CODE_SUPPORTED
|
||||||
|
# define PNG_OPTIMIZED_CODE_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
|
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
|
||||||
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
|
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
# define PNG_ASSEMBLER_CODE_SUPPORTED
|
# define PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4)
|
||||||
|
/* work around 64-bit gcc compiler bugs in gcc-3.x */
|
||||||
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
# define PNG_MMX_CODE_SUPPORTED
|
# define PNG_NO_MMX_CODE
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* If you are sure that you don't need thread safety and you are compiling
|
# if defined(__APPLE__)
|
||||||
with PNG_USE_PNGCCRD for an MMX application, you can define this for
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
faster execution. See pnggccrd.c.
|
# define PNG_NO_MMX_CODE
|
||||||
#define PNG_THREAD_UNSAFE_OK
|
# endif
|
||||||
*/
|
# endif
|
||||||
|
|
||||||
|
# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh))
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
|
# define PNG_NO_MMX_CODE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
|
# define PNG_MMX_CODE_SUPPORTED
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* end of obsolete code to be removed from libpng-1.4.0 */
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
|
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
|
||||||
|
@ -688,6 +812,11 @@
|
||||||
# define PNG_USER_HEIGHT_MAX 1000000L
|
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||||
#endif
|
#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 */
|
/* These are currently experimental features, define them if you want */
|
||||||
|
|
||||||
/* very little testing */
|
/* very little testing */
|
||||||
|
@ -815,14 +944,22 @@
|
||||||
# define PNG_READ_zTXt_SUPPORTED
|
# define PNG_READ_zTXt_SUPPORTED
|
||||||
# define PNG_zTXt_SUPPORTED
|
# define PNG_zTXt_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef PNG_NO_READ_OPT_PLTE
|
||||||
|
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
|
||||||
|
#endif /* optional PLTE chunk in RGB and RGBA images */
|
||||||
|
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
|
||||||
|
defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
|
# define PNG_READ_TEXT_SUPPORTED
|
||||||
|
# define PNG_TEXT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
||||||
|
|
||||||
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
|
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
|
||||||
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
|
||||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(PNG_NO_READ_USER_CHUNKS) && \
|
#if !defined(PNG_NO_READ_USER_CHUNKS) && \
|
||||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
@ -835,17 +972,14 @@
|
||||||
# undef PNG_NO_HANDLE_AS_UNKNOWN
|
# undef PNG_NO_HANDLE_AS_UNKNOWN
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef PNG_NO_READ_OPT_PLTE
|
|
||||||
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
|
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||||
#endif /* optional PLTE chunk in RGB and RGBA images */
|
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
|
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
defined(PNG_READ_zTXt_SUPPORTED)
|
# endif
|
||||||
# define PNG_READ_TEXT_SUPPORTED
|
|
||||||
# define PNG_TEXT_SUPPORTED
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
|
||||||
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
|
||||||
#ifdef PNG_NO_WRITE_TEXT
|
#ifdef PNG_NO_WRITE_TEXT
|
||||||
|
@ -957,17 +1091,6 @@
|
||||||
# define PNG_zTXt_SUPPORTED
|
# define PNG_zTXt_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
|
|
||||||
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
|
||||||
# endif
|
|
||||||
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
|
||||||
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
|
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_zTXt_SUPPORTED)
|
defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||||
# define PNG_WRITE_TEXT_SUPPORTED
|
# define PNG_WRITE_TEXT_SUPPORTED
|
||||||
|
@ -978,6 +1101,20 @@
|
||||||
|
|
||||||
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
|
||||||
|
# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
|
||||||
|
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
|
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
||||||
/* Turn this off to disable png_read_png() and
|
/* Turn this off to disable png_read_png() and
|
||||||
* png_write_png() and leave the row_pointers member
|
* png_write_png() and leave the row_pointers member
|
||||||
* out of the info structure.
|
* out of the info structure.
|
||||||
|
@ -1121,6 +1258,9 @@ typedef double FAR * FAR * png_doublepp;
|
||||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||||
typedef char FAR * FAR * FAR * png_charppp;
|
typedef char FAR * FAR * FAR * png_charppp;
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
|
/* SPC - Is this stuff deprecated? */
|
||||||
|
/* It'll be removed as of libpng-1.4.0 - GR-P */
|
||||||
/* libpng typedefs for types in zlib. If zlib changes
|
/* libpng typedefs for types in zlib. If zlib changes
|
||||||
* or another compression library is used, then change these.
|
* or another compression library is used, then change these.
|
||||||
* Eliminates need to change all the source files.
|
* Eliminates need to change all the source files.
|
||||||
|
@ -1128,6 +1268,7 @@ typedef char FAR * FAR * FAR * png_charppp;
|
||||||
typedef charf * png_zcharp;
|
typedef charf * png_zcharp;
|
||||||
typedef charf * FAR * png_zcharpp;
|
typedef charf * FAR * png_zcharpp;
|
||||||
typedef z_stream FAR * png_zstreamp;
|
typedef z_stream FAR * png_zstreamp;
|
||||||
|
#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define PNG_BUILD_DLL if the module being built is a Windows
|
* Define PNG_BUILD_DLL if the module being built is a Windows
|
||||||
|
@ -1179,20 +1320,17 @@ typedef z_stream FAR * png_zstreamp;
|
||||||
* but might be required for some pre-1.0.5c applications.
|
* but might be required for some pre-1.0.5c applications.
|
||||||
*/
|
*/
|
||||||
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
|
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
|
||||||
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
|
# if defined(PNG_NO_GLOBAL_ARRAYS) || \
|
||||||
|
(defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER)
|
||||||
# define PNG_USE_LOCAL_ARRAYS
|
# define PNG_USE_LOCAL_ARRAYS
|
||||||
# else
|
# else
|
||||||
# define PNG_USE_GLOBAL_ARRAYS
|
# define PNG_USE_GLOBAL_ARRAYS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__CYGWIN__) || defined(__WINE__)
|
#if defined(__CYGWIN__)
|
||||||
# undef PNGAPI
|
# undef PNGAPI
|
||||||
# if defined(__WINE__)
|
|
||||||
# define PNGAPI
|
|
||||||
# else
|
|
||||||
# define PNGAPI __cdecl
|
# define PNGAPI __cdecl
|
||||||
# endif
|
|
||||||
# undef PNG_IMPEXP
|
# undef PNG_IMPEXP
|
||||||
# define PNG_IMPEXP
|
# define PNG_IMPEXP
|
||||||
#endif
|
#endif
|
||||||
|
@ -1271,20 +1409,6 @@ typedef z_stream FAR * png_zstreamp;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__VISAGECPP__)
|
|
||||||
/* I don't compile with this _System linkage for wxWidgets */
|
|
||||||
# ifdef PNGAPI
|
|
||||||
# undef PNGAPI
|
|
||||||
# endif
|
|
||||||
# define PNGAPI _Optlink
|
|
||||||
# define PNG_IMPEXP
|
|
||||||
# define PNG_USE_LOCAL_ARRAYS
|
|
||||||
# ifdef PNG_USE_GLOBAL_ARRAYS
|
|
||||||
# undef PNG_USE_GLOBAL_ARRAYS
|
|
||||||
# endif
|
|
||||||
extern const char png_libpng_ver[18];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PNGAPI
|
#ifndef PNGAPI
|
||||||
# define PNGAPI
|
# define PNGAPI
|
||||||
#endif
|
#endif
|
||||||
|
@ -1292,6 +1416,17 @@ extern const char png_libpng_ver[18];
|
||||||
# define PNG_IMPEXP
|
# define PNG_IMPEXP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_BUILDSYMS
|
||||||
|
# ifndef PNG_EXPORT
|
||||||
|
# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
|
||||||
|
# endif
|
||||||
|
# ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
|
# ifndef PNG_EXPORT_VAR
|
||||||
|
# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_EXPORT
|
#ifndef PNG_EXPORT
|
||||||
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
|
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
|
||||||
#endif
|
#endif
|
||||||
|
@ -1323,8 +1458,7 @@ extern const char png_libpng_ver[18];
|
||||||
# define NOCHECK 0
|
# define NOCHECK 0
|
||||||
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
|
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
|
||||||
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
|
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
|
||||||
# define png_strcpy _fstrcpy
|
# define png_snprintf _fsnprintf /* Added to v 1.2.19 */
|
||||||
# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
|
|
||||||
# define png_strlen _fstrlen
|
# define png_strlen _fstrlen
|
||||||
# define png_memcmp _fmemcmp /* SJT: added */
|
# define png_memcmp _fmemcmp /* SJT: added */
|
||||||
# define png_memcpy _fmemcpy
|
# define png_memcpy _fmemcpy
|
||||||
|
@ -1332,8 +1466,27 @@ extern const char png_libpng_ver[18];
|
||||||
#else /* use the usual functions */
|
#else /* use the usual functions */
|
||||||
# define CVT_PTR(ptr) (ptr)
|
# define CVT_PTR(ptr) (ptr)
|
||||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||||
# define png_strcpy strcpy
|
# ifndef PNG_NO_SNPRINTF
|
||||||
# define png_strncpy strncpy /* Added to v 1.2.6 */
|
# ifdef _MSC_VER
|
||||||
|
# define png_snprintf _snprintf /* Added to v 1.2.19 */
|
||||||
|
# define png_snprintf2 _snprintf
|
||||||
|
# define png_snprintf6 _snprintf
|
||||||
|
# else
|
||||||
|
# define png_snprintf snprintf /* Added to v 1.2.19 */
|
||||||
|
# define png_snprintf2 snprintf
|
||||||
|
# define png_snprintf6 snprintf
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
/* You don't have or don't want to use snprintf(). Caution: Using
|
||||||
|
* sprintf instead of snprintf exposes your application to accidental
|
||||||
|
* or malevolent buffer overflows. If you don't have snprintf()
|
||||||
|
* as a general rule you should provide one (you can get one from
|
||||||
|
* Portable OpenSSH). */
|
||||||
|
# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
|
||||||
|
# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
|
||||||
|
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
|
||||||
|
sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
|
||||||
|
# endif
|
||||||
# define png_strlen strlen
|
# define png_strlen strlen
|
||||||
# define png_memcmp memcmp /* SJT: added */
|
# define png_memcmp memcmp /* SJT: added */
|
||||||
# define png_memcpy memcpy
|
# define png_memcpy memcpy
|
||||||
|
@ -1349,46 +1502,7 @@ extern const char png_libpng_ver[18];
|
||||||
# define PNG_ZBUF_SIZE 65536L
|
# define PNG_ZBUF_SIZE 65536L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
/* Added at libpng-1.2.8 */
|
||||||
/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
|
#endif /* PNG_VERSION_INFO_ONLY */
|
||||||
#if defined(PNG_INTERNAL)
|
|
||||||
|
|
||||||
/* These are the default thresholds before the MMX code kicks in; if either
|
|
||||||
* rowbytes or bitdepth is below the threshold, plain C code is used. These
|
|
||||||
* can be overridden at runtime via the png_set_mmx_thresholds() call in
|
|
||||||
* libpng 1.2.0 and later. The values below were chosen by Intel.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
|
|
||||||
# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
|
|
||||||
#endif
|
|
||||||
#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
|
|
||||||
# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set this in the makefile for VC++ on Pentium, not here. */
|
|
||||||
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
|
|
||||||
* MMX will be detected at run time and used if present.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_USE_PNGVCRD
|
|
||||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set this in the makefile for gcc/as on Pentium, not here. */
|
|
||||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
|
|
||||||
* MMX will be detected at run time and used if present.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_USE_PNGGCCRD
|
|
||||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
#endif
|
|
||||||
/* - see pnggccrd.c for info about what is currently enabled */
|
|
||||||
|
|
||||||
#endif /* PNG_INTERNAL */
|
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
|
||||||
|
|
||||||
#endif /* PNGCONF_H */
|
#endif /* PNGCONF_H */
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* libpng version 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This file provides a location for all error handling. Users who
|
* This file provides a location for all error handling. Users who
|
||||||
* need special error handling are expected to write replacement functions
|
* need special error handling are expected to write replacement functions
|
||||||
* and use png_set_error_fn() to use those functions. See the instructions
|
* and use png_set_error_fn() to use those functions. See the instructions
|
||||||
|
@ -15,38 +18,46 @@
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_error PNGARG((png_structp png_ptr,
|
png_default_error PNGARG((png_structp png_ptr,
|
||||||
png_const_charp error_message));
|
png_const_charp error_message));
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning PNGARG((png_structp png_ptr,
|
png_default_warning PNGARG((png_structp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
/* This function is called whenever there is a fatal error. This function
|
/* This function is called whenever there is a fatal error. This function
|
||||||
* should not be changed. If there is a need to handle errors differently,
|
* should not be changed. If there is a need to handle errors differently,
|
||||||
* you should supply a replacement error function and use png_set_error_fn()
|
* you should supply a replacement error function and use png_set_error_fn()
|
||||||
* to replace the error function at run-time.
|
* to replace the error function at run-time.
|
||||||
*/
|
*/
|
||||||
|
#ifndef PNG_NO_ERROR_TEXT
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_error(png_structp png_ptr, png_const_charp error_message)
|
png_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
char msg[16];
|
char msg[16];
|
||||||
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
if (png_ptr->flags&
|
||||||
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||||
{
|
{
|
||||||
if (*error_message == '#')
|
if (*error_message == '#')
|
||||||
{
|
{
|
||||||
|
/* Strip "#nnnn " from beginning of error message. */
|
||||||
int offset;
|
int offset;
|
||||||
for (offset = 1; offset<15; offset++)
|
for (offset = 1; offset<15; offset++)
|
||||||
if (*(error_message+offset) == ' ')
|
if (error_message[offset] == ' ')
|
||||||
break;
|
break;
|
||||||
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < offset - 1; i++)
|
for (i = 0; i < offset - 1; i++)
|
||||||
msg[i] = error_message[i + 1];
|
msg[i] = error_message[i + 1];
|
||||||
msg[i]='\0';
|
msg[i - 1] = '\0';
|
||||||
error_message = msg;
|
error_message = msg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -62,6 +73,7 @@ png_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
(*(png_ptr->error_fn))(png_ptr, error_message);
|
(*(png_ptr->error_fn))(png_ptr, error_message);
|
||||||
|
@ -70,7 +82,20 @@ png_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
png_default_error(png_ptr, error_message);
|
png_default_error(png_ptr, error_message);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void PNGAPI
|
||||||
|
png_err(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
|
(*(png_ptr->error_fn))(png_ptr, '\0');
|
||||||
|
|
||||||
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
|
use the default handler, which will not return. */
|
||||||
|
png_default_error(png_ptr, '\0');
|
||||||
|
}
|
||||||
|
#endif /* PNG_NO_ERROR_TEXT */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
/* This function is called whenever there is a non-fatal error. This function
|
/* This function is called whenever there is a non-fatal error. This function
|
||||||
* should not be changed. If there is a need to handle warnings differently,
|
* should not be changed. If there is a need to handle warnings differently,
|
||||||
* you should supply a replacement warning function and use
|
* you should supply a replacement warning function and use
|
||||||
|
@ -80,22 +105,28 @@ void PNGAPI
|
||||||
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
if (png_ptr->flags&
|
||||||
|
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (*warning_message == '#')
|
if (*warning_message == '#')
|
||||||
{
|
{
|
||||||
for (offset = 1; offset < 15; offset++)
|
for (offset = 1; offset < 15; offset++)
|
||||||
if (*(warning_message+offset) == ' ')
|
if (warning_message[offset] == ' ')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
|
||||||
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
(*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
|
||||||
else
|
else
|
||||||
png_default_warning(png_ptr, warning_message + offset);
|
png_default_warning(png_ptr, warning_message + offset);
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
|
|
||||||
/* These utilities are used internally to build an error message that relates
|
/* These utilities are used internally to build an error message that relates
|
||||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
|
@ -109,6 +140,9 @@ static PNG_CONST char png_digit[16] = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PNG_MAX_ERROR_TEXT 64
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
error_message)
|
error_message)
|
||||||
|
@ -132,31 +166,47 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error_message == NULL)
|
if (error_message == NULL)
|
||||||
buffer[iout] = 0;
|
buffer[iout] = '\0';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer[iout++] = ':';
|
buffer[iout++] = ':';
|
||||||
buffer[iout++] = ' ';
|
buffer[iout++] = ' ';
|
||||||
png_strncpy(buffer+iout, error_message, 63);
|
png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||||
buffer[iout+63] = 0;
|
buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
char msg[18+64];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
png_error(png_ptr, error_message);
|
||||||
|
else
|
||||||
|
{
|
||||||
png_format_buffer(png_ptr, msg, error_message);
|
png_format_buffer(png_ptr, msg, error_message);
|
||||||
png_error(png_ptr, msg);
|
png_error(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
char msg[18+64];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
png_warning(png_ptr, warning_message);
|
||||||
|
else
|
||||||
|
{
|
||||||
png_format_buffer(png_ptr, msg, warning_message);
|
png_format_buffer(png_ptr, msg, warning_message);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
|
|
||||||
/* This is the default error handling function. Note that replacements for
|
/* This is the default error handling function. Note that replacements for
|
||||||
* this function MUST NOT RETURN, or the program will likely crash. This
|
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||||
|
@ -170,29 +220,40 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
|
||||||
if (*error_message == '#')
|
if (*error_message == '#')
|
||||||
{
|
{
|
||||||
|
/* Strip "#nnnn " from beginning of error message. */
|
||||||
int offset;
|
int offset;
|
||||||
char error_number[16];
|
char error_number[16];
|
||||||
for (offset = 0; offset<15; offset++)
|
for (offset = 0; offset<15; offset++)
|
||||||
{
|
{
|
||||||
error_number[offset] = *(error_message+offset+1);
|
error_number[offset] = error_message[offset + 1];
|
||||||
if (*(error_message+offset) == ' ')
|
if (error_message[offset] == ' ')
|
||||||
break;
|
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,
|
fprintf(stderr, "libpng error no. %s: %s",
|
||||||
error_message+offset);
|
error_number, error_message + offset + 1);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
|
{
|
||||||
|
fprintf(stderr, "libpng error: %s, offset=%d",
|
||||||
|
error_message, offset);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "libpng error: %s\n", error_message);
|
{
|
||||||
|
fprintf(stderr, "libpng error: %s", error_message);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
if (png_ptr)
|
||||||
|
{
|
||||||
# ifdef USE_FAR_KEYWORD
|
# ifdef USE_FAR_KEYWORD
|
||||||
{
|
{
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
|
@ -202,18 +263,16 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
# else
|
# else
|
||||||
longjmp(png_ptr->jmpbuf, 1);
|
longjmp(png_ptr->jmpbuf, 1);
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* make compiler happy */ ;
|
|
||||||
if (png_ptr)
|
|
||||||
PNG_ABORT();
|
PNG_ABORT();
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_NO_CONSOLE_IO
|
#ifdef PNG_NO_CONSOLE_IO
|
||||||
/* make compiler happy */ ;
|
error_message = error_message; /* Make compiler happy */
|
||||||
if (&error_message != NULL)
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
/* This function is called when there is a warning, but the library thinks
|
/* This function is called when there is a warning, but the library thinks
|
||||||
* it can continue anyway. Replacement functions don't have to do anything
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
* here if you don't want them to. In the default configuration, png_ptr is
|
* here if you don't want them to. In the default configuration, png_ptr is
|
||||||
|
@ -230,31 +289,36 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
char warning_number[16];
|
char warning_number[16];
|
||||||
for (offset = 0; offset < 15; offset++)
|
for (offset = 0; offset < 15; offset++)
|
||||||
{
|
{
|
||||||
warning_number[offset]=*(warning_message+offset+1);
|
warning_number[offset] = warning_message[offset + 1];
|
||||||
if (*(warning_message+offset) == ' ')
|
if (warning_message[offset] == ' ')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((offset > 1) && (offset < 15))
|
if ((offset > 1) && (offset < 15))
|
||||||
{
|
{
|
||||||
warning_number[offset-1]='\0';
|
warning_number[offset + 1] = '\0';
|
||||||
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
|
fprintf(stderr, "libpng warning no. %s: %s",
|
||||||
warning_message+offset);
|
warning_number, warning_message + offset);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
{
|
||||||
|
fprintf(stderr, "libpng warning: %s",
|
||||||
|
warning_message);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
{
|
||||||
|
fprintf(stderr, "libpng warning: %s", warning_message);
|
||||||
|
fprintf(stderr, PNG_STRING_NEWLINE);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* make compiler happy */ ;
|
warning_message = warning_message; /* Make compiler happy */
|
||||||
if (warning_message)
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
/* make compiler happy */ ;
|
png_ptr = png_ptr; /* Make compiler happy */
|
||||||
if (png_ptr)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
* of handling errors and warnings. Note that the error function MUST NOT
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
|
@ -265,6 +329,8 @@ void PNGAPI
|
||||||
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
png_error_ptr error_fn, png_error_ptr warning_fn)
|
png_error_ptr error_fn, png_error_ptr warning_fn)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->error_ptr = error_ptr;
|
png_ptr->error_ptr = error_ptr;
|
||||||
png_ptr->error_fn = error_fn;
|
png_ptr->error_fn = error_fn;
|
||||||
png_ptr->warning_fn = warning_fn;
|
png_ptr->warning_fn = warning_fn;
|
||||||
|
@ -278,6 +344,8 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_error_ptr(png_structp png_ptr)
|
png_get_error_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return NULL;
|
||||||
return ((png_voidp)png_ptr->error_ptr);
|
return ((png_voidp)png_ptr->error_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,3 +361,4 @@ png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,21 +1,27 @@
|
||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->valid & flag);
|
return(info_ptr->valid & flag);
|
||||||
|
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +31,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->rowbytes);
|
return(info_ptr->rowbytes);
|
||||||
|
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -35,20 +42,20 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
return(info_ptr->row_pointers);
|
return(info_ptr->row_pointers);
|
||||||
|
|
||||||
else
|
else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
#ifdef PNG_EASY_ACCESS_SUPPORTED
|
||||||
/* easy access to info, added in libpng-0.99 */
|
/* Easy access to info, added in libpng-0.99 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
png_get_image_width(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->width;
|
return info_ptr->width;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +63,8 @@ png_uint_32 PNGAPI
|
||||||
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
png_get_image_height(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->height;
|
return info_ptr->height;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +72,8 @@ png_byte PNGAPI
|
||||||
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->bit_depth;
|
return info_ptr->bit_depth;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +81,8 @@ png_byte PNGAPI
|
||||||
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
png_get_color_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->color_type;
|
return info_ptr->color_type;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +90,8 @@ png_byte PNGAPI
|
||||||
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->filter_type;
|
return info_ptr->filter_type;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +99,8 @@ png_byte PNGAPI
|
||||||
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->interlace_type;
|
return info_ptr->interlace_type;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +108,8 @@ png_byte PNGAPI
|
||||||
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
{
|
|
||||||
return info_ptr->compression_type;
|
return info_ptr->compression_type;
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,10 +120,13 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
#if defined(PNG_pHYs_SUPPORTED)
|
#if defined(PNG_pHYs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
|
png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
|
||||||
|
|
||||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->x_pixels_per_unit);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->x_pixels_per_unit);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -137,10 +141,13 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
#if defined(PNG_pHYs_SUPPORTED)
|
#if defined(PNG_pHYs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
|
png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
|
||||||
|
|
||||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->y_pixels_per_unit);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->y_pixels_per_unit);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -155,11 +162,14 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
|
||||||
#if defined(PNG_pHYs_SUPPORTED)
|
#if defined(PNG_pHYs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
if (info_ptr->valid & PNG_INFO_pHYs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
|
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
||||||
|
|
||||||
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
|
||||||
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->x_pixels_per_unit);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->x_pixels_per_unit);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -173,9 +183,10 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
#if defined(PNG_pHYs_SUPPORTED)
|
#if defined(PNG_pHYs_SUPPORTED)
|
||||||
|
|
||||||
if (info_ptr->valid & PNG_INFO_pHYs)
|
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)
|
if (info_ptr->x_pixels_per_unit == 0)
|
||||||
return ((float)0.0);
|
return ((float)0.0);
|
||||||
else
|
else
|
||||||
|
@ -194,12 +205,16 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
#if defined(PNG_oFFs_SUPPORTED)
|
#if defined(PNG_oFFs_SUPPORTED)
|
||||||
|
|
||||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
||||||
|
|
||||||
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->x_offset);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->x_offset);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -211,13 +226,17 @@ png_int_32 PNGAPI
|
||||||
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
|
||||||
#if defined(PNG_oFFs_SUPPORTED)
|
#if defined(PNG_oFFs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
||||||
|
|
||||||
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->y_offset);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->y_offset);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -229,13 +248,17 @@ png_int_32 PNGAPI
|
||||||
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
|
||||||
#if defined(PNG_oFFs_SUPPORTED)
|
#if defined(PNG_oFFs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
|
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
||||||
|
|
||||||
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->x_offset);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->x_offset);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -247,13 +270,17 @@ png_int_32 PNGAPI
|
||||||
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
|
|
||||||
#if defined(PNG_oFFs_SUPPORTED)
|
#if defined(PNG_oFFs_SUPPORTED)
|
||||||
if (info_ptr->valid & PNG_INFO_oFFs)
|
if (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
|
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
||||||
|
|
||||||
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
|
||||||
return (0);
|
return (0);
|
||||||
else return (info_ptr->y_offset);
|
|
||||||
|
else
|
||||||
|
return (info_ptr->y_offset);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -306,7 +333,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))
|
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)
|
if (res_x != NULL)
|
||||||
{
|
{
|
||||||
*res_x = info_ptr->x_pixels_per_unit;
|
*res_x = info_ptr->x_pixels_per_unit;
|
||||||
|
@ -363,7 +390,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
|
||||||
&& background != NULL)
|
&& background != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "bKGD");
|
png_debug1(1, "in %s retrieval function", "bKGD");
|
||||||
*background = &(info_ptr->background);
|
*background = &(info_ptr->background);
|
||||||
return (PNG_INFO_bKGD);
|
return (PNG_INFO_bKGD);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +407,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))
|
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)
|
if (white_x != NULL)
|
||||||
*white_x = (double)info_ptr->x_white;
|
*white_x = (double)info_ptr->x_white;
|
||||||
if (white_y != NULL)
|
if (white_y != NULL)
|
||||||
|
@ -411,7 +438,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))
|
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)
|
if (white_x != NULL)
|
||||||
*white_x = info_ptr->int_x_white;
|
*white_x = info_ptr->int_x_white;
|
||||||
if (white_y != NULL)
|
if (white_y != NULL)
|
||||||
|
@ -443,7 +470,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||||
&& file_gamma != NULL)
|
&& 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;
|
*file_gamma = (double)info_ptr->gamma;
|
||||||
return (PNG_INFO_gAMA);
|
return (PNG_INFO_gAMA);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +485,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
|
||||||
&& int_file_gamma != NULL)
|
&& 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;
|
*int_file_gamma = info_ptr->int_gamma;
|
||||||
return (PNG_INFO_gAMA);
|
return (PNG_INFO_gAMA);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +501,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
|
||||||
&& file_srgb_intent != NULL)
|
&& 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;
|
*file_srgb_intent = (int)info_ptr->srgb_intent;
|
||||||
return (PNG_INFO_sRGB);
|
return (PNG_INFO_sRGB);
|
||||||
}
|
}
|
||||||
|
@ -491,11 +518,12 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
|
||||||
&& name != NULL && profile != NULL && proflen != NULL)
|
&& 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;
|
*name = info_ptr->iccp_name;
|
||||||
*profile = info_ptr->iccp_profile;
|
*profile = info_ptr->iccp_profile;
|
||||||
/* compression_type is a dummy so the API won't have to change
|
/* Compression_type is a dummy so the API won't have to change
|
||||||
if we introduce multiple compression types later. */
|
* if we introduce multiple compression types later.
|
||||||
|
*/
|
||||||
*proflen = (int)info_ptr->iccp_proflen;
|
*proflen = (int)info_ptr->iccp_proflen;
|
||||||
*compression_type = (int)info_ptr->iccp_compression;
|
*compression_type = (int)info_ptr->iccp_compression;
|
||||||
return (PNG_INFO_iCCP);
|
return (PNG_INFO_iCCP);
|
||||||
|
@ -510,9 +538,12 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_sPLT_tpp spalettes)
|
png_sPLT_tpp spalettes)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||||
|
{
|
||||||
*spalettes = info_ptr->splt_palettes;
|
*spalettes = info_ptr->splt_palettes;
|
||||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||||
}
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_hIST_SUPPORTED)
|
#if defined(PNG_hIST_SUPPORTED)
|
||||||
|
@ -522,7 +553,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
|
||||||
&& hist != NULL)
|
&& hist != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "hIST");
|
png_debug1(1, "in %s retrieval function", "hIST");
|
||||||
*hist = info_ptr->hist;
|
*hist = info_ptr->hist;
|
||||||
return (PNG_INFO_hIST);
|
return (PNG_INFO_hIST);
|
||||||
}
|
}
|
||||||
|
@ -540,27 +571,34 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
|
||||||
bit_depth != NULL && color_type != 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;
|
*width = info_ptr->width;
|
||||||
*height = info_ptr->height;
|
*height = info_ptr->height;
|
||||||
*bit_depth = info_ptr->bit_depth;
|
*bit_depth = info_ptr->bit_depth;
|
||||||
if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
|
if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
|
||||||
png_error(png_ptr, "Invalid bit depth");
|
png_error(png_ptr, "Invalid bit depth");
|
||||||
|
|
||||||
*color_type = info_ptr->color_type;
|
*color_type = info_ptr->color_type;
|
||||||
|
|
||||||
if (info_ptr->color_type > 6)
|
if (info_ptr->color_type > 6)
|
||||||
png_error(png_ptr, "Invalid color type");
|
png_error(png_ptr, "Invalid color type");
|
||||||
|
|
||||||
if (compression_type != NULL)
|
if (compression_type != NULL)
|
||||||
*compression_type = info_ptr->compression_type;
|
*compression_type = info_ptr->compression_type;
|
||||||
|
|
||||||
if (filter_type != NULL)
|
if (filter_type != NULL)
|
||||||
*filter_type = info_ptr->filter_type;
|
*filter_type = info_ptr->filter_type;
|
||||||
|
|
||||||
if (interlace_type != NULL)
|
if (interlace_type != NULL)
|
||||||
*interlace_type = info_ptr->interlace_type;
|
*interlace_type = info_ptr->interlace_type;
|
||||||
|
|
||||||
/* check for potential overflow of rowbytes */
|
/* Check for potential overflow of rowbytes */
|
||||||
if (width == 0 || *width > PNG_UINT_31_MAX)
|
if (*width == 0 || *width > PNG_UINT_31_MAX)
|
||||||
png_error(png_ptr, "Invalid image width");
|
png_error(png_ptr, "Invalid image width");
|
||||||
if (height == 0 || *height > PNG_UINT_31_MAX)
|
|
||||||
|
if (*height == 0 || *height > PNG_UINT_31_MAX)
|
||||||
png_error(png_ptr, "Invalid image height");
|
png_error(png_ptr, "Invalid image height");
|
||||||
|
|
||||||
if (info_ptr->width > (PNG_UINT_32_MAX
|
if (info_ptr->width > (PNG_UINT_32_MAX
|
||||||
>> 3) /* 8-byte RGBA pixels */
|
>> 3) /* 8-byte RGBA pixels */
|
||||||
- 64 /* bigrowbuf hack */
|
- 64 /* bigrowbuf hack */
|
||||||
|
@ -571,6 +609,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Width too large for libpng to process image data.");
|
"Width too large for libpng to process image data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -584,7 +623,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
|
||||||
&& offset_x != NULL && offset_y != NULL && unit_type != NULL)
|
&& 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_x = info_ptr->x_offset;
|
||||||
*offset_y = info_ptr->y_offset;
|
*offset_y = info_ptr->y_offset;
|
||||||
*unit_type = (int)info_ptr->offset_unit_type;
|
*unit_type = (int)info_ptr->offset_unit_type;
|
||||||
|
@ -604,7 +643,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||||
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
&& purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
|
||||||
nparams != NULL && units != NULL && params != 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;
|
*purpose = info_ptr->pcal_purpose;
|
||||||
*X0 = info_ptr->pcal_X0;
|
*X0 = info_ptr->pcal_X0;
|
||||||
*X1 = info_ptr->pcal_X1;
|
*X1 = info_ptr->pcal_X1;
|
||||||
|
@ -664,17 +703,20 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
|
||||||
if (png_ptr != NULL && info_ptr != NULL &&
|
if (png_ptr != NULL && info_ptr != NULL &&
|
||||||
(info_ptr->valid & PNG_INFO_pHYs))
|
(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)
|
if (res_x != NULL)
|
||||||
{
|
{
|
||||||
*res_x = info_ptr->x_pixels_per_unit;
|
*res_x = info_ptr->x_pixels_per_unit;
|
||||||
retval |= PNG_INFO_pHYs;
|
retval |= PNG_INFO_pHYs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res_y != NULL)
|
if (res_y != NULL)
|
||||||
{
|
{
|
||||||
*res_y = info_ptr->y_pixels_per_unit;
|
*res_y = info_ptr->y_pixels_per_unit;
|
||||||
retval |= PNG_INFO_pHYs;
|
retval |= PNG_INFO_pHYs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit_type != NULL)
|
if (unit_type != NULL)
|
||||||
{
|
{
|
||||||
*unit_type = (int)info_ptr->phys_unit_type;
|
*unit_type = (int)info_ptr->phys_unit_type;
|
||||||
|
@ -692,10 +734,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
|
||||||
&& palette != NULL)
|
&& palette != NULL)
|
||||||
{
|
{
|
||||||
png_debug1(1, "in %s retrieval function\n", "PLTE");
|
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||||
*palette = info_ptr->palette;
|
*palette = info_ptr->palette;
|
||||||
*num_palette = info_ptr->num_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 (PNG_INFO_PLTE);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -708,7 +750,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
|
||||||
&& sig_bit != NULL)
|
&& 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);
|
*sig_bit = &(info_ptr->sig_bit);
|
||||||
return (PNG_INFO_sBIT);
|
return (PNG_INFO_sBIT);
|
||||||
}
|
}
|
||||||
|
@ -723,13 +765,16 @@ 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)
|
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_ptr->chunk_name[0] == '\0' ? "text"
|
||||||
: (png_const_charp)png_ptr->chunk_name));
|
: (png_const_charp)png_ptr->chunk_name));
|
||||||
|
|
||||||
if (text_ptr != NULL)
|
if (text_ptr != NULL)
|
||||||
*text_ptr = info_ptr->text;
|
*text_ptr = info_ptr->text;
|
||||||
|
|
||||||
if (num_text != NULL)
|
if (num_text != NULL)
|
||||||
*num_text = info_ptr->num_text;
|
*num_text = info_ptr->num_text;
|
||||||
|
|
||||||
return ((png_uint_32)info_ptr->num_text);
|
return ((png_uint_32)info_ptr->num_text);
|
||||||
}
|
}
|
||||||
if (num_text != NULL)
|
if (num_text != NULL)
|
||||||
|
@ -745,7 +790,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)
|
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
|
||||||
&& mod_time != NULL)
|
&& 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);
|
*mod_time = &(info_ptr->mod_time);
|
||||||
return (PNG_INFO_tIME);
|
return (PNG_INFO_tIME);
|
||||||
}
|
}
|
||||||
|
@ -761,7 +806,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_uint_32 retval = 0;
|
png_uint_32 retval = 0;
|
||||||
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
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 (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
if (trans != NULL)
|
if (trans != NULL)
|
||||||
|
@ -769,6 +814,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
*trans = info_ptr->trans;
|
*trans = info_ptr->trans;
|
||||||
retval |= PNG_INFO_tRNS;
|
retval |= PNG_INFO_tRNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans_values != NULL)
|
if (trans_values != NULL)
|
||||||
*trans_values = &(info_ptr->trans_values);
|
*trans_values = &(info_ptr->trans_values);
|
||||||
}
|
}
|
||||||
|
@ -779,6 +825,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
*trans_values = &(info_ptr->trans_values);
|
*trans_values = &(info_ptr->trans_values);
|
||||||
retval |= PNG_INFO_tRNS;
|
retval |= PNG_INFO_tRNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans != NULL)
|
if (trans != NULL)
|
||||||
*trans = NULL;
|
*trans = NULL;
|
||||||
}
|
}
|
||||||
|
@ -798,9 +845,12 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_unknown_chunkpp unknowns)
|
png_unknown_chunkpp unknowns)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||||
|
{
|
||||||
*unknowns = info_ptr->unknown_chunks;
|
*unknowns = info_ptr->unknown_chunks;
|
||||||
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
||||||
}
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||||
|
@ -827,98 +877,56 @@ png_get_compression_buffer_size(png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_1_0_X
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
#ifndef PNG_1_0_X
|
||||||
|
/* This function was added to libpng 1.2.0 and should exist by default */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_asm_flags (png_structp png_ptr)
|
png_get_asm_flags (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0L: 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
/* This function was added to libpng 1.2.0 and should exist by default */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_asm_flagmask (int flag_select)
|
png_get_asm_flagmask (int flag_select)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_asm_flags = 0;
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
flag_select=flag_select;
|
||||||
if (flag_select & PNG_SELECT_READ)
|
return 0L;
|
||||||
settable_asm_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
/* no non-MMX flags yet */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* GRR: no write-flags yet, either, but someday... */
|
|
||||||
if (flag_select & PNG_SELECT_WRITE)
|
|
||||||
settable_asm_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
return settable_asm_flags; /* _theoretically_ settable capabilities only */
|
|
||||||
}
|
}
|
||||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
|
||||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* This function was added to libpng 1.2.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_mmx_flags = 0;
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
flag_select=flag_select;
|
||||||
if (flag_select & PNG_SELECT_READ)
|
|
||||||
settable_mmx_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
#if 0
|
|
||||||
/* GRR: no MMX write support yet, but someday... */
|
|
||||||
if (flag_select & PNG_SELECT_WRITE)
|
|
||||||
settable_mmx_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
if (compilerID != NULL) {
|
|
||||||
#ifdef PNG_USE_PNGVCRD
|
|
||||||
*compilerID = 1; /* MSVC */
|
|
||||||
#else
|
|
||||||
#ifdef PNG_USE_PNGGCCRD
|
|
||||||
*compilerID = 2; /* gcc/gas */
|
|
||||||
#else
|
|
||||||
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
||||||
#endif
|
return 0L;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
|
/* This function was added to libpng 1.2.0 */
|
||||||
}
|
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* This function was added to libpng 1.2.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
|
/* Obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0L: 0L);
|
||||||
}
|
}
|
||||||
|
#endif /* ?PNG_1_0_X */
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_SET_USER_LIMITS_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_uint_32 PNGAPI
|
||||||
png_get_user_width_max (png_structp png_ptr)
|
png_get_user_width_max (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
@ -931,4 +939,5 @@ png_get_user_height_max (png_structp png_ptr)
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||||
|
|
||||||
#endif /* ?PNG_1_0_X */
|
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* libpng version 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This file provides a location for all memory allocation. Users who
|
* This file provides a location for all memory allocation. Users who
|
||||||
* need special memory handling are expected to supply replacement
|
* need special memory handling are expected to supply replacement
|
||||||
* functions for png_malloc() and png_free(), and to use
|
* functions for png_malloc() and png_free(), and to use
|
||||||
|
@ -16,10 +19,11 @@
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
/* Borland DOS special memory handler */
|
/* Borland DOS special memory handler */
|
||||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||||
/* if you change this, be sure to change the one in png.h also */
|
/* If you change this, be sure to change the one in png.h also */
|
||||||
|
|
||||||
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
/* Allocate memory for a png_struct. The malloc and memset can be replaced
|
||||||
by a single call to calloc() if this is thought to improve performance. */
|
by a single call to calloc() if this is thought to improve performance. */
|
||||||
|
@ -135,6 +139,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
png_voidp ret;
|
png_voidp ret;
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
if (png_ptr == NULL || size == 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +157,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
if (png_ptr->offset_table == NULL)
|
if (png_ptr->offset_table == NULL)
|
||||||
{
|
{
|
||||||
/* try to see if we need to do any of this fancy stuff */
|
/* Try to see if we need to do any of this fancy stuff */
|
||||||
ret = farmalloc(size);
|
ret = farmalloc(size);
|
||||||
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
if (ret == NULL || ((png_size_t)ret & 0xffff))
|
||||||
{
|
{
|
||||||
|
@ -265,9 +272,10 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free a pointer allocated by png_malloc(). In the default
|
/* Free a pointer allocated by png_malloc(). In the default
|
||||||
configuration, png_ptr is not used, but is passed in case it
|
* configuration, png_ptr is not used, but is passed in case it
|
||||||
is needed. If ptr is NULL, return without taking any action. */
|
* is needed. If ptr is NULL, return without taking any action.
|
||||||
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
png_free(png_structp png_ptr, png_voidp ptr)
|
||||||
{
|
{
|
||||||
|
@ -280,7 +288,8 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else png_free_default(png_ptr, ptr);
|
else
|
||||||
|
png_free_default(png_ptr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
|
@ -288,6 +297,9 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||||
{
|
{
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
if (png_ptr == NULL || ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (png_ptr->offset_table != NULL)
|
if (png_ptr->offset_table != NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -413,10 +425,12 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
/* Allocate memory. For reasonable files, size should never exceed
|
||||||
64K. However, zlib may allocate more then 64K if you don't tell
|
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||||
it not to. See zconf.h and png.h for more information. zlib does
|
* it not to. See zconf.h and png.h for more information. zlib does
|
||||||
need to allocate exactly 64K, so whatever you call here must
|
* need to allocate exactly 64K, so whatever you call here must
|
||||||
have the ability to do that. */
|
* have the ability to do that.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_malloc(png_structp png_ptr, png_uint_32 size)
|
png_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
|
@ -449,7 +463,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
{
|
{
|
||||||
#ifndef PNG_USER_MEM_SUPPORTED
|
#ifndef PNG_USER_MEM_SUPPORTED
|
||||||
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -486,7 +500,8 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||||
without taking any action. */
|
* without taking any action.
|
||||||
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_free(png_structp png_ptr, png_voidp ptr)
|
png_free(png_structp png_ptr, png_voidp ptr)
|
||||||
{
|
{
|
||||||
|
@ -499,7 +514,8 @@ png_free(png_structp png_ptr, png_voidp ptr)
|
||||||
(*(png_ptr->free_fn))(png_ptr, ptr);
|
(*(png_ptr->free_fn))(png_ptr, ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else png_free_default(png_ptr, ptr);
|
else
|
||||||
|
png_free_default(png_ptr, ptr);
|
||||||
}
|
}
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_free_default(png_structp png_ptr, png_voidp ptr)
|
png_free_default(png_structp png_ptr, png_voidp ptr)
|
||||||
|
@ -534,8 +550,11 @@ png_voidp PNGAPI
|
||||||
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
png_voidp ptr;
|
png_voidp ptr;
|
||||||
png_uint_32 save_flags=png_ptr->flags;
|
png_uint_32 save_flags;
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
save_flags = png_ptr->flags;
|
||||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||||
png_ptr->flags=save_flags;
|
png_ptr->flags=save_flags;
|
||||||
|
@ -577,11 +596,14 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
malloc_fn, png_free_ptr free_fn)
|
malloc_fn, png_free_ptr free_fn)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
png_ptr->mem_ptr = mem_ptr;
|
png_ptr->mem_ptr = mem_ptr;
|
||||||
png_ptr->malloc_fn = malloc_fn;
|
png_ptr->malloc_fn = malloc_fn;
|
||||||
png_ptr->free_fn = free_fn;
|
png_ptr->free_fn = free_fn;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This function returns a pointer to the mem_ptr associated with the user
|
/* This function returns a pointer to the mem_ptr associated with the user
|
||||||
* functions. The application should free any memory associated with this
|
* functions. The application should free any memory associated with this
|
||||||
|
@ -590,6 +612,9 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_mem_ptr(png_structp png_ptr)
|
png_get_mem_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
return ((png_voidp)png_ptr->mem_ptr);
|
return ((png_voidp)png_ptr->mem_ptr);
|
||||||
}
|
}
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,22 @@
|
||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This file contains routines that an application calls directly to
|
* This file contains routines that an application calls directly to
|
||||||
* read a PNG file or stream.
|
* read a PNG file or stream.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED)
|
||||||
|
|
||||||
/* Create a PNG structure for reading, and allocate any memory needed. */
|
/* Create a PNG structure for reading, and allocate any memory needed. */
|
||||||
png_structp PNGAPI
|
png_structp PNGAPI
|
||||||
|
@ -33,6 +37,9 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
{
|
{
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
volatile
|
||||||
|
#endif
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
@ -43,7 +50,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_debug(1, "in png_create_read_struct\n");
|
png_debug(1, "in png_create_read_struct");
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
|
png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
|
||||||
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
|
(png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
|
||||||
|
@ -53,13 +60,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
/* Added at libpng-1.2.6 */
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
|
||||||
|
|
||||||
/* added at libpng-1.2.6 */
|
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
||||||
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
||||||
|
@ -93,12 +94,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
|
|
||||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||||
|
|
||||||
|
if (user_png_ver)
|
||||||
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
do
|
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;
|
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||||
} while (png_libpng_ver[i++]);
|
} while (png_libpng_ver[i++]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||||
|
|
||||||
|
|
||||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||||
{
|
{
|
||||||
|
@ -115,11 +122,13 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
char msg[80];
|
char msg[80];
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -131,7 +140,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* Initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)png_ptr->zbuf_size);
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
|
@ -169,9 +178,10 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
return (png_ptr);
|
return (png_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
/* Initialize PNG structure for reading, and allocate any memory needed.
|
/* Initialize PNG structure for reading, and allocate any memory needed.
|
||||||
This interface is deprecated in favour of the png_create_read_struct(),
|
This interface is deprecated in favour of the png_create_read_struct(),
|
||||||
and it will eventually disappear. */
|
and it will disappear as of libpng-1.3.0. */
|
||||||
#undef png_read_init
|
#undef png_read_init
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_init(png_structp png_ptr)
|
png_read_init(png_structp png_ptr)
|
||||||
|
@ -185,6 +195,8 @@ 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)
|
png_size_t png_struct_size, png_size_t png_info_size)
|
||||||
{
|
{
|
||||||
/* We only come here via pre-1.0.12-compiled applications */
|
/* We only come here via pre-1.0.12-compiled applications */
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#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)
|
png_sizeof(png_info) > png_info_size)
|
||||||
|
@ -193,11 +205,13 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||||
png_ptr->warning_fn = NULL;
|
png_ptr->warning_fn = NULL;
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
|
@ -222,6 +236,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
||||||
}
|
}
|
||||||
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
|
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_1_0_X || PNG_1_2_X */
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||||
|
@ -235,6 +250,9 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||||
|
|
||||||
png_structp png_ptr=*ptr_ptr;
|
png_structp png_ptr=*ptr_ptr;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (user_png_ver[i] != png_libpng_ver[i])
|
if (user_png_ver[i] != png_libpng_ver[i])
|
||||||
|
@ -250,10 +268,10 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||||
}
|
}
|
||||||
} while (png_libpng_ver[i++]);
|
} 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
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* save jump buffer and error functions */
|
/* 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
|
#endif
|
||||||
|
|
||||||
|
@ -264,21 +282,21 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||||
png_ptr = *ptr_ptr;
|
png_ptr = *ptr_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset all variables to 0 */
|
/* 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
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* restore jump buffer */
|
/* 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
|
#endif
|
||||||
|
|
||||||
/* added at libpng-1.2.6 */
|
/* Added at libpng-1.2.6 */
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
||||||
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* initialize zbuf - compression buffer */
|
/* Initialize zbuf - compression buffer */
|
||||||
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
||||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)png_ptr->zbuf_size);
|
(png_uint_32)png_ptr->zbuf_size);
|
||||||
|
@ -313,7 +331,9 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
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 we haven't checked all of the PNG signature bytes, do so now. */
|
||||||
if (png_ptr->sig_bytes < 8)
|
if (png_ptr->sig_bytes < 8)
|
||||||
{
|
{
|
||||||
|
@ -338,90 +358,85 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_CONST PNG_IHDR;
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
PNG_IEND;
|
PNG_CONST PNG_IEND;
|
||||||
PNG_PLTE;
|
PNG_CONST PNG_PLTE;
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
PNG_bKGD;
|
PNG_CONST PNG_bKGD;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
PNG_cHRM;
|
PNG_CONST PNG_cHRM;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
PNG_gAMA;
|
PNG_CONST PNG_gAMA;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
PNG_hIST;
|
PNG_CONST PNG_hIST;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
PNG_iCCP;
|
PNG_CONST PNG_iCCP;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
PNG_iTXt;
|
PNG_CONST PNG_iTXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
PNG_oFFs;
|
PNG_CONST PNG_oFFs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
PNG_pCAL;
|
PNG_CONST PNG_pCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
PNG_pHYs;
|
PNG_CONST PNG_pHYs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
PNG_sBIT;
|
PNG_CONST PNG_sBIT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
PNG_sCAL;
|
PNG_CONST PNG_sCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
PNG_sPLT;
|
PNG_CONST PNG_sPLT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
PNG_sRGB;
|
PNG_CONST PNG_sRGB;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
PNG_tEXt;
|
PNG_CONST PNG_tEXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
PNG_tIME;
|
PNG_CONST PNG_tIME;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
PNG_tRNS;
|
PNG_CONST PNG_tRNS;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
PNG_zTXt;
|
PNG_CONST PNG_zTXt;
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_GLOBAL_ARRAYS */
|
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||||
png_byte chunk_length[4];
|
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||||
png_uint_32 length;
|
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
||||||
|
|
||||||
png_read_data(png_ptr, chunk_length, 4);
|
|
||||||
length = png_get_uint_31(png_ptr,chunk_length);
|
|
||||||
|
|
||||||
png_reset_crc(png_ptr);
|
|
||||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
|
||||||
|
|
||||||
png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
|
|
||||||
length);
|
|
||||||
|
|
||||||
/* This should be a binary subdivision search or a hash for
|
/* This should be a binary subdivision search or a hash for
|
||||||
* matching the chunk name rather than a linear search.
|
* matching the chunk name rather than a linear search.
|
||||||
*/
|
*/
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
|
if (png_ptr->mode & PNG_AFTER_IDAT)
|
||||||
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
|
|
||||||
|
if (!png_memcmp(chunk_name, png_IHDR, 4))
|
||||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
else if (!png_memcmp(chunk_name, png_IEND, 4))
|
||||||
png_handle_IEND(png_ptr, info_ptr, length);
|
png_handle_IEND(png_ptr, info_ptr, length);
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
else if (png_handle_as_unknown(png_ptr, chunk_name))
|
||||||
{
|
{
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
png_handle_unknown(png_ptr, info_ptr, length);
|
png_handle_unknown(png_ptr, info_ptr, length);
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||||
|
@ -432,9 +447,9 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR))
|
||||||
png_error(png_ptr, "Missing IHDR before IDAT");
|
png_error(png_ptr, "Missing IHDR before IDAT");
|
||||||
|
@ -447,71 +462,71 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
||||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
||||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
||||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
else if (!png_memcmp(chunk_name, png_hIST, 4))
|
||||||
png_handle_hIST(png_ptr, info_ptr, length);
|
png_handle_hIST(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
||||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
||||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
||||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
||||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
||||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
||||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
||||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
||||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
||||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
else if (!png_memcmp(chunk_name, png_tIME, 4))
|
||||||
png_handle_tIME(png_ptr, info_ptr, length);
|
png_handle_tIME(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
||||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
||||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
||||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
@ -520,11 +535,13 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
||||||
|
|
||||||
/* optional call to update the users info_ptr structure */
|
/* Optional call to update the users info_ptr structure */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_read_update_info\n");
|
png_debug(1, "in png_read_update_info");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
else
|
else
|
||||||
|
@ -542,7 +559,9 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_start_read_image(png_structp png_ptr)
|
png_start_read_image(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_start_read_image\n");
|
png_debug(1, "in png_start_read_image");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
}
|
}
|
||||||
|
@ -553,18 +572,21 @@ void PNGAPI
|
||||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
||||||
const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
0xff};
|
||||||
|
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
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);
|
png_ptr->row_number, png_ptr->pass);
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||||
{
|
{
|
||||||
/* check for transforms that have been set but were defined out */
|
/* Check for transforms that have been set but were defined out */
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
|
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||||
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
|
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
|
||||||
|
@ -596,7 +618,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||||
/* if interlaced and we do not need a new row, combine row and return */
|
/* If interlaced and we do not need a new row, combine row and return */
|
||||||
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
||||||
{
|
{
|
||||||
switch (png_ptr->pass)
|
switch (png_ptr->pass)
|
||||||
|
@ -683,15 +705,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
{
|
{
|
||||||
while (!png_ptr->idat_size)
|
while (!png_ptr->idat_size)
|
||||||
{
|
{
|
||||||
png_byte chunk_length[4];
|
|
||||||
|
|
||||||
png_crc_finish(png_ptr, 0);
|
png_crc_finish(png_ptr, 0);
|
||||||
|
|
||||||
png_read_data(png_ptr, chunk_length, 4);
|
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||||
png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
|
|
||||||
|
|
||||||
png_reset_crc(png_ptr);
|
|
||||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
|
||||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
png_error(png_ptr, "Not enough image data");
|
png_error(png_ptr, "Not enough image data");
|
||||||
}
|
}
|
||||||
|
@ -744,18 +760,19 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (png_ptr->transformations)
|
|
||||||
|
if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
|
||||||
png_do_read_transformations(png_ptr);
|
png_do_read_transformations(png_ptr);
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||||
/* blow up interlaced rows to full size */
|
/* Blow up interlaced rows to full size */
|
||||||
if (png_ptr->interlaced &&
|
if (png_ptr->interlaced &&
|
||||||
(png_ptr->transformations & PNG_INTERLACE))
|
(png_ptr->transformations & PNG_INTERLACE))
|
||||||
{
|
{
|
||||||
if (png_ptr->pass < 6)
|
if (png_ptr->pass < 6)
|
||||||
/* old interface (pre-1.0.9):
|
/* Old interface (pre-1.0.9):
|
||||||
png_do_read_interlace(&(png_ptr->row_info),
|
* png_do_read_interlace(&(png_ptr->row_info),
|
||||||
png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
|
* png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
|
||||||
*/
|
*/
|
||||||
png_do_read_interlace(png_ptr);
|
png_do_read_interlace(png_ptr);
|
||||||
|
|
||||||
|
@ -803,7 +820,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
* not called png_set_interlace_handling(), the display_row buffer will
|
* not called png_set_interlace_handling(), the display_row buffer will
|
||||||
* be ignored, so pass NULL to it.
|
* be ignored, so pass NULL to it.
|
||||||
*
|
*
|
||||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7
|
* [*] png_handle_alpha() does not exist yet, as of this version of libpng
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
|
@ -814,7 +831,9 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||||
png_bytepp rp;
|
png_bytepp rp;
|
||||||
png_bytepp dp;
|
png_bytepp dp;
|
||||||
|
|
||||||
png_debug(1, "in png_read_rows\n");
|
png_debug(1, "in png_read_rows");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
rp = row;
|
rp = row;
|
||||||
dp = display_row;
|
dp = display_row;
|
||||||
if (rp != NULL && dp != NULL)
|
if (rp != NULL && dp != NULL)
|
||||||
|
@ -853,7 +872,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||||
* only call this function once. If you desire to have an image for
|
* only call this function once. If you desire to have an image for
|
||||||
* each pass of a interlaced image, use png_read_rows() instead.
|
* each pass of a interlaced image, use png_read_rows() instead.
|
||||||
*
|
*
|
||||||
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.7
|
* [*] png_handle_alpha() does not exist yet, as of this version of libpng
|
||||||
*/
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_image(png_structp png_ptr, png_bytepp image)
|
png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
|
@ -862,7 +881,9 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
int pass, j;
|
int pass, j;
|
||||||
png_bytepp rp;
|
png_bytepp rp;
|
||||||
|
|
||||||
png_debug(1, "in png_read_image\n");
|
png_debug(1, "in png_read_image");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
pass = png_set_interlace_handling(png_ptr);
|
pass = png_set_interlace_handling(png_ptr);
|
||||||
|
@ -897,176 +918,167 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
png_byte chunk_length[4];
|
png_debug(1, "in png_read_end");
|
||||||
png_uint_32 length;
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_debug(1, "in png_read_end\n");
|
|
||||||
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_CONST PNG_IHDR;
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
PNG_IEND;
|
PNG_CONST PNG_IEND;
|
||||||
PNG_PLTE;
|
PNG_CONST PNG_PLTE;
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
PNG_bKGD;
|
PNG_CONST PNG_bKGD;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
PNG_cHRM;
|
PNG_CONST PNG_cHRM;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
PNG_gAMA;
|
PNG_CONST PNG_gAMA;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
PNG_hIST;
|
PNG_CONST PNG_hIST;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
PNG_iCCP;
|
PNG_CONST PNG_iCCP;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
PNG_iTXt;
|
PNG_CONST PNG_iTXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
PNG_oFFs;
|
PNG_CONST PNG_oFFs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
PNG_pCAL;
|
PNG_CONST PNG_pCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
PNG_pHYs;
|
PNG_CONST PNG_pHYs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
PNG_sBIT;
|
PNG_CONST PNG_sBIT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
PNG_sCAL;
|
PNG_CONST PNG_sCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
PNG_sPLT;
|
PNG_CONST PNG_sPLT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
PNG_sRGB;
|
PNG_CONST PNG_sRGB;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
PNG_tEXt;
|
PNG_CONST PNG_tEXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
PNG_tIME;
|
PNG_CONST PNG_tIME;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
PNG_tRNS;
|
PNG_CONST PNG_tRNS;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
PNG_zTXt;
|
PNG_CONST PNG_zTXt;
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_GLOBAL_ARRAYS */
|
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||||
|
png_uint_32 length = png_read_chunk_header(png_ptr);
|
||||||
|
PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
|
||||||
|
|
||||||
png_read_data(png_ptr, chunk_length, 4);
|
if (!png_memcmp(chunk_name, png_IHDR, 4))
|
||||||
length = png_get_uint_31(png_ptr,chunk_length);
|
|
||||||
|
|
||||||
png_reset_crc(png_ptr);
|
|
||||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
|
||||||
|
|
||||||
png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
|
|
||||||
|
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
|
|
||||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
|
else if (!png_memcmp(chunk_name, png_IEND, 4))
|
||||||
png_handle_IEND(png_ptr, info_ptr, length);
|
png_handle_IEND(png_ptr, info_ptr, length);
|
||||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
|
else if (png_handle_as_unknown(png_ptr, chunk_name))
|
||||||
{
|
{
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||||
png_error(png_ptr, "Too many IDAT's found");
|
png_error(png_ptr, "Too many IDAT's found");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
|
||||||
png_handle_unknown(png_ptr, info_ptr, length);
|
png_handle_unknown(png_ptr, info_ptr, length);
|
||||||
if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||||
png_ptr->mode |= PNG_HAVE_PLTE;
|
png_ptr->mode |= PNG_HAVE_PLTE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
else if (!png_memcmp(chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
/* Zero length IDATs are legal after the last IDAT has been
|
/* Zero length IDATs are legal after the last IDAT has been
|
||||||
* read, but not after other chunks have been read.
|
* read, but not after other chunks have been read.
|
||||||
*/
|
*/
|
||||||
if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT)
|
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
|
||||||
png_error(png_ptr, "Too many IDAT's found");
|
png_error(png_ptr, "Too many IDAT's found");
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
}
|
}
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
|
else if (!png_memcmp(chunk_name, png_PLTE, 4))
|
||||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
|
else if (!png_memcmp(chunk_name, png_bKGD, 4))
|
||||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
|
else if (!png_memcmp(chunk_name, png_cHRM, 4))
|
||||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
|
else if (!png_memcmp(chunk_name, png_gAMA, 4))
|
||||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
|
else if (!png_memcmp(chunk_name, png_hIST, 4))
|
||||||
png_handle_hIST(png_ptr, info_ptr, length);
|
png_handle_hIST(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
|
else if (!png_memcmp(chunk_name, png_oFFs, 4))
|
||||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
|
else if (!png_memcmp(chunk_name, png_pCAL, 4))
|
||||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
|
else if (!png_memcmp(chunk_name, png_sCAL, 4))
|
||||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
|
else if (!png_memcmp(chunk_name, png_pHYs, 4))
|
||||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
|
else if (!png_memcmp(chunk_name, png_sBIT, 4))
|
||||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
|
else if (!png_memcmp(chunk_name, png_sRGB, 4))
|
||||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
|
else if (!png_memcmp(chunk_name, png_iCCP, 4))
|
||||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
|
else if (!png_memcmp(chunk_name, png_sPLT, 4))
|
||||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
|
else if (!png_memcmp(chunk_name, png_tEXt, 4))
|
||||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
|
else if (!png_memcmp(chunk_name, png_tIME, 4))
|
||||||
png_handle_tIME(png_ptr, info_ptr, length);
|
png_handle_tIME(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
|
else if (!png_memcmp(chunk_name, png_tRNS, 4))
|
||||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
|
else if (!png_memcmp(chunk_name, png_zTXt, 4))
|
||||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
|
else if (!png_memcmp(chunk_name, png_iTXt, 4))
|
||||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
@ -1075,7 +1087,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||||
}
|
}
|
||||||
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
||||||
|
|
||||||
/* free all memory used by the read */
|
/* Free all memory used by the read */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||||
png_infopp end_info_ptr_ptr)
|
png_infopp end_info_ptr_ptr)
|
||||||
|
@ -1083,13 +1095,20 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
png_free_ptr free_fn;
|
png_free_ptr free_fn = NULL;
|
||||||
png_voidp mem_ptr;
|
png_voidp mem_ptr = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_destroy_read_struct\n");
|
png_debug(1, "in png_destroy_read_struct");
|
||||||
if (png_ptr_ptr != NULL)
|
if (png_ptr_ptr != NULL)
|
||||||
png_ptr = *png_ptr_ptr;
|
png_ptr = *png_ptr_ptr;
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
mem_ptr = png_ptr->mem_ptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (info_ptr_ptr != NULL)
|
if (info_ptr_ptr != NULL)
|
||||||
info_ptr = *info_ptr_ptr;
|
info_ptr = *info_ptr_ptr;
|
||||||
|
@ -1097,11 +1116,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||||
if (end_info_ptr_ptr != NULL)
|
if (end_info_ptr_ptr != NULL)
|
||||||
end_info_ptr = *end_info_ptr_ptr;
|
end_info_ptr = *end_info_ptr_ptr;
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
free_fn = png_ptr->free_fn;
|
|
||||||
mem_ptr = png_ptr->mem_ptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
||||||
|
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
|
@ -1145,7 +1159,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free all memory used by the read (old method) */
|
/* Free all memory used by the read (old method) */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
||||||
{
|
{
|
||||||
|
@ -1159,7 +1173,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||||
png_free_ptr free_fn;
|
png_free_ptr free_fn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_read_destroy\n");
|
png_debug(1, "in png_read_destroy");
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
png_info_destroy(png_ptr, info_ptr);
|
png_info_destroy(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
@ -1169,6 +1183,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||||
png_free(png_ptr, png_ptr->zbuf);
|
png_free(png_ptr, png_ptr->zbuf);
|
||||||
png_free(png_ptr, png_ptr->big_row_buf);
|
png_free(png_ptr, png_ptr->big_row_buf);
|
||||||
png_free(png_ptr, png_ptr->prev_row);
|
png_free(png_ptr, png_ptr->prev_row);
|
||||||
|
png_free(png_ptr, png_ptr->chunkdata);
|
||||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||||
png_free(png_ptr, png_ptr->palette_lookup);
|
png_free(png_ptr, png_ptr->palette_lookup);
|
||||||
png_free(png_ptr, png_ptr->dither_index);
|
png_free(png_ptr, png_ptr->dither_index);
|
||||||
|
@ -1293,6 +1308,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->read_row_fn = read_row_fn;
|
png_ptr->read_row_fn = read_row_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,8 +1323,10 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||||
/* invert the alpha channel from opacity to transparency
|
/* Invert the alpha channel from opacity to transparency
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||||
png_set_invert_alpha(png_ptr);
|
png_set_invert_alpha(png_ptr);
|
||||||
|
@ -1323,7 +1342,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
/* -------------- image transformations start here ------------------- */
|
/* -------------- image transformations start here ------------------- */
|
||||||
|
|
||||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||||
/* tell libpng to strip 16 bit/color files down to 8 bits per color
|
/* Tell libpng to strip 16 bit/color files down to 8 bits per color.
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_STRIP_16)
|
if (transforms & PNG_TRANSFORM_STRIP_16)
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
@ -1370,7 +1389,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(PNG_READ_INVERT_SUPPORTED)
|
#if defined(PNG_READ_INVERT_SUPPORTED)
|
||||||
/* invert monochrome files to have 0 as white and 1 as black
|
/* Invert monochrome files to have 0 as white and 1 as black
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
||||||
png_set_invert_mono(png_ptr);
|
png_set_invert_mono(png_ptr);
|
||||||
|
@ -1392,21 +1411,21 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_BGR_SUPPORTED)
|
#if defined(PNG_READ_BGR_SUPPORTED)
|
||||||
/* flip the RGB pixels to BGR (or RGBA to BGRA)
|
/* Flip the RGB pixels to BGR (or RGBA to BGRA)
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_BGR)
|
if (transforms & PNG_TRANSFORM_BGR)
|
||||||
png_set_bgr(png_ptr);
|
png_set_bgr(png_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
||||||
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
|
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
||||||
png_set_swap_alpha(png_ptr);
|
png_set_swap_alpha(png_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED)
|
||||||
/* swap bytes of 16 bit files to least significant byte first
|
/* Swap bytes of 16 bit files to least significant byte first
|
||||||
*/
|
*/
|
||||||
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
||||||
png_set_swap(png_ptr);
|
png_set_swap(png_ptr);
|
||||||
|
@ -1429,25 +1448,26 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
||||||
{
|
{
|
||||||
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
|
||||||
info_ptr->height * png_sizeof(png_bytep));
|
info_ptr->height * png_sizeof(png_bytep));
|
||||||
|
png_memset(info_ptr->row_pointers, 0, info_ptr->height
|
||||||
|
* png_sizeof(png_bytep));
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
info_ptr->free_me |= PNG_FREE_ROWS;
|
info_ptr->free_me |= PNG_FREE_ROWS;
|
||||||
#endif
|
#endif
|
||||||
for (row = 0; row < (int)info_ptr->height; row++)
|
for (row = 0; row < (int)info_ptr->height; row++)
|
||||||
{
|
|
||||||
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
|
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
|
||||||
png_get_rowbytes(png_ptr, info_ptr));
|
png_get_rowbytes(png_ptr, info_ptr));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
png_read_image(png_ptr, info_ptr->row_pointers);
|
png_read_image(png_ptr, info_ptr->row_pointers);
|
||||||
info_ptr->valid |= PNG_INFO_IDAT;
|
info_ptr->valid |= PNG_INFO_IDAT;
|
||||||
|
|
||||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
/* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
if(transforms == 0 || params == NULL)
|
transforms = transforms; /* Quiet compiler warnings */
|
||||||
/* quiet compiler warnings */ return;
|
params = params;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
||||||
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This file provides a location for all input. Users who need
|
* This file provides a location for all input. Users who need
|
||||||
* special handling are expected to write a function that has the same
|
* special handling are expected to write a function that has the same
|
||||||
* arguments as this and performs a similar function, but that possibly
|
* arguments as this and performs a similar function, but that possibly
|
||||||
|
@ -17,16 +20,18 @@
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED)
|
||||||
|
|
||||||
/* Read the data from whatever input you are using. The default routine
|
/* Read the data from whatever input you are using. The default routine
|
||||||
reads from a file pointer. Note that this routine sometimes gets called
|
* reads from a file pointer. Note that this routine sometimes gets called
|
||||||
with very small lengths, so you should implement some kind of simple
|
* with very small lengths, so you should implement some kind of simple
|
||||||
buffering if you are using unbuffered reads. This should never be asked
|
* buffering if you are using unbuffered reads. This should never be asked
|
||||||
to read more then 64K on a 16 bit machine. */
|
* to read more then 64K on a 16 bit machine.
|
||||||
|
*/
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
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)
|
if (png_ptr->read_data_fn != NULL)
|
||||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||||
else
|
else
|
||||||
|
@ -35,15 +40,18 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
/* This is the function that does the actual reading of data. If you are
|
/* This is the function that does the actual reading of data. If you are
|
||||||
not reading from a standard C stream, you should create a replacement
|
* not reading from a standard C stream, you should create a replacement
|
||||||
read_data function and use it at run time with png_set_read_fn(), rather
|
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
than changing the library. */
|
* than changing the library.
|
||||||
|
*/
|
||||||
#ifndef USE_FAR_KEYWORD
|
#ifndef USE_FAR_KEYWORD
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
png_size_t check;
|
png_size_t check;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
/* 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.
|
* instead of an int, which is what fread() actually returns.
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +67,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_error(png_ptr, "Read Error");
|
png_error(png_ptr, "Read Error");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* this is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
the data.
|
the data.
|
||||||
*/
|
*/
|
||||||
|
@ -67,13 +75,15 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
#define NEAR_BUF_SIZE 1024
|
#define NEAR_BUF_SIZE 1024
|
||||||
#define MIN(a,b) (a <= b ? a : b)
|
#define MIN(a,b) (a <= b ? a : b)
|
||||||
|
|
||||||
static void /* PRIVATE */
|
static void PNGAPI
|
||||||
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
int check;
|
int check;
|
||||||
png_byte *n_data;
|
png_byte *n_data;
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
/* Check if data really is near. If so, use usual code. */
|
/* Check if data really is near. If so, use usual code. */
|
||||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||||
|
@ -118,22 +128,27 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply a new input function
|
/* This function allows the application to supply a new input function
|
||||||
for libpng if standard C streams aren't being used.
|
* for libpng if standard C streams aren't being used.
|
||||||
|
*
|
||||||
This function takes as its arguments:
|
* This function takes as its arguments:
|
||||||
png_ptr - pointer to a png input data structure
|
* png_ptr - pointer to a png input data structure
|
||||||
io_ptr - pointer to user supplied structure containing info about
|
* io_ptr - pointer to user supplied structure containing info about
|
||||||
the input functions. May be NULL.
|
* the input functions. May be NULL.
|
||||||
read_data_fn - pointer to a new input function that takes as its
|
* read_data_fn - pointer to a new input function that takes as its
|
||||||
arguments a pointer to a png_struct, a pointer to
|
* arguments a pointer to a png_struct, a pointer to
|
||||||
a location where input data can be stored, and a 32-bit
|
* a location where input data can be stored, and a 32-bit
|
||||||
unsigned int that is the number of bytes to be read.
|
* unsigned int that is the number of bytes to be read.
|
||||||
To exit and output any fatal error messages the new write
|
* To exit and output any fatal error messages the new write
|
||||||
function should call png_error(png_ptr, "Error msg"). */
|
* function should call png_error(png_ptr, "Error msg").
|
||||||
|
* May be NULL, in which case libpng's default function will
|
||||||
|
* be used.
|
||||||
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr read_data_fn)
|
png_rw_ptr read_data_fn)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
|
@ -159,3 +174,4 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_ptr->output_flush_fn = NULL;
|
png_ptr->output_flush_fn = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.39 [August 13, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* The functions here are used during reads to store data from the file
|
* The functions here are used during reads to store data from the file
|
||||||
* into the info struct, and during writes to store application data
|
* into the info struct, and during writes to store application data
|
||||||
* into the info struct for writing into the file. This abstracts the
|
* into the info struct for writing into the file. This abstracts the
|
||||||
|
@ -15,12 +18,13 @@
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
#if defined(PNG_bKGD_SUPPORTED)
|
#if defined(PNG_bKGD_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -36,29 +40,10 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
double white_x, double white_y, double red_x, double red_y,
|
double white_x, double white_y, double red_x, double red_y,
|
||||||
double green_x, double green_y, double blue_x, double blue_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
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->x_white = (float)white_x;
|
||||||
info_ptr->y_white = (float)white_y;
|
info_ptr->y_white = (float)white_y;
|
||||||
info_ptr->x_red = (float)red_x;
|
info_ptr->x_red = (float)red_x;
|
||||||
|
@ -79,7 +64,8 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
info_ptr->valid |= PNG_INFO_cHRM;
|
info_ptr->valid |= PNG_INFO_cHRM;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* PNG_FLOATING_POINT_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
@ -87,32 +73,15 @@ 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 red_y, png_fixed_point green_x, png_fixed_point green_y,
|
||||||
png_fixed_point blue_x, png_fixed_point blue_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (white_x < 0 || white_y < 0 ||
|
#if !defined(PNG_NO_CHECK_cHRM)
|
||||||
red_x < 0 || red_y < 0 ||
|
if (png_check_cHRM_fixed(png_ptr,
|
||||||
green_x < 0 || green_y < 0 ||
|
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
|
||||||
blue_x < 0 || blue_y < 0)
|
#endif
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
|
||||||
"Ignoring attempt to set negative chromaticity value");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (white_x > (double) PNG_UINT_31_MAX ||
|
|
||||||
white_y > (double) PNG_UINT_31_MAX ||
|
|
||||||
red_x > (double) PNG_UINT_31_MAX ||
|
|
||||||
red_y > (double) PNG_UINT_31_MAX ||
|
|
||||||
green_x > (double) PNG_UINT_31_MAX ||
|
|
||||||
green_y > (double) PNG_UINT_31_MAX ||
|
|
||||||
blue_x > (double) PNG_UINT_31_MAX ||
|
|
||||||
blue_y > (double) 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_x_white = white_x;
|
||||||
info_ptr->int_y_white = white_y;
|
info_ptr->int_y_white = white_y;
|
||||||
info_ptr->int_x_red = red_x;
|
info_ptr->int_x_red = red_x;
|
||||||
|
@ -133,16 +102,17 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
||||||
#endif
|
#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)
|
#if defined(PNG_gAMA_SUPPORTED)
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||||
{
|
{
|
||||||
double gamma;
|
double png_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -150,16 +120,16 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
|
||||||
if (file_gamma > 21474.83)
|
if (file_gamma > 21474.83)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Limiting gamma to 21474.83");
|
png_warning(png_ptr, "Limiting gamma to 21474.83");
|
||||||
gamma=21474.83;
|
png_gamma=21474.83;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gamma=file_gamma;
|
png_gamma = file_gamma;
|
||||||
info_ptr->gamma = (float)gamma;
|
info_ptr->gamma = (float)png_gamma;
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
info_ptr->int_gamma = (int)(gamma*100000.+.5);
|
info_ptr->int_gamma = (int)(png_gamma*100000.+.5);
|
||||||
#endif
|
#endif
|
||||||
info_ptr->valid |= PNG_INFO_gAMA;
|
info_ptr->valid |= PNG_INFO_gAMA;
|
||||||
if(gamma == 0.0)
|
if (png_gamma == 0.0)
|
||||||
png_warning(png_ptr, "Setting gamma=0");
|
png_warning(png_ptr, "Setting gamma=0");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -167,35 +137,35 @@ void PNGAPI
|
||||||
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
|
||||||
int_gamma)
|
int_gamma)
|
||||||
{
|
{
|
||||||
png_fixed_point gamma;
|
png_fixed_point png_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX)
|
if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Limiting gamma to 21474.83");
|
png_warning(png_ptr, "Limiting gamma to 21474.83");
|
||||||
gamma=PNG_UINT_31_MAX;
|
png_gamma=PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (int_gamma < 0)
|
if (int_gamma < 0)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Setting negative gamma to zero");
|
png_warning(png_ptr, "Setting negative gamma to zero");
|
||||||
gamma=0;
|
png_gamma = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gamma=int_gamma;
|
png_gamma = int_gamma;
|
||||||
}
|
}
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
info_ptr->gamma = (float)(gamma/100000.);
|
info_ptr->gamma = (float)(png_gamma/100000.);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
info_ptr->int_gamma = gamma;
|
info_ptr->int_gamma = png_gamma;
|
||||||
#endif
|
#endif
|
||||||
info_ptr->valid |= PNG_INFO_gAMA;
|
info_ptr->valid |= PNG_INFO_gAMA;
|
||||||
if(gamma == 0)
|
if (png_gamma == 0)
|
||||||
png_warning(png_ptr, "Setting gamma=0");
|
png_warning(png_ptr, "Setting gamma=0");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -206,22 +176,25 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
||||||
{
|
{
|
||||||
int i;
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
if (info_ptr->num_palette == 0)
|
if (info_ptr->num_palette == 0 || info_ptr->num_palette
|
||||||
|
> PNG_MAX_PALETTE_LENGTH)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Palette size 0, hIST allocation skipped.");
|
"Invalid palette size, hIST allocation skipped.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
|
||||||
#endif
|
#endif
|
||||||
/* Changed from info->num_palette to 256 in version 1.2.1 */
|
/* 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_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
|
||||||
(png_uint_32)(256 * png_sizeof (png_uint_16)));
|
(png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
|
||||||
if (png_ptr->hist == NULL)
|
if (png_ptr->hist == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
|
png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
|
||||||
|
@ -247,11 +220,11 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
int color_type, int interlace_type, int compression_type,
|
int color_type, int interlace_type, int compression_type,
|
||||||
int filter_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* check for width and height valid values */
|
/* Check for width and height valid values */
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
png_error(png_ptr, "Image width or height is zero in IHDR");
|
png_error(png_ptr, "Image width or height is zero in IHDR");
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
|
@ -271,7 +244,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
- 8) /* extra max_pixel_depth pad */
|
- 8) /* extra max_pixel_depth pad */
|
||||||
png_warning(png_ptr, "Width is too large for libpng to process pixels");
|
png_warning(png_ptr, "Width is too large for libpng to process pixels");
|
||||||
|
|
||||||
/* check other values */
|
/* Check other values */
|
||||||
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
|
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
|
||||||
bit_depth != 8 && bit_depth != 16)
|
bit_depth != 8 && bit_depth != 16)
|
||||||
png_error(png_ptr, "Invalid bit depth in IHDR");
|
png_error(png_ptr, "Invalid bit depth in IHDR");
|
||||||
|
@ -303,7 +276,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
* 5. The color_type is RGB or RGBA
|
* 5. The color_type is RGB or RGBA
|
||||||
*/
|
*/
|
||||||
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\n");
|
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
|
||||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
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) &&
|
||||||
|
@ -337,7 +310,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
||||||
info_ptr->channels++;
|
info_ptr->channels++;
|
||||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||||
|
|
||||||
/* check for potential overflow */
|
/* Check for potential overflow */
|
||||||
if (width > (PNG_UINT_32_MAX
|
if (width > (PNG_UINT_32_MAX
|
||||||
>> 3) /* 8-byte RGBA pixels */
|
>> 3) /* 8-byte RGBA pixels */
|
||||||
- 64 /* bigrowbuf hack */
|
- 64 /* bigrowbuf hack */
|
||||||
|
@ -354,7 +327,7 @@ void PNGAPI
|
||||||
png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
|
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_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -374,12 +347,13 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_uint_32 length;
|
png_uint_32 length;
|
||||||
int i;
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
length = png_strlen(purpose) + 1;
|
length = png_strlen(purpose) + 1;
|
||||||
png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
|
png_debug1(3, "allocating purpose for info (%lu bytes)",
|
||||||
|
(unsigned long)length);
|
||||||
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->pcal_purpose == NULL)
|
if (info_ptr->pcal_purpose == NULL)
|
||||||
{
|
{
|
||||||
|
@ -388,14 +362,15 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||||
}
|
}
|
||||||
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
|
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_X0 = X0;
|
||||||
info_ptr->pcal_X1 = X1;
|
info_ptr->pcal_X1 = X1;
|
||||||
info_ptr->pcal_type = (png_byte)type;
|
info_ptr->pcal_type = (png_byte)type;
|
||||||
info_ptr->pcal_nparams = (png_byte)nparams;
|
info_ptr->pcal_nparams = (png_byte)nparams;
|
||||||
|
|
||||||
length = png_strlen(units) + 1;
|
length = png_strlen(units) + 1;
|
||||||
png_debug1(3, "allocating units for info (%lu bytes)\n", length);
|
png_debug1(3, "allocating units for info (%lu bytes)",
|
||||||
|
(unsigned long)length);
|
||||||
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->pcal_units == NULL)
|
if (info_ptr->pcal_units == NULL)
|
||||||
{
|
{
|
||||||
|
@ -412,12 +387,13 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr->pcal_params[nparams] = NULL;
|
png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++)
|
for (i = 0; i < nparams; i++)
|
||||||
{
|
{
|
||||||
length = png_strlen(params[i]) + 1;
|
length = png_strlen(params[i]) + 1;
|
||||||
png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
|
png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
|
||||||
|
(unsigned long)length);
|
||||||
info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->pcal_params[i] == NULL)
|
if (info_ptr->pcal_params[i] == NULL)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +416,7 @@ void PNGAPI
|
||||||
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
|
png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
|
||||||
int unit, double width, double height)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -458,31 +434,37 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
||||||
{
|
{
|
||||||
png_uint_32 length;
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
info_ptr->scal_unit = (png_byte)unit;
|
info_ptr->scal_unit = (png_byte)unit;
|
||||||
|
|
||||||
length = png_strlen(swidth) + 1;
|
length = png_strlen(swidth) + 1;
|
||||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
png_debug1(3, "allocating unit for info (%u bytes)",
|
||||||
|
(unsigned int)length);
|
||||||
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->scal_s_width == NULL)
|
if (info_ptr->scal_s_width == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
|
png_warning(png_ptr,
|
||||||
|
"Memory allocation failed while processing sCAL.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
||||||
|
|
||||||
length = png_strlen(sheight) + 1;
|
length = png_strlen(sheight) + 1;
|
||||||
png_debug1(3, "allocating unit for info (%d bytes)\n", length);
|
png_debug1(3, "allocating unit for info (%u bytes)",
|
||||||
|
(unsigned int)length);
|
||||||
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->scal_s_height == NULL)
|
if (info_ptr->scal_s_height == NULL)
|
||||||
{
|
{
|
||||||
png_free (png_ptr, info_ptr->scal_s_width);
|
png_free (png_ptr, info_ptr->scal_s_width);
|
||||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
|
info_ptr->scal_s_width = NULL;
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Memory allocation failed while processing sCAL.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
||||||
|
|
||||||
info_ptr->valid |= PNG_INFO_sCAL;
|
info_ptr->valid |= PNG_INFO_sCAL;
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||||
|
@ -497,7 +479,7 @@ void PNGAPI
|
||||||
png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
|
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_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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -513,10 +495,21 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_colorp palette, int num_palette)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
||||||
|
{
|
||||||
|
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
|
png_error(png_ptr, "Invalid palette length");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Invalid palette length");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It may not actually be necessary to set png_ptr->palette here;
|
* It may not actually be necessary to set png_ptr->palette here;
|
||||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
|
@ -526,11 +519,14 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries,
|
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
|
||||||
in case of an invalid PNG file that has too-large sample values. */
|
* of num_palette entries, in case of an invalid PNG file that has
|
||||||
|
* too-large sample values.
|
||||||
|
*/
|
||||||
png_ptr->palette = (png_colorp)png_malloc(png_ptr,
|
png_ptr->palette = (png_colorp)png_malloc(png_ptr,
|
||||||
256 * png_sizeof(png_color));
|
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
|
||||||
png_memset(png_ptr->palette, 0, 256 * 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->palette = png_ptr->palette;
|
||||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||||
|
@ -549,7 +545,7 @@ void PNGAPI
|
||||||
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_color_8p sig_bit)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -562,7 +558,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -586,12 +582,10 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
||||||
png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
|
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;
|
int_green_y, int_blue_x, int_blue_y;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
|
||||||
png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
|
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -609,7 +603,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_cHRM_SUPPORTED)
|
#if defined(PNG_cHRM_SUPPORTED)
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
|
||||||
int_white_x = 31270L;
|
int_white_x = 31270L;
|
||||||
int_white_y = 32900L;
|
int_white_y = 32900L;
|
||||||
int_red_x = 64000L;
|
int_red_x = 64000L;
|
||||||
|
@ -619,10 +612,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
int_blue_x = 15000L;
|
int_blue_x = 15000L;
|
||||||
int_blue_y = 6000L;
|
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
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
white_x = (float).3127;
|
white_x = (float).3127;
|
||||||
white_y = (float).3290;
|
white_y = (float).3290;
|
||||||
|
@ -632,13 +621,27 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
|
||||||
green_y = (float).60;
|
green_y = (float).60;
|
||||||
blue_x = (float).15;
|
blue_x = (float).15;
|
||||||
blue_y = (float).06;
|
blue_y = (float).06;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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,
|
png_set_cHRM(png_ptr, info_ptr,
|
||||||
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
|
white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* cHRM */
|
||||||
|
}
|
||||||
|
#endif /* sRGB */
|
||||||
|
|
||||||
|
|
||||||
#if defined(PNG_iCCP_SUPPORTED)
|
#if defined(PNG_iCCP_SUPPORTED)
|
||||||
|
@ -649,23 +652,26 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
||||||
{
|
{
|
||||||
png_charp new_iccp_name;
|
png_charp new_iccp_name;
|
||||||
png_charp new_iccp_profile;
|
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)
|
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1);
|
length = png_strlen(name)+1;
|
||||||
|
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (new_iccp_name == NULL)
|
if (new_iccp_name == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
|
png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_strcpy(new_iccp_name, name);
|
png_memcpy(new_iccp_name, name, length);
|
||||||
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
|
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
|
||||||
if (new_iccp_profile == NULL)
|
if (new_iccp_profile == NULL)
|
||||||
{
|
{
|
||||||
png_free (png_ptr, new_iccp_name);
|
png_free (png_ptr, new_iccp_name);
|
||||||
png_warning(png_ptr, "Insufficient memory to process iCCP profile.");
|
png_warning(png_ptr,
|
||||||
|
"Insufficient memory to process iCCP profile.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
|
||||||
|
@ -702,7 +708,8 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
{
|
{
|
||||||
int i;
|
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 == NULL ||
|
||||||
|
png_ptr->chunk_name[0] == '\0') ?
|
||||||
"text" : (png_const_charp)png_ptr->chunk_name));
|
"text" : (png_const_charp)png_ptr->chunk_name));
|
||||||
|
|
||||||
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||||
|
@ -744,7 +751,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||||
#endif
|
#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);
|
info_ptr->max_text);
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_text; i++)
|
for (i = 0; i < num_text; i++)
|
||||||
|
@ -766,7 +773,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
else
|
else
|
||||||
#ifdef PNG_iTXt_SUPPORTED
|
#ifdef PNG_iTXt_SUPPORTED
|
||||||
{
|
{
|
||||||
/* set iTXt data */
|
/* Set iTXt data */
|
||||||
if (text_ptr[i].lang != NULL)
|
if (text_ptr[i].lang != NULL)
|
||||||
lang_len = png_strlen(text_ptr[i].lang);
|
lang_len = png_strlen(text_ptr[i].lang);
|
||||||
else
|
else
|
||||||
|
@ -800,15 +807,16 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
textp->key = (png_charp)png_malloc_warn(png_ptr,
|
textp->key = (png_charp)png_malloc_warn(png_ptr,
|
||||||
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
|
(png_uint_32)
|
||||||
|
(key_len + text_length + lang_len + lang_key_len + 4));
|
||||||
if (textp->key == NULL)
|
if (textp->key == NULL)
|
||||||
return(1);
|
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),
|
(png_uint_32)
|
||||||
|
(key_len + lang_len + lang_key_len + text_length + 4),
|
||||||
(int)textp->key);
|
(int)textp->key);
|
||||||
|
|
||||||
png_memcpy(textp->key, text_ptr[i].key,
|
png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
|
||||||
(png_size_t)(key_len));
|
|
||||||
*(textp->key + key_len) = '\0';
|
*(textp->key + key_len) = '\0';
|
||||||
#ifdef PNG_iTXt_SUPPORTED
|
#ifdef PNG_iTXt_SUPPORTED
|
||||||
if (text_ptr[i].compression > 0)
|
if (text_ptr[i].compression > 0)
|
||||||
|
@ -849,9 +857,8 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
textp->itxt_length = 0;
|
textp->itxt_length = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
info_ptr->text[info_ptr->num_text]= *textp;
|
|
||||||
info_ptr->num_text++;
|
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);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -861,7 +868,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
|
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 ||
|
if (png_ptr == NULL || info_ptr == NULL ||
|
||||||
(png_ptr->mode & PNG_WROTE_tIME))
|
(png_ptr->mode & PNG_WROTE_tIME))
|
||||||
return;
|
return;
|
||||||
|
@ -876,7 +883,7 @@ void PNGAPI
|
||||||
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_bytep trans, int num_trans, png_color_16p trans_values)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -887,29 +894,45 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
* function used to do the allocation.
|
* function used to do the allocation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||||
#endif
|
#endif
|
||||||
/* Changed from num_trans to 256 in version 1.2.1 */
|
|
||||||
|
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
||||||
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
|
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)256);
|
(png_uint_32)PNG_MAX_PALETTE_LENGTH);
|
||||||
|
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||||
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
|
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trans_values != NULL)
|
||||||
|
{
|
||||||
|
int sample_max = (1 << info_ptr->bit_depth);
|
||||||
|
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||||
|
(int)trans_values->gray > sample_max) ||
|
||||||
|
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||||
|
((int)trans_values->red > sample_max ||
|
||||||
|
(int)trans_values->green > sample_max ||
|
||||||
|
(int)trans_values->blue > sample_max)))
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"tRNS chunk has out-of-range samples for bit_depth");
|
||||||
|
png_memcpy(&(info_ptr->trans_values), trans_values,
|
||||||
|
png_sizeof(png_color_16));
|
||||||
|
if (num_trans == 0)
|
||||||
|
num_trans = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
info_ptr->num_trans = (png_uint_16)num_trans;
|
||||||
|
if (num_trans != 0)
|
||||||
|
{
|
||||||
|
info_ptr->valid |= PNG_INFO_tRNS;
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||||
#else
|
#else
|
||||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans_values != NULL)
|
|
||||||
{
|
|
||||||
png_memcpy(&(info_ptr->trans_values), trans_values,
|
|
||||||
png_sizeof(png_color_16));
|
|
||||||
if (num_trans == 0)
|
|
||||||
num_trans = 1;
|
|
||||||
}
|
|
||||||
info_ptr->num_trans = (png_uint_16)num_trans;
|
|
||||||
info_ptr->valid |= PNG_INFO_tRNS;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -917,12 +940,23 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_sPLT(png_structp png_ptr,
|
png_set_sPLT(png_structp png_ptr,
|
||||||
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
png_infop info_ptr, png_sPLT_tp entries, int nentries)
|
||||||
|
/*
|
||||||
|
* entries - array of png_sPLT_t structures
|
||||||
|
* to be added to the list of palettes
|
||||||
|
* in the info structure.
|
||||||
|
* nentries - number of palette structures to be
|
||||||
|
* added.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
png_sPLT_tp np;
|
png_sPLT_tp np;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
np = (png_sPLT_tp)png_malloc_warn(png_ptr,
|
np = (png_sPLT_tp)png_malloc_warn(png_ptr,
|
||||||
(info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
|
(info_ptr->splt_palettes_num + nentries) *
|
||||||
|
(png_uint_32)png_sizeof(png_sPLT_t));
|
||||||
if (np == NULL)
|
if (np == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "No memory for sPLT palettes.");
|
png_warning(png_ptr, "No memory for sPLT palettes.");
|
||||||
|
@ -938,16 +972,29 @@ png_set_sPLT(png_structp png_ptr,
|
||||||
{
|
{
|
||||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||||
png_sPLT_tp from = entries + i;
|
png_sPLT_tp from = entries + i;
|
||||||
|
png_uint_32 length;
|
||||||
|
|
||||||
to->name = (png_charp)png_malloc(png_ptr,
|
length = png_strlen(from->name) + 1;
|
||||||
png_strlen(from->name) + 1);
|
to->name = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
/* TODO: use png_malloc_warn */
|
if (to->name == NULL)
|
||||||
png_strcpy(to->name, from->name);
|
{
|
||||||
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
|
png_warning(png_ptr,
|
||||||
from->nentries * png_sizeof(png_sPLT_t));
|
"Out of memory while processing sPLT chunk");
|
||||||
/* TODO: use png_malloc_warn */
|
continue;
|
||||||
|
}
|
||||||
|
png_memcpy(to->name, from->name, length);
|
||||||
|
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||||
|
(png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry)));
|
||||||
|
if (to->entries == NULL)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing sPLT chunk");
|
||||||
|
png_free(png_ptr, to->name);
|
||||||
|
to->name = NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
png_memcpy(to->entries, from->entries,
|
png_memcpy(to->entries, from->entries,
|
||||||
from->nentries * png_sizeof(png_sPLT_t));
|
from->nentries * png_sizeof(png_sPLT_entry));
|
||||||
to->nentries = from->nentries;
|
to->nentries = from->nentries;
|
||||||
to->depth = from->depth;
|
to->depth = from->depth;
|
||||||
}
|
}
|
||||||
|
@ -973,11 +1020,12 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
|
||||||
(info_ptr->unknown_chunks_num + num_unknowns) *
|
(png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) *
|
||||||
png_sizeof(png_unknown_chunk));
|
png_sizeof(png_unknown_chunk)));
|
||||||
if (np == NULL)
|
if (np == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Out of memory while processing unknown chunk.");
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing unknown chunk.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,19 +1039,28 @@ png_set_unknown_chunks(png_structp png_ptr,
|
||||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||||
png_unknown_chunkp from = unknowns + i;
|
png_unknown_chunkp from = unknowns + i;
|
||||||
|
|
||||||
png_strncpy((png_charp)to->name, (png_charp)from->name, 5);
|
png_memcpy((png_charp)to->name,
|
||||||
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
|
(png_charp)from->name,
|
||||||
if (to->data == NULL)
|
png_sizeof(from->name));
|
||||||
{
|
to->name[png_sizeof(to->name)-1] = '\0';
|
||||||
png_warning(png_ptr, "Out of memory processing unknown chunk.");
|
to->size = from->size;
|
||||||
}
|
/* Note our location in the read or write sequence */
|
||||||
|
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||||
|
|
||||||
|
if (from->size == 0)
|
||||||
|
to->data=NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
to->data = (png_bytep)png_malloc_warn(png_ptr,
|
||||||
|
(png_uint_32)from->size);
|
||||||
|
if (to->data == NULL)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing unknown chunk.");
|
||||||
|
to->size = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
png_memcpy(to->data, from->data, from->size);
|
png_memcpy(to->data, from->data, from->size);
|
||||||
to->size = from->size;
|
|
||||||
|
|
||||||
/* note our location in the read or write sequence */
|
|
||||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,27 +1080,29 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
||||||
{
|
{
|
||||||
/* This function is deprecated in favor of png_permit_mng_features()
|
/* This function is deprecated in favor of png_permit_mng_features()
|
||||||
and will be removed from libpng-2.0.0 */
|
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)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
png_ptr->mng_features_permitted = (png_byte)
|
png_ptr->mng_features_permitted = (png_byte)
|
||||||
((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
|
((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) |
|
||||||
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
|
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
|
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)
|
if (png_ptr == NULL)
|
||||||
return (png_uint_32)0;
|
return (png_uint_32)0;
|
||||||
png_ptr->mng_features_permitted =
|
png_ptr->mng_features_permitted =
|
||||||
|
@ -1059,6 +1118,8 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||||
{
|
{
|
||||||
png_bytep new_list, p;
|
png_bytep new_list, p;
|
||||||
int i, old_num_chunks;
|
int i, old_num_chunks;
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (num_chunks == 0)
|
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)
|
||||||
|
@ -1076,7 +1137,8 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
|
||||||
return;
|
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,
|
new_list=(png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(5*(num_chunks+old_num_chunks)));
|
(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_memcpy(new_list, png_ptr->chunk_list,
|
||||||
|
@ -1101,7 +1163,9 @@ void PNGAPI
|
||||||
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||||
png_user_chunk_ptr read_user_chunk_fn)
|
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;
|
png_ptr->read_user_chunk_fn = read_user_chunk_fn;
|
||||||
png_ptr->user_chunk_ptr = user_chunk_ptr;
|
png_ptr->user_chunk_ptr = user_chunk_ptr;
|
||||||
}
|
}
|
||||||
|
@ -1111,7 +1175,7 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
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)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -1126,9 +1190,11 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
png_set_compression_buffer_size(png_structp png_ptr,
|
||||||
|
png_uint_32 size)
|
||||||
{
|
{
|
||||||
if(png_ptr->zbuf)
|
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_size = (png_size_t)size;
|
||||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
||||||
|
@ -1141,68 +1207,39 @@ void PNGAPI
|
||||||
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
||||||
{
|
{
|
||||||
if (png_ptr && info_ptr)
|
if (png_ptr && info_ptr)
|
||||||
info_ptr->valid &= ~(mask);
|
info_ptr->valid &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef PNG_1_0_X
|
#ifndef PNG_1_0_X
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
/* this function was added to libpng 1.2.0 and should always exist by default */
|
/* Function was added to libpng 1.2.0 and should always exist by default */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_asm_flags;
|
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||||
png_uint_32 settable_mmx_flags;
|
if (png_ptr != NULL)
|
||||||
|
png_ptr->asm_flags = 0;
|
||||||
settable_mmx_flags =
|
asm_flags = asm_flags; /* Quiet the compiler */
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
#endif
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
#endif
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
|
|
||||||
#endif
|
|
||||||
0;
|
|
||||||
|
|
||||||
/* could be some non-MMX ones in the future, but not currently: */
|
|
||||||
settable_asm_flags = settable_mmx_flags;
|
|
||||||
|
|
||||||
if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
|
|
||||||
!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
|
|
||||||
{
|
|
||||||
/* clear all MMX flags if MMX isn't supported */
|
|
||||||
settable_asm_flags &= ~settable_mmx_flags;
|
|
||||||
png_ptr->asm_flags &= ~settable_mmx_flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we're replacing the settable bits with those passed in by the user,
|
/* This function was added to libpng 1.2.0 */
|
||||||
* so first zero them out of the master copy, then logical-OR in the
|
|
||||||
* allowed subset that was requested */
|
|
||||||
|
|
||||||
png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */
|
|
||||||
png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */
|
|
||||||
}
|
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_mmx_thresholds (png_structp png_ptr,
|
png_set_mmx_thresholds (png_structp png_ptr,
|
||||||
png_byte mmx_bitdepth_threshold,
|
png_byte mmx_bitdepth_threshold,
|
||||||
png_uint_32 mmx_rowbytes_threshold)
|
png_uint_32 mmx_rowbytes_threshold)
|
||||||
{
|
{
|
||||||
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
|
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||||
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
/* Quiet the compiler */
|
||||||
|
mmx_bitdepth_threshold = mmx_bitdepth_threshold;
|
||||||
|
mmx_rowbytes_threshold = mmx_rowbytes_threshold;
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
/* this function was added to libpng 1.2.6 */
|
/* This function was added to libpng 1.2.6 */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
||||||
png_uint_32 user_height_max)
|
png_uint_32 user_height_max)
|
||||||
|
@ -1211,9 +1248,12 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
||||||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||||
* regardless of dimensions, set both limits to 0x7ffffffL.
|
* regardless of dimensions, set both limits to 0x7ffffffL.
|
||||||
*/
|
*/
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->user_width_max = user_width_max;
|
png_ptr->user_width_max = user_width_max;
|
||||||
png_ptr->user_height_max = user_height_max;
|
png_ptr->user_height_max = user_height_max;
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||||
|
|
||||||
#endif /* ?PNG_1_0_X */
|
#endif /* ?PNG_1_0_X */
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngtest.c - a simple test program to test libpng
|
/* pngtest.c - a simple test program to test libpng
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This program reads in a PNG image, writes it out again, and then
|
* This program reads in a PNG image, writes it out again, and then
|
||||||
* compares the two files. If the files are identical, this shows that
|
* compares the two files. If the files are identical, this shows that
|
||||||
* the basic chunk handling, filtering, and (de)compression code is working
|
* the basic chunk handling, filtering, and (de)compression code is working
|
||||||
|
@ -44,7 +47,6 @@
|
||||||
#else
|
#else
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <assert.h>
|
|
||||||
# define READFILE(file, data, length, check) \
|
# define READFILE(file, data, length, check) \
|
||||||
check=(png_size_t)fread(data, (png_size_t)1, length, file)
|
check=(png_size_t)fread(data, (png_size_t)1, length, file)
|
||||||
# define WRITEFILE(file, data, length, check) \
|
# define WRITEFILE(file, data, length, check) \
|
||||||
|
@ -66,7 +68,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !PNG_DEBUG
|
#if !PNG_DEBUG
|
||||||
# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */
|
# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Turn on CPU timing
|
/* Turn on CPU timing
|
||||||
|
@ -82,21 +84,10 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
|
||||||
#ifndef png_jmpbuf
|
|
||||||
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNGTEST_TIMING
|
|
||||||
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
|
||||||
#if !defined(PNG_tIME_SUPPORTED)
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
#define PNG_tIME_STRING_LENGTH 29
|
||||||
static int tIME_chunk_present = 0;
|
static int tIME_chunk_present = 0;
|
||||||
static char tIME_string[30] = "no tIME chunk present in file";
|
static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
@ -107,11 +98,21 @@ int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
|
||||||
#include <mem.h>
|
#include <mem.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* defined so I can write to a file on gui/windowing platforms */
|
/* Defined so I can write to a file on gui/windowing platforms */
|
||||||
/* #define STDERR stderr */
|
/* #define STDERR stderr */
|
||||||
#define STDERR stdout /* for DOS */
|
#define STDERR stdout /* For DOS */
|
||||||
|
|
||||||
/* example of using row callbacks to make a simple progress meter */
|
/* In case a system header (e.g., on AIX) defined jmpbuf */
|
||||||
|
#ifdef jmpbuf
|
||||||
|
# undef jmpbuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Example of using row callbacks to make a simple progress meter */
|
||||||
static int status_pass = 1;
|
static int status_pass = 1;
|
||||||
static int status_dots_requested = 0;
|
static int status_dots_requested = 0;
|
||||||
static int status_dots = 1;
|
static int status_dots = 1;
|
||||||
|
@ -127,7 +128,8 @@ PNGAPI
|
||||||
#endif
|
#endif
|
||||||
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||||
{
|
{
|
||||||
if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return;
|
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
|
||||||
|
return;
|
||||||
if (status_pass != pass)
|
if (status_pass != pass)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n Pass %d: ", pass);
|
fprintf(stdout, "\n Pass %d: ", pass);
|
||||||
|
@ -154,15 +156,17 @@ PNGAPI
|
||||||
#endif
|
#endif
|
||||||
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
|
||||||
{
|
{
|
||||||
if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return;
|
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
|
||||||
|
return;
|
||||||
fprintf(stdout, "w");
|
fprintf(stdout, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||||
/* Example of using user transform callback (we don't transform anything,
|
/* Example of using user transform callback (we don't transform anything,
|
||||||
but merely examine the row filters. We set this to 256 rather than
|
* but merely examine the row filters. We set this to 256 rather than
|
||||||
5 in case illegal filter values are present.) */
|
* 5 in case illegal filter values are present.)
|
||||||
|
*/
|
||||||
static png_uint_32 filters_used[256];
|
static png_uint_32 filters_used[256];
|
||||||
void
|
void
|
||||||
#ifdef PNG_1_0_X
|
#ifdef PNG_1_0_X
|
||||||
|
@ -181,8 +185,9 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
/* example of using user transform callback (we don't transform anything,
|
/* Example of using user transform callback (we don't transform anything,
|
||||||
but merely count the zero samples) */
|
* but merely count the zero samples)
|
||||||
|
*/
|
||||||
|
|
||||||
static png_uint_32 zero_samples;
|
static png_uint_32 zero_samples;
|
||||||
|
|
||||||
|
@ -200,7 +205,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
png_bytep dp = data;
|
png_bytep dp = data;
|
||||||
if (png_ptr == NULL)return;
|
if (png_ptr == NULL)return;
|
||||||
|
|
||||||
/* contents of row_info:
|
/* Contents of row_info:
|
||||||
* png_uint_32 width width of row
|
* png_uint_32 width width of row
|
||||||
* png_uint_32 rowbytes number of bytes in row
|
* png_uint_32 rowbytes number of bytes in row
|
||||||
* png_byte color_type color type of pixels
|
* png_byte color_type color type of pixels
|
||||||
|
@ -209,8 +214,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
* png_byte pixel_depth bits per pixel (depth*channels)
|
* png_byte pixel_depth bits per pixel (depth*channels)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Counts the number of zero samples (or zero pixels if color_type is 3 */
|
||||||
/* counts the number of zero samples (or zero pixels if color_type is 3 */
|
|
||||||
|
|
||||||
if (row_info->color_type == 0 || row_info->color_type == 3)
|
if (row_info->color_type == 0 || row_info->color_type == 3)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +224,8 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 1)
|
if (row_info->bit_depth == 1)
|
||||||
{
|
{
|
||||||
if(((*dp << pos++ ) & 0x80) == 0) zero_samples++;
|
if (((*dp << pos++ ) & 0x80) == 0)
|
||||||
|
zero_samples++;
|
||||||
if (pos == 8)
|
if (pos == 8)
|
||||||
{
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -229,7 +234,8 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
}
|
}
|
||||||
if (row_info->bit_depth == 2)
|
if (row_info->bit_depth == 2)
|
||||||
{
|
{
|
||||||
if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++;
|
if (((*dp << (pos+=2)) & 0xc0) == 0)
|
||||||
|
zero_samples++;
|
||||||
if (pos == 8)
|
if (pos == 8)
|
||||||
{
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -238,7 +244,8 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
}
|
}
|
||||||
if (row_info->bit_depth == 4)
|
if (row_info->bit_depth == 4)
|
||||||
{
|
{
|
||||||
if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++;
|
if (((*dp << (pos+=4)) & 0xf0) == 0)
|
||||||
|
zero_samples++;
|
||||||
if (pos == 8)
|
if (pos == 8)
|
||||||
{
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -246,15 +253,17 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
if(*dp++ == 0) zero_samples++;
|
if (*dp++ == 0)
|
||||||
|
zero_samples++;
|
||||||
if (row_info->bit_depth == 16)
|
if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
if((*dp | *(dp+1)) == 0) zero_samples++;
|
if ((*dp | *(dp+1)) == 0)
|
||||||
|
zero_samples++;
|
||||||
dp+=2;
|
dp+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* other color types */
|
else /* Other color types */
|
||||||
{
|
{
|
||||||
png_uint_32 n, nstop;
|
png_uint_32 n, nstop;
|
||||||
int channel;
|
int channel;
|
||||||
|
@ -266,17 +275,20 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
|
||||||
for (channel = 0; channel < color_channels; channel++)
|
for (channel = 0; channel < color_channels; channel++)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
if(*dp++ == 0) zero_samples++;
|
if (*dp++ == 0)
|
||||||
|
zero_samples++;
|
||||||
if (row_info->bit_depth == 16)
|
if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
if((*dp | *(dp+1)) == 0) zero_samples++;
|
if ((*dp | *(dp+1)) == 0)
|
||||||
|
zero_samples++;
|
||||||
dp+=2;
|
dp+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (row_info->color_type > 3)
|
if (row_info->color_type > 3)
|
||||||
{
|
{
|
||||||
dp++;
|
dp++;
|
||||||
if(row_info->bit_depth == 16)dp++;
|
if (row_info->bit_depth == 16)
|
||||||
|
dp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,12 +299,13 @@ static int wrote_question = 0;
|
||||||
|
|
||||||
#if defined(PNG_NO_STDIO)
|
#if defined(PNG_NO_STDIO)
|
||||||
/* START of code to validate stdio-free compilation */
|
/* START of code to validate stdio-free compilation */
|
||||||
/* These copies of the default read/write functions come from pngrio.c and */
|
/* These copies of the default read/write functions come from pngrio.c and
|
||||||
/* pngwio.c. They allow "don't include stdio" testing of the library. */
|
* pngwio.c. They allow "don't include stdio" testing of the library.
|
||||||
/* This is the function that does the actual reading of data. If you are
|
* This is the function that does the actual reading of data. If you are
|
||||||
not reading from a standard C stream, you should create a replacement
|
* not reading from a standard C stream, you should create a replacement
|
||||||
read_data function and use it at run time with png_set_read_fn(), rather
|
* read_data function and use it at run time with png_set_read_fn(), rather
|
||||||
than changing the library. */
|
* than changing the library.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef USE_FAR_KEYWORD
|
#ifndef USE_FAR_KEYWORD
|
||||||
static void
|
static void
|
||||||
|
@ -311,7 +324,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* this is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
the data.
|
the data.
|
||||||
*/
|
*/
|
||||||
|
@ -343,7 +356,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
read = MIN(NEAR_BUF_SIZE, remaining);
|
read = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
READFILE(io_ptr, buf, 1, err);
|
READFILE(io_ptr, buf, 1, err);
|
||||||
png_memcpy(data, buf, read); /* copy far buffer to near buffer */
|
png_memcpy(data, buf, read); /* Copy far buffer to near buffer */
|
||||||
if (err != read)
|
if (err != read)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
|
@ -354,29 +367,24 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
while (remaining != 0);
|
while (remaining != 0);
|
||||||
}
|
}
|
||||||
if (check != length)
|
if (check != length)
|
||||||
{
|
|
||||||
png_error(png_ptr, "read Error");
|
png_error(png_ptr, "read Error");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
static void
|
static void
|
||||||
pngtest_flush(png_structp png_ptr)
|
pngtest_flush(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#if !defined(_WIN32_WCE)
|
/* Do nothing; fflush() is said to be just a waste of energy. */
|
||||||
png_FILE_p io_ptr;
|
png_ptr = png_ptr; /* Stifle compiler warning */
|
||||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
|
||||||
if (io_ptr != NULL)
|
|
||||||
fflush(io_ptr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This is the function that does the actual writing of data. If you are
|
/* This is the function that does the actual writing of data. If you are
|
||||||
not writing to a standard C stream, you should create a replacement
|
* not writing to a standard C stream, you should create a replacement
|
||||||
write_data function and use it at run time with png_set_write_fn(), rather
|
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
than changing the library. */
|
* than changing the library.
|
||||||
|
*/
|
||||||
#ifndef USE_FAR_KEYWORD
|
#ifndef USE_FAR_KEYWORD
|
||||||
static void
|
static void
|
||||||
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
@ -390,7 +398,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* this is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
can't handle far buffers in the medium and small models, we have to copy
|
||||||
the data.
|
the data.
|
||||||
*/
|
*/
|
||||||
|
@ -421,7 +429,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
png_memcpy(buf, data, written); /* copy far buffer to near buffer */
|
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||||
WRITEFILE(io_ptr, buf, written, err);
|
WRITEFILE(io_ptr, buf, written, err);
|
||||||
if (err != written)
|
if (err != written)
|
||||||
break;
|
break;
|
||||||
|
@ -437,7 +445,6 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
/* This function is called when there is a warning, but the library thinks
|
/* This function is called when there is a warning, but the library thinks
|
||||||
|
@ -464,7 +471,8 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||||
{
|
{
|
||||||
pngtest_warning(png_ptr, message);
|
pngtest_warning(png_ptr, message);
|
||||||
/* We can return because png_error calls the default handler, which is
|
/* We can return because png_error calls the default handler, which is
|
||||||
* actually OK in this case. */
|
* actually OK in this case.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#endif /* PNG_NO_STDIO */
|
#endif /* PNG_NO_STDIO */
|
||||||
/* END of code to validate stdio-free compilation */
|
/* END of code to validate stdio-free compilation */
|
||||||
|
@ -473,13 +481,14 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
|
||||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
|
|
||||||
/* Allocate memory. For reasonable files, size should never exceed
|
/* Allocate memory. For reasonable files, size should never exceed
|
||||||
64K. However, zlib may allocate more then 64K if you don't tell
|
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||||
it not to. See zconf.h and png.h for more information. zlib does
|
* it not to. See zconf.h and png.h for more information. zlib does
|
||||||
need to allocate exactly 64K, so whatever you call here must
|
* need to allocate exactly 64K, so whatever you call here must
|
||||||
have the ability to do that.
|
* have the ability to do that.
|
||||||
|
*
|
||||||
This piece of code can be compiled to validate max 64K allocations
|
* This piece of code can be compiled to validate max 64K allocations
|
||||||
by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
|
* by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K.
|
||||||
|
*/
|
||||||
typedef struct memory_information
|
typedef struct memory_information
|
||||||
{
|
{
|
||||||
png_uint_32 size;
|
png_uint_32 size;
|
||||||
|
@ -502,7 +511,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* png_malloc has already tested for NULL; png_create_struct calls
|
/* png_malloc has already tested for NULL; png_create_struct calls
|
||||||
png_debug_malloc directly, with png_ptr == NULL which is OK */
|
* png_debug_malloc directly, with png_ptr == NULL which is OK
|
||||||
|
*/
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -523,7 +533,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
maximum_allocation = current_allocation;
|
maximum_allocation = current_allocation;
|
||||||
pinfo->pointer = (png_voidp)png_malloc(png_ptr, size);
|
pinfo->pointer = (png_voidp)png_malloc(png_ptr, size);
|
||||||
/* Restore malloc_fn and free_fn */
|
/* Restore malloc_fn and free_fn */
|
||||||
png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
|
png_set_mem_fn(png_ptr,
|
||||||
|
png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
|
||||||
(png_free_ptr)png_debug_free);
|
(png_free_ptr)png_debug_free);
|
||||||
if (size != 0 && pinfo->pointer == NULL)
|
if (size != 0 && pinfo->pointer == NULL)
|
||||||
{
|
{
|
||||||
|
@ -537,8 +548,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
||||||
/* Make sure the caller isn't assuming zeroed memory. */
|
/* Make sure the caller isn't assuming zeroed memory. */
|
||||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer);
|
printf("png_malloc %lu bytes at %x\n", (unsigned long)size,
|
||||||
assert(pinfo->size != 12345678);
|
pinfo->pointer);
|
||||||
return (png_voidp)(pinfo->pointer);
|
return (png_voidp)(pinfo->pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,6 +605,74 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
|
#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
|
||||||
/* END of code to test memory allocation/deallocation */
|
/* END of code to test memory allocation/deallocation */
|
||||||
|
|
||||||
|
|
||||||
|
/* Demonstration of user chunk support of the sTER and vpAg chunks */
|
||||||
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
|
||||||
|
/* (sTER is a public chunk not yet known by libpng. vpAg is a private
|
||||||
|
chunk used in ImageMagick to store "virtual page" size). */
|
||||||
|
|
||||||
|
static png_uint_32 user_chunk_data[4];
|
||||||
|
|
||||||
|
/* 0: sTER mode + 1
|
||||||
|
* 1: vpAg width
|
||||||
|
* 2: vpAg height
|
||||||
|
* 3: vpAg units
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int read_user_chunk_callback(png_struct *png_ptr,
|
||||||
|
png_unknown_chunkp chunk)
|
||||||
|
{
|
||||||
|
png_uint_32
|
||||||
|
*my_user_chunk_data;
|
||||||
|
|
||||||
|
/* Return one of the following:
|
||||||
|
* return (-n); chunk had an error
|
||||||
|
* return (0); did not recognize
|
||||||
|
* return (n); success
|
||||||
|
*
|
||||||
|
* The unknown chunk structure contains the chunk data:
|
||||||
|
* png_byte name[5];
|
||||||
|
* png_byte *data;
|
||||||
|
* png_size_t size;
|
||||||
|
*
|
||||||
|
* Note that libpng has already taken care of the CRC handling.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */
|
||||||
|
chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */
|
||||||
|
{
|
||||||
|
/* Found sTER chunk */
|
||||||
|
if (chunk->size != 1)
|
||||||
|
return (-1); /* Error return */
|
||||||
|
if (chunk->data[0] != 0 && chunk->data[0] != 1)
|
||||||
|
return (-1); /* Invalid mode */
|
||||||
|
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||||
|
my_user_chunk_data[0]=chunk->data[0]+1;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */
|
||||||
|
chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */
|
||||||
|
return (0); /* Did not recognize */
|
||||||
|
|
||||||
|
/* Found ImageMagick vpAg chunk */
|
||||||
|
|
||||||
|
if (chunk->size != 9)
|
||||||
|
return (-1); /* Error return */
|
||||||
|
|
||||||
|
my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
|
||||||
|
|
||||||
|
my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
|
||||||
|
my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
|
||||||
|
my_user_chunk_data[3]=(png_uint_32)chunk->data[8];
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* END of code to demonstrate user chunk support */
|
||||||
|
|
||||||
/* Test one file */
|
/* Test one file */
|
||||||
int
|
int
|
||||||
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
|
@ -652,26 +731,40 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_debug(0, "Allocating read and write structures\n");
|
png_debug(0, "Allocating read and write structures");
|
||||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
read_ptr =
|
||||||
|
png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
|
png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
|
||||||
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||||
#else
|
#else
|
||||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
read_ptr =
|
||||||
|
png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL);
|
png_error_ptr_NULL, png_error_ptr_NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_NO_STDIO)
|
#if defined(PNG_NO_STDIO)
|
||||||
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
||||||
pngtest_warning);
|
pngtest_warning);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
user_chunk_data[0] = 0;
|
||||||
|
user_chunk_data[1] = 0;
|
||||||
|
user_chunk_data[2] = 0;
|
||||||
|
user_chunk_data[3] = 0;
|
||||||
|
png_set_read_user_chunk_fn(read_ptr, user_chunk_data,
|
||||||
|
read_user_chunk_callback);
|
||||||
|
|
||||||
|
#endif
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
write_ptr =
|
||||||
|
png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
|
png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
|
||||||
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
|
||||||
#else
|
#else
|
||||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
write_ptr =
|
||||||
|
png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL);
|
png_error_ptr_NULL, png_error_ptr_NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_NO_STDIO)
|
#if defined(PNG_NO_STDIO)
|
||||||
|
@ -679,7 +772,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
pngtest_warning);
|
pngtest_warning);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
png_debug(0, "Allocating read_info, write_info and end_info structures");
|
||||||
read_info_ptr = png_create_info_struct(read_ptr);
|
read_info_ptr = png_create_info_struct(read_ptr);
|
||||||
end_info_ptr = png_create_info_struct(read_ptr);
|
end_info_ptr = png_create_info_struct(read_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
@ -688,7 +781,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
png_debug(0, "Setting jmpbuf for read struct\n");
|
png_debug(0, "Setting jmpbuf for read struct");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(jmpbuf))
|
if (setjmp(jmpbuf))
|
||||||
#else
|
#else
|
||||||
|
@ -696,8 +789,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||||
if (row_buf)
|
|
||||||
png_free(read_ptr, row_buf);
|
png_free(read_ptr, row_buf);
|
||||||
|
row_buf = NULL;
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||||
|
@ -712,7 +805,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_debug(0, "Setting jmpbuf for write struct\n");
|
png_debug(0, "Setting jmpbuf for write struct");
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
if (setjmp(jmpbuf))
|
if (setjmp(jmpbuf))
|
||||||
#else
|
#else
|
||||||
|
@ -735,7 +828,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Initializing input and output streams\n");
|
png_debug(0, "Initializing input and output streams");
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
png_init_io(read_ptr, fpin);
|
png_init_io(read_ptr, fpin);
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
@ -795,10 +888,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_bytep_NULL, 0);
|
png_bytep_NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Reading info struct\n");
|
png_debug(0, "Reading info struct");
|
||||||
png_read_info(read_ptr, read_info_ptr);
|
png_read_info(read_ptr, read_info_ptr);
|
||||||
|
|
||||||
png_debug(0, "Transferring info struct\n");
|
png_debug(0, "Transferring info struct");
|
||||||
{
|
{
|
||||||
int interlace_type, compression_type, filter_type;
|
int interlace_type, compression_type, filter_type;
|
||||||
|
|
||||||
|
@ -831,10 +924,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_fixed_point gamma;
|
png_fixed_point gamma;
|
||||||
|
|
||||||
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
|
if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
|
||||||
{
|
|
||||||
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
|
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#else /* Use floating point versions */
|
#else /* Use floating point versions */
|
||||||
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
#if defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
|
@ -855,13 +946,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
double gamma;
|
double gamma;
|
||||||
|
|
||||||
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
|
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
|
||||||
{
|
|
||||||
png_set_gAMA(write_ptr, write_info_ptr, gamma);
|
png_set_gAMA(write_ptr, write_info_ptr, gamma);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* floating point */
|
#endif /* Floating point */
|
||||||
#endif /* fixed point */
|
#endif /* Fixed point */
|
||||||
#if defined(PNG_iCCP_SUPPORTED)
|
#if defined(PNG_iCCP_SUPPORTED)
|
||||||
{
|
{
|
||||||
png_charp name;
|
png_charp name;
|
||||||
|
@ -882,20 +971,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
int intent;
|
int intent;
|
||||||
|
|
||||||
if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
|
if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
|
||||||
{
|
|
||||||
png_set_sRGB(write_ptr, write_info_ptr, intent);
|
png_set_sRGB(write_ptr, write_info_ptr, intent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
png_colorp palette;
|
png_colorp palette;
|
||||||
int num_palette;
|
int num_palette;
|
||||||
|
|
||||||
if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
|
if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
|
||||||
{
|
|
||||||
png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
|
png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if defined(PNG_bKGD_SUPPORTED)
|
#if defined(PNG_bKGD_SUPPORTED)
|
||||||
{
|
{
|
||||||
png_color_16p background;
|
png_color_16p background;
|
||||||
|
@ -911,17 +996,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_uint_16p hist;
|
png_uint_16p hist;
|
||||||
|
|
||||||
if (png_get_hIST(read_ptr, read_info_ptr, &hist))
|
if (png_get_hIST(read_ptr, read_info_ptr, &hist))
|
||||||
{
|
|
||||||
png_set_hIST(write_ptr, write_info_ptr, hist);
|
png_set_hIST(write_ptr, write_info_ptr, hist);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_oFFs_SUPPORTED)
|
#if defined(PNG_oFFs_SUPPORTED)
|
||||||
{
|
{
|
||||||
png_int_32 offset_x, offset_y;
|
png_int_32 offset_x, offset_y;
|
||||||
int unit_type;
|
int unit_type;
|
||||||
|
|
||||||
if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type))
|
if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
|
||||||
|
&unit_type))
|
||||||
{
|
{
|
||||||
png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
|
png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
|
||||||
}
|
}
|
||||||
|
@ -948,20 +1032,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
int unit_type;
|
int unit_type;
|
||||||
|
|
||||||
if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
|
if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
|
||||||
{
|
|
||||||
png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
|
png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_sBIT_SUPPORTED)
|
#if defined(PNG_sBIT_SUPPORTED)
|
||||||
{
|
{
|
||||||
png_color_8p sig_bit;
|
png_color_8p sig_bit;
|
||||||
|
|
||||||
if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
|
if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
|
||||||
{
|
|
||||||
png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
|
png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_sCAL_SUPPORTED)
|
#if defined(PNG_sCAL_SUPPORTED)
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
@ -997,7 +1077,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
|
|
||||||
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
|
if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
|
||||||
{
|
{
|
||||||
png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
|
png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||||
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1010,10 +1090,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
{
|
{
|
||||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
/* we have to use png_strcpy instead of "=" because the string
|
/* We have to use png_memcpy instead of "=" because the string
|
||||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
* pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||||
we use it */
|
* we use it.
|
||||||
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
*/
|
||||||
|
png_memcpy(tIME_string,
|
||||||
|
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||||
|
png_sizeof(tIME_string));
|
||||||
|
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||||
tIME_chunk_present++;
|
tIME_chunk_present++;
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
}
|
}
|
||||||
|
@ -1028,6 +1112,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
|
if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
|
||||||
&trans_values))
|
&trans_values))
|
||||||
{
|
{
|
||||||
|
int sample_max = (1 << read_info_ptr->bit_depth);
|
||||||
|
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
|
||||||
|
if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||||
|
(int)trans_values->gray > sample_max) ||
|
||||||
|
(read_info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||||
|
((int)trans_values->red > sample_max ||
|
||||||
|
(int)trans_values->green > sample_max ||
|
||||||
|
(int)trans_values->blue > sample_max))))
|
||||||
png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
|
png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
|
||||||
trans_values);
|
trans_values);
|
||||||
}
|
}
|
||||||
|
@ -1043,9 +1135,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
|
||||||
num_unknowns);
|
num_unknowns);
|
||||||
/* copy the locations from the read_info_ptr. The automatically
|
/* Copy the locations from the read_info_ptr. The automatically
|
||||||
generated locations in write_info_ptr are wrong because we
|
* generated locations in write_info_ptr are wrong because we
|
||||||
haven't written anything yet */
|
* haven't written anything yet.
|
||||||
|
*/
|
||||||
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
||||||
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
|
||||||
unknowns[i].location);
|
unknowns[i].location);
|
||||||
|
@ -1054,21 +1147,55 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_debug(0, "\nWriting info struct\n");
|
png_debug(0, "Writing info struct");
|
||||||
|
|
||||||
/* If we wanted, we could write info in two steps:
|
/* If we wanted, we could write info in two steps:
|
||||||
png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
* png_write_info_before_PLTE(write_ptr, write_info_ptr);
|
||||||
*/
|
*/
|
||||||
png_write_info(write_ptr, write_info_ptr);
|
png_write_info(write_ptr, write_info_ptr);
|
||||||
|
|
||||||
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if (user_chunk_data[0] != 0)
|
||||||
|
{
|
||||||
|
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||||
|
|
||||||
|
unsigned char
|
||||||
|
ster_chunk_data[1];
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(STDERR, "\n stereo mode = %lu\n",
|
||||||
|
(unsigned long)(user_chunk_data[0] - 1));
|
||||||
|
ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);
|
||||||
|
png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);
|
||||||
|
}
|
||||||
|
if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
|
||||||
|
{
|
||||||
|
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||||
|
|
||||||
|
unsigned char
|
||||||
|
vpag_chunk_data[9];
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n",
|
||||||
|
(unsigned long)user_chunk_data[1],
|
||||||
|
(unsigned long)user_chunk_data[2],
|
||||||
|
(unsigned long)user_chunk_data[3]);
|
||||||
|
png_save_uint_32(vpag_chunk_data, user_chunk_data[1]);
|
||||||
|
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]);
|
||||||
|
vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff);
|
||||||
|
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SINGLE_ROWBUF_ALLOC
|
#ifdef SINGLE_ROWBUF_ALLOC
|
||||||
png_debug(0, "\nAllocating row buffer...");
|
png_debug(0, "Allocating row buffer...");
|
||||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||||
png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf);
|
png_debug1(0, "0x%08lx", (unsigned long)row_buf);
|
||||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||||
png_debug(0, "Writing row data\n");
|
png_debug(0, "Writing row data");
|
||||||
|
|
||||||
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||||
|
@ -1087,14 +1214,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif
|
#endif
|
||||||
for (pass = 0; pass < num_pass; pass++)
|
for (pass = 0; pass < num_pass; pass++)
|
||||||
{
|
{
|
||||||
png_debug1(0, "Writing row data for pass %d\n",pass);
|
png_debug1(0, "Writing row data for pass %d", pass);
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
#ifndef SINGLE_ROWBUF_ALLOC
|
#ifndef SINGLE_ROWBUF_ALLOC
|
||||||
png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y);
|
png_debug2(0, "Allocating row buffer (pass %d, y = %ld)...", pass, y);
|
||||||
row_buf = (png_bytep)png_malloc(read_ptr,
|
row_buf = (png_bytep)png_malloc(read_ptr,
|
||||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||||
png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf,
|
png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf,
|
||||||
png_get_rowbytes(read_ptr, read_info_ptr));
|
png_get_rowbytes(read_ptr, read_info_ptr));
|
||||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||||
png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1);
|
png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1);
|
||||||
|
@ -1114,8 +1241,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
#endif /* PNG_WRITE_SUPPORTED */
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|
||||||
#ifndef SINGLE_ROWBUF_ALLOC
|
#ifndef SINGLE_ROWBUF_ALLOC
|
||||||
png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y);
|
png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y);
|
||||||
png_free(read_ptr, row_buf);
|
png_free(read_ptr, row_buf);
|
||||||
|
row_buf = NULL;
|
||||||
#endif /* !SINGLE_ROWBUF_ALLOC */
|
#endif /* !SINGLE_ROWBUF_ALLOC */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1127,7 +1255,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Reading and writing end_info data\n");
|
png_debug(0, "Reading and writing end_info data");
|
||||||
|
|
||||||
png_read_end(read_ptr, end_info_ptr);
|
png_read_end(read_ptr, end_info_ptr);
|
||||||
#if defined(PNG_TEXT_SUPPORTED)
|
#if defined(PNG_TEXT_SUPPORTED)
|
||||||
|
@ -1137,7 +1265,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
|
|
||||||
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
|
||||||
{
|
{
|
||||||
png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
|
png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
|
||||||
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,10 +1278,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
{
|
{
|
||||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
/* we have to use png_strcpy instead of "=" because the string
|
/* We have to use png_memcpy instead of "=" because the string
|
||||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||||
we use it */
|
we use it */
|
||||||
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
png_memcpy(tIME_string,
|
||||||
|
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||||
|
png_sizeof(tIME_string));
|
||||||
|
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
|
||||||
tIME_chunk_present++;
|
tIME_chunk_present++;
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
}
|
}
|
||||||
|
@ -1170,9 +1301,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
|
||||||
num_unknowns);
|
num_unknowns);
|
||||||
/* copy the locations from the read_info_ptr. The automatically
|
/* Copy the locations from the read_info_ptr. The automatically
|
||||||
generated locations in write_end_info_ptr are wrong because we
|
* generated locations in write_end_info_ptr are wrong because we
|
||||||
haven't written the end_info yet */
|
* haven't written the end_info yet.
|
||||||
|
*/
|
||||||
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
for (i = 0; i < (png_size_t)num_unknowns; i++)
|
||||||
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
|
||||||
unknowns[i].location);
|
unknowns[i].location);
|
||||||
|
@ -1189,31 +1321,31 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
png_uint_32 iwidth, iheight;
|
png_uint_32 iwidth, iheight;
|
||||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||||
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||||
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
|
||||||
iwidth, iheight);
|
(unsigned long)iwidth, (unsigned long)iheight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(0, "Destroying data structs\n");
|
png_debug(0, "Destroying data structs");
|
||||||
#ifdef SINGLE_ROWBUF_ALLOC
|
#ifdef SINGLE_ROWBUF_ALLOC
|
||||||
png_debug(1, "destroying row_buf for read_ptr\n");
|
png_debug(1, "destroying row_buf for read_ptr");
|
||||||
png_free(read_ptr, row_buf);
|
png_free(read_ptr, row_buf);
|
||||||
row_buf = NULL;
|
row_buf = NULL;
|
||||||
#endif /* SINGLE_ROWBUF_ALLOC */
|
#endif /* SINGLE_ROWBUF_ALLOC */
|
||||||
png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n");
|
png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr");
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_debug(1, "destroying write_end_info_ptr\n");
|
png_debug(1, "destroying write_end_info_ptr");
|
||||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||||
png_debug(1, "destroying write_ptr, write_info_ptr\n");
|
png_debug(1, "destroying write_ptr, write_info_ptr");
|
||||||
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
png_destroy_write_struct(&write_ptr, &write_info_ptr);
|
||||||
#endif
|
#endif
|
||||||
png_debug(0, "Destruction complete.\n");
|
png_debug(0, "Destruction complete.");
|
||||||
|
|
||||||
FCLOSE(fpin);
|
FCLOSE(fpin);
|
||||||
FCLOSE(fpout);
|
FCLOSE(fpout);
|
||||||
|
|
||||||
png_debug(0, "Opening files for comparison\n");
|
png_debug(0, "Opening files for comparison");
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE)
|
||||||
MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
|
MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
|
||||||
if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
|
if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
|
||||||
|
@ -1295,7 +1427,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* input and output filenames */
|
/* Input and output filenames */
|
||||||
#ifdef RISCOS
|
#ifdef RISCOS
|
||||||
static PNG_CONST char *inname = "pngtest/png";
|
static PNG_CONST char *inname = "pngtest/png";
|
||||||
static PNG_CONST char *outname = "pngout/png";
|
static PNG_CONST char *outname = "pngout/png";
|
||||||
|
@ -1310,22 +1442,24 @@ main(int argc, char *argv[])
|
||||||
int multiple = 0;
|
int multiple = 0;
|
||||||
int ierror = 0;
|
int ierror = 0;
|
||||||
|
|
||||||
fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
|
||||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||||
fprintf(STDERR, "%s", png_get_copyright(NULL));
|
fprintf(STDERR, "%s", png_get_copyright(NULL));
|
||||||
/* Show the version of libpng used in building the library */
|
/* Show the version of libpng used in building the library */
|
||||||
fprintf(STDERR," library (%lu):%s", png_access_version_number(),
|
fprintf(STDERR, " library (%lu):%s",
|
||||||
|
(unsigned long)png_access_version_number(),
|
||||||
png_get_header_version(NULL));
|
png_get_header_version(NULL));
|
||||||
/* Show the version of libpng used in building the application */
|
/* Show the version of libpng used in building the application */
|
||||||
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
|
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
|
||||||
PNG_HEADER_VERSION_STRING);
|
PNG_HEADER_VERSION_STRING);
|
||||||
fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n",
|
fprintf(STDERR, " sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
|
||||||
(long)png_sizeof(png_struct), (long)png_sizeof(png_info));
|
(long)png_sizeof(png_struct), (long)png_sizeof(png_info));
|
||||||
|
|
||||||
/* Do some consistency checking on the memory allocation settings, I'm
|
/* Do some consistency checking on the memory allocation settings, I'm
|
||||||
not sure this matters, but it is nice to know, the first of these
|
* not sure this matters, but it is nice to know, the first of these
|
||||||
tests should be impossible because of the way the macros are set
|
* tests should be impossible because of the way the macros are set
|
||||||
in pngconf.h */
|
* in pngconf.h
|
||||||
|
*/
|
||||||
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
|
||||||
fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
|
fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1397,12 +1531,13 @@ main(int argc, char *argv[])
|
||||||
int k;
|
int k;
|
||||||
#endif
|
#endif
|
||||||
int kerror;
|
int kerror;
|
||||||
fprintf(STDERR, "Testing %s:",argv[i]);
|
fprintf(STDERR, "\n Testing %s:", argv[i]);
|
||||||
kerror = test_one_file(argv[i], outname);
|
kerror = test_one_file(argv[i], outname);
|
||||||
if (kerror == 0)
|
if (kerror == 0)
|
||||||
{
|
{
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||||
|
(unsigned long)zero_samples);
|
||||||
#else
|
#else
|
||||||
fprintf(STDERR, " PASS\n");
|
fprintf(STDERR, " PASS\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1410,7 +1545,7 @@ main(int argc, char *argv[])
|
||||||
for (k = 0; k<256; k++)
|
for (k = 0; k<256; k++)
|
||||||
if (filters_used[k])
|
if (filters_used[k])
|
||||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||||
k,filters_used[k]);
|
k, (unsigned long)filters_used[k]);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
if (tIME_chunk_present != 0)
|
if (tIME_chunk_present != 0)
|
||||||
|
@ -1435,7 +1570,8 @@ main(int argc, char *argv[])
|
||||||
current_allocation);
|
current_allocation);
|
||||||
while (pinfo != NULL)
|
while (pinfo != NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, " %lu bytes at %x\n", pinfo->size,
|
fprintf(STDERR, " %lu bytes at %x\n",
|
||||||
|
(unsigned long)pinfo->size,
|
||||||
(unsigned int) pinfo->pointer);
|
(unsigned int) pinfo->pointer);
|
||||||
pinfo = pinfo->next;
|
pinfo = pinfo->next;
|
||||||
}
|
}
|
||||||
|
@ -1465,7 +1601,7 @@ main(int argc, char *argv[])
|
||||||
if (i == 1) status_dots_requested = 1;
|
if (i == 1) status_dots_requested = 1;
|
||||||
else if (verbose == 0)status_dots_requested = 0;
|
else if (verbose == 0)status_dots_requested = 0;
|
||||||
if (i == 0 || verbose == 1 || ierror != 0)
|
if (i == 0 || verbose == 1 || ierror != 0)
|
||||||
fprintf(STDERR, "Testing %s:",inname);
|
fprintf(STDERR, "\n Testing %s:", inname);
|
||||||
kerror = test_one_file(inname, outname);
|
kerror = test_one_file(inname, outname);
|
||||||
if (kerror == 0)
|
if (kerror == 0)
|
||||||
{
|
{
|
||||||
|
@ -1475,7 +1611,8 @@ main(int argc, char *argv[])
|
||||||
int k;
|
int k;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||||
|
(unsigned long)zero_samples);
|
||||||
#else
|
#else
|
||||||
fprintf(STDERR, " PASS\n");
|
fprintf(STDERR, " PASS\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1483,7 +1620,8 @@ main(int argc, char *argv[])
|
||||||
for (k = 0; k<256; k++)
|
for (k = 0; k<256; k++)
|
||||||
if (filters_used[k])
|
if (filters_used[k])
|
||||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||||
k,filters_used[k]);
|
k,
|
||||||
|
(unsigned long)filters_used[k]);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
if (tIME_chunk_present != 0)
|
if (tIME_chunk_present != 0)
|
||||||
|
@ -1494,7 +1632,7 @@ main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verbose == 0 && i != 2)
|
if (verbose == 0 && i != 2)
|
||||||
fprintf(STDERR, "Testing %s:",inname);
|
fprintf(STDERR, "\n Testing %s:", inname);
|
||||||
fprintf(STDERR, " FAIL\n");
|
fprintf(STDERR, " FAIL\n");
|
||||||
ierror += kerror;
|
ierror += kerror;
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1649,7 @@ main(int argc, char *argv[])
|
||||||
while (pinfo != NULL)
|
while (pinfo != NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, " %lu bytes at %x\n",
|
fprintf(STDERR, " %lu bytes at %x\n",
|
||||||
pinfo->size, (unsigned int)pinfo->pointer);
|
(unsigned long)pinfo->size, (unsigned int)pinfo->pointer);
|
||||||
pinfo = pinfo->next;
|
pinfo = pinfo->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1551,4 +1689,4 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef version_1_2_7 your_png_h_is_not_version_1_2_7;
|
typedef version_1_2_39 your_png_h_is_not_version_1_2_39;
|
||||||
|
|
|
@ -1,43 +1,53 @@
|
||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.36 [May 14, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
|
|
||||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||||
/* turn on BGR-to-RGB mapping */
|
/* Turn on BGR-to-RGB mapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_bgr(png_structp png_ptr)
|
png_set_bgr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_bgr\n");
|
png_debug(1, "in png_set_bgr");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_BGR;
|
png_ptr->transformations |= PNG_BGR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
/* turn on 16 bit byte swapping */
|
/* Turn on 16 bit byte swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap(png_structp png_ptr)
|
png_set_swap(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap\n");
|
png_debug(1, "in png_set_swap");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (png_ptr->bit_depth == 16)
|
if (png_ptr->bit_depth == 16)
|
||||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||||
/* turn on pixel packing */
|
/* Turn on pixel packing */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packing(png_structp png_ptr)
|
png_set_packing(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packing\n");
|
png_debug(1, "in png_set_packing");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (png_ptr->bit_depth < 8)
|
if (png_ptr->bit_depth < 8)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_PACK;
|
png_ptr->transformations |= PNG_PACK;
|
||||||
|
@ -47,11 +57,13 @@ png_set_packing(png_structp png_ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||||
/* turn on packed pixel swapping */
|
/* Turn on packed pixel swapping */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_packswap(png_structp png_ptr)
|
png_set_packswap(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packswap\n");
|
png_debug(1, "in png_set_packswap");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
if (png_ptr->bit_depth < 8)
|
if (png_ptr->bit_depth < 8)
|
||||||
png_ptr->transformations |= PNG_PACKSWAP;
|
png_ptr->transformations |= PNG_PACKSWAP;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +73,9 @@ png_set_packswap(png_structp png_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_shift\n");
|
png_debug(1, "in png_set_shift");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_SHIFT;
|
png_ptr->transformations |= PNG_SHIFT;
|
||||||
png_ptr->shift = *true_bits;
|
png_ptr->shift = *true_bits;
|
||||||
}
|
}
|
||||||
|
@ -72,8 +86,8 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_set_interlace_handling(png_structp png_ptr)
|
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->interlaced)
|
if (png_ptr && png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_INTERLACE;
|
png_ptr->transformations |= PNG_INTERLACE;
|
||||||
return (7);
|
return (7);
|
||||||
|
@ -92,7 +106,9 @@ png_set_interlace_handling(png_structp png_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filler\n");
|
png_debug(1, "in png_set_filler");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_FILLER;
|
png_ptr->transformations |= PNG_FILLER;
|
||||||
png_ptr->filler = (png_byte)filler;
|
png_ptr->filler = (png_byte)filler;
|
||||||
if (filler_loc == PNG_FILLER_AFTER)
|
if (filler_loc == PNG_FILLER_AFTER)
|
||||||
|
@ -124,7 +140,9 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_add_alpha\n");
|
png_debug(1, "in png_set_add_alpha");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_set_filler(png_ptr, filler, filler_loc);
|
png_set_filler(png_ptr, filler, filler_loc);
|
||||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +155,9 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_swap_alpha(png_structp png_ptr)
|
png_set_swap_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap_alpha\n");
|
png_debug(1, "in png_set_swap_alpha");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,7 +167,9 @@ png_set_swap_alpha(png_structp png_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_alpha(png_structp png_ptr)
|
png_set_invert_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_alpha\n");
|
png_debug(1, "in png_set_invert_alpha");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,15 +178,17 @@ png_set_invert_alpha(png_structp png_ptr)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_invert_mono(png_structp png_ptr)
|
png_set_invert_mono(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_mono\n");
|
png_debug(1, "in png_set_invert_mono");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invert monochrome grayscale data */
|
/* Invert monochrome grayscale data */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_invert(png_row_infop row_info, png_bytep row)
|
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:
|
/* This test removed from libpng version 1.0.13 and 1.2.0:
|
||||||
* if (row_info->bit_depth == 1 &&
|
* if (row_info->bit_depth == 1 &&
|
||||||
*/
|
*/
|
||||||
|
@ -215,11 +239,11 @@ png_do_invert(png_row_infop row_info, png_bytep row)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
|
||||||
/* swaps byte order on 16 bit depth images */
|
/* Swaps byte order on 16 bit depth images */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_swap(png_row_infop row_info, png_bytep row)
|
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 (
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL &&
|
row != NULL && row_info != NULL &&
|
||||||
|
@ -241,7 +265,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
|
||||||
static png_byte onebppswaptable[256] = {
|
static PNG_CONST png_byte onebppswaptable[256] = {
|
||||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
||||||
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||||
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
||||||
|
@ -276,7 +300,7 @@ static png_byte onebppswaptable[256] = {
|
||||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
static png_byte twobppswaptable[256] = {
|
static PNG_CONST png_byte twobppswaptable[256] = {
|
||||||
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
|
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
|
||||||
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
|
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
|
||||||
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
|
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
|
||||||
|
@ -311,7 +335,7 @@ static png_byte twobppswaptable[256] = {
|
||||||
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
|
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
static png_byte fourbppswaptable[256] = {
|
static PNG_CONST png_byte fourbppswaptable[256] = {
|
||||||
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
|
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
|
||||||
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
|
||||||
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
|
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
|
||||||
|
@ -346,11 +370,11 @@ static png_byte fourbppswaptable[256] = {
|
||||||
0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
|
0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
/* swaps pixel packing order within bytes */
|
/* Swaps pixel packing order within bytes */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_packswap(png_row_infop row_info, png_bytep row)
|
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 (
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL &&
|
row != NULL && row_info != NULL &&
|
||||||
|
@ -362,11 +386,11 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||||
end = row + row_info->rowbytes;
|
end = row + row_info->rowbytes;
|
||||||
|
|
||||||
if (row_info->bit_depth == 1)
|
if (row_info->bit_depth == 1)
|
||||||
table = onebppswaptable;
|
table = (png_bytep)onebppswaptable;
|
||||||
else if (row_info->bit_depth == 2)
|
else if (row_info->bit_depth == 2)
|
||||||
table = twobppswaptable;
|
table = (png_bytep)twobppswaptable;
|
||||||
else if (row_info->bit_depth == 4)
|
else if (row_info->bit_depth == 4)
|
||||||
table = fourbppswaptable;
|
table = (png_bytep)fourbppswaptable;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -378,11 +402,11 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
|
||||||
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
||||||
/* remove filler or alpha byte(s) */
|
/* Remove filler or alpha byte(s) */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
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 defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
if (row != NULL && row_info != NULL)
|
if (row != NULL && row_info != NULL)
|
||||||
#endif
|
#endif
|
||||||
|
@ -392,7 +416,9 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||||
png_uint_32 row_width=row_info->width;
|
png_uint_32 row_width=row_info->width;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
|
||||||
|
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
|
||||||
|
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||||
row_info->channels == 4)
|
row_info->channels == 4)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
|
@ -471,7 +497,9 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||||
}
|
}
|
||||||
row_info->channels = 3;
|
row_info->channels = 3;
|
||||||
}
|
}
|
||||||
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY &&
|
else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
|
(row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
|
||||||
|
(flags & PNG_FLAG_STRIP_ALPHA))) &&
|
||||||
row_info->channels == 2)
|
row_info->channels == 2)
|
||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
|
@ -525,16 +553,18 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
|
||||||
}
|
}
|
||||||
row_info->channels = 1;
|
row_info->channels = 1;
|
||||||
}
|
}
|
||||||
|
if (flags & PNG_FLAG_STRIP_ALPHA)
|
||||||
|
row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
|
||||||
/* swaps red and blue bytes within a pixel */
|
/* Swaps red and blue bytes within a pixel */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_bgr(png_row_infop row_info, png_bytep row)
|
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 (
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL &&
|
row != NULL && row_info != NULL &&
|
||||||
|
@ -607,13 +637,15 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||||
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
|
||||||
|
|
||||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
|
defined(PNG_LEGACY_SUPPORTED) || \
|
||||||
defined(PNG_LEGACY_SUPPORTED)
|
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_user_transform_info\n");
|
png_debug(1, "in png_set_user_transform_info");
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||||
|
@ -634,11 +666,12 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_user_transform_ptr(png_structp png_ptr)
|
png_get_user_transform_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return (NULL);
|
||||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||||
#else
|
#else
|
||||||
if(png_ptr)
|
|
||||||
return (NULL);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* libpng 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
* This file provides a location for all output. Users who need
|
* This file provides a location for all output. Users who need
|
||||||
* special handling are expected to write functions that have the same
|
* special handling are expected to write functions that have the same
|
||||||
* arguments as these and perform similar functions, but that possibly
|
* arguments as these and perform similar functions, but that possibly
|
||||||
|
@ -20,10 +23,11 @@
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
|
|
||||||
/* Write the data to whatever output you are using. The default routine
|
/* Write the data to whatever output you are using. The default routine
|
||||||
writes to a file pointer. Note that this routine sometimes gets called
|
* writes to a file pointer. Note that this routine sometimes gets called
|
||||||
with very small lengths, so you should implement some kind of simple
|
* with very small lengths, so you should implement some kind of simple
|
||||||
buffering if you are using unbuffered writes. This should never be asked
|
* buffering if you are using unbuffered writes. This should never be asked
|
||||||
to write more than 64K on a 16 bit machine. */
|
* to write more than 64K on a 16 bit machine.
|
||||||
|
*/
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
@ -36,15 +40,18 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
/* This is the function that does the actual writing of data. If you are
|
/* This is the function that does the actual writing of data. If you are
|
||||||
not writing to a standard C stream, you should create a replacement
|
* not writing to a standard C stream, you should create a replacement
|
||||||
write_data function and use it at run time with png_set_write_fn(), rather
|
* write_data function and use it at run time with png_set_write_fn(), rather
|
||||||
than changing the library. */
|
* than changing the library.
|
||||||
|
*/
|
||||||
#ifndef USE_FAR_KEYWORD
|
#ifndef USE_FAR_KEYWORD
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
png_uint_32 check;
|
png_uint_32 check;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE)
|
||||||
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||||
check = 0;
|
check = 0;
|
||||||
|
@ -55,9 +62,9 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* this is the model-independent version. Since the standard I/O library
|
/* This is the model-independent version. Since the standard I/O library
|
||||||
can't handle far buffers in the medium and small models, we have to copy
|
* can't handle far buffers in the medium and small models, we have to copy
|
||||||
the data.
|
* the data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NEAR_BUF_SIZE 1024
|
#define NEAR_BUF_SIZE 1024
|
||||||
|
@ -70,6 +77,8 @@ 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_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
/* Check if data really is near. If so, use usual code. */
|
/* Check if data really is near. If so, use usual code. */
|
||||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||||
|
@ -91,7 +100,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
written = MIN(NEAR_BUF_SIZE, remaining);
|
written = MIN(NEAR_BUF_SIZE, remaining);
|
||||||
png_memcpy(buf, data, written); /* copy far buffer to near buffer */
|
png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE)
|
||||||
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
|
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
|
||||||
err = 0;
|
err = 0;
|
||||||
|
@ -100,8 +109,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
#endif
|
#endif
|
||||||
if (err != written)
|
if (err != written)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else
|
else
|
||||||
check += err;
|
check += err;
|
||||||
|
|
||||||
data += written;
|
data += written;
|
||||||
remaining -= written;
|
remaining -= written;
|
||||||
}
|
}
|
||||||
|
@ -115,8 +126,9 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is called to output any data pending writing (normally
|
/* This function is called to output any data pending writing (normally
|
||||||
to disk). After png_flush is called, there should be no data pending
|
* to disk). After png_flush is called, there should be no data pending
|
||||||
writing in any buffers. */
|
* writing in any buffers.
|
||||||
|
*/
|
||||||
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_flush(png_structp png_ptr)
|
png_flush(png_structp png_ptr)
|
||||||
|
@ -131,8 +143,11 @@ png_default_flush(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#if !defined(_WIN32_WCE)
|
#if !defined(_WIN32_WCE)
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
#endif
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
#if !defined(_WIN32_WCE)
|
||||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||||
if (io_ptr != NULL)
|
|
||||||
fflush(io_ptr);
|
fflush(io_ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -140,36 +155,47 @@ png_default_flush(png_structp png_ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function allows the application to supply new output functions for
|
/* This function allows the application to supply new output functions for
|
||||||
libpng if standard C streams aren't being used.
|
* libpng if standard C streams aren't being used.
|
||||||
|
*
|
||||||
This function takes as its arguments:
|
* This function takes as its arguments:
|
||||||
png_ptr - pointer to a png output data structure
|
* png_ptr - pointer to a png output data structure
|
||||||
io_ptr - pointer to user supplied structure containing info about
|
* io_ptr - pointer to user supplied structure containing info about
|
||||||
the output functions. May be NULL.
|
* the output functions. May be NULL.
|
||||||
write_data_fn - pointer to a new output function that takes as its
|
* write_data_fn - pointer to a new output function that takes as its
|
||||||
arguments a pointer to a png_struct, a pointer to
|
* arguments a pointer to a png_struct, a pointer to
|
||||||
data to be written, and a 32-bit unsigned int that is
|
* data to be written, and a 32-bit unsigned int that is
|
||||||
the number of bytes to be written. The new write
|
* the number of bytes to be written. The new write
|
||||||
function should call png_error(png_ptr, "Error msg")
|
* function should call png_error(png_ptr, "Error msg")
|
||||||
to exit and output any fatal error messages.
|
* to exit and output any fatal error messages. May be
|
||||||
flush_data_fn - pointer to a new flush function that takes as its
|
* NULL, in which case libpng's default function will
|
||||||
arguments a pointer to a png_struct. After a call to
|
* be used.
|
||||||
the flush function, there should be no data in any buffers
|
* flush_data_fn - pointer to a new flush function that takes as its
|
||||||
or pending transmission. If the output method doesn't do
|
* arguments a pointer to a png_struct. After a call to
|
||||||
any buffering of ouput, a function prototype must still be
|
* the flush function, there should be no data in any buffers
|
||||||
supplied although it doesn't have to do anything. If
|
* or pending transmission. If the output method doesn't do
|
||||||
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
* any buffering of ouput, a function prototype must still be
|
||||||
time, output_flush_fn will be ignored, although it must be
|
* supplied although it doesn't have to do anything. If
|
||||||
supplied for compatibility. */
|
* PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||||
|
* time, output_flush_fn will be ignored, although it must be
|
||||||
|
* supplied for compatibility. May be NULL, in which case
|
||||||
|
* libpng's default function will be used, if
|
||||||
|
* PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||||
|
* a good idea if io_ptr does not point to a standard
|
||||||
|
* *FILE structure.
|
||||||
|
*/
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
if (write_data_fn != NULL)
|
if (write_data_fn != NULL)
|
||||||
png_ptr->write_data_fn = write_data_fn;
|
png_ptr->write_data_fn = write_data_fn;
|
||||||
|
|
||||||
else
|
else
|
||||||
png_ptr->write_data_fn = png_default_write_data;
|
png_ptr->write_data_fn = png_default_write_data;
|
||||||
#else
|
#else
|
||||||
|
@ -180,6 +206,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
if (output_flush_fn != NULL)
|
if (output_flush_fn != NULL)
|
||||||
png_ptr->output_flush_fn = output_flush_fn;
|
png_ptr->output_flush_fn = output_flush_fn;
|
||||||
|
|
||||||
else
|
else
|
||||||
png_ptr->output_flush_fn = png_default_flush;
|
png_ptr->output_flush_fn = png_default_flush;
|
||||||
#else
|
#else
|
||||||
|
@ -206,9 +233,11 @@ void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||||
void FAR *far_ptr;
|
void FAR *far_ptr;
|
||||||
FP_OFF(near_ptr) = FP_OFF(ptr);
|
FP_OFF(near_ptr) = FP_OFF(ptr);
|
||||||
far_ptr = (void FAR *)near_ptr;
|
far_ptr = (void FAR *)near_ptr;
|
||||||
|
|
||||||
if (check != 0)
|
if (check != 0)
|
||||||
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
if (FP_SEG(ptr) != FP_SEG(far_ptr))
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
png_error(png_ptr, "segment lost in conversion");
|
||||||
|
|
||||||
return(near_ptr);
|
return(near_ptr);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
|
@ -218,9 +247,11 @@ void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
|
||||||
void FAR *far_ptr;
|
void FAR *far_ptr;
|
||||||
near_ptr = (void FAR *)ptr;
|
near_ptr = (void FAR *)ptr;
|
||||||
far_ptr = (void FAR *)near_ptr;
|
far_ptr = (void FAR *)near_ptr;
|
||||||
|
|
||||||
if (check != 0)
|
if (check != 0)
|
||||||
if (far_ptr != ptr)
|
if (far_ptr != ptr)
|
||||||
png_error(png_ptr, "segment lost in conversion");
|
png_error(png_ptr, "segment lost in conversion");
|
||||||
|
|
||||||
return(near_ptr);
|
return(near_ptr);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* libpng version 1.2.7 - September 12, 2004
|
* Last changed in libpng 1.2.37 [June 4, 2009]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNG_INTERNAL
|
#define PNG_INTERNAL
|
||||||
|
@ -18,7 +21,7 @@
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_write_transformations(png_structp png_ptr)
|
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)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -26,7 +29,7 @@ png_do_write_transformations(png_structp png_ptr)
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
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->write_user_transform_fn)) /* User write transform function */
|
||||||
(png_ptr, /* png_ptr */
|
(png_ptr, /* png_ptr */
|
||||||
&(png_ptr->row_info), /* row_info: */
|
&(png_ptr->row_info), /* row_info: */
|
||||||
/* png_uint_32 width; width of row */
|
/* png_uint_32 width; width of row */
|
||||||
|
@ -60,14 +63,14 @@ png_do_write_transformations(png_structp png_ptr)
|
||||||
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
&(png_ptr->shift));
|
&(png_ptr->shift));
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
|
||||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
|
||||||
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
|
||||||
#endif
|
|
||||||
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||||
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||||
|
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||||
|
png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
#endif
|
||||||
#if defined(PNG_WRITE_BGR_SUPPORTED)
|
#if defined(PNG_WRITE_BGR_SUPPORTED)
|
||||||
if (png_ptr->transformations & PNG_BGR)
|
if (png_ptr->transformations & PNG_BGR)
|
||||||
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||||
|
@ -86,7 +89,7 @@ png_do_write_transformations(png_structp png_ptr)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
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 (row_info->bit_depth == 8 &&
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL &&
|
row != NULL && row_info != NULL &&
|
||||||
|
@ -212,7 +215,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
png_do_shift(png_row_infop row_info, png_bytep row, png_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 defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
if (row != NULL && row_info != NULL &&
|
if (row != NULL && row_info != NULL &&
|
||||||
#else
|
#else
|
||||||
|
@ -248,7 +251,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||||
channels++;
|
channels++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* with low row depths, could only be grayscale, so one channel */
|
/* With low row depths, could only be grayscale, so one channel */
|
||||||
if (row_info->bit_depth < 8)
|
if (row_info->bit_depth < 8)
|
||||||
{
|
{
|
||||||
png_bytep bp = row;
|
png_bytep bp = row;
|
||||||
|
@ -336,7 +339,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
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 defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
if (row != NULL && row_info != NULL)
|
if (row != NULL && row_info != NULL)
|
||||||
#endif
|
#endif
|
||||||
|
@ -424,7 +427,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
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 defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
if (row != NULL && row_info != NULL)
|
if (row != NULL && row_info != NULL)
|
||||||
#endif
|
#endif
|
||||||
|
@ -439,9 +442,12 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
|
/* Does nothing
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=3; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,12 +460,15 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
|
/* Does nothing
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=6; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
|
@ -489,8 +498,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
|
|
||||||
for (i = 0, sp = dp = row; i < row_width; i++)
|
for (i = 0, sp = dp = row; i < row_width; i++)
|
||||||
{
|
{
|
||||||
|
/* Does nothing
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
|
*/
|
||||||
|
sp+=2; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
|
@ -501,11 +513,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||||
/* undoes intrapixel differencing */
|
/* Undoes intrapixel differencing */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
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 (
|
||||||
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
#if defined(PNG_USELESS_TESTS_SUPPORTED)
|
||||||
row != NULL && row_info != NULL &&
|
row != NULL && row_info != NULL &&
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue