mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Imported from libpng-1.7.0beta70.tar
This commit is contained in:
4
ANNOUNCE
4
ANNOUNCE
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.7.0beta70 - December 1, 2015
|
Libpng 1.7.0beta70 - December 3, 2015
|
||||||
|
|
||||||
This is not intended to be a public release. It will be replaced
|
This is not intended to be a public release. It will be replaced
|
||||||
within a few weeks by a public version or by another test version.
|
within a few weeks by a public version or by another test version.
|
||||||
@@ -1022,7 +1022,7 @@ Version 1.7.0beta69 [November 24, 2015]
|
|||||||
Temporarily disabled filter selection while writing, and temporarily
|
Temporarily disabled filter selection while writing, and temporarily
|
||||||
replaced pngtest.png accordingly.
|
replaced pngtest.png accordingly.
|
||||||
|
|
||||||
Version 1.7.0beta70 [December 1, 2015]
|
Version 1.7.0beta70 [December 3, 2015]
|
||||||
Fixed a simple bracket problem that prevented reading non-interlaced
|
Fixed a simple bracket problem that prevented reading non-interlaced
|
||||||
PNG files with height == 1.
|
PNG files with height == 1.
|
||||||
The code failed to zero out the row buffer at the start of a pass where
|
The code failed to zero out the row buffer at the start of a pass where
|
||||||
|
|||||||
2
CHANGES
2
CHANGES
@@ -5321,7 +5321,7 @@ Version 1.7.0beta69 [November 24, 2015]
|
|||||||
Temporarily disabled filter selection while writing, and temporarily
|
Temporarily disabled filter selection while writing, and temporarily
|
||||||
replaced pngtest.png accordingly.
|
replaced pngtest.png accordingly.
|
||||||
|
|
||||||
Version 1.7.0beta70 [December 1, 2015]
|
Version 1.7.0beta70 [December 3, 2015]
|
||||||
Fixed a simple bracket problem that prevented reading non-interlaced
|
Fixed a simple bracket problem that prevented reading non-interlaced
|
||||||
PNG files with height == 1.
|
PNG files with height == 1.
|
||||||
The code failed to zero out the row buffer at the start of a pass where
|
The code failed to zero out the row buffer at the start of a pass where
|
||||||
|
|||||||
4
LICENSE
4
LICENSE
@@ -10,7 +10,7 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, November 24, 2015, are
|
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, December 3, 2015, are
|
||||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||||
derived from libpng-1.0.6, and are distributed according to the same
|
derived from libpng-1.0.6, and are distributed according to the same
|
||||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@@ -109,4 +109,4 @@ the additional disclaimers inserted at version 1.0.7.
|
|||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
November 24, 2015
|
December 3, 2015
|
||||||
|
|||||||
2
README
2
README
@@ -1,4 +1,4 @@
|
|||||||
README for libpng version 1.7.0beta70 - November 24, 2015 (shared library 17.0)
|
README for libpng version 1.7.0beta70 - December 3, 2015 (shared library 17.0)
|
||||||
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.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngvalid.c - validate libpng by constructing then reading png files.
|
/* pngvalid.c - validate libpng by constructing then reading png files.
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.5.25 [RDATE%]
|
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||||
* Copyright (c) 2014-2015 Glenn Randers-Pehrson
|
* Copyright (c) 2014-2015 Glenn Randers-Pehrson
|
||||||
* Written by John Cunningham Bowler
|
* Written by John Cunningham Bowler
|
||||||
*
|
*
|
||||||
@@ -4276,17 +4276,11 @@ make_error(png_store* const ps, png_byte const colour_type,
|
|||||||
#undef exception__env
|
#undef exception__env
|
||||||
|
|
||||||
/* And clear these flags */
|
/* And clear these flags */
|
||||||
|
ps->expect_error = 0;
|
||||||
ps->expect_warning = 0;
|
ps->expect_warning = 0;
|
||||||
|
|
||||||
if (ps->expect_error)
|
|
||||||
ps->expect_error = 0;
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Now write the whole image, just to make sure that the detected, or
|
/* Now write the whole image, just to make sure that the detected, or
|
||||||
* undetected, errro has not created problems inside libpng. This
|
* undetected, errro has not created problems inside libpng.
|
||||||
* doesn't work if there was a png_error in png_write_info because that
|
|
||||||
* can abort before PLTE was written.
|
|
||||||
*/
|
*/
|
||||||
if (png_get_rowbytes(pp, pi) !=
|
if (png_get_rowbytes(pp, pi) !=
|
||||||
transform_rowsize(pp, colour_type, bit_depth))
|
transform_rowsize(pp, colour_type, bit_depth))
|
||||||
@@ -4311,18 +4305,16 @@ make_error(png_store* const ps, png_byte const colour_type,
|
|||||||
transform_row(pp, buffer, colour_type, bit_depth, y);
|
transform_row(pp, buffer, colour_type, bit_depth, y);
|
||||||
|
|
||||||
# if do_own_interlace
|
# if do_own_interlace
|
||||||
/* If do_own_interlace *and* the image is interlaced we
|
/* If do_own_interlace *and* the image is interlaced we need a
|
||||||
* need a reduced interlace row; this may be reduced to
|
* reduced interlace row; this may be reduced to empty.
|
||||||
* empty.
|
|
||||||
*/
|
*/
|
||||||
if (interlace_type == PNG_INTERLACE_ADAM7)
|
if (interlace_type == PNG_INTERLACE_ADAM7)
|
||||||
{
|
{
|
||||||
/* The row must not be written if it doesn't exist,
|
/* The row must not be written if it doesn't exist, notice
|
||||||
* notice that there are two conditions here, either the
|
* that there are two conditions here, either the row isn't
|
||||||
* row isn't ever in the pass or the row would be but
|
* ever in the pass or the row would be but isn't wide
|
||||||
* isn't wide enough to contribute any pixels. In fact
|
* enough to contribute any pixels. In fact the wPass test
|
||||||
* the wPass test can be used to skip the whole y loop
|
* can be used to skip the whole y loop in this case.
|
||||||
* in this case.
|
|
||||||
*/
|
*/
|
||||||
if (PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
if (PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
||||||
PNG_PASS_COLS(w, pass) > 0)
|
PNG_PASS_COLS(w, pass) > 0)
|
||||||
@@ -4337,10 +4329,9 @@ make_error(png_store* const ps, png_byte const colour_type,
|
|||||||
png_write_row(pp, buffer);
|
png_write_row(pp, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* image writing */
|
}
|
||||||
|
|
||||||
png_write_end(pp, pi);
|
png_write_end(pp, pi);
|
||||||
}
|
|
||||||
|
|
||||||
/* The following deletes the file that was just written. */
|
/* The following deletes the file that was just written. */
|
||||||
store_write_reset(ps);
|
store_write_reset(ps);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
libpng version 1.7.0beta70 - December 1, 2015
|
libpng version 1.7.0beta70 - December 3, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<glennrp at users.sourceforge.net>
|
<glennrp at users.sourceforge.net>
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
|||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.7.0beta70 - December 1, 2015
|
libpng versions 0.97, January 1998, through 1.7.0beta70 - December 3, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
|||||||
12
libpng.3
12
libpng.3
@@ -1,4 +1,4 @@
|
|||||||
.TH LIBPNG 3 "December 1, 2015"
|
.TH LIBPNG 3 "December 3, 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta70
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta70
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -498,7 +498,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
|
||||||
|
|
||||||
libpng version 1.7.0beta70 - December 1, 2015
|
libpng version 1.7.0beta70 - December 3, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<glennrp at users.sourceforge.net>
|
<glennrp at users.sourceforge.net>
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
@@ -509,7 +509,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
|||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.7.0beta70 - December 1, 2015
|
libpng versions 0.97, January 1998, through 1.7.0beta70 - December 3, 2015
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
|
|
||||||
@@ -5980,7 +5980,7 @@ possible without all of you.
|
|||||||
|
|
||||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||||
|
|
||||||
Libpng version 1.7.0beta70 - December 1, 2015:
|
Libpng version 1.7.0beta70 - December 3, 2015:
|
||||||
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.
|
||||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||||
|
|
||||||
@@ -6005,7 +6005,7 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, December 1, 2015, are
|
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, December 3, 2015, are
|
||||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||||
derived from libpng-1.0.6, and are distributed according to the same
|
derived from libpng-1.0.6, and are distributed according to the same
|
||||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@@ -6104,7 +6104,7 @@ the additional disclaimers inserted at version 1.0.7.
|
|||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
December 1, 2015
|
December 3, 2015
|
||||||
|
|
||||||
.\" end of man page
|
.\" end of man page
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH LIBPNGPF 3 "November 24, 2015"
|
.TH LIBPNGPF 3 "December 3, 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta70
|
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta70
|
||||||
(private functions)
|
(private functions)
|
||||||
|
|||||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
|||||||
.TH PNG 5 "November 24, 2015"
|
.TH PNG 5 "December 3, 2015"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
png \- Portable Network Graphics (PNG) format
|
png \- Portable Network Graphics (PNG) format
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|||||||
4
png.c
4
png.c
@@ -712,13 +712,13 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.7.0beta70 - November 30, 2015" PNG_STRING_NEWLINE \
|
"libpng version 1.7.0beta70 - December 3, 2015" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.7.0beta70 - November 30, 2015\
|
return "libpng version 1.7.0beta70 - December 3, 2015\
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2015 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.";
|
||||||
|
|||||||
10
png.h
10
png.h
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.7.0beta70, November 30, 2015
|
* libpng version 1.7.0beta70, December 3, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.7.0beta70, November 30, 2015:
|
* libpng versions 0.97, January 1998, through 1.7.0beta70, December 3, 2015:
|
||||||
* Glenn Randers-Pehrson.
|
* Glenn Randers-Pehrson.
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, November 30, 2015, are
|
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta70, December 3, 2015, are
|
||||||
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||||
* derived from libpng-1.0.6, and are distributed according to the same
|
* derived from libpng-1.0.6, and are distributed according to the same
|
||||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* November 30, 2015
|
* December 3, 2015
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
@@ -288,7 +288,7 @@
|
|||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta70"
|
#define PNG_LIBPNG_VER_STRING "1.7.0beta70"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.7.0beta70 - November 30, 2015\n"
|
" libpng version 1.7.0beta70 - December 3, 2015\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 17
|
#define PNG_LIBPNG_VER_SONUM 17
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 17
|
#define PNG_LIBPNG_VER_DLLNUM 17
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.7.0beta70, November 24, 2015
|
* libpng version 1.7.0beta70, December 3, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
|||||||
@@ -727,20 +727,22 @@ png_read_destroy(png_structrp png_ptr)
|
|||||||
png_free(png_ptr, png_ptr->read_buffer);
|
png_free(png_ptr, png_ptr->read_buffer);
|
||||||
png_ptr->read_buffer = NULL;
|
png_ptr->read_buffer = NULL;
|
||||||
|
|
||||||
if (png_ptr->palette != NULL)
|
if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->palette);
|
png_free(png_ptr, png_ptr->palette);
|
||||||
png_ptr->num_palette = 0;
|
png_ptr->num_palette = 0;
|
||||||
png_ptr->palette = NULL;
|
png_ptr->palette = NULL;
|
||||||
}
|
}
|
||||||
|
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_PLTE);
|
||||||
|
|
||||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||||
if (png_ptr->trans_alpha != NULL)
|
if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->trans_alpha);
|
png_free(png_ptr, png_ptr->trans_alpha);
|
||||||
png_ptr->num_trans = 0;
|
png_ptr->num_trans = 0;
|
||||||
png_ptr->trans_alpha = NULL;
|
png_ptr->trans_alpha = NULL;
|
||||||
}
|
}
|
||||||
|
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_TRNS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (png_ptr->zstream.state != NULL)
|
if (png_ptr->zstream.state != NULL)
|
||||||
|
|||||||
36
pngrtran.c
36
pngrtran.c
@@ -5985,15 +5985,21 @@ setup_palette_cache(png_structp png_ptr, png_byte cache[8*256])
|
|||||||
static void
|
static void
|
||||||
png_remove_PLTE_and_tRNS(png_structrp png_ptr)
|
png_remove_PLTE_and_tRNS(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
if (png_ptr->palette != NULL)
|
if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
|
||||||
|
{
|
||||||
|
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_PLTE);
|
||||||
png_free(png_ptr, png_ptr->palette);
|
png_free(png_ptr, png_ptr->palette);
|
||||||
|
}
|
||||||
|
|
||||||
png_ptr->palette = NULL;
|
png_ptr->palette = NULL;
|
||||||
png_ptr->num_palette = 0;
|
png_ptr->num_palette = 0;
|
||||||
|
|
||||||
# ifdef PNG_READ_tRNS_SUPPORTED
|
# ifdef PNG_READ_tRNS_SUPPORTED
|
||||||
if (png_ptr->trans_alpha != NULL)
|
if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
|
||||||
|
{
|
||||||
|
png_ptr->free_me &= PNG_BIC_MASK(PNG_FREE_TRNS);
|
||||||
png_free(png_ptr, png_ptr->trans_alpha);
|
png_free(png_ptr, png_ptr->trans_alpha);
|
||||||
|
}
|
||||||
|
|
||||||
png_ptr->trans_alpha = NULL;
|
png_ptr->trans_alpha = NULL;
|
||||||
png_ptr->num_trans = 0;
|
png_ptr->num_trans = 0;
|
||||||
@@ -6096,10 +6102,13 @@ update_palette(png_structp png_ptr, png_cache_paramsp cp,
|
|||||||
* entries were shifted or inverted. This could be fixed, but it would
|
* entries were shifted or inverted. This could be fixed, but it would
|
||||||
* complicate the libpng API to expose the information.
|
* complicate the libpng API to expose the information.
|
||||||
*/
|
*/
|
||||||
|
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||||
|
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||||
|
png_ptr->free_me |= PNG_FREE_PLTE;
|
||||||
|
|
||||||
/* Write the transformed palette: */
|
/* Write the transformed palette: */
|
||||||
{
|
{
|
||||||
png_colorp palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
png_colorp palette = png_ptr->palette;
|
||||||
sizeof (png_color[PNG_MAX_PALETTE_LENGTH])));
|
|
||||||
png_const_bytep p;
|
png_const_bytep p;
|
||||||
const int is_color = (cp->tend.format & PNG_FORMAT_FLAG_COLOR) != 0;
|
const int is_color = (cp->tend.format & PNG_FORMAT_FLAG_COLOR) != 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -6109,10 +6118,6 @@ update_palette(png_structp png_ptr, png_cache_paramsp cp,
|
|||||||
png_byte trans_alpha[PNG_MAX_PALETTE_LENGTH];
|
png_byte trans_alpha[PNG_MAX_PALETTE_LENGTH];
|
||||||
# endif /* READ_tRNS */
|
# endif /* READ_tRNS */
|
||||||
|
|
||||||
memset(palette, 0xFFU, sizeof (png_color[PNG_MAX_PALETTE_LENGTH]));
|
|
||||||
png_free(png_ptr, png_ptr->palette);
|
|
||||||
png_ptr->palette = palette;
|
|
||||||
|
|
||||||
for (i=0, p=cache.b8; i<cp->tend.width; ++i)
|
for (i=0, p=cache.b8; i<cp->tend.width; ++i)
|
||||||
{
|
{
|
||||||
if (is_color)
|
if (is_color)
|
||||||
@@ -6143,17 +6148,12 @@ update_palette(png_structp png_ptr, png_cache_paramsp cp,
|
|||||||
# ifdef PNG_READ_tRNS_SUPPORTED
|
# ifdef PNG_READ_tRNS_SUPPORTED
|
||||||
if (num_trans > 0)
|
if (num_trans > 0)
|
||||||
{
|
{
|
||||||
png_bytep tRNS = png_voidcast(png_bytep, png_malloc(png_ptr,
|
png_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||||
PNG_MAX_PALETTE_LENGTH));
|
PNG_MAX_PALETTE_LENGTH));
|
||||||
|
png_ptr->free_me |= PNG_FREE_TRNS;
|
||||||
memset(tRNS, 0xFFU, PNG_MAX_PALETTE_LENGTH);
|
memcpy(png_ptr->trans_alpha, trans_alpha, num_trans);
|
||||||
|
memset(png_ptr->trans_alpha+num_trans, 0xFFU,
|
||||||
if (png_ptr->trans_alpha != NULL)
|
PNG_MAX_PALETTE_LENGTH-num_trans);
|
||||||
png_free(png_ptr, png_ptr->trans_alpha);
|
|
||||||
|
|
||||||
png_ptr->trans_alpha = tRNS;
|
|
||||||
|
|
||||||
memcpy(tRNS, trans_alpha, num_trans);
|
|
||||||
png_ptr->num_trans = png_check_bits(png_ptr, num_trans, 9);
|
png_ptr->num_trans = png_check_bits(png_ptr, num_trans, 9);
|
||||||
}
|
}
|
||||||
# endif /* READ_tRNS */
|
# endif /* READ_tRNS */
|
||||||
|
|||||||
73
pngrutil.c
73
pngrutil.c
@@ -849,7 +849,8 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
{
|
{
|
||||||
png_color palette[PNG_MAX_PALETTE_LENGTH];
|
png_color palette[PNG_MAX_PALETTE_LENGTH];
|
||||||
png_uint_32 length = png_ptr->chunk_length;
|
png_uint_32 length = png_ptr->chunk_length;
|
||||||
png_uint_32 max_palette_length, num, i;
|
int max_palette_length, num, i;
|
||||||
|
png_colorp pal_ptr;
|
||||||
|
|
||||||
png_debug(1, "in png_handle_PLTE");
|
png_debug(1, "in png_handle_PLTE");
|
||||||
|
|
||||||
@@ -877,7 +878,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
|
/* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
|
||||||
num = length / 3U;
|
num = (int)length / 3;
|
||||||
|
|
||||||
/* If the palette has 256 or fewer entries but is too large for the bit
|
/* If the palette has 256 or fewer entries but is too large for the bit
|
||||||
* depth, we don't issue an error, to preserve the behavior of previous
|
* depth, we don't issue an error, to preserve the behavior of previous
|
||||||
@@ -885,21 +886,21 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
max_palette_length = (1U << png_ptr->bit_depth);
|
max_palette_length = (1 << png_ptr->bit_depth);
|
||||||
else
|
else
|
||||||
max_palette_length = PNG_MAX_PALETTE_LENGTH;
|
max_palette_length = PNG_MAX_PALETTE_LENGTH;
|
||||||
|
|
||||||
if (num > max_palette_length)
|
if (num > max_palette_length)
|
||||||
num = max_palette_length;
|
num = max_palette_length;
|
||||||
|
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
|
||||||
{
|
{
|
||||||
png_byte buf[3];
|
png_byte buf[3];
|
||||||
|
|
||||||
png_crc_read(png_ptr, buf, 3);
|
png_crc_read(png_ptr, buf, 3);
|
||||||
palette[i].red = buf[0];
|
pal_ptr->red = buf[0];
|
||||||
palette[i].green = buf[1];
|
pal_ptr->green = buf[1];
|
||||||
palette[i].blue = buf[2];
|
pal_ptr->blue = buf[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we actually need the PLTE chunk (ie for a paletted image), we do
|
/* If we actually need the PLTE chunk (ie for a paletted image), we do
|
||||||
@@ -910,7 +911,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
#endif
|
#endif
|
||||||
png_crc_finish(png_ptr, length - num * 3U);
|
png_crc_finish(png_ptr, (int) length - num * 3);
|
||||||
|
|
||||||
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
|
||||||
@@ -941,16 +942,16 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
#endif /* READ_OPT_PLTE */
|
#endif /* READ_OPT_PLTE */
|
||||||
|
|
||||||
|
/* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its
|
||||||
|
* own copy of the palette. This has the side effect that when png_start_row
|
||||||
|
* is called (this happens after any call to png_read_update_info) the
|
||||||
|
* info_ptr palette gets changed. This is extremely unexpected and
|
||||||
|
* confusing.
|
||||||
|
*
|
||||||
|
* Fix this by not sharing the palette in this way.
|
||||||
|
*/
|
||||||
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
png_set_PLTE(png_ptr, info_ptr, palette, num);
|
||||||
|
|
||||||
/* Ok, make our own copy since the set succeeded: */
|
|
||||||
debug(png_ptr->palette == NULL); /* should only get set once */
|
|
||||||
png_ptr->palette = png_voidcast(png_colorp, png_malloc(png_ptr,
|
|
||||||
sizeof (png_color[PNG_MAX_PALETTE_LENGTH])));
|
|
||||||
memset(png_ptr->palette, 0xFFU, sizeof (png_color[PNG_MAX_PALETTE_LENGTH]));
|
|
||||||
memcpy(png_ptr->palette, info_ptr->palette, 3*num);
|
|
||||||
png_ptr->num_palette = info_ptr->num_palette;
|
|
||||||
|
|
||||||
/* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before
|
/* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before
|
||||||
* IDAT. Prior to 1.6.0 this was not checked; instead the code merely
|
* IDAT. Prior to 1.6.0 this was not checked; instead the code merely
|
||||||
* checked the apparent validity of a tRNS chunk inserted before PLTE on a
|
* checked the apparent validity of a tRNS chunk inserted before PLTE on a
|
||||||
@@ -1605,13 +1606,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
static void
|
static void
|
||||||
png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
{
|
{
|
||||||
png_uint_32 num_trans;
|
|
||||||
png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
|
png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
|
||||||
|
|
||||||
png_debug(1, "in png_handle_tRNS");
|
png_debug(1, "in png_handle_tRNS");
|
||||||
|
|
||||||
png_ptr->num_trans = 0U; /* safety */
|
|
||||||
|
|
||||||
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
|
||||||
{
|
{
|
||||||
/* libpng 1.7.0: this used to be a benign error, but it doesn't look very
|
/* libpng 1.7.0: this used to be a benign error, but it doesn't look very
|
||||||
@@ -1635,7 +1633,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_crc_read(png_ptr, buf, 2);
|
png_crc_read(png_ptr, buf, 2);
|
||||||
num_trans = 1U;
|
png_ptr->num_trans = 1;
|
||||||
png_ptr->trans_color.gray = png_get_uint_16(buf);
|
png_ptr->trans_color.gray = png_get_uint_16(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1650,7 +1648,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_crc_read(png_ptr, buf, 6);
|
png_crc_read(png_ptr, buf, 6);
|
||||||
num_trans = 1U;
|
png_ptr->num_trans = 1;
|
||||||
png_ptr->trans_color.red = png_get_uint_16(buf);
|
png_ptr->trans_color.red = png_get_uint_16(buf);
|
||||||
png_ptr->trans_color.green = png_get_uint_16(buf + 2);
|
png_ptr->trans_color.green = png_get_uint_16(buf + 2);
|
||||||
png_ptr->trans_color.blue = png_get_uint_16(buf + 4);
|
png_ptr->trans_color.blue = png_get_uint_16(buf + 4);
|
||||||
@@ -1658,18 +1656,21 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
|
|
||||||
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
|
png_uint_32 length;
|
||||||
|
|
||||||
/* png_find_chunk_op checks this: */
|
/* png_find_chunk_op checks this: */
|
||||||
debug(png_ptr->mode & PNG_HAVE_PLTE);
|
debug(png_ptr->mode & PNG_HAVE_PLTE);
|
||||||
|
|
||||||
num_trans = png_ptr->chunk_length;
|
length = png_ptr->chunk_length;
|
||||||
|
|
||||||
if (num_trans > png_ptr->num_palette || num_trans == 0)
|
if (length > png_ptr->num_palette || length == 0)
|
||||||
{
|
{
|
||||||
png_handle_bad_length(png_ptr);
|
png_handle_bad_length(png_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_crc_read(png_ptr, readbuf, num_trans);
|
png_crc_read(png_ptr, readbuf, length);
|
||||||
|
png_ptr->num_trans = length & 0x1FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -1679,22 +1680,20 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (png_crc_finish(png_ptr, 0))
|
if (png_crc_finish(png_ptr, 0))
|
||||||
return;
|
|
||||||
|
|
||||||
/* Set it into the info_struct: */
|
|
||||||
png_set_tRNS(png_ptr, info_ptr, readbuf, num_trans, &png_ptr->trans_color);
|
|
||||||
|
|
||||||
/* Now make a copy of the buffer if one is required (palette images). */
|
|
||||||
debug(png_ptr->trans_alpha == NULL);
|
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
|
||||||
{
|
{
|
||||||
png_ptr->trans_alpha = png_voidcast(png_bytep,
|
png_ptr->num_trans = 0;
|
||||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
return;
|
||||||
memset(png_ptr->trans_alpha, 0xFFU, PNG_MAX_PALETTE_LENGTH);
|
|
||||||
memcpy(png_ptr->trans_alpha, info_ptr->trans_alpha, num_trans);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr->num_trans = png_check_bits(png_ptr, num_trans, 9);
|
/* TODO: this is a horrible side effect in the palette case because the
|
||||||
|
* png_struct ends up with a pointer to the tRNS buffer owned by the
|
||||||
|
* png_info. Fix this.
|
||||||
|
*/
|
||||||
|
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
|
||||||
|
&(png_ptr->trans_color));
|
||||||
|
|
||||||
|
if (info_ptr != NULL)
|
||||||
|
png_ptr->trans_alpha = info_ptr->trans_alpha;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define png_handle_tRNS NULL
|
# define png_handle_tRNS NULL
|
||||||
|
|||||||
22
pngset.c
22
pngset.c
@@ -533,20 +533,30 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
png_error(png_ptr, "Invalid palette");
|
png_error(png_ptr, "Invalid palette");
|
||||||
#endif /* MNG_FEATURES */
|
#endif /* MNG_FEATURES */
|
||||||
|
|
||||||
|
/* It may not actually be necessary to set png_ptr->palette here;
|
||||||
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
|
* function used to do the allocation.
|
||||||
|
*
|
||||||
|
* 1.6.0: the above statement appears to be incorrect; something has to set
|
||||||
|
* the palette inside png_struct on read.
|
||||||
|
*/
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
|
||||||
|
|
||||||
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
|
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
|
||||||
* of num_palette entries, in case of an invalid PNG file or incorrect
|
* of num_palette entries, in case of an invalid PNG file or incorrect
|
||||||
* call to png_set_PLTE() with too-large sample values.
|
* call to png_set_PLTE() with too-large sample values.
|
||||||
*/
|
*/
|
||||||
info_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||||
|
|
||||||
if (num_palette > 0)
|
if (num_palette > 0)
|
||||||
memcpy(info_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||||
|
info_ptr->palette = png_ptr->palette;
|
||||||
|
info_ptr->num_palette = png_ptr->num_palette = png_check_bits(png_ptr,
|
||||||
|
num_palette, 9);
|
||||||
|
|
||||||
info_ptr->num_palette = png_check_bits(png_ptr, num_palette, 9);
|
|
||||||
info_ptr->free_me |= PNG_FREE_PLTE;
|
info_ptr->free_me |= PNG_FREE_PLTE;
|
||||||
|
|
||||||
info_ptr->valid |= PNG_INFO_PLTE;
|
info_ptr->valid |= PNG_INFO_PLTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,11 +962,11 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
/* Expect png_set_PLTE to happen before png_set_tRNS, so num_palette will
|
/* Expect png_set_PLTE to happen before png_set_tRNS, so num_palette will
|
||||||
* be set, but this is not a requirement of the API.
|
* be set, but this is not a requirement of the API.
|
||||||
*/
|
*/
|
||||||
if (info_ptr->num_palette)
|
if (png_ptr->num_palette)
|
||||||
max_num = info_ptr->num_palette;
|
max_num = png_ptr->num_palette;
|
||||||
|
|
||||||
else
|
else
|
||||||
max_num = 1 << info_ptr->bit_depth;
|
max_num = 1 << png_ptr->bit_depth;
|
||||||
|
|
||||||
if (num_trans > max_num)
|
if (num_trans > max_num)
|
||||||
{
|
{
|
||||||
|
|||||||
31
pngstruct.h
31
pngstruct.h
@@ -370,18 +370,17 @@ struct png_struct_def
|
|||||||
* the hope is that such processors will generate code that is both smaller
|
* the hope is that such processors will generate code that is both smaller
|
||||||
* and faster.
|
* and faster.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_READ_SUPPORTED
|
|
||||||
png_colorp palette; /* palette from the input file */
|
png_colorp palette; /* palette from the input file */
|
||||||
#endif /* READ */
|
|
||||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||||
png_bytep trans_alpha; /* alpha values for paletted files */
|
png_bytep trans_alpha; /* alpha values for paletted files */
|
||||||
#endif /* READ_tRNS */
|
#endif
|
||||||
|
|
||||||
png_uint_32 width; /* width of image in pixels */
|
png_uint_32 width; /* width of image in pixels */
|
||||||
png_uint_32 height; /* height of image in pixels */
|
png_uint_32 height; /* height of image in pixels */
|
||||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||||
png_uint_32 chunk_length; /* Length (possibly remaining) in said chunk. */
|
png_uint_32 chunk_length; /* Length (possibly remaining) in said chunk. */
|
||||||
png_uint_32 crc; /* current chunk CRC value */
|
png_uint_32 crc; /* current chunk CRC value */
|
||||||
|
png_uint_32 free_me; /* items libpng is responsible for freeing */
|
||||||
|
|
||||||
unsigned int flags; /* flags (should be bit fields) */
|
unsigned int flags; /* flags (should be bit fields) */
|
||||||
unsigned int mode :6; /* where we are in the PNG file */
|
unsigned int mode :6; /* where we are in the PNG file */
|
||||||
@@ -600,7 +599,12 @@ struct png_struct_def
|
|||||||
int zlib_set_window_bits;
|
int zlib_set_window_bits;
|
||||||
int zlib_set_mem_level;
|
int zlib_set_mem_level;
|
||||||
int zlib_set_strategy;
|
int zlib_set_strategy;
|
||||||
#endif /* WRITE */
|
|
||||||
|
unsigned int zbuffer_start; /* Bytes written from start */
|
||||||
|
png_uint_32 zbuffer_len; /* Length of data in list */
|
||||||
|
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||||
|
png_compression_bufferp *zbuffer_end; /* 'next' field of current buffer */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ERROR HANDLING */
|
/* ERROR HANDLING */
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
@@ -744,23 +748,14 @@ struct png_struct_def
|
|||||||
* zlib expects a 'zstream' as the fundamental control structure, it allows
|
* zlib expects a 'zstream' as the fundamental control structure, it allows
|
||||||
* all the parameters to be passed as one pointer.
|
* all the parameters to be passed as one pointer.
|
||||||
*/
|
*/
|
||||||
z_stream zstream; /* decompression structure */
|
|
||||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
z_stream zstream; /* decompression structure */
|
||||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
unsigned int zstream_start:1; /* before first byte of stream */
|
||||||
png_compression_bufferp *zbuffer_end; /* 'next' field of current buffer */
|
unsigned int zstream_ended:1; /* no more zlib output available */
|
||||||
png_uint_32 zbuffer_len; /* Length of data in list */
|
unsigned int zstream_error:1; /* zlib error message has been output */
|
||||||
unsigned int zbuffer_start; /* Bytes written from start */
|
|
||||||
# endif /* WRITE */
|
|
||||||
# ifdef PNG_READ_SUPPORTED
|
|
||||||
unsigned int zstream_ended:1; /* no more zlib output available [read] */
|
|
||||||
unsigned int zstream_error:1; /* zlib error message has been output [read] */
|
|
||||||
# endif /* READ */
|
|
||||||
# ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
|
||||||
unsigned int zstream_eod :1; /* all the required uncompressed data has been
|
unsigned int zstream_eod :1; /* all the required uncompressed data has been
|
||||||
* received; set by the zstream using code for
|
* received; set by the zstream using code for
|
||||||
* its own purposes. [progressive read] */
|
* its own purposes. */
|
||||||
# endif /* PROGRESSIVE_READ */
|
|
||||||
|
|
||||||
/* MNG SUPPORT */
|
/* MNG SUPPORT */
|
||||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
|||||||
23
pngtrans.c
23
pngtrans.c
@@ -580,13 +580,12 @@ init_transform_mech(png_structrp png_ptr, png_transform_control *tc, int start)
|
|||||||
|
|
||||||
#ifdef PNG_PALETTE_MAX_SUPPORTED
|
#ifdef PNG_PALETTE_MAX_SUPPORTED
|
||||||
static int
|
static int
|
||||||
set_palette_max(png_structrp png_ptr, png_transformp tr, unsigned int max,
|
set_palette_max(png_structrp png_ptr, png_transformp tr, unsigned int max)
|
||||||
unsigned int format_max)
|
|
||||||
/* Called whenever a new maximum pixel value is found */
|
/* Called whenever a new maximum pixel value is found */
|
||||||
{
|
{
|
||||||
/* One of these must be true: */
|
/* One of these must be true: */
|
||||||
# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
if (max >= tr->args && !png_ptr->palette_index_check_issued)
|
if (max >= png_ptr->num_palette && !png_ptr->palette_index_check_issued)
|
||||||
{
|
{
|
||||||
# ifdef PNG_READ_SUPPORTED
|
# ifdef PNG_READ_SUPPORTED
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
@@ -605,7 +604,7 @@ set_palette_max(png_structrp png_ptr, png_transformp tr, unsigned int max,
|
|||||||
png_ptr->palette_index_max = png_check_bits(png_ptr, max, 9);
|
png_ptr->palette_index_max = png_check_bits(png_ptr, max, 9);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (max == format_max)
|
if (max == (1U << png_ptr->bit_depth)-1U)
|
||||||
{
|
{
|
||||||
tr->fn = NULL; /* no point continuing once the max has been seen */
|
tr->fn = NULL; /* no point continuing once the max has been seen */
|
||||||
return 1; /* stop */
|
return 1; /* stop */
|
||||||
@@ -634,7 +633,7 @@ palette_max_1bpp(png_transformp *tr, png_transform_controlp tc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If the code reaches this point there is a set pixel */
|
/* If the code reaches this point there is a set pixel */
|
||||||
(void)set_palette_max(tc->png_ptr, *tr, 1U, 1U);
|
(void)set_palette_max(tc->png_ptr, *tr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -691,7 +690,7 @@ palette_max_2bpp(png_transformp *tr, png_transform_controlp tc)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* new_max is greater than max: */
|
/* new_max is greater than max: */
|
||||||
if (set_palette_max(tc->png_ptr, *tr, new_max, 3U))
|
if (set_palette_max(tc->png_ptr, *tr, new_max))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Record new_max: */
|
/* Record new_max: */
|
||||||
@@ -727,7 +726,7 @@ palette_max_4bpp(png_transformp *tr, png_transform_controlp tc)
|
|||||||
|
|
||||||
if (max > (*tr)->args)
|
if (max > (*tr)->args)
|
||||||
{
|
{
|
||||||
if (set_palette_max(tc->png_ptr, *tr, max, 15U))
|
if (set_palette_max(tc->png_ptr, *tr, max))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*tr)->args = max;
|
(*tr)->args = max;
|
||||||
@@ -753,7 +752,7 @@ palette_max_8bpp(png_transformp *tr, png_transform_controlp tc)
|
|||||||
|
|
||||||
if (max > (*tr)->args)
|
if (max > (*tr)->args)
|
||||||
{
|
{
|
||||||
if (set_palette_max(tc->png_ptr, *tr, max, 255U))
|
if (set_palette_max(tc->png_ptr, *tr, max))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*tr)->args = max;
|
(*tr)->args = max;
|
||||||
@@ -766,12 +765,7 @@ palette_max_init(png_transformp *tr, png_transform_controlp tc)
|
|||||||
# define png_ptr (tc->png_ptr)
|
# define png_ptr (tc->png_ptr)
|
||||||
if ((tc->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
if ((tc->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||||
{
|
{
|
||||||
if (tc->init == PNG_TC_INIT_FINAL)
|
if (tc->init == PNG_TC_INIT_FINAL) switch (tc->bit_depth)
|
||||||
{
|
|
||||||
/* Record the palette depth to check here: */
|
|
||||||
(*tr)->args = png_ptr->num_palette;
|
|
||||||
|
|
||||||
switch (tc->bit_depth)
|
|
||||||
{
|
{
|
||||||
case 1: (*tr)->fn = palette_max_1bpp; break;
|
case 1: (*tr)->fn = palette_max_1bpp; break;
|
||||||
case 2: (*tr)->fn = palette_max_2bpp; break;
|
case 2: (*tr)->fn = palette_max_2bpp; break;
|
||||||
@@ -780,7 +774,6 @@ palette_max_init(png_transformp *tr, png_transform_controlp tc)
|
|||||||
default:impossible("palette bit depth");
|
default:impossible("palette bit depth");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
(*tr)->fn = NULL; /* not applicable */
|
(*tr)->fn = NULL; /* not applicable */
|
||||||
|
|||||||
137
pngwutil.c
137
pngwutil.c
@@ -1319,6 +1319,14 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
|||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
affirm(num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH);
|
affirm(num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH);
|
||||||
|
if ((unsigned int)/*SAFE*/num_trans > png_ptr->num_palette)
|
||||||
|
{
|
||||||
|
/* This is an error which can only be reliably detected late. */
|
||||||
|
png_app_error(png_ptr,
|
||||||
|
"Invalid number of transparent colors specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
# ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
# ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
union
|
union
|
||||||
@@ -1899,14 +1907,62 @@ png_start_IDAT(png_structrp png_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
png_write_IDAT(png_structrp png_ptr, int end_of_image)
|
png_compress_IDAT(png_structrp png_ptr, png_const_voidp input, uInt input_len,
|
||||||
|
int flush)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* The stream must have been claimed: */
|
||||||
|
affirm(png_ptr->zowner == png_IDAT);
|
||||||
|
|
||||||
|
/* z_stream::{next,avail}_out are set by png_compress to point into the
|
||||||
|
* buffer list. next_in must be set here, avail_in comes from the input_len
|
||||||
|
* parameter:
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
png_uint_32 output_len = 0U;
|
||||||
|
|
||||||
|
png_ptr->zstream.next_in =
|
||||||
|
PNGZ_INPUT_CAST(png_voidcast(const Bytef*,input));
|
||||||
|
ret = png_compress(png_ptr, &png_ptr->zstream, &png_ptr->zbuffer_end,
|
||||||
|
input_len, &output_len, flush);
|
||||||
|
implies(ret == Z_OK || ret == Z_FINISH, png_ptr->zstream.avail_in == 0U);
|
||||||
|
png_ptr->zstream.next_in = NULL;
|
||||||
|
png_ptr->zstream.avail_in = 0U; /* safety */
|
||||||
|
|
||||||
|
/* If IDAT_size is set to PNG_UINT_31_MAX the length will be larger, but
|
||||||
|
* not enough to overflow a png_uint_32.
|
||||||
|
*/
|
||||||
|
png_ptr->zbuffer_len += output_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the return code. */
|
||||||
|
if (ret == Z_OK || ret == Z_STREAM_END)
|
||||||
|
{
|
||||||
|
/* Z_FINISH should give Z_STREAM_END, everything else should give Z_OK,
|
||||||
|
* so:
|
||||||
|
*/
|
||||||
|
debug((ret == Z_STREAM_END) == (flush == Z_FINISH));
|
||||||
|
|
||||||
|
/* At this point png_compress has produced (in total) zbuffer_start +
|
||||||
|
* zbuffer_len compressed bytes in a list of compression buffers starting
|
||||||
|
* with zbuffer_list and ending with the buffer containing *zbuffer_end,
|
||||||
|
* which may be NULL or may point to unused compression buffers.
|
||||||
|
*
|
||||||
|
* This code has already written out zbuffer_start bytes from the first
|
||||||
|
* buffer. Can we write more? If flush is Z_FINISH this is the end of
|
||||||
|
* the stream and there should be final bytes to write. Otherwise wait
|
||||||
|
* for IDAT_size bytes before writing a chunk. If nothing is to be
|
||||||
|
* written this function call is complete.
|
||||||
|
*/
|
||||||
|
if (flush == Z_FINISH || png_ptr->zbuffer_len >= png_ptr->IDAT_size)
|
||||||
|
{
|
||||||
png_compression_bufferp *listp = &png_ptr->zbuffer_list;
|
png_compression_bufferp *listp = &png_ptr->zbuffer_list;
|
||||||
png_compression_bufferp list;
|
png_compression_bufferp list;
|
||||||
png_uint_32 output_len = png_ptr->zbuffer_len;
|
png_uint_32 output_len = png_ptr->zbuffer_len;
|
||||||
png_uint_32 start = png_ptr->zbuffer_start;
|
png_uint_32 start = png_ptr->zbuffer_start;
|
||||||
png_uint_32 size = png_ptr->IDAT_size;
|
png_uint_32 size = png_ptr->IDAT_size;
|
||||||
const png_uint_32 min_size = (end_of_image ? 1U : size);
|
const png_uint_32 min_size = (flush == Z_FINISH ? 1U : size);
|
||||||
|
|
||||||
affirm(output_len >= min_size);
|
affirm(output_len >= min_size);
|
||||||
|
|
||||||
@@ -1986,7 +2042,7 @@ png_write_IDAT(png_structrp png_ptr, int end_of_image)
|
|||||||
|
|
||||||
if (output_len > 0U) /* Still got stuff to write */
|
if (output_len > 0U) /* Still got stuff to write */
|
||||||
{
|
{
|
||||||
affirm(!end_of_image && list != NULL);
|
affirm(flush != Z_FINISH && list != NULL);
|
||||||
|
|
||||||
/* If any compression buffers have been completely written move them
|
/* If any compression buffers have been completely written move them
|
||||||
* to the end of the list so that they can be re-used and move
|
* to the end of the list so that they can be re-used and move
|
||||||
@@ -2008,7 +2064,7 @@ png_write_IDAT(png_structrp png_ptr, int end_of_image)
|
|||||||
|
|
||||||
else /* output_len == 0U; all compressed data has been written */
|
else /* output_len == 0U; all compressed data has been written */
|
||||||
{
|
{
|
||||||
if (end_of_image)
|
if (flush == Z_FINISH) /* end of data */
|
||||||
{
|
{
|
||||||
png_ptr->zowner = 0U; /* release z_stream */
|
png_ptr->zowner = 0U; /* release z_stream */
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||||
@@ -2026,78 +2082,7 @@ png_write_IDAT(png_structrp png_ptr, int end_of_image)
|
|||||||
png_ptr->zbuffer_len = 0U;
|
png_ptr->zbuffer_len = 0U;
|
||||||
png_ptr->zbuffer_end = &png_ptr->zbuffer_list;
|
png_ptr->zbuffer_end = &png_ptr->zbuffer_list;
|
||||||
} /* output_len == 0 */
|
} /* output_len == 0 */
|
||||||
}
|
} /* flush == FINISH || png_ptr->zbuffer_len >= png_ptr->IDAT_size */
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
png_compression_bufferp *zbuffer_end; /* 'next' field of current buffer */
|
|
||||||
png_uint_32 zbuffer_len; /* Length of data in list */
|
|
||||||
} png_IDAT_compression_state;
|
|
||||||
|
|
||||||
static int
|
|
||||||
png_compress_IDAT_test(png_structrp png_ptr, png_IDAT_compression_state *state,
|
|
||||||
z_stream *zstream, png_const_voidp input, uInt input_len, int flush)
|
|
||||||
{
|
|
||||||
png_uint_32 output_len = 0U;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* The stream must have been claimed: */
|
|
||||||
affirm(png_ptr->zowner == png_IDAT);
|
|
||||||
|
|
||||||
/* z_stream::{next,avail}_out are set by png_compress to point into the
|
|
||||||
* buffer list. next_in must be set here, avail_in comes from the input_len
|
|
||||||
* parameter:
|
|
||||||
*/
|
|
||||||
zstream->next_in = PNGZ_INPUT_CAST(png_voidcast(const Bytef*, input));
|
|
||||||
ret = png_compress(png_ptr, zstream, &state->zbuffer_end, input_len,
|
|
||||||
&output_len, flush);
|
|
||||||
implies(ret == Z_OK || ret == Z_FINISH, zstream->avail_in == 0U);
|
|
||||||
zstream->next_in = NULL;
|
|
||||||
zstream->avail_in = 0U; /* safety */
|
|
||||||
|
|
||||||
/* If IDAT_size is set to PNG_UINT_31_MAX the length will be larger, but
|
|
||||||
* not enough to overflow a png_uint_32.
|
|
||||||
*/
|
|
||||||
state->zbuffer_len += output_len;
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
png_compress_IDAT(png_structp png_ptr, png_const_voidp input, uInt input_len,
|
|
||||||
int flush)
|
|
||||||
{
|
|
||||||
png_IDAT_compression_state state;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
state.zbuffer_end = png_ptr->zbuffer_end;
|
|
||||||
state.zbuffer_len = png_ptr->zbuffer_len;
|
|
||||||
ret = png_compress_IDAT_test(png_ptr, &state, &png_ptr->zstream, input,
|
|
||||||
input_len, flush);
|
|
||||||
png_ptr->zbuffer_end = state.zbuffer_end;
|
|
||||||
png_ptr->zbuffer_len = state.zbuffer_len;
|
|
||||||
|
|
||||||
/* Check the return code. */
|
|
||||||
if (ret == Z_OK || ret == Z_STREAM_END)
|
|
||||||
{
|
|
||||||
/* Z_FINISH should give Z_STREAM_END, everything else should give Z_OK,
|
|
||||||
* so:
|
|
||||||
*/
|
|
||||||
debug((ret == Z_STREAM_END) == (flush == Z_FINISH));
|
|
||||||
|
|
||||||
/* At this point png_compress has produced (in total) zbuffer_start +
|
|
||||||
* zbuffer_len compressed bytes in a list of compression buffers starting
|
|
||||||
* with zbuffer_list and ending with the buffer containing *zbuffer_end,
|
|
||||||
* which may be NULL or may point to unused compression buffers.
|
|
||||||
*
|
|
||||||
* This code has already written out zbuffer_start bytes from the first
|
|
||||||
* buffer. Can we write more? If flush is Z_FINISH this is the end of
|
|
||||||
* the stream and there should be final bytes to write. Otherwise wait
|
|
||||||
* for IDAT_size bytes before writing a chunk. If nothing is to be
|
|
||||||
* written this function call is complete.
|
|
||||||
*/
|
|
||||||
if (flush == Z_FINISH || png_ptr->zbuffer_len >= png_ptr->IDAT_size)
|
|
||||||
png_write_IDAT(png_ptr, flush == Z_FINISH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else /* ret != Z_OK && ret != Z_STREAM_END */
|
else /* ret != Z_OK && ret != Z_STREAM_END */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
VisualStudio instructions
|
VisualStudio instructions
|
||||||
|
|
||||||
libpng version 1.7.0beta70 - November 24, 2015
|
libpng version 1.7.0beta70 - December 3, 2015
|
||||||
|
|
||||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
* zlib.props - location of zlib source
|
* zlib.props - location of zlib source
|
||||||
*
|
*
|
||||||
* libpng version 1.7.0beta70 - November 24, 2015
|
* libpng version 1.7.0beta70 - December 3, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Makefiles for libpng version 1.7.0beta70 - November 24, 2015
|
Makefiles for libpng version 1.7.0beta70 - December 3, 2015
|
||||||
|
|
||||||
pnglibconf.h.prebuilt => Stores configuration settings
|
pnglibconf.h.prebuilt => Stores configuration settings
|
||||||
makefile.linux => Linux/ELF makefile
|
makefile.linux => Linux/ELF makefile
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* Libpng version 1.7.0beta70 - November 30, 2015 */
|
/* Libpng version 1.7.0beta70 - December 3, 2015 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user