mirror of https://github.com/stella-emu/stella.git
Updated built-in PNG lib to version 1.4.5 (current latest release).
Hopefully this marks a return to Stella development, as I haven't had much free time over the past month or so. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2194 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
8705a33f18
commit
af181e925a
|
@ -12,6 +12,13 @@
|
|||
Release History
|
||||
===========================================================================
|
||||
|
||||
3.3 to 3.4: (xx. xx, 2010)
|
||||
|
||||
* Updated built-in version of the PNG library to the latest version.
|
||||
|
||||
-Have fun!
|
||||
|
||||
|
||||
3.2.2 to 3.3: (November 12, 2010)
|
||||
|
||||
* Added the following Distella 'directives', which are used to override
|
||||
|
@ -103,8 +110,6 @@
|
|||
* State files from older versions will no longer work in this release,
|
||||
because of the extensive changes to the debugger and disassembler.
|
||||
|
||||
-Have fun!
|
||||
|
||||
|
||||
3.2.1 to 3.2.2: (September 17, 2010)
|
||||
|
||||
|
|
|
@ -17,11 +17,7 @@
|
|||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_4_3 Your_png_h_is_not_version_1_4_3;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
typedef version_1_4_5 Your_png_h_is_not_version_1_4_5;
|
||||
|
||||
/* 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
|
||||
|
@ -551,13 +547,13 @@ png_get_copyright(png_structp png_ptr)
|
|||
#else
|
||||
#ifdef __STDC__
|
||||
return ((png_charp) PNG_STRING_NEWLINE \
|
||||
"libpng version 1.4.3 - June 26, 2010" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.4.5 - December 9, 2010" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE);
|
||||
#else
|
||||
return ((png_charp) "libpng version 1.4.3 - June 26, 2010\
|
||||
return ((png_charp) "libpng version 1.4.5 - December 9, 2010\
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
|
||||
|
|
452
src/libpng/png.h
452
src/libpng/png.h
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.4.3 - June 26, 2010
|
||||
* libpng version 1.4.5 - December 9, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -44,14 +44,14 @@
|
|||
* includes the resource compiler for Windows DLL configurations.
|
||||
*/
|
||||
#ifdef PNG_USER_CONFIG
|
||||
# include "pngusr.h"
|
||||
# ifndef PNG_USER_PRIVATEBUILD
|
||||
# define PNG_USER_PRIVATEBUILD
|
||||
# endif
|
||||
# include "pngusr.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If you create a private DLL you need to define in "pngusr.h" the followings:
|
||||
* If you create a private DLL you should define in "pngusr.h" the following:
|
||||
* #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."
|
||||
|
@ -59,7 +59,7 @@
|
|||
* 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"
|
||||
* e.g. // private DLL "libpng14gx.dll"
|
||||
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
|
||||
*
|
||||
* The following macros are also at your disposal if you want to complete the
|
||||
|
@ -278,11 +278,19 @@
|
|||
* #define PNG_NO_STDIO
|
||||
*/
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
# define PNG_NO_STDIO
|
||||
# define PNG_NO_TIME_RFC1123
|
||||
# ifdef PNG_DEBUG
|
||||
# undef PNG_DEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
|
||||
# define PNG_STDIO_SUPPORTED
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PNG_BUILD_DLL
|
||||
# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
|
@ -448,7 +456,7 @@
|
|||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
* If you do not want to use const, define PNG_NO_CONST.
|
||||
*/
|
||||
|
||||
#ifndef PNG_CONST
|
||||
|
@ -463,8 +471,10 @@
|
|||
* library that you will not be using. I wish I could figure out how to
|
||||
* automate this, but I can't do that without making it seriously hard
|
||||
* on the users. So if you are not using an ability, change the #define
|
||||
* to and #undef, and that part of the library will not be compiled. If
|
||||
* your linker can't find a function, you may want to make sure the
|
||||
* to an #undef, or pass in PNG_NO_feature and that part of the library
|
||||
* will not be compiled.
|
||||
|
||||
* If your linker can't find a function, you may want to make sure the
|
||||
* ability is defined here. Some of these depend upon some others being
|
||||
* defined. I haven't figured out all the interactions here, so you may
|
||||
* have to experiment awhile to get everything to compile. If you are
|
||||
|
@ -1123,7 +1133,7 @@ typedef unsigned char png_byte;
|
|||
#else
|
||||
typedef size_t png_size_t;
|
||||
#endif
|
||||
#define png_sizeof(x) sizeof(x)
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
* pngpriv.h header. Needs modification for other compilers besides
|
||||
|
@ -1245,6 +1255,13 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_DLL
|
||||
#endif
|
||||
|
||||
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
|
||||
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
|
||||
* Don't ignore those warnings; you must also reset the default calling
|
||||
* convention in your compiler to match your PNGAPI, and you must build
|
||||
* zlib and your applications the same way you build libpng.
|
||||
*/
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# undef PNGAPI
|
||||
# define PNGAPI __cdecl
|
||||
|
@ -1252,14 +1269,11 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_IMPEXP
|
||||
#endif
|
||||
|
||||
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
|
||||
|
||||
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
|
||||
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
|
||||
* Don't ignore those warnings; you must also reset the default calling
|
||||
* convention in your compiler to match your PNGAPI, and you must build
|
||||
* zlib and your applications the same way you build libpng.
|
||||
*/
|
||||
#ifdef __WATCOMC__
|
||||
# ifndef PNGAPI
|
||||
# define PNGAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
|
||||
# ifndef PNG_NO_MODULEDEF
|
||||
|
@ -1344,6 +1358,8 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
|
||||
#endif
|
||||
|
||||
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
|
||||
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* functions in png.h will generate compiler warnings.
|
||||
|
@ -1421,7 +1437,7 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
|
||||
/* memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
# ifdef _WINDOWS_
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
|
@ -1442,7 +1458,8 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define png_memset _fmemset
|
||||
# define png_sprintf sprintf
|
||||
#else
|
||||
# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
|
||||
# /* Favor Windows over C runtime fns */
|
||||
# define CVT_PTR(ptr) (ptr)
|
||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
# define png_strcpy lstrcpyA
|
||||
|
@ -1462,6 +1479,9 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define png_memcpy memcpy
|
||||
# define png_memset memset
|
||||
# define png_sprintf sprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_SNPRINTF
|
||||
# ifdef _MSC_VER
|
||||
# define png_snprintf _snprintf /* Added to v 1.2.19 */
|
||||
|
@ -1479,12 +1499,10 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
* 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_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
|
||||
# define png_snprintf2(s1,n,fmt,x1,x2) png_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
|
||||
# endif
|
||||
png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
|
||||
#endif
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
||||
|
@ -1497,22 +1515,19 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
* to encounter practical situations that require such conversions.
|
||||
*/
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# define png_mem_alloc farmalloc
|
||||
# define png_mem_free farfree
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
# define png_mem_alloc(s) halloc(s, 1)
|
||||
# define png_mem_free hfree
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
# else
|
||||
# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
|
||||
# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
|
||||
/* This is an attempt to detect an old Windows system where (int) is
|
||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
||||
* bigger size to accomodate the requirements of the library.
|
||||
*/
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
# else
|
||||
# define png_mem_alloc malloc
|
||||
# define png_mem_free free
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
# endif
|
||||
# endif
|
||||
|
|
|
@ -1109,6 +1109,8 @@ png_push_process_row(png_structp png_ptr)
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case 6:
|
||||
{
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* libpng version 1.4.3 - June 26, 2010
|
||||
* libpng version 1.4.5 - December 9, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef PNG_EXTERN
|
||||
/* The functions exported by PNG_EXTERN are internal functions, which
|
||||
* aren't usually used outside the library (as far as I know), so it is
|
||||
* debatable if they should be exported at all. In the future, when it
|
||||
|
@ -36,6 +37,7 @@
|
|||
# define PNG_EXTERN extern
|
||||
*/
|
||||
# define PNG_EXTERN
|
||||
#endif
|
||||
|
||||
/* Other defines specific to compilers can go here. Try to keep
|
||||
* them inside an appropriate ifdef/endif pair for portability.
|
||||
|
@ -75,10 +77,6 @@
|
|||
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
|
||||
defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h> /* defines _WINDOWS_ macro */
|
||||
/* I have no idea why is this necessary... */
|
||||
# ifdef _MSC_VER
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Various modes of operation. Note that after an init, mode is set to
|
||||
|
@ -292,6 +290,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
|
|||
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
|
||||
png_size_t length));
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Read the chunk header (length + type name) */
|
||||
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
||||
|
||||
|
@ -672,7 +673,7 @@ PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length));
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
|
||||
|
@ -707,7 +708,7 @@ PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length));
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
|
||||
|
@ -828,14 +829,14 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
|
|||
int filter_type));
|
||||
|
||||
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
|
||||
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_infop end_info_ptr));
|
||||
|
||||
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
|
||||
extern void png_write_destroy PNGARG((png_structp png_ptr));
|
||||
PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
|
||||
|
||||
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
|
||||
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
||||
PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
||||
int check));
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -218,30 +218,8 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
||||
if (png_ptr->sig_bytes < 8)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
num_to_check = 8 - num_checked;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
|
||||
#endif
|
||||
|
||||
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
|
||||
png_ptr->sig_bytes = 8;
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
if (num_checked < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
/* Read and check the PNG file signature. */
|
||||
png_read_sig(png_ptr, info_ptr);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -524,6 +502,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
|
@ -534,6 +513,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ((png_ptr->row_number & 0x07) != 4)
|
||||
{
|
||||
|
@ -544,6 +524,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
|
||||
{
|
||||
|
@ -554,6 +535,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ((png_ptr->row_number & 3) != 2)
|
||||
{
|
||||
|
@ -564,6 +546,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
|
||||
{
|
||||
|
@ -574,6 +557,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 6:
|
||||
if (!(png_ptr->row_number & 1))
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.4.2 [May 6, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||
break;
|
||||
|
||||
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
|
||||
break;
|
||||
}
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
|
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
case 8:
|
||||
|
||||
case 16:
|
||||
|
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
gs = 1.0 / (png_ptr->background_gamma *
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid background gamma type");
|
||||
}
|
||||
|
||||
png_ptr->background_1.gray = (png_uint_16)(pow(
|
||||
|
@ -1626,6 +1636,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
|
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
|||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
png_bytep bp;
|
||||
|
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
|
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3522,6 +3547,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8;
|
||||
|
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.3 [June 26, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -23,50 +23,98 @@
|
|||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
||||
{
|
||||
png_uint_32 i = png_get_uint_32(buf);
|
||||
if (i > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
return (i);
|
||||
}
|
||||
#ifndef PNG_USE_READ_MACROS
|
||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_32(png_bytep buf)
|
||||
{
|
||||
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
|
||||
((png_uint_32)(*(buf + 1)) << 16) +
|
||||
((png_uint_32)(*(buf + 2)) << 8) +
|
||||
(png_uint_32)(*(buf + 3));
|
||||
png_uint_32 val = png_get_uint_32(buf);
|
||||
|
||||
return (i);
|
||||
if (val > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
return (val);
|
||||
}
|
||||
|
||||
#ifndef PNG_USE_READ_MACROS
|
||||
/* The parentheses around "PNGAPI function_name" in the following three
|
||||
* functions are necessary because they allow the macros to co-exist with
|
||||
* these (unused but exported) functions.
|
||||
*/
|
||||
|
||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||
png_uint_32 (PNGAPI
|
||||
png_get_uint_32)(png_bytep buf)
|
||||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000L) == 0) /* non-negative */
|
||||
return uval;
|
||||
|
||||
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
|
||||
return -(png_int_32)uval;
|
||||
}
|
||||
|
||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
|
||||
* data is stored in the PNG file in two's complement format, and it is
|
||||
* assumed that the machine format for signed integers is the same.
|
||||
* data is stored in the PNG file in two's complement format and there
|
||||
* is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
|
||||
* the following code does a two's complement to native conversion.
|
||||
*/
|
||||
png_int_32 PNGAPI
|
||||
png_get_int_32(png_bytep buf)
|
||||
png_int_32 (PNGAPI
|
||||
png_get_int_32)(png_bytep buf)
|
||||
{
|
||||
png_int_32 i = ((png_int_32)(*buf) << 24) +
|
||||
((png_int_32)(*(buf + 1)) << 16) +
|
||||
((png_int_32)(*(buf + 2)) << 8) +
|
||||
(png_int_32)(*(buf + 3));
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000L) == 0) /* non-negative */
|
||||
return uval;
|
||||
|
||||
return (i);
|
||||
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
|
||||
return -(png_int_32)uval;
|
||||
}
|
||||
|
||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||
png_uint_16 PNGAPI
|
||||
png_get_uint_16(png_bytep buf)
|
||||
png_uint_16 (PNGAPI
|
||||
png_get_uint_16)(png_bytep buf)
|
||||
{
|
||||
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1)));
|
||||
/* ANSI-C requires an int value to accomodate at least 16 bits so this
|
||||
* works and allows the compiler not to worry about possible narrowing
|
||||
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* than 16 bits either.)
|
||||
*/
|
||||
unsigned int val =
|
||||
((unsigned int)(*buf) << 8) +
|
||||
((unsigned int)(*(buf + 1)));
|
||||
|
||||
return (i);
|
||||
return (png_uint_16)val;
|
||||
}
|
||||
#endif /* PNG_USE_READ_MACROS */
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
void /* PRIVATE */
|
||||
png_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_size_t num_checked, num_to_check;
|
||||
|
||||
/* Exit if the user application does not expect a signature. */
|
||||
if (png_ptr->sig_bytes >= 8)
|
||||
return;
|
||||
|
||||
num_checked = png_ptr->sig_bytes;
|
||||
num_to_check = 8 - num_checked;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
|
||||
#endif
|
||||
|
||||
/* The signature must be serialized in a single I/O call. */
|
||||
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
|
||||
png_ptr->sig_bytes = 8;
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
if (num_checked < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
/* Read the chunk header (length + type name).
|
||||
* Put the type name into png_ptr->chunk_name, and return the length.
|
||||
*/
|
||||
|
@ -77,32 +125,31 @@ png_read_chunk_header(png_structp png_ptr)
|
|||
png_uint_32 length;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that the chunk header is being read.
|
||||
* PNG_IO_CHUNK_HDR requires a single I/O call.
|
||||
*/
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
|
||||
#endif
|
||||
|
||||
/* Read the length and the chunk name */
|
||||
/* Read the length and the chunk name.
|
||||
* This must be performed in a single I/O call.
|
||||
*/
|
||||
png_read_data(png_ptr, buf, 8);
|
||||
length = png_get_uint_31(png_ptr, buf);
|
||||
|
||||
/* Put the chunk name into png_ptr->chunk_name */
|
||||
/* Put the chunk name into png_ptr->chunk_name. */
|
||||
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
|
||||
|
||||
png_debug2(0, "Reading %s chunk, length = %lu",
|
||||
png_ptr->chunk_name, length);
|
||||
|
||||
/* Reset the crc and run it over the chunk name */
|
||||
/* Reset the crc and run it over the chunk name. */
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
|
||||
|
||||
/* Check to see if chunk name is valid */
|
||||
/* Check to see if chunk name is valid. */
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that chunk data will (possibly) be read.
|
||||
* PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
|
||||
/* It is unspecified how many I/O calls will be performed
|
||||
* during the serialization of the chunk data.
|
||||
*/
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||
#endif
|
||||
|
@ -116,6 +163,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
|
|||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_read_data(png_ptr, buf, length);
|
||||
png_calculate_crc(png_ptr, buf, length);
|
||||
}
|
||||
|
@ -135,6 +183,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
|||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, i);
|
||||
|
@ -149,11 +198,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
|||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "CRC error");
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -176,6 +227,7 @@ png_crc_error(png_structp png_ptr)
|
|||
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||
need_crc = 0;
|
||||
}
|
||||
|
||||
else /* critical */
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
|
||||
|
@ -183,11 +235,10 @@ png_crc_error(png_structp png_ptr)
|
|||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that the chunk CRC is being read */
|
||||
/* PNG_IO_CHUNK_CRC requires the I/O to be done at once */
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
|
||||
#endif
|
||||
|
||||
/* The chunk CRC must be serialized in a single I/O call. */
|
||||
png_read_data(png_ptr, crc_bytes, 4);
|
||||
|
||||
if (need_crc)
|
||||
|
@ -195,6 +246,7 @@ png_crc_error(png_structp png_ptr)
|
|||
crc = png_get_uint_32(crc_bytes);
|
||||
return ((int)(crc != png_ptr->crc));
|
||||
}
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
@ -234,6 +286,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||
if (avail < copy) copy = avail;
|
||||
png_memcpy(output + count, png_ptr->zbuf, copy);
|
||||
}
|
||||
|
||||
count += avail;
|
||||
}
|
||||
|
||||
|
@ -267,9 +320,11 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||
case Z_BUF_ERROR:
|
||||
msg = "Buffer error in compressed datastream in %s chunk";
|
||||
break;
|
||||
|
||||
case Z_DATA_ERROR:
|
||||
msg = "Data error in compressed datastream in %s chunk";
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = "Incomplete compressed datastream in %s chunk";
|
||||
break;
|
||||
|
@ -369,6 +424,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||
png_warning(png_ptr, "png_inflate logic error");
|
||||
png_free(png_ptr, text);
|
||||
}
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Not enough memory to decompress chunk");
|
||||
}
|
||||
|
@ -1128,12 +1184,13 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
|
||||
if (profile_size > profile_length)
|
||||
{
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
char umsg[50];
|
||||
#endif
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
png_warning(png_ptr, "Ignoring truncated iCCP profile");
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
{
|
||||
char umsg[50];
|
||||
|
||||
png_snprintf(umsg, 50, "declared profile size = %lu",
|
||||
(unsigned long)profile_size);
|
||||
|
@ -1141,7 +1198,6 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
png_snprintf(umsg, 50, "actual profile length = %lu",
|
||||
(unsigned long)profile_length);
|
||||
png_warning(png_ptr, umsg);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1875,9 +1931,6 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
png_warning(png_ptr, "malformed height string in sCAL chunk");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, swidth);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
@ -1888,9 +1941,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, swidth);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
png_memcpy(sheight, ep, png_strlen(ep));
|
||||
|
@ -3111,17 +3162,10 @@ png_read_finish_row(png_structp png_ptr)
|
|||
{
|
||||
while (!png_ptr->idat_size)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
|
||||
png_crc_finish(png_ptr, 0);
|
||||
|
||||
png_read_data(png_ptr, chunk_length, 4);
|
||||
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
|
||||
}
|
||||
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_in = png_ptr->zbuf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -690,6 +690,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
if (text_ptr[i].key == NULL)
|
||||
continue;
|
||||
|
||||
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
|
||||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "text compression mode is out of range");
|
||||
continue;
|
||||
}
|
||||
|
||||
key_len = png_strlen(text_ptr[i].key);
|
||||
|
||||
if (text_ptr[i].compression <= 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -263,6 +263,48 @@ static int wrote_question = 0;
|
|||
* than changing the library.
|
||||
*/
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op);
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op)
|
||||
{
|
||||
png_uint_32 io_state = png_get_io_state(png_ptr);
|
||||
int err = 0;
|
||||
|
||||
/* Check if the current operation (reading / writing) is as expected. */
|
||||
if ((io_state & PNG_IO_MASK_OP) != io_op)
|
||||
png_error(png_ptr, "Incorrect operation in I/O state");
|
||||
|
||||
/* Check if the buffer size specific to the current location
|
||||
* (file signature / header / data / crc) is as expected.
|
||||
*/
|
||||
switch (io_state & PNG_IO_MASK_LOC)
|
||||
{
|
||||
case PNG_IO_SIGNATURE:
|
||||
if (data_length > 8)
|
||||
err = 1;
|
||||
break;
|
||||
case PNG_IO_CHUNK_HDR:
|
||||
if (data_length != 8)
|
||||
err = 1;
|
||||
break;
|
||||
case PNG_IO_CHUNK_DATA:
|
||||
break; /* no restrictions here */
|
||||
case PNG_IO_CHUNK_CRC:
|
||||
if (data_length != 4)
|
||||
err = 1;
|
||||
break;
|
||||
default:
|
||||
err = 1; /* uninitialized */
|
||||
}
|
||||
if (err)
|
||||
png_error(png_ptr, "Bad I/O state or buffer size");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
|
@ -281,8 +323,12 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error!");
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
|
@ -302,7 +348,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
|
@ -328,7 +374,11 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
png_error(png_ptr, "read Error");
|
||||
png_error(png_ptr, "Read Error");
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
@ -351,12 +401,18 @@ static void
|
|||
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_FILE_p io_ptr;
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
||||
check = fwrite(data, 1, length, io_ptr);
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
|
@ -405,6 +461,10 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
@ -1627,4 +1687,4 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_4_3 your_png_h_is_not_version_1_4_3;
|
||||
typedef version_1_4_5 your_png_h_is_not_version_1_4_5;
|
||||
|
|
|
@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = (png_byte)bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||
|
|
|
@ -246,10 +246,12 @@ png_text_compress(png_structp png_ptr,
|
|||
*/
|
||||
|
||||
/* Set up the compression buffers */
|
||||
/* TODO: the following cast hides a potential overflow problem. */
|
||||
png_ptr->zstream.avail_in = (uInt)text_len;
|
||||
/* NOTE: assume zlib doesn't overwrite the input */
|
||||
png_ptr->zstream.next_in = (Bytef *)text;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
|
||||
/* This is the same compression loop as in png_write_row() */
|
||||
do
|
||||
|
|
Loading…
Reference in New Issue