Commit 11101b6f authored by Adrià Arrufat's avatar Adrià Arrufat Committed by Davis E. King
Browse files

update libpng to version 1.6.37

parent 23e50632
README for libpng version 1.6.7 - November 14, 2013 (shared library 16.0) README for libpng version 1.6.37 - April 14, 2019
See the note about version numbers near the top of png.h =================================================
See the note about version numbers near the top of png.h.
See INSTALL for instructions on how to install libpng. See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz or Libpng comes in several distribution formats. Get libpng-*.tar.gz or
libpng-*.tar.xz or if you want UNIX-style line endings in the text files, libpng-*.tar.xz or if you want UNIX-style line endings in the text
or lpng*.7z or lpng*.zip if you want DOS-style line endings. files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in fact that it's the first release fool you. The libpng library has been
extensive use and testing since mid-1995. By late 1997 it had in extensive use and testing since mid-1995. By late 1997 it had
finally gotten to the stage where there hadn't been significant finally gotten to the stage where there hadn't been significant
changes to the API in some time, and people have a bad feeling about changes to the API in some time, and people have a bad feeling about
libraries with versions < 1.0. Version 1.0.0 was released in libraries with versions < 1.0. Version 1.0.0 was released in
...@@ -23,18 +24,25 @@ earlier versions if you are using a shared library. The type of the ...@@ -23,18 +24,25 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use png_uint_32, which will affect shared-library applications that use
this function. this function.
To avoid problems with changes to the internals of png_info_struct, To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when png_get_<chunk> functions. These functions should be used when
accessing/storing the info_struct data, rather than manipulating it accessing/storing the info_struct data, rather than manipulating it
directly, to avoid such problems in the future. directly, to avoid such problems in the future.
It is important to note that the APIs do not make current programs It is important to note that the APIs did not make current programs
that access the info struct directly incompatible with the new that access the info struct directly incompatible with the new
library. However, it is strongly suggested that new programs use library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
the new APIs (as shown in example.c and pngtest.c), and older programs be a transitional release, members of the png_struct and the
be converted to the new format, to facilitate upgrades in the future. info_struct can still be accessed, but the compiler will issue a
warning about deprecated usage. Since libpng-1.5.0, direct access
to these structs is not allowed, and the definitions of the structs
reside in private pngstruct.h and pnginfo.h header files that are not
accessible to applications. It is strongly suggested that new
programs use the new APIs (as shown in example.c and pngtest.c), and
older programs be converted to the new format, to facilitate upgrades
in the future.
**** ****
Additions since 0.90 include the ability to compile libpng as a Additions since 0.90 include the ability to compile libpng as a
...@@ -53,88 +61,59 @@ the library action on the detection of chunk CRC errors. It is possible ...@@ -53,88 +61,59 @@ the library action on the detection of chunk CRC errors. It is possible
to set different actions based on whether the CRC error occurred in a to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk. critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions For a detailed description on using libpng, read libpng-manual.txt.
on the PNG-implement mailing list and not on material submitted For examples of libpng in a program, see example.c and pngtest.c. For
privately to Guy, Andreas, or Glenn. They will forward any good usage information and restrictions (what little they are) on libpng,
suggestions to the list. see png.h. For a description on using zlib (the compression library
used by libpng) and zlib's restrictions, see zlib.h
For a detailed description on using libpng, read libpng-manual.txt. For
examples of libpng in a program, see example.c and pngtest.c. For usage
information and restrictions (what little they are) on libpng, see
png.h. For a description on using zlib (the compression library used by
libpng) and zlib's restrictions, see zlib.h
I have included a general makefile, as well as several machine and I have included a general makefile, as well as several machine and
compiler specific ones, but you may have to modify one for your own needs. compiler specific ones, but you may have to modify one for your own
needs.
You should use zlib 1.0.4 or later to run this, but it MAY work with You should use zlib 1.0.4 or later to run this, but it MAY work with
versions as old as zlib 0.95. Even so, there are bugs in older zlib versions as old as zlib 0.95. Even so, there are bugs in older zlib
versions which can cause the output of invalid compression streams for versions which can cause the output of invalid compression streams for
some images. You will definitely need zlib 1.0.4 or later if you are some images.
taking advantage of the MS-DOS "far" structure allocation for the small
and medium memory models. You should also note that zlib is a You should also note that zlib is a compression library that is useful
compression library that is useful for more things than just PNG files. for more things than just PNG files. You can use zlib as a drop-in
You can use zlib as a drop-in replacement for fread() and fwrite() if replacement for fread() and fwrite(), if you are so inclined.
you are so inclined.
zlib should be available at the same place that libpng is, or at zlib.net. zlib should be available at the same place that libpng is, or at
https://zlib.net.
You may also want a copy of the PNG specification. It is available You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/ these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sf.net in the This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it [DOWNLOAD] area, and at http://libpng.download/src .
in any of those places, e-mail me, and I'll help you find it.
This release, based in a large way on Glenn's, Guy's and Andreas'
If you have any code changes, requests, problems, etc., please e-mail earlier work, was created and will be supported by myself and the PNG
them to me. Also, I'd appreciate any make files or project files,
and any modifications you needed to make to get libpng to compile,
along with a #define variable to tell what compiler/system you are on.
If you needed to add transformations to libpng, or wish libpng would
provide the image in a different way, drop me a note (and code, if
possible), so I can consider supporting the transformation.
Finally, if you get any warning messages when compiling libpng
(note: not zlib), and they are easy to fix, I'd appreciate the
fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG
development group. development group.
Send comments/corrections/commendations to png-mng-implement at Send comments/corrections/commendations to png-mng-implement at
lists.sourceforge.net (subscription required; visit lists.sourceforge.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net to subscribe).
You can't reach Guy, the original libpng author, at the addresses Send general questions about the PNG specification to png-mng-misc
given in previous versions of this document. He and Andreas will at lists.sourceforge.net (subscription required; visit
read mail addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
png-mng-misc at lists.sf.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
subscribe). If you have a question about something subscribe).
in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng,
and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for eighteen years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.
Files in this distribution: Files in this distribution:
ANNOUNCE => Announcement of this version, with recent changes ANNOUNCE => Announcement of this version, with recent changes
AUTHORS => List of contributing authors
CHANGES => Description of changes between libpng versions CHANGES => Description of changes between libpng versions
KNOWNBUG => List of known bugs and deficiencies KNOWNBUG => List of known bugs and deficiencies
LICENSE => License to use and redistribute libpng LICENSE => License to use and redistribute libpng
README => This file README => This file
TODO => Things not implemented in the current library TODO => Things not implemented in the current library
Y2KINFO => Statement of Y2K compliance TRADEMARK => Trademark information
example.c => Example code for using libpng functions example.c => Example code for using libpng functions
libpng.3 => manual page for libpng (includes libpng-manual.txt) libpng.3 => manual page for libpng (includes libpng-manual.txt)
libpng-manual.txt => Description of libpng and its functions libpng-manual.txt => Description of libpng and its functions
...@@ -166,18 +145,25 @@ Files in this distribution: ...@@ -166,18 +145,25 @@ Files in this distribution:
pngwtran.c => Write data transformations pngwtran.c => Write data transformations
pngwutil.c => Write utility functions pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform arm => Contains optimized code for the ARM platform
powerpc => Contains optimized code for the PowerPC platform
contrib => Contributions contrib => Contributions
arm-neon => Optimized code for ARM-NEON platform
powerpc-vsx => Optimized code for POWERPC-VSX platform
examples => Example programs examples => Example programs
gregbook => source code for PNG reading and writing, from gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide", Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999 O'Reilly, 1999
libtests => Test programs libtests => Test programs
mips-msa => Optimized code for MIPS-MSA platform
pngminim => Minimal decoder, encoder, and progressive decoder pngminim => Minimal decoder, encoder, and progressive decoder
programs demonstrating use of pngusr.dfa programs demonstrating use of pngusr.dfa
pngminus => Simple pnm2png and png2pnm programs pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images pngsuite => Test images
testpngs
tools => Various tools tools => Various tools
visupng => Contains a MSVC workspace for VisualPng visupng => Contains a MSVC workspace for VisualPng
intel => Optimized code for INTEL-SSE2 platform
mips => Optimized code for MIPS platform
projects => Contains project files and workspaces for projects => Contains project files and workspaces for
building a DLL building a DLL
owatcom => Contains a WATCOM project for building libpng owatcom => Contains a WATCOM project for building libpng
...@@ -188,15 +174,10 @@ Files in this distribution: ...@@ -188,15 +174,10 @@ Files in this distribution:
scripts => Directory containing scripts for building libpng: scripts => Directory containing scripts for building libpng:
(see scripts/README.txt for the list of scripts) (see scripts/README.txt for the list of scripts)
Good luck, and happy coding. Good luck, and happy coding!
-Glenn Randers-Pehrson (current maintainer, since 1998)
Internet: glennrp at users.sourceforge.net
-Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
-Guy Eric Schalnat (original author and former maintainer, 1995-1996) * Cosmin Truta (current maintainer, since 2018)
(formerly of Group 42, Inc) * Glenn Randers-Pehrson (former maintainer, 1998-2018)
Internet: gschal at infinet.com * Andreas Eric Dilger (former maintainer, 1996-1997)
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc.)
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
*
* Copyright (c) 2018-2019 Cosmin Truta
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
* Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#include "../pngpriv.h"
#if PNG_ARM_NEON_IMPLEMENTATION == 1
#if defined(_MSC_VER) && defined(_M_ARM64)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
void
png_riffle_palette_neon(png_structrp png_ptr)
{
png_const_colorp palette = png_ptr->palette;
png_bytep riffled_palette = png_ptr->riffled_palette;
png_const_bytep trans_alpha = png_ptr->trans_alpha;
int num_trans = png_ptr->num_trans;
int i;
png_debug(1, "in png_riffle_palette_neon");
/* Initially black, opaque. */
uint8x16x4_t w = {{
vdupq_n_u8(0x00),
vdupq_n_u8(0x00),
vdupq_n_u8(0x00),
vdupq_n_u8(0xff),
}};
/* First, riffle the RGB colours into an RGBA8 palette.
* The alpha component is set to opaque for now.
*/
for (i = 0; i < 256; i += 16)
{
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
w.val[0] = v.val[0];
w.val[1] = v.val[1];
w.val[2] = v.val[2];
vst4q_u8(riffled_palette + (i << 2), w);
}
/* Fix up the missing transparency values. */
for (i = 0; i < num_trans; i++)
riffled_palette[(i << 2) + 3] = trans_alpha[i];
}
/* Expands a palettized row into RGBA8. */
int
png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
{
png_uint_32 row_width = row_info->width;
const png_uint_32 *riffled_palette =
(const png_uint_32 *)png_ptr->riffled_palette;
const png_int_32 pixels_per_chunk = 4;
int i;
png_debug(1, "in png_do_expand_palette_rgba8_neon");
if (row_width < pixels_per_chunk)
return 0;
/* This function originally gets the last byte of the output row.
* The NEON part writes forward from a given position, so we have
* to seek this back by 4 pixels x 4 bytes.
*/
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
for (i = 0; i < row_width; i += pixels_per_chunk)
{
uint32x4_t cur;
png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
vst1q_u32((void *)dp, cur);
}
if (i != row_width)
{
/* Remove the amount that wasn't processed. */
i -= pixels_per_chunk;
}
/* Decrement output pointers. */
*ssp = *ssp - i;
*ddp = *ddp - (i << 2);
return i;
}
/* Expands a palettized row into RGB8. */
int
png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
{
png_uint_32 row_width = row_info->width;
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
const png_uint_32 pixels_per_chunk = 8;
int i;
png_debug(1, "in png_do_expand_palette_rgb8_neon");
if (row_width <= pixels_per_chunk)
return 0;
/* Seeking this back by 8 pixels x 3 bytes. */
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
for (i = 0; i < row_width; i += pixels_per_chunk)
{
uint8x8x3_t cur;
png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
vst3_u8((void *)dp, cur);
}
if (i != row_width)
{
/* Remove the amount that wasn't processed. */
i -= pixels_per_chunk;
}
/* Decrement output pointers. */
*ssp = *ssp - i;
*ddp = *ddp - ((i << 1) + i);
return i;
}
#endif /* PNG_ARM_NEON_IMPLEMENTATION */
This diff is collapsed.
This diff is collapsed.
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine-configurable file for libpng
* *
* libpng version 1.6.7 - November 14, 2013 * libpng version 1.6.37
* *
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 2018-2019 Cosmin Truta
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
* and license in png.h * 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
* are configuring libpng for a machine, you may want to read the section * are configuring libpng for a machine, you may want to read the section
* starting here down to where it starts to typedef png_color, png_text, * starting here down to where it starts to typedef png_color, png_text,
* and png_info. * and png_info.
*/ */
#ifdef _MSC_VER
// Disable the following warnings for Visual Studio
// This is a warning you get from visual studio 2005 about things in the standard C++
// library being "deprecated." I checked the C++ standard and it doesn't say jack
// about any of them (I checked the searchable PDF). So this warning is total Bunk.
#pragma warning(disable : 4996)
#endif
#ifndef PNGCONF_H #ifndef PNGCONF_H
#define PNGCONF_H #define PNGCONF_H
/* To do: Do all of this in scripts/pnglibconf.dfa */
#ifdef PNG_SAFE_LIMITS_SUPPORTED
# ifdef PNG_USER_WIDTH_MAX
# undef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000L
# endif
# ifdef PNG_USER_HEIGHT_MAX
# undef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000L
# endif
# ifdef PNG_USER_CHUNK_MALLOC_MAX
# undef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
# endif
# ifdef PNG_USER_CHUNK_CACHE_MAX
# undef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
#endif
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
...@@ -88,14 +58,13 @@ ...@@ -88,14 +58,13 @@
#endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNG_BUILDING_SYMBOL_TABLE */
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using /* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
* PNG_NO_CONST; this is no longer supported except for data declarations which * using PNG_NO_CONST. This is no longer supported.
* apparently still cause problems in 2011 on some compilers.
*/ */
#define PNG_CONST const /* backward compatibility only */ #define PNG_CONST const /* backward compatibility only */
/* This controls optimization of the reading of 16 and 32 bit values /* This controls optimization of the reading of 16-bit and 32-bit
* from PNG files. It can be set on a per-app-file basis - it * values from PNG files. It can be set on a per-app-file basis: it
* just changes whether a macro is used when the function is called. * just changes whether a macro is used when the function is called.
* The library builder sets the default; if read functions are not * The library builder sets the default; if read functions are not
* built into the library the macro implementation is forced on. * built into the library the macro implementation is forced on.
...@@ -158,7 +127,7 @@ ...@@ -158,7 +127,7 @@
* *
* These cases only differ if the operating system does not use the C * These cases only differ if the operating system does not use the C
* calling convention, at present this just means the above cases * calling convention, at present this just means the above cases
* (x86 DOS/Windows sytems) and, even then, this does not apply to * (x86 DOS/Windows systems) and, even then, this does not apply to
* Cygwin running on those systems. * Cygwin running on those systems.
* *
* Note that the value must be defined in pnglibconf.h so that what * Note that the value must be defined in pnglibconf.h so that what
...@@ -326,11 +295,11 @@ ...@@ -326,11 +295,11 @@
* table entries, so we discard it here. See the .dfn files in the * table entries, so we discard it here. See the .dfn files in the
* scripts directory. * scripts directory.
*/ */
#ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ #ifndef PNG_EXPORTA
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ # define PNG_EXPORTA(ordinal, type, name, args, attributes) \
extern attributes) PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
PNG_LINKAGE_API attributes)
#endif #endif
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
...@@ -338,7 +307,7 @@ ...@@ -338,7 +307,7 @@
*/ */
#define PNG_EMPTY /*empty list*/ #define PNG_EMPTY /*empty list*/
#define PNG_EXPORT(ordinal, type, name, args)\ #define PNG_EXPORT(ordinal, type, name, args) \
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
/* Use PNG_REMOVED to comment out a removed interface. */ /* Use PNG_REMOVED to comment out a removed interface. */
...@@ -370,7 +339,33 @@ ...@@ -370,7 +339,33 @@
* version 1.2.41. Disabling these removes the warnings but may also produce * version 1.2.41. Disabling these removes the warnings but may also produce
* less efficient code. * less efficient code.
*/ */
# if defined(__GNUC__) # if defined(__clang__) && defined(__has_attribute)
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
# endif
# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)
# define PNG_NORETURN __attribute__((__noreturn__))
# endif
# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)
# define PNG_ALLOCATED __attribute__((__malloc__))
# endif
# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)
# define PNG_DEPRECATED __attribute__((__deprecated__))
# endif
# if !defined(PNG_PRIVATE)
# ifdef __has_extension
# if __has_extension(attribute_unavailable_with_message)
# define PNG_PRIVATE __attribute__((__unavailable__(\
"This function is not exported by libpng.")))
# endif
# endif
# endif
# ifndef PNG_RESTRICT
# define PNG_RESTRICT __restrict
# endif
# elif defined(__GNUC__)
# ifndef PNG_USE_RESULT # ifndef PNG_USE_RESULT
# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # define PNG_USE_RESULT __attribute__((__warn_unused_result__))
# endif # endif
...@@ -393,11 +388,11 @@ ...@@ -393,11 +388,11 @@
__attribute__((__deprecated__)) __attribute__((__deprecated__))
# endif # endif
# endif # endif
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
# ifndef PNG_RESTRICT # ifndef PNG_RESTRICT
# define PNG_RESTRICT __restrict # define PNG_RESTRICT __restrict
# endif # endif
# endif /* __GNUC__ == 3.0 */ # endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */
# endif /* __GNUC__ >= 3 */ # endif /* __GNUC__ >= 3 */
# elif defined(_MSC_VER) && (_MSC_VER >= 1300) # elif defined(_MSC_VER) && (_MSC_VER >= 1300)
...@@ -428,7 +423,7 @@ ...@@ -428,7 +423,7 @@
# ifndef PNG_RESTRICT # ifndef PNG_RESTRICT
# define PNG_RESTRICT __restrict # define PNG_RESTRICT __restrict
# endif # endif
# endif /* _MSC_VER */ # endif
#endif /* PNG_PEDANTIC_WARNINGS */ #endif /* PNG_PEDANTIC_WARNINGS */
#ifndef PNG_DEPRECATED #ifndef PNG_DEPRECATED
...@@ -449,6 +444,7 @@ ...@@ -449,6 +444,7 @@
#ifndef PNG_RESTRICT #ifndef PNG_RESTRICT
# define PNG_RESTRICT /* The C99 "restrict" feature */ # define PNG_RESTRICT /* The C99 "restrict" feature */
#endif #endif
#ifndef PNG_FP_EXPORT /* A floating point API. */ #ifndef PNG_FP_EXPORT /* A floating point API. */
# ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
# define PNG_FP_EXPORT(ordinal, type, name, args)\ # define PNG_FP_EXPORT(ordinal, type, name, args)\
...@@ -484,7 +480,7 @@ ...@@ -484,7 +480,7 @@
#if CHAR_BIT == 8 && UCHAR_MAX == 255 #if CHAR_BIT == 8 && UCHAR_MAX == 255
typedef unsigned char png_byte; typedef unsigned char png_byte;
#else #else
# error "libpng requires 8 bit bytes" # error "libpng requires 8-bit bytes"
#endif #endif
#if INT_MIN == -32768 && INT_MAX == 32767 #if INT_MIN == -32768 && INT_MAX == 32767
...@@ -492,7 +488,7 @@ ...@@ -492,7 +488,7 @@
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 #elif SHRT_MIN == -32768 && SHRT_MAX == 32767
typedef short png_int_16; typedef short png_int_16;
#else #else
# error "libpng requires a signed 16 bit type" # error "libpng requires a signed 16-bit type"
#endif #endif
#if UINT_MAX == 65535 #if UINT_MAX == 65535
...@@ -500,7 +496,7 @@ ...@@ -500,7 +496,7 @@
#elif USHRT_MAX == 65535 #elif USHRT_MAX == 65535
typedef unsigned short png_uint_16; typedef unsigned short png_uint_16;
#else #else
# error "libpng requires an unsigned 16 bit type" # error "libpng requires an unsigned 16-bit type"
#endif #endif
#if INT_MIN < -2147483646 && INT_MAX > 2147483646 #if INT_MIN < -2147483646 && INT_MAX > 2147483646
...@@ -508,19 +504,21 @@ ...@@ -508,19 +504,21 @@
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
typedef long int png_int_32; typedef long int png_int_32;
#else #else
# error "libpng requires a signed 32 bit (or more) type" # error "libpng requires a signed 32-bit (or more) type"
#endif #endif
#if UINT_MAX > 4294967294 #if UINT_MAX > 4294967294U
typedef unsigned int png_uint_32; typedef unsigned int png_uint_32;
#elif ULONG_MAX > 4294967294 #elif ULONG_MAX > 4294967294U
typedef unsigned long int png_uint_32; typedef unsigned long int png_uint_32;
#else #else
# error "libpng requires an unsigned 32 bit (or more) type" # error "libpng requires an unsigned 32-bit (or more) type"
#endif #endif
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, /* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.
* requires an ISOC90 compiler and relies on consistent behavior of sizeof. * From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant
* behavior of sizeof and ptrdiff_t are required.
* The legacy typedefs are provided here for backwards compatibility.
*/ */
typedef size_t png_size_t; typedef size_t png_size_t;
typedef ptrdiff_t png_ptrdiff_t; typedef ptrdiff_t png_ptrdiff_t;
...@@ -541,13 +539,12 @@ typedef ptrdiff_t png_ptrdiff_t; ...@@ -541,13 +539,12 @@ typedef ptrdiff_t png_ptrdiff_t;
# endif # endif
#endif #endif
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no /* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to * than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are
* png_alloc_size_t are not necessary; in fact, it is recommended not to use * not necessary; in fact, it is recommended not to use them at all, so that
* them at all so that the compiler can complain when something turns out to be * the compiler can complain when something turns out to be problematic.
* problematic.
* *
* Casts in the other direction (from png_alloc_size_t to png_size_t or * Casts in the other direction (from png_alloc_size_t to size_t or
* png_uint_32) should be explicitly applied; however, we do not expect to * png_uint_32) should be explicitly applied; however, we do not expect to
* encounter practical situations that require such conversions. * encounter practical situations that require such conversions.
* *
...@@ -557,7 +554,7 @@ typedef ptrdiff_t png_ptrdiff_t; ...@@ -557,7 +554,7 @@ typedef ptrdiff_t png_ptrdiff_t;
#ifdef PNG_SMALL_SIZE_T #ifdef PNG_SMALL_SIZE_T
typedef png_uint_32 png_alloc_size_t; typedef png_uint_32 png_alloc_size_t;
#else #else
typedef png_size_t png_alloc_size_t; typedef size_t png_alloc_size_t;
#endif #endif
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
...@@ -593,8 +590,8 @@ typedef char * png_charp; ...@@ -593,8 +590,8 @@ typedef char * png_charp;
typedef const char * png_const_charp; typedef const char * png_const_charp;
typedef png_fixed_point * png_fixed_point_p; typedef png_fixed_point * png_fixed_point_p;
typedef const png_fixed_point * png_const_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p;
typedef png_size_t * png_size_tp; typedef size_t * png_size_tp;
typedef const png_size_t * png_const_size_tp; typedef const size_t * png_const_size_tp;
#ifdef PNG_STDIO_SUPPORTED #ifdef PNG_STDIO_SUPPORTED
typedef FILE * png_FILE_p; typedef FILE * png_FILE_p;
......
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
* *
* Copyright (c) 1998-2011 Glenn Randers-Pehrson * Copyright (c) 2018 Cosmin Truta
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * Copyright (c) 1996-1997 Andreas Dilger
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
* Last changed in libpng 1.5.0 [January 6, 2011]
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
* (actually ((void)0)). * (actually ((void)0)).
* *
* level: level of detail of message, starting at 0. A level 'n' * level: level of detail of message, starting at 0. A level 'n'
* message is preceded by 'n' tab characters (not implemented * message is preceded by 'n' 3-space indentations (not implemented
* on Microsoft compilers unless PNG_DEBUG_FILE is also * on Microsoft compilers unless PNG_DEBUG_FILE is also
* defined, to allow debug DLL compilation with no standard IO). * defined, to allow debug DLL compilation with no standard IO).
* message: a printf(3) style text string. A trailing '\n' is added * message: a printf(3) style text string. A trailing '\n' is added
...@@ -77,32 +76,29 @@ ...@@ -77,32 +76,29 @@
# endif /* PNG_DEBUG_FILE */ # endif /* PNG_DEBUG_FILE */
# if (PNG_DEBUG > 1) # if (PNG_DEBUG > 1)
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
* non-ISO compilers
*/
# ifdef __STDC__ # ifdef __STDC__
# ifndef png_debug # ifndef png_debug
# define png_debug(l,m) \ # define png_debug(l,m) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
} while (0) } while (0)
# endif # endif
# ifndef png_debug1 # ifndef png_debug1
# define png_debug1(l,m,p1) \ # define png_debug1(l,m,p1) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
} while (0) } while (0)
# endif # endif
# ifndef png_debug2 # ifndef png_debug2
# define png_debug2(l,m,p1,p2) \ # define png_debug2(l,m,p1,p2) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
} while (0) } while (0)
# endif # endif
# else /* __STDC __ */ # else /* __STDC __ */
......
This diff is collapsed.
This diff is collapsed.
/* pnginfo.h - header file for PNG reference library /* pnginfo.h - header file for PNG reference library
* *
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 2018 Cosmin Truta
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * Copyright (c) 1996-1997 Andreas Dilger
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
* Last changed in libpng 1.6.1 [March 28, 2013]
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
...@@ -59,7 +58,7 @@ struct png_info_def ...@@ -59,7 +58,7 @@ struct png_info_def
png_uint_32 width; /* width of image in pixels (from IHDR) */ png_uint_32 width; /* width of image in pixels (from IHDR) */
png_uint_32 height; /* height of image in pixels (from IHDR) */ png_uint_32 height; /* height of image in pixels (from IHDR) */
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
png_size_t rowbytes; /* bytes needed to hold an untransformed row */ size_t rowbytes; /* bytes needed to hold an untransformed row */
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
...@@ -121,7 +120,7 @@ struct png_info_def ...@@ -121,7 +120,7 @@ struct png_info_def
int num_text; /* number of comments read or comments to write */ int num_text; /* number of comments read or comments to write */
int max_text; /* current size of text array */ int max_text; /* current size of text array */
png_textp text; /* array of comments read or comments to write */ png_textp text; /* array of comments read or comments to write */
#endif /* PNG_TEXT_SUPPORTED */ #endif /* TEXT */
#ifdef PNG_tIME_SUPPORTED #ifdef PNG_tIME_SUPPORTED
/* The tIME chunk holds the last time the displayed image data was /* The tIME chunk holds the last time the displayed image data was
...@@ -186,6 +185,14 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) ...@@ -186,6 +185,14 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
#endif #endif
#ifdef PNG_eXIf_SUPPORTED
int num_exif; /* Added at libpng-1.6.31 */
png_bytep exif;
# ifdef PNG_READ_eXIf_SUPPORTED
png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
# endif
#endif
#ifdef PNG_hIST_SUPPORTED #ifdef PNG_hIST_SUPPORTED
/* The hIST chunk contains the relative frequency or importance of the /* The hIST chunk contains the relative frequency or importance of the
* various palette entries, so that a viewer can intelligently select a * various palette entries, so that a viewer can intelligently select a
...@@ -240,7 +247,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) ...@@ -240,7 +247,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
/* The sCAL chunk describes the actual physical dimensions of the /* The sCAL chunk describes the actual physical dimensions of the
* subject matter of the graphic. The chunk contains a unit specification * subject matter of the graphic. The chunk contains a unit specification
* a byte value, and two ASCII strings representing floating-point * a byte value, and two ASCII strings representing floating-point
* values. The values are width and height corresponsing to one pixel * values. The values are width and height corresponding to one pixel
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
* non-zero. * non-zero.
*/ */
......
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* Last changed in libpng 1.6.0 [February 14, 2013] * Copyright (c) 2018 Cosmin Truta
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * Copyright (c) 1996-1997 Andreas Dilger
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
...@@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr) ...@@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr)
} }
/* 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 than 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.
...@@ -73,9 +73,13 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), ...@@ -73,9 +73,13 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
* to implement a user memory handler. This checks to be sure it isn't * to implement a user memory handler. This checks to be sure it isn't
* called with big numbers. * called with big numbers.
*/ */
#ifdef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
PNG_UNUSED(png_ptr) PNG_UNUSED(png_ptr)
#endif #endif
/* Some compilers complain that this is always true. However, it
* can be false when integer overflow happens.
*/
if (size > 0 && size <= PNG_SIZE_MAX if (size > 0 && size <= PNG_SIZE_MAX
# ifdef PNG_MAX_MALLOC_64K # ifdef PNG_MAX_MALLOC_64K
&& size <= 65536U && size <= 65536U
...@@ -95,6 +99,8 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), ...@@ -95,6 +99,8 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
return NULL; return NULL;
} }
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 /* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
* that arises because of the checks in png_realloc_array that are repeated in * that arises because of the checks in png_realloc_array that are repeated in
* png_malloc_array. * png_malloc_array.
...@@ -103,7 +109,7 @@ static png_voidp ...@@ -103,7 +109,7 @@ static png_voidp
png_malloc_array_checked(png_const_structrp png_ptr, int nelements, png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
size_t element_size) size_t element_size)
{ {
png_alloc_size_t req = nelements; /* known to be > 0 */ png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
if (req <= PNG_SIZE_MAX/element_size) if (req <= PNG_SIZE_MAX/element_size)
return png_malloc_base(png_ptr, req * element_size); return png_malloc_base(png_ptr, req * element_size);
...@@ -156,6 +162,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, ...@@ -156,6 +162,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
return NULL; /* error */ return NULL; /* error */
} }
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
/* Various functions that have different error handling are derived from this. /* Various functions that have different error handling are derived from this.
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
...@@ -195,7 +202,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), ...@@ -195,7 +202,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
return ret; return ret;
} }
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* USER_MEM */
/* This function was added at libpng version 1.2.3. The png_malloc_warn() /* This function was added at libpng version 1.2.3. The png_malloc_warn()
* function will issue a png_warning and return NULL instead of issuing a * function will issue a png_warning and return NULL instead of issuing a
...@@ -240,7 +247,7 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) ...@@ -240,7 +247,7 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
{ {
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
return; return;
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* USER_MEM */
free(ptr); free(ptr);
} }
...@@ -273,5 +280,5 @@ png_get_mem_ptr(png_const_structrp png_ptr) ...@@ -273,5 +280,5 @@ png_get_mem_ptr(png_const_structrp png_ptr)
return png_ptr->mem_ptr; return png_ptr->mem_ptr;
} }
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* USER_MEM */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ #endif /* READ || WRITE */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* Last changed in libpng 1.6.0 [February 14, 2013] * Copyright (c) 2018 Cosmin Truta
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * Copyright (c) 1996-1997 Andreas Dilger
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
* 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_structrp png_ptr, png_const_bytep data, png_size_t length) png_write_data(png_structrp png_ptr, png_const_bytep data, size_t length)
{ {
/* NOTE: write_data_fn must not change the buffer! */ /* NOTE: write_data_fn must not change the buffer! */
if (png_ptr->write_data_fn != NULL ) if (png_ptr->write_data_fn != NULL )
...@@ -48,9 +48,9 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) ...@@ -48,9 +48,9 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
* than changing the library. * than changing the library.
*/ */
void PNGCBAPI void PNGCBAPI
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, size_t length)
{ {
png_size_t check; size_t check;
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
...@@ -149,8 +149,11 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, ...@@ -149,8 +149,11 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
# else # else
png_ptr->output_flush_fn = output_flush_fn; png_ptr->output_flush_fn = output_flush_fn;
# endif # endif
#endif /* PNG_WRITE_FLUSH_SUPPORTED */ #else
PNG_UNUSED(output_flush_fn)
#endif /* WRITE_FLUSH */
#ifdef PNG_READ_SUPPORTED
/* It is an error to read while writing a png file */ /* It is an error to read while writing a png file */
if (png_ptr->read_data_fn != NULL) if (png_ptr->read_data_fn != NULL)
{ {
...@@ -160,5 +163,6 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, ...@@ -160,5 +163,6 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
"Can't set both read_data_fn and write_data_fn in the" "Can't set both read_data_fn and write_data_fn in the"
" same structure"); " same structure");
} }
#endif
} }
#endif /* PNG_WRITE_SUPPORTED */ #endif /* WRITE */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment