Upgrade bundled libpng to version 1.6.40 - cont'd

This commit is contained in:
ManoloFLTK 2023-07-24 20:18:05 +02:00
parent 2fdd1cea91
commit 1127ebfcd3
12 changed files with 291 additions and 344 deletions

View File

@ -1,5 +1,5 @@
libpng 1.6.37 - April 14, 2019 libpng 1.6.40 - June 21, 2023
============================== =============================
This is a public release of libpng, intended for use in production code. This is a public release of libpng, intended for use in production code.
@ -9,13 +9,13 @@ Files available for download
Source files with LF line endings (for Unix/Linux): Source files with LF line endings (for Unix/Linux):
* libpng-1.6.37.tar.xz (LZMA-compressed, recommended) * libpng-1.6.40.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.37.tar.gz * libpng-1.6.40.tar.gz
Source files with CRLF line endings (for Windows): Source files with CRLF line endings (for Windows):
* lp1637.7z (LZMA-compressed, recommended) * lpng1640.7z (LZMA-compressed, recommended)
* lp1637.zip * lpng1640.zip
Other information: Other information:
@ -25,20 +25,15 @@ Other information:
* TRADEMARK.md * TRADEMARK.md
Changes since the previous public release (version 1.6.36) Changes from version 1.6.39 to version 1.6.40
---------------------------------------------------------- ---------------------------------------------
* Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. * Fixed the eXIf chunk multiplicity checks.
* Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. * Fixed a memory leak in pCAL processing.
* Fixed a memory leak in pngtest.c. * Corrected the validity report about tRNS inside png_get_valid().
* Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in * Fixed various build issues on *BSD, Mac and Windows.
contrib/pngminus; refactor. * Updated the configurations and the scripts for continuous integration.
* Changed the license of contrib/pngminus to MIT; refresh makefile and docs. * Cleaned up the code, the build scripts, and the documentation.
(Contributed by Willem van Schaik)
* Fixed a typo in the libpng license v2.
(Contributed by Miguel Ojeda)
* Added makefiles for AddressSanitizer-enabled builds.
* Cleaned up various makefiles.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Send comments/corrections/commendations to png-mng-implement at lists.sf.net.

View File

@ -204,7 +204,7 @@ Version 0.97 [January, 1998]
Added simple sRGB support (Glenn R-P) Added simple sRGB support (Glenn R-P)
Easier conditional compiling, e.g., Easier conditional compiling, e.g.,
define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
all configurable options can be selected from command-line instead all configurable options can be selected from command line instead
of having to edit pngconf.h (Glenn R-P) of having to edit pngconf.h (Glenn R-P)
Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
Added more conditions for png_do_background, to avoid changing Added more conditions for png_do_background, to avoid changing
@ -942,7 +942,7 @@ Version 1.0.8 [July 24, 2000]
Version 1.0.9beta1 [November 10, 2000] Version 1.0.9beta1 [November 10, 2000]
Fixed typo in scripts/makefile.hpux Fixed typo in scripts/makefile.hpux
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
Changed "cdrom.com" in documentation to "libpng.org" Changed "cdrom.com" in documentation to "libpng.org"
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
Changed type of "params" from voidp to png_voidp in png_read|write_png(). Changed type of "params" from voidp to png_voidp in png_read|write_png().
@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009]
Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
Version 1.4.0beta59 [May 15, 2009] Version 1.4.0beta59 [May 15, 2009]
Reformated sources in libpng style (3-space indentation, comment format) Reformatted sources in libpng style (3-space indentation, comment format)
Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
Added sections about the git repository and our coding style to the Added sections about the git repository and our coding style to the
documentation documentation
@ -2661,7 +2661,7 @@ Version 1.4.1beta06 [January 28, 2010]
Version 1.4.1beta07 [February 6, 2010] Version 1.4.1beta07 [February 6, 2010]
Folded some long lines in the source files. Folded some long lines in the source files.
Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
and a PNG_USER_LIMITS_SUPPORTED flag. and a PNG_USER_LIMITS_SUPPORTED flag.
Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
png_ptr->png_user_chunk_malloc_max. png_ptr->png_user_chunk_malloc_max.
@ -3919,7 +3919,7 @@ Version 1.6.0beta08 [February 1, 2012]
version checking to configure.ac version checking to configure.ac
Improved pngstest speed by not doing redundant tests and add const to Improved pngstest speed by not doing redundant tests and add const to
the background parameter of png_image_finish_read. The --background the background parameter of png_image_finish_read. The --background
option is now done automagically only when required, so that commandline option is now done automagically only when required, so that command-line
option no longer exists. option no longer exists.
Cleaned up pngpriv.h to consistently declare all functions and data. Cleaned up pngpriv.h to consistently declare all functions and data.
Also eliminated PNG_CONST_DATA, which is apparently not needed but we Also eliminated PNG_CONST_DATA, which is apparently not needed but we
@ -5927,7 +5927,7 @@ Version 1.6.32beta03 [August 2, 2017]
(Bug report from the OSS-fuzz project). (Bug report from the OSS-fuzz project).
Version 1.6.32beta04 [August 2, 2017] Version 1.6.32beta04 [August 2, 2017]
Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf(). Replaced local eXIf_buf with info_ptr->eXIf_buf in png_handle_eXIf().
Update libpng.3 and libpng-manual.txt about eXIf functions. Update libpng.3 and libpng-manual.txt about eXIf functions.
Version 1.6.32beta05 [August 2, 2017] Version 1.6.32beta05 [August 2, 2017]
@ -6121,6 +6121,14 @@ Version 1.6.39 [November 20, 2022]
removed the obsolete makefile.cegcc. removed the obsolete makefile.cegcc.
Cleaned up the code and updated the internal documentation. Cleaned up the code and updated the internal documentation.
Version 1.6.40 [June 21, 2023]
Fixed the eXIf chunk multiplicity checks.
Fixed a memory leak in pCAL processing.
Corrected the validity report about tRNS inside png_get_valid().
Fixed various build issues on *BSD, Mac and Windows.
Updated the configurations and the scripts for continuous integration.
Cleaned up the code, the build scripts, and the documentation.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -128,16 +128,18 @@ Your directory structure should look like this:
README README
*.h, *.c => libpng source files *.h, *.c => libpng source files
CMakeLists.txt => "cmake" script CMakeLists.txt => "cmake" script
ci
ci_*.sh
configuration files: configuration files:
configure.ac, configure, Makefile.am, Makefile.in, configure.ac, configure, Makefile.am, Makefile.in,
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in, autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
libpng-config.in, aclocal.m4, config.h.in, config.sub, libpng-config.in, aclocal.m4, config.h.in, config.sub,
depcomp, install-sh, mkinstalldirs, test-pngtest.sh depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc.
contrib contrib
arm-neon, conftest, examples, gregbook, libtests, pngminim, arm-neon, conftest, examples, gregbook, libtests, pngminim,
pngminus, pngsuite, tools, visupng pngminus, pngsuite, tools, visupng
projects projects
cbuilder5, owatcom, visualc71, vstudio, xcode owatcom, visualc71, vstudio
scripts scripts
makefile.* makefile.*
*.def (module definition files) *.def (module definition files)
@ -145,7 +147,7 @@ Your directory structure should look like this:
pngtest.png pngtest.png
etc. etc.
zlib zlib
README, *.h, *.c contrib, etc. README, *.h, *.c, contrib, etc.
If the line endings in the files look funny, you may wish to get the other If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line distribution of libpng. It is available in both tar.gz (UNIX style line
@ -153,28 +155,27 @@ endings) and zip (DOS style line endings) formats.
VI. Building with project files VI. Building with project files
If you are building libpng with MSVC, you can enter the If you are building libpng with Microsoft Visual Studio, you can enter
libpng projects\visualc71 or vstudio directory and follow the instructions the directory projects\visualc71 or projects\vstudio and follow the
in README.txt. instructions in README.txt.
Otherwise enter the zlib directory and follow the instructions in zlib/README, Otherwise, enter the zlib directory and follow the instructions in
then come back here and run "configure" or choose the appropriate zlib/README, then come back here and run "configure" or choose the
makefile.sys in the scripts directory. appropriate makefile in the scripts directory.
VII. Building with makefiles VII. Building with makefiles
Copy the file (or files) that you need from the Copy the file (or files) that you need from the
scripts directory into this directory, for example scripts directory into this directory, for example
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example: UNIX example:
cp scripts/makefile.std makefile cp scripts/makefile.std Makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h make
Windows example:
nmake -f scripts\makefile.vcwin32
Read the makefile to see if you need to change any source or Read the makefile to see if you need to change any source or
target directories to match your preferences. target directories to match your preferences.
@ -191,36 +192,33 @@ test. For more confidence, you can run another test by typing
Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
your output with the result shown in contrib/pngsuite/README. your output with the result shown in contrib/pngsuite/README.
Most of the makefiles will allow you to run "make install" to Most of the makefiles used to allow you to run "make install" to put
put the library in its final resting place (if you want to the library in its final resting place, but that feature is no longer
do that, run "make install" in the zlib directory first if necessary). supported. The only tested and supported manners to install libpng are
Some also allow you to run "make test-installed" after you have the conventional build and install procedures driven by the configure
run "make install". script or by the CMake file.
VIII. Configuring libpng for 16-bit platforms VIII. Configuring for DOS and other 16-bit platforms
You will want to look into zconf.h to tell zlib (and thus libpng) that Officially, the support for 16-bit platforms has been removed.
it cannot allocate more than 64K at a time. Even if you can, the memory
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
IX. Configuring for DOS
For DOS users who only have access to the lower 640K, you will For DOS users who only have access to the lower 640K, you will
have to limit zlib's memory usage via a png_set_compression_mem_level() have to limit zlib's memory usage via a png_set_compression_mem_level()
call. See zlib.h or zconf.h in the zlib library for more information. call. See zlib.h or zconf.h in the zlib library for more information.
X. Configuring for Medium Model You may be or may not be in luck if you target the "large" memory model,
but all the smaller models ("small", "compact" and "medium") are known
to be unworkable. For DOS users who have access beyond the lower 640K,
a "flat" 32-bit DOS model (such as DJGPP) is strongly recommended.
Libpng's support for medium model has been tested on most of the popular For DOS users who only have access to the lower 640K, you will have to
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets limit zlib's memory usage via a png_set_compression_mem_level() call.
defined, and FAR gets defined to far in pngconf.h, and you should be You will also have to look into zconf.h to tell zlib (and thus libpng)
all set. Everything in the library (except for zlib's structure) is that it cannot allocate more than 64K at a time. Even if you can, the
expecting far data. You must use the typedefs with the p or pp on memory won't be accessible. Therefore, you should limit zlib and libpng
the end for pointers (or at least look at them and be careful). Make to 64K by defining MAXSEG_64K.
note that the rows of data are defined as png_bytepp, which is
an "unsigned char far * far *".
XI. Prepending a prefix to exported symbols IX. Prepending a prefix to exported symbols
Starting with libpng-1.6.0, you can configure libpng (when using the Starting with libpng-1.6.0, you can configure libpng (when using the
"configure" script) to prefix all exported symbols by means of the "configure" script) to prefix all exported symbols by means of the
@ -231,7 +229,7 @@ identifier). This creates a set of macros in pnglibconf.h, so this is
transparent to applications; their function calls get transformed by transparent to applications; their function calls get transformed by
the macros to use the modified names. the macros to use the modified names.
XII. Configuring for compiler xxx: X. Configuring for compiler xxx:
All includes for libpng are in pngconf.h. If you need to add, change All includes for libpng are in pngconf.h. If you need to add, change
or delete an include, this is the place to do it. or delete an include, this is the place to do it.
@ -243,7 +241,7 @@ As of libpng-1.5.0, pngpriv.h also includes three other private header
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
that previously appeared in the public headers. that previously appeared in the public headers.
XIII. Removing unwanted object code XI. Removing unwanted object code
There are a bunch of #define's in pngconf.h that control what parts of There are a bunch of #define's in pngconf.h that control what parts of
libpng are compiled. All the defines end in _SUPPORTED. If you are libpng are compiled. All the defines end in _SUPPORTED. If you are
@ -282,7 +280,7 @@ library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only The size of the library itself should not be an issue, because only
those sections that are actually used will be loaded into memory. those sections that are actually used will be loaded into memory.
XIV. Enabling or disabling hardware optimizations XII. Enabling or disabling hardware optimizations
Certain hardware capabilities, such as the Intel SSE instructions, Certain hardware capabilities, such as the Intel SSE instructions,
are normally detected at run time. Enable them with configure options are normally detected at run time. Enable them with configure options
@ -332,7 +330,7 @@ or disable them all at once with
cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
XV. Changes to the build and configuration of libpng in libpng-1.5.x XIII. Changes to the build and configuration of libpng in libpng-1.5.x
Details of internal changes to the library code can be found in the CHANGES Details of internal changes to the library code can be found in the CHANGES
file and in the GIT repository logs. These will be of no concern to the vast file and in the GIT repository logs. These will be of no concern to the vast
@ -423,7 +421,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built
libpng, because than the settings would not accurately reflect the settings libpng, because than the settings would not accurately reflect the settings
that were used to build libpng. that were used to build libpng.
XVI. Setjmp/longjmp issues XIV. Setjmp/longjmp issues
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp() Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
is known to be not thread-safe on some platforms and we don't know of is known to be not thread-safe on some platforms and we don't know of
@ -441,7 +439,7 @@ This requires setjmp/longjmp, so you must either build the library
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined. and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
XVII. Common linking failures XV. Common linking failures
If your application fails to find libpng or zlib entries while linking: If your application fails to find libpng or zlib entries while linking:
@ -453,12 +451,13 @@ If your application fails to find libpng or zlib entries while linking:
If you are using the vstudio project, observe the WARNING in If you are using the vstudio project, observe the WARNING in
project/vstudio/README.txt. project/vstudio/README.txt.
XVIII. Other sources of information about libpng: XVI. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5. libpng.3 and png.5.
Copyright (c) 2022 Cosmin Truta
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer For conditions of distribution and use, see the disclaimer

View File

@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2 PNG Reference Library License version 2
--------------------------------------- ---------------------------------------
* Copyright (c) 1995-2019 The PNG Reference Library Authors. * Copyright (c) 1995-2023 The PNG Reference Library Authors.
* Copyright (c) 2018-2019 Cosmin Truta. * Copyright (c) 2018-2023 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger. * Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

View File

@ -1,57 +1,88 @@
README for libpng version 1.6.37 - April 14, 2019 README for libpng version 1.6.40
================================================= ================================
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`
libpng-*.tar.xz or if you want UNIX-style line endings in the text or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
files, 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 For a detailed description on using libpng, read `libpng-manual.txt`.
fact that it's the first release fool you. The libpng library has been For examples of libpng in a program, see `example.c` and `pngtest.c`.
in extensive use and testing since mid-1995. By late 1997 it had For usage information and restrictions (what little they are) on libpng,
finally gotten to the stage where there hadn't been significant see `png.h`. For a description on using zlib (the compression library
changes to the API in some time, and people have a bad feeling about used by libpng) and zlib's restrictions, see `zlib.h`.
libraries with versions < 1.0. Version 1.0.0 was released in
March 1998.
**** You should use zlib 1.0.4 or later to run this, but it _may_ work with
Note that some of the changes to the png_info structure render this 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
some images.
You should also note that zlib is a compression library that is useful
for more things than just PNG files. You can use zlib as a drop-in
replacement for `fread()` and `fwrite()`, if you are so inclined.
zlib should be available at the same place that libpng is, or at
https://zlib.net .
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at https://libpng.sourceforge.io
in the download area, and at http://libpng.download/src .
This release, based in a large way on Glenn's, Guy's and Andreas'
earlier work, was created and will be supported by myself and the PNG
development group.
Send comments, corrections and commendations to `png-mng-implement`
at `lists.sourceforge.net`. (Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe.)
Send general questions about the PNG specification to `png-mng-misc`
at `lists.sourceforge.net`. (Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-misc
to subscribe.)
Historical notes
----------------
The libpng library has been in extensive use and testing since mid-1995.
Version 0.89, published a year later, was the first official release.
By late 1997, it had 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 libraries with versions below 1.0. Version 1.0.0 was
released in March 1998.
Note that some of the changes to the `png_info` structure render this
version of the library binary incompatible with libpng-0.89 or version of the library binary incompatible with libpng-0.89 or
earlier versions if you are using a shared library. The type of the earlier versions if you are using a shared library. The type of the
"filler" parameter for png_set_filler() has changed from png_byte to `filler` parameter for `png_set_filler()` has changed from `png_byte`
png_uint_32, which will affect shared-library applications that use to `png_uint_32`, which will affect shared-library applications that
this function. use this function.
To avoid problems with changes to the internals of the png info_struct, To avoid problems with changes to the internals of the `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 did 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, through libpng-1.2.x. In libpng-1.4.x, which was meant to library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
be a transitional release, members of the png_struct and the be a transitional release, members of the `png_struct` and the
info_struct can still be accessed, but the compiler will issue a `info_struct` can still be accessed, but the compiler will issue a
warning about deprecated usage. Since libpng-1.5.0, direct access warning about deprecated usage. Since libpng-1.5.0, direct access
to these structs is not allowed, and the definitions of the structs 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 reside in private `pngstruct.h` and `pnginfo.h` header files that are
accessible to applications. It is strongly suggested that new not accessible to applications. It is strongly suggested that new
programs use the new APIs (as shown in example.c and pngtest.c), and programs use the new APIs (as shown in `example.c` and `pngtest.c`),
older programs be converted to the new format, to facilitate upgrades and older programs be converted to the new format, to facilitate
in the future. upgrades in the future.
****
Additions since 0.90 include the ability to compile libpng as a
Windows DLL, and new APIs for accessing data in the info struct.
Experimental functions include the ability to set weighting and cost
factors for row filter selection, direct reads of integers from buffers
on big-endian processors that support misaligned data access, faster
methods of doing alpha composition, and more accurate 16->8 bit color
conversion.
The additions since 0.89 include the ability to read from a PNG stream The additions since 0.89 include the ability to read from a PNG stream
which has had some (or all) of the signature bytes read by the calling which has had some (or all) of the signature bytes read by the calling
@ -61,118 +92,86 @@ 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.
For a detailed description on using libpng, read libpng-manual.txt. The additions since 0.90 include the ability to compile libpng as a
For examples of libpng in a program, see example.c and pngtest.c. For Windows DLL, and new APIs for accessing data in the `info_struct`.
usage information and restrictions (what little they are) on libpng, Experimental functions included the ability to set weighting and cost
see png.h. For a description on using zlib (the compression library factors for row filter selection, direct reads of integers from buffers
used by libpng) and zlib's restrictions, see zlib.h on big-endian processors that support misaligned data access, faster
methods of doing alpha composition, and more accurate 16-to-8 bit color
conversion. Some of these experimental functions, such as the weighted
filter heuristics, have since been removed.
I have included a general makefile, as well as several machine and Files included in this distribution
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 ANNOUNCE => Announcement of this version, with recent changes
versions as old as zlib 0.95. Even so, there are bugs in older zlib AUTHORS => List of contributing authors
versions which can cause the output of invalid compression streams for CHANGES => Description of changes between libpng versions
some images. INSTALL => Instructions to install libpng
LICENSE => License to use and redistribute libpng
You should also note that zlib is a compression library that is useful README => This file
for more things than just PNG files. You can use zlib as a drop-in TODO => Things not implemented in the current library
replacement for fread() and fwrite(), if you are so inclined. TRADEMARK => Trademark information
example.c => Example code for using libpng functions
zlib should be available at the same place that libpng is, or at libpng.3 => Manual page for libpng (includes libpng-manual.txt)
https://zlib.net. libpng-manual.txt => Description of libpng and its functions
libpngpf.3 => Manual page for libpng's private functions (deprecated)
You may also want a copy of the PNG specification. It is available png.5 => Manual page for the PNG format
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find png.c => Basic interface functions common to library
these at http://www.libpng.org/pub/png/pngdocs.html . png.h => Library function and interface declarations (public)
pngpriv.h => Library function and interface declarations (private)
This code is currently being archived at libpng.sourceforge.io in the pngconf.h => System specific library configuration (public)
[DOWNLOAD] area, and at http://libpng.download/src . pngstruct.h => png_struct declaration (private)
pnginfo.h => png_info struct declaration (private)
This release, based in a large way on Glenn's, Guy's and Andreas' pngdebug.h => debugging macros (private)
earlier work, was created and will be supported by myself and the PNG pngerror.c => Error/warning message I/O functions
development group. pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
Send comments/corrections/commendations to png-mng-implement at pngbar.png => PNG logo, 88x31
lists.sourceforge.net (subscription required; visit pngnow.png => PNG logo, 98x31
https://lists.sourceforge.net/lists/listinfo/png-mng-implement pngpread.c => Progressive reading functions
to subscribe). pngread.c => Read data/helper high-level functions
pngrio.c => Lowest-level data read I/O functions
Send general questions about the PNG specification to png-mng-misc pngrtran.c => Read data transformation functions
at lists.sourceforge.net (subscription required; visit pngrutil.c => Read data utility functions
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to pngset.c => Functions for storing data into the info_struct
subscribe). pngtest.c => Library test program
pngtest.png => Library test sample image
Files in this distribution: pngtrans.c => Common data transformation functions
pngwio.c => Lowest-level write I/O functions
ANNOUNCE => Announcement of this version, with recent changes pngwrite.c => High-level write functions
AUTHORS => List of contributing authors pngwtran.c => Write data transformations
CHANGES => Description of changes between libpng versions pngwutil.c => Write utility functions
KNOWNBUG => List of known bugs and deficiencies arm/ => Optimized code for the ARM platform
LICENSE => License to use and redistribute libpng intel/ => Optimized code for the INTEL-SSE2 platform
README => This file mips/ => Optimized code for the MIPS platform
TODO => Things not implemented in the current library powerpc/ => Optimized code for the PowerPC platform
TRADEMARK => Trademark information ci/ => Scripts for continuous integration
example.c => Example code for using libpng functions contrib/ => External contributions
libpng.3 => manual page for libpng (includes libpng-manual.txt) arm-neon/ => Optimized code for the ARM-NEON platform
libpng-manual.txt => Description of libpng and its functions mips-msa/ => Optimized code for the MIPS-MSA platform
libpngpf.3 => manual page for libpng's private functions powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
png.5 => manual page for the PNG format examples/ => Examples of libpng usage
png.c => Basic interface functions common to library gregbook/ => Source code for PNG reading and writing, from
png.h => Library function and interface declarations (public) "PNG: The Definitive Guide" by Greg Roelofs,
pngpriv.h => Library function and interface declarations (private) O'Reilly, 1999
pngconf.h => System specific library configuration (public) libtests/ => Test programs
pngstruct.h => png_struct declaration (private) oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing
pnginfo.h => png_info struct declaration (private) libpng
pngdebug.h => debugging macros (private) pngminim/ => Minimal decoder, encoder, and progressive decoder
pngerror.c => Error/warning message I/O functions programs demonstrating the use of pngusr.dfa
pngget.c => Functions for retrieving info from struct pngminus/ => Simple pnm2png and png2pnm programs
pngmem.c => Memory handling functions pngsuite/ => Test images
pngbar.png => PNG logo, 88x31 testpngs/ => Test images
pngnow.png => PNG logo, 98x31 tools/ => Various tools
pngpread.c => Progressive reading functions visupng/ => VisualPng, a Windows viewer for PNG images
pngread.c => Read data/helper high-level functions projects/ => Project files and workspaces for various IDEs
pngrio.c => Lowest-level data read I/O functions owatcom/ => OpenWatcom project
pngrtran.c => Read data transformation functions visualc71/ => Microsoft Visual C++ 7.1 workspace
pngrutil.c => Read data utility functions vstudio/ => Microsoft Visual Studio workspace
pngset.c => Functions for storing data into the info_struct scripts/ => Scripts and makefiles for building libpng
pngtest.c => Library test program (see scripts/README.txt for the complete list)
pngtest.png => Library test sample image tests/ => Test scripts
pngtrans.c => Common data transformation functions
pngwio.c => Lowest-level write I/O functions
pngwrite.c => High-level write functions
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform
powerpc => Contains optimized code for the PowerPC platform
contrib => Contributions
arm-neon => Optimized code for ARM-NEON platform
powerpc-vsx => Optimized code for POWERPC-VSX platform
examples => Example programs
gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999
libtests => Test programs
mips-msa => Optimized code for MIPS-MSA platform
pngminim => Minimal decoder, encoder, and progressive decoder
programs demonstrating use of pngusr.dfa
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
testpngs
tools => Various tools
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
building a DLL
owatcom => Contains a WATCOM project for building libpng
visualc71 => Contains a Microsoft Visual C++ (MSVC)
workspace for building libpng and zlib
vstudio => Contains a Microsoft Visual C++ (MSVC)
workspace for building libpng and zlib
scripts => Directory containing scripts for building libpng:
(see scripts/README.txt for the list of scripts)
Good luck, and happy coding! Good luck, and happy coding!

View File

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2023 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson Copyright (c) 1998-2018 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
@ -9,9 +9,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng version 1.6.36, December 2018, through 1.6.37 - April 2019 libpng version 1.6.36, December 2018, through 1.6.40 - June 2023
Updated and distributed by Cosmin Truta Updated and distributed by Cosmin Truta
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2023 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018 libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
@ -877,7 +877,7 @@ described below (the latter being the two common names for associated alpha
color channels). Note that PNG files always contain non-associated color color channels). Note that PNG files always contain non-associated color
channels; png_set_alpha_mode() with one of the modes causes the decoder to channels; png_set_alpha_mode() with one of the modes causes the decoder to
convert the pixels to an associated form before returning them to your convert the pixels to an associated form before returning them to your
application. application.
Since it is not necessary to perform arithmetic on opaque color values so Since it is not necessary to perform arithmetic on opaque color values so
long as they are not to be resampled and are in the final color space it is long as they are not to be resampled and are in the final color space it is
@ -1792,7 +1792,7 @@ the information. If, instead, you want to convert the image to an opaque
version with no alpha channel use png_set_background; see below. version with no alpha channel use png_set_background; see below.
As of libpng version 1.5.2, almost all useful expansions are supported, the As of libpng version 1.5.2, almost all useful expansions are supported, the
major ommissions are conversion of grayscale to indexed images (which can be major omissions are conversion of grayscale to indexed images (which can be
done trivially in the application) and conversion of indexed to grayscale (which done trivially in the application) and conversion of indexed to grayscale (which
can be done by a trivial manipulation of the palette.) can be done by a trivial manipulation of the palette.)

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "April 14, 2019" .TH LIBPNG 3 "June 21, 2023"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.40
.SH SYNOPSIS .SH SYNOPSIS
\fB#include <png.h>\fP \fB#include <png.h>\fP
@ -519,7 +519,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2023 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson Copyright (c) 1998-2018 Glenn Randers-Pehrson
This document is released under the libpng license. This document is released under the libpng license.
@ -528,9 +528,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng version 1.6.36, December 2018, through 1.6.37 - April 2019 libpng version 1.6.36, December 2018, through 1.6.40 - June 2023
Updated and distributed by Cosmin Truta Updated and distributed by Cosmin Truta
Copyright (c) 2018-2019 Cosmin Truta Copyright (c) 2018-2023 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018 libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
@ -1396,7 +1396,7 @@ described below (the latter being the two common names for associated alpha
color channels). Note that PNG files always contain non-associated color color channels). Note that PNG files always contain non-associated color
channels; png_set_alpha_mode() with one of the modes causes the decoder to channels; png_set_alpha_mode() with one of the modes causes the decoder to
convert the pixels to an associated form before returning them to your convert the pixels to an associated form before returning them to your
application. application.
Since it is not necessary to perform arithmetic on opaque color values so Since it is not necessary to perform arithmetic on opaque color values so
long as they are not to be resampled and are in the final color space it is long as they are not to be resampled and are in the final color space it is
@ -2311,7 +2311,7 @@ the information. If, instead, you want to convert the image to an opaque
version with no alpha channel use png_set_background; see below. version with no alpha channel use png_set_background; see below.
As of libpng version 1.5.2, almost all useful expansions are supported, the As of libpng version 1.5.2, almost all useful expansions are supported, the
major ommissions are conversion of grayscale to indexed images (which can be major omissions are conversion of grayscale to indexed images (which can be
done trivially in the application) and conversion of indexed to grayscale (which done trivially in the application) and conversion of indexed to grayscale (which
can be done by a trivial manipulation of the palette.) can be done by a trivial manipulation of the palette.)
@ -5995,35 +5995,25 @@ letter, until version 1.0.6j; from then on they were given the upcoming
public release number plus "betaNN" or "rcNN". public release number plus "betaNN" or "rcNN".
.SH "SEE ALSO" .SH "SEE ALSO"
.IR libpngpf(3) ", " png(5) .BR "png"(5)
.LP
.IR libpng :
.IP .IP
https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link) The PNG (Portable Network Graphics) format specification.
http://www.libpng.org/pub/png
.LP .LP
.IR zlib : .B libpng
.IP .IP
(generally) at the same location as http://www.libpng.org/pub/png/libpng.html (canonical home page)
.I libpng
or at
.br .br
https://zlib.net/ https://github.com/pnggroup/libpng (canonical Git repository)
.br
https://libpng.sourceforge.io (downloadable archives)
.LP .LP
.IR PNG specification: RFC 2083 .B zlib
.IP .IP
(generally) at the same location as https://zlib.net (canonical home page)
.I libpng
or at
.br .br
https://www.ietf.org/rfc/rfc2083.txt https://github.com/madler/zlib (canonical Git repository)
.br .br
or (as a W3C Recommendation) at A copy of zlib may also be found at the same location as libpng.
.br
https://www.w3.org/TR/REC-png.html
.LP .LP
In the case of any inconsistency between the PNG specification In the case of any inconsistency between the PNG specification
and this library, the specification takes precedence. and this library, the specification takes precedence.
@ -6043,10 +6033,10 @@ Libpng:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Maintained by Cosmin Truta. Maintained by Cosmin Truta.
Supported by the PNG development group Supported by the PNG development group.
.br .br
png-mng-implement at lists.sourceforge.net (subscription required; visit png-mng-implement at lists.sourceforge.net. (Subscription is required;
https://lists.sourceforge.net/lists/listinfo/png-mng-implement visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe). to subscribe.)
.\" end of man page .\" end of man page

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "April 14, 2019" .TH LIBPNGPF 3 "June 21, 2023"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.40
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,4 +1,4 @@
.TH PNG 5 "April 14, 2019" .TH PNG 5 "June 21, 2023"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
@ -18,7 +18,7 @@ Also, PNG can store gamma and chromaticity data for improved color
matching on heterogeneous platforms. matching on heterogeneous platforms.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) .BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP .LP
PNG Specification (Second Edition), November 2003: PNG Specification (Second Edition), November 2003:
.IP .IP
@ -43,7 +43,7 @@ or W3C Recommendation
https://www.w3.org/TR/REC-png-961001 https://www.w3.org/TR/REC-png-961001
.SH AUTHORS .SH AUTHORS
This man page: Cosmin Truta, Glenn Randers-Pehrson This man page: Glenn Randers-Pehrson, Cosmin Truta
.LP .LP
Portable Network Graphics (PNG) Specification (Second Edition) Portable Network Graphics (PNG) Specification (Second Edition)
Information technology - Computer graphics and image processing - Information technology - Computer graphics and image processing -
@ -51,34 +51,9 @@ Portable Network Graphics (PNG): Functional specification.
ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others. ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others.
.LP .LP
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999): Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
Glenn Randers-Pehrson and others (png-list). Glenn Randers-Pehrson and others.
.LP .LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996): Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list). Thomas Boutell and others.
.SH COPYRIGHT
.LP
This man page is
.br
Copyright (c) 2018-2019 Cosmin Truta.
.br
Copyright (c) 1998-2006 Glenn Randers-Pehrson.
.br
See png.h for conditions of use and distribution.
.LP
The PNG Specification (Second Edition) is
.br
Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
.LP
The PNG-1.2 Specification is
.br
Copyright (c) 1999 Glenn Randers-Pehrson.
.br
See the specification for conditions of use and distribution.
.LP
The PNG-1.0 Specification is
.br
Copyright (c) 1996 Massachusetts Institute of Technology.
.br
See the specification for conditions of use and distribution.
.\" end of man page .\" end of man page

View File

@ -1,9 +1,9 @@
/* pngconf.h - machine-configurable file for libpng /* pngconf.h - machine-configurable file for libpng
* *
* libpng version 1.6.37 * libpng version 1.6.40
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -180,8 +180,8 @@
* compiler-specific macros to the values required to change the calling * compiler-specific macros to the values required to change the calling
* conventions of the various functions. * conventions of the various functions.
*/ */
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ #if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) defined(__CYGWIN__)
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
* MinGW on any architecture currently supported by Windows. Also includes * MinGW on any architecture currently supported by Windows. Also includes
* Watcom builds but these need special treatment because they are not * Watcom builds but these need special treatment because they are not

View File

@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng /* pngpriv.h - private declarations for use inside libpng
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2023 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -174,7 +174,7 @@
# else /* !defined __ARM_NEON__ */ # else /* !defined __ARM_NEON__ */
/* The 'intrinsics' code simply won't compile without this -mfpu=neon: /* The 'intrinsics' code simply won't compile without this -mfpu=neon:
*/ */
# if !defined(__aarch64__) # if !defined(__aarch64__) && !defined(_M_ARM64)
/* The assembler code currently does not work on ARM64 */ /* The assembler code currently does not work on ARM64 */
# define PNG_ARM_NEON_IMPLEMENTATION 2 # define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* __aarch64__ */ # endif /* __aarch64__ */
@ -185,6 +185,8 @@
/* Use the intrinsics code by default. */ /* Use the intrinsics code by default. */
# define PNG_ARM_NEON_IMPLEMENTATION 1 # define PNG_ARM_NEON_IMPLEMENTATION 1
# endif # endif
#else /* PNG_ARM_NEON_OPT == 0 */
# define PNG_ARM_NEON_IMPLEMENTATION 0
#endif /* PNG_ARM_NEON_OPT > 0 */ #endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_MIPS_MSA_OPT #ifndef PNG_MIPS_MSA_OPT
@ -263,11 +265,15 @@
# ifndef PNG_MIPS_MSA_IMPLEMENTATION # ifndef PNG_MIPS_MSA_IMPLEMENTATION
# define PNG_MIPS_MSA_IMPLEMENTATION 1 # define PNG_MIPS_MSA_IMPLEMENTATION 1
# endif # endif
#else
# define PNG_MIPS_MSA_IMPLEMENTATION 0
#endif /* PNG_MIPS_MSA_OPT > 0 */ #endif /* PNG_MIPS_MSA_OPT > 0 */
#if PNG_POWERPC_VSX_OPT > 0 #if PNG_POWERPC_VSX_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
# define PNG_POWERPC_VSX_IMPLEMENTATION 1 # define PNG_POWERPC_VSX_IMPLEMENTATION 1
#else
# define PNG_POWERPC_VSX_IMPLEMENTATION 0
#endif #endif
@ -492,16 +498,7 @@
static_cast<type>(static_cast<const void*>(value)) static_cast<type>(static_cast<const void*>(value))
#else #else
# define png_voidcast(type, value) (value) # define png_voidcast(type, value) (value)
# ifdef _WIN64 # define png_constcast(type, value) ((type)(void*)(const void*)(value))
# ifdef __GNUC__
typedef unsigned long long png_ptruint;
# else
typedef unsigned __int64 png_ptruint;
# endif
# else
typedef unsigned long png_ptruint;
# endif
# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
# define png_aligncast(type, value) ((void*)(value)) # define png_aligncast(type, value) ((void*)(value))
# define png_aligncastconst(type, value) ((const void*)(value)) # define png_aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -543,9 +540,8 @@
# include <alloc.h> # include <alloc.h>
#endif #endif
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ #if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
defined(_WIN32) || defined(__WIN32__) # include <windows.h>
# include <windows.h> /* defines _WINDOWS_ macro */
#endif #endif
#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNG_VERSION_INFO_ONLY */
@ -554,24 +550,20 @@
* functions that are passed far data must be model-independent. * functions that are passed far data must be model-independent.
*/ */
/* Memory model/platform independent fns */ /* Platform-independent functions */
#ifndef PNG_ABORT #ifndef PNG_ABORT
# ifdef _WINDOWS_ # define PNG_ABORT() abort()
# define PNG_ABORT() ExitProcess(0)
# else
# define PNG_ABORT() abort()
# endif
#endif #endif
/* These macros may need to be architecture dependent. */ /* These macros may need to be architecture dependent. */
#define PNG_ALIGN_NONE 0 /* do not use data alignment */ #define PNG_ALIGN_NONE 0 /* do not use data alignment */
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ #define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
#ifdef offsetof #ifdef offsetof
# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ # define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
#else #else
# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ # define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
#endif #endif
#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ #define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
#ifndef PNG_ALIGN_TYPE #ifndef PNG_ALIGN_TYPE
/* Default to using aligned access optimizations and requiring alignment to a /* Default to using aligned access optimizations and requiring alignment to a
@ -585,26 +577,25 @@
/* This is used because in some compiler implementations non-aligned /* This is used because in some compiler implementations non-aligned
* structure members are supported, so the offsetof approach below fails. * structure members are supported, so the offsetof approach below fails.
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
* is good for performance. Do not do this unless you have tested the result * is good for performance. Do not do this unless you have tested the
* and understand it. * result and understand it.
*/ */
# define png_alignof(type) (sizeof (type)) # define png_alignof(type) (sizeof(type))
#else #else
# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET # if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
# define png_alignof(type) offsetof(struct{char c; type t;}, t) # define png_alignof(type) offsetof(struct{char c; type t;}, t)
# else # else
# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS # if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
# define png_alignof(type) (1) # define png_alignof(type) 1
# endif # endif
/* Else leave png_alignof undefined to prevent use thereof */ /* Else leave png_alignof undefined to prevent use thereof */
# endif # endif
#endif #endif
/* This implicitly assumes alignment is always to a power of 2. */ /* This implicitly assumes alignment is always a multiple of 2. */
#ifdef png_alignof #ifdef png_alignof
# define png_isaligned(ptr, type)\ # define png_isaligned(ptr, type) \
(((type)((const char*)ptr-(const char*)0) & \ (((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0)
(type)(png_alignof(type)-1)) == 0)
#else #else
# define png_isaligned(ptr, type) 0 # define png_isaligned(ptr, type) 0
#endif #endif
@ -635,7 +626,7 @@
#define PNG_BACKGROUND_IS_GRAY 0x800U #define PNG_BACKGROUND_IS_GRAY 0x800U
#define PNG_HAVE_PNG_SIGNATURE 0x1000U #define PNG_HAVE_PNG_SIGNATURE 0x1000U
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
/* 0x4000U (unused) */ #define PNG_WROTE_eXIf 0x4000U
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ #define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
/* Flags for the transformations the PNG library does on the image data */ /* Flags for the transformations the PNG library does on the image data */
@ -1919,7 +1910,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
*/ */
#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ #define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
/* Result codes for the parser (boolean - true meants ok, false means /* Result codes for the parser (boolean - true means ok, false means
* not ok yet.) * not ok yet.)
*/ */
#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ #define PNG_FP_MAYBE 0 /* The number may be valid in the future */
@ -1955,7 +1946,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
* the problem character.) This has not been tested within libpng. * the problem character.) This has not been tested within libpng.
*/ */
PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); size_t size, int *statep, size_t *whereami),PNG_EMPTY);
/* This is the same but it checks a complete string and returns true /* This is the same but it checks a complete string and returns true
* only if it just contains a floating point number. As of 1.5.4 this * only if it just contains a floating point number. As of 1.5.4 this

View File

@ -1,7 +1,7 @@
/* pngstruct.h - header file for PNG reference library /* pngstruct.h - header file for PNG reference library
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -334,18 +334,8 @@ struct png_struct_def
size_t current_buffer_size; /* amount of data now in current_buffer */ size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */ int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */ int cur_palette; /* current push library palette index */
#endif /* PROGRESSIVE_READ */ #endif /* PROGRESSIVE_READ */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* For the Borland special 64K segment handler */
png_bytepp offset_table_ptr;
png_bytep offset_table;
png_uint_16 offset_table_number;
png_uint_16 offset_table_count;
png_uint_16 offset_table_count_free;
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED #ifdef PNG_READ_QUANTIZE_SUPPORTED
png_bytep palette_lookup; /* lookup table for quantizing */ png_bytep palette_lookup; /* lookup table for quantizing */
png_bytep quantize_index; /* index translation for palette files */ png_bytep quantize_index; /* index translation for palette files */