Imported from libpng-1.0.1b.tar
This commit is contained in:
parent
896239be20
commit
1d96361273
40
ANNOUNCE
40
ANNOUNCE
@ -1,24 +1,34 @@
|
||||
|
||||
Libpng 1.0.1a April 21, 1998
|
||||
Libpng 1.0.1b May 2, 1998
|
||||
|
||||
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.
|
||||
|
||||
Changes since the last release:
|
||||
Changes since the last public release:
|
||||
|
||||
Optimized Paeth calculations by replacing abs() function calls with intrinsics
|
||||
plus other loop optimizations. Improves avg decoding speed by about 20 percent.
|
||||
Commented out i386istic "align" compiler flags in makefile.lnx.
|
||||
Reduced the default warning level in some makefiles, to make them consistent.
|
||||
Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
|
||||
Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
|
||||
Added grayscale and 16-bit capability to png_do_read_filler().
|
||||
Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
|
||||
too large when writing an image with bit_depth < 8 (Bob Dellaca).
|
||||
Corrected some bugs in the experimental weighted filtering heuristics.
|
||||
Moved a misplaced pngrutil code block that truncates tRNS if it has more
|
||||
than num_palette entries -- test was done before num_palette was defined.
|
||||
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
|
||||
libpng-1.0.1a:
|
||||
Optimized Paeth calculations by replacing abs() function calls with intrinsics
|
||||
plus other loop optimizations. Improves avg decoding speed by about 20 percent.
|
||||
Commented out i386istic "align" compiler flags in makefile.lnx.
|
||||
Reduced the default warning level in some makefiles, to make them consistent.
|
||||
Removed references to IJG and JPEG in the ansi2knr.c copyright statement.
|
||||
Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation.
|
||||
Added grayscale and 16-bit capability to png_do_read_filler().
|
||||
Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes
|
||||
too large when writing an image with bit_depth < 8 (Bob Dellaca).
|
||||
Corrected some bugs in the experimental weighted filtering heuristics.
|
||||
Moved a misplaced pngrutil code block that truncates tRNS if it has more
|
||||
than num_palette entries -- test was done before num_palette was defined.
|
||||
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
|
||||
libpng-1.0.1b:
|
||||
Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
|
||||
Relocated the png_composite macros from pngrtran.c to png.h (Greg).
|
||||
Added makefile.sco (contributed by Mike Hopkirk).
|
||||
Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
|
||||
Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
|
||||
More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert).
|
||||
More work on loop optimization which may help when compiled with C++ compilers.
|
||||
Added warnings when people try to use transforms they've defined out.
|
||||
|
||||
Send comments/corrections/commendations to
|
||||
png-implement@dworkin.wustl.edu or to randeg@alumni.rpi.edu
|
||||
|
11
CHANGES
11
CHANGES
@ -300,4 +300,13 @@ version 1.0.1a [April 21, 1998]
|
||||
Moved a misplaced pngrutil code block that truncates tRNS if it has more
|
||||
than num_palette entries -- test was done before num_palette was defined.
|
||||
Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins).
|
||||
Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen)
|
||||
Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen).
|
||||
version 1.0.1b [May 2, 1998]
|
||||
Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg).
|
||||
Relocated the png_composite macros from pngrtran.c to png.h (Greg).
|
||||
Added makefile.sco (contributed by Mike Hopkirk).
|
||||
Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a.
|
||||
Fixed a bug in pngrtran.c that would set channels=5 under some circumstances.
|
||||
More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert).
|
||||
More work on loop optimization which may help when compiled with C++ compilers.
|
||||
Added warnings when people try to use transforms they've defined out.
|
||||
|
20
KNOWNBUG
20
KNOWNBUG
@ -111,3 +111,23 @@ Known bugs and suggested enhancements in libpng-1.0.1
|
||||
The "ptime->date % 31" is wrong, should be "ptime->date % 32".
|
||||
|
||||
STATUS: Fixed in libpng-1.0.1a
|
||||
|
||||
11. April 21, 1998 -- ENHANCEMENT -- relocation of composite macros
|
||||
|
||||
png_composite() and png_composite_16() relocated to png.h
|
||||
|
||||
STATUS: Done in libpng-1.0.1b
|
||||
|
||||
12. April 22, 1998 -- ENHANCEMENT -- makefile.sco
|
||||
|
||||
Mike Hopkirk contributed a makefile for SCO osr5 and sco UW7
|
||||
|
||||
STATUS: Added to libpng-1.0.1b distribution
|
||||
|
||||
13: April 30, 1998 -- ENHANCEMENT -- warnings
|
||||
|
||||
When people define out some of the read transformations and then
|
||||
try to use them, the request is silently ignored. It was suggested
|
||||
that a warning be issued in such cases.
|
||||
|
||||
STATUS: Done in libpng-1.0.1b
|
||||
|
6
libpng.3
6
libpng.3
@ -1,4 +1,4 @@
|
||||
.TH LIBPNG 3 "April 21, 1998"
|
||||
.TH LIBPNG 3 "May 2, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
.SH SYNOPSIS
|
||||
@ -396,7 +396,7 @@ Following is a copy of the libpng.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.0.1a April 21, 1998
|
||||
libpng version 1.0.1b May 2, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
@ -2372,7 +2372,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.0.1a April 21, 1998:
|
||||
Libpng version 1.0.1b May 2, 1998:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (randeg@alumni.rpi.edu).
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
libpng.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.0.1a April 21, 1998
|
||||
libpng version 1.0.1b May 2, 1998
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<randeg@alumni.rpi.edu>
|
||||
Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH LIBPNGPF 3 "April 21, 1998"
|
||||
.TH LIBPNGPF 3 "May 2, 1998"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library
|
||||
(private functions)
|
||||
|
2
png.5
2
png.5
@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "April 21, 1998"
|
||||
.TH PNG 5 "May 2, 1998"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
6
png.c
6
png.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@ -16,7 +16,7 @@
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
char png_libpng_ver[12] = "1.0.1a";
|
||||
char png_libpng_ver[12] = "1.0.1b";
|
||||
|
||||
/* Place to hold the signature string for a PNG file. */
|
||||
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
87
png.h
87
png.h
@ -1,12 +1,12 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see the COPYRIGHT NOTICE below.
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998 Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
*
|
||||
@ -18,30 +18,31 @@
|
||||
*
|
||||
* source png.h png.h shared-lib
|
||||
* version string int version
|
||||
* ------- ------ ------ ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
|
||||
* 0.97c 0.97 97 2.0.97
|
||||
* 0.98 0.98 98 2.0.98
|
||||
* 0.99 0.99 98 2.0.99
|
||||
* 0.99a-m 0.99 99 2.0.99
|
||||
* 1.00 1.00 100 2.1.0 [int should be 10000]
|
||||
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
|
||||
* 1.0.1 1.0.1 10001 2.1.0
|
||||
* 1.0.1a 1.0.1a 10002 2.1.0
|
||||
* ------- ------ ----- ----------
|
||||
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89
|
||||
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90]
|
||||
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95]
|
||||
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96]
|
||||
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97]
|
||||
* 0.97c 0.97 97 2.0.97
|
||||
* 0.98 0.98 98 2.0.98
|
||||
* 0.99 0.99 98 2.0.99
|
||||
* 0.99a-m 0.99 99 2.0.99
|
||||
* 1.00 1.00 100 2.1.0 [int should be 10000]
|
||||
* 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
|
||||
* 1.0.1 1.0.1 10001 2.1.0
|
||||
* 1.0.1a 1.0.1a 10002 2.1.0
|
||||
* 1.0.1b 1.0.1b 10002 2.1.0
|
||||
*
|
||||
* Henceforth the source version will match the shared-library minor
|
||||
* and patch numbers; the shared-library major version number will be
|
||||
* used for changes in backward compatibility, as it is intended.
|
||||
* The PNG_PNGLIB_VER macro, which is not used within libpng but
|
||||
* is available for applications, is an unsigned integer of the form
|
||||
* xyyzz corresponding to the source version x.y.z (leading zeros in y and z).
|
||||
* used for changes in backward compatibility, as it is intended. The
|
||||
* PNG_PNGLIB_VER macro, which is not used within libpng but is available
|
||||
* for applications, is an unsigned integer of the form xyyzz corresponding
|
||||
* to the source version x.y.z (leading zeros in y and z).
|
||||
*
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification is
|
||||
* available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
|
||||
* and as a W3C Recommendation <http://www.w3.org/TR/REC.png.html>
|
||||
*
|
||||
* Contributing Authors:
|
||||
@ -118,7 +119,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.1a"
|
||||
#define PNG_LIBPNG_VER_STRING "1.0.1b"
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||
* We must not include leading zeros.
|
||||
@ -1443,6 +1444,45 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define png_debug2(l, m, p1, p2)
|
||||
#endif /* (PNG_DEBUG > 0) */
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
/* With these routines, we avoid an integer divide, which will be slower on
|
||||
* many machines. However, it does take more operations than the corresponding
|
||||
* divide method, so it may be slower on some RISC systems. There are two
|
||||
* shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
|
||||
*
|
||||
* Note that the rounding factors are NOT supposed to be the same! 128 and
|
||||
* 32768 are correct for the NODIV code; 127 and 32767 are correct for the
|
||||
* standard method.
|
||||
*
|
||||
* [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
|
||||
*/
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
{ png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg)*(png_uint_16)(255 - \
|
||||
(png_uint_16)(alpha)) + (png_uint_16)128); \
|
||||
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
{ png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - \
|
||||
(png_uint_32)(alpha)) + (png_uint_32)32768L); \
|
||||
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
|
||||
|
||||
#else /* standard method using integer division */
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
(png_uint_16)127) / 255)
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
|
||||
(png_uint_32)32767) / (png_uint_32)65535L)
|
||||
|
||||
#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
||||
|
||||
/* These next functions are used internally in the code. They generally
|
||||
* shouldn't be used unless you are writing code to add or replace some
|
||||
* functionality in libpng. More information about most functions can
|
||||
@ -1525,6 +1565,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
|
||||
#define PNG_FLAG_FREE_HIST 0x4000
|
||||
#define PNG_FLAG_HAVE_CHUNK_HEADER 0x8000L
|
||||
#define PNG_FLAG_WROTE_tIME 0x10000L
|
||||
#define PNG_FLAG_BACKGROUND_IS_GRAY 0x20000L
|
||||
|
||||
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* This file provides a location for all error handling. Users which
|
||||
* need special error handling are expected to write replacement functions
|
||||
|
4
pngget.c
4
pngget.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
4
pngmem.c
4
pngmem.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* This file provides a location for all memory allocation. Users who
|
||||
* need special memory handling are expected to modify the code in this file
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
|
95
pngread.c
95
pngread.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* This file contains routines that an application calls directly to
|
||||
* read a PNG file or stream.
|
||||
@ -279,6 +279,38 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
/* save jump buffer and error functions */
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
png_read_start_row(png_ptr);
|
||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
{
|
||||
/* check for transforms that have been set but were defined out */
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined.");
|
||||
#endif
|
||||
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined.");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||
/* if interlaced and we do not need a new row, combine row and return */
|
||||
@ -488,25 +520,34 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
||||
/* save jump buffer and error functions */
|
||||
rp = row;
|
||||
dp = display_row;
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr;
|
||||
png_bytep dptr;
|
||||
|
||||
if (rp != NULL)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp != NULL)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row != NULL)
|
||||
rp++;
|
||||
if (display_row != NULL)
|
||||
dp++;
|
||||
}
|
||||
if(rp != NULL && dp != NULL)
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr = *rp++;
|
||||
png_bytep dptr = *dp++;
|
||||
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < num_rows; i++)
|
||||
{
|
||||
png_bytep rptr;
|
||||
png_bytep dptr;
|
||||
|
||||
if (rp != NULL)
|
||||
rptr = *rp;
|
||||
else
|
||||
rptr = NULL;
|
||||
if (dp != NULL)
|
||||
dptr = *dp;
|
||||
else
|
||||
dptr = NULL;
|
||||
png_read_row(png_ptr, rptr, dptr);
|
||||
if (row != NULL)
|
||||
rp++;
|
||||
if (display_row != NULL)
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the entire image. If the image has an alpha channel or a tRNS
|
||||
@ -729,8 +770,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
{
|
||||
int i,istop;
|
||||
istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_table[i]);
|
||||
@ -741,8 +782,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_16_table);
|
||||
if (png_ptr->gamma_16_from_1 != NULL)
|
||||
{
|
||||
int i,istop;
|
||||
istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
|
||||
@ -751,8 +792,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
||||
png_free(png_ptr, png_ptr->gamma_16_from_1);
|
||||
if (png_ptr->gamma_16_to_1 != NULL)
|
||||
{
|
||||
int i,istop;
|
||||
istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
int i;
|
||||
int istop = (1 << (8 - png_ptr->gamma_shift));
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
|
||||
|
4
pngrio.c
4
pngrio.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* This file provides a location for all input. Users which need
|
||||
* special handling are expected to write a function which has the same
|
||||
|
434
pngrtran.c
434
pngrtran.c
@ -1,12 +1,12 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng 1.0.1a
|
||||
* libpng 1.0.1b
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Copyright (c) 1998, Glenn Randers-Pehrson
|
||||
* April 21, 1998
|
||||
* May 2, 1998
|
||||
*
|
||||
* This file contains functions optionally called by an application
|
||||
* in order to tell libpng how to handle data when reading a PNG.
|
||||
@ -17,46 +17,6 @@
|
||||
#define PNG_INTERNAL
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||
/* With these routines, we avoid an integer divide, which will be slower on
|
||||
* many machines. However, it does take more operations than the corresponding
|
||||
* divide method, so it may be slower on some RISC systems. There are two
|
||||
* shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
|
||||
*
|
||||
* Note that the rounding factors are NOT supposed to be the same! 128 and
|
||||
* 32768 are correct for the NODIV code; 127 and 32767 are correct for the
|
||||
* standard method.
|
||||
*
|
||||
* [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
|
||||
*/
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
{ png_uint_16 temp = ((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg)*(png_uint_16)(255 - \
|
||||
(png_uint_16)(alpha)) + (png_uint_16)128); \
|
||||
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
{ png_uint_32 temp = ((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - \
|
||||
(png_uint_32)(alpha)) + (png_uint_32)32768L); \
|
||||
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
|
||||
|
||||
#else /* standard method using integer division */
|
||||
|
||||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
(png_uint_16)127) / 255)
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
|
||||
(png_uint_32)32767) / (png_uint_32)65535L)
|
||||
|
||||
#endif /* ?PNG_READ_COMPOSITE_NODIV_SUPPORTED */
|
||||
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
void
|
||||
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
@ -125,11 +85,21 @@ png_set_background(png_structp png_ptr,
|
||||
}
|
||||
|
||||
png_ptr->transformations |= PNG_BACKGROUND;
|
||||
png_memcpy(&(png_ptr->background), background_color,
|
||||
sizeof(png_color_16));
|
||||
png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16));
|
||||
png_ptr->background_gamma = (float)background_gamma;
|
||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||
png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
|
||||
|
||||
/* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA
|
||||
* (in which case need_expand is superfluous anyway), the background color
|
||||
* might actually be gray yet not be flagged as such. This is not a problem
|
||||
* for the current code, which uses PNG_FLAG_BACKGROUND_IS_GRAY only to
|
||||
* decide when to do the png_do_gray_to_rgb() transformation.
|
||||
*/
|
||||
if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) ||
|
||||
(!need_expand && background_color->red == background_color->green &&
|
||||
background_color->red == background_color->blue))
|
||||
png_ptr->flags |= PNG_FLAG_BACKGROUND_IS_GRAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -447,9 +417,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
if (hash[i] != NULL)
|
||||
{
|
||||
png_dsortp p;
|
||||
|
||||
p = hash[i];
|
||||
png_dsortp p = hash[i];
|
||||
while (p)
|
||||
{
|
||||
png_dsortp t;
|
||||
@ -478,17 +446,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
if (full_dither)
|
||||
{
|
||||
int i;
|
||||
int total_bits, num_red, num_green, num_blue;
|
||||
png_size_t num_entries;
|
||||
png_bytep distance;
|
||||
|
||||
total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
|
||||
int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
|
||||
PNG_DITHER_BLUE_BITS;
|
||||
|
||||
num_red = (1 << PNG_DITHER_RED_BITS);
|
||||
num_green = (1 << PNG_DITHER_GREEN_BITS);
|
||||
num_blue = (1 << PNG_DITHER_BLUE_BITS);
|
||||
num_entries = ((png_size_t)1 << total_bits);
|
||||
int num_red = (1 << PNG_DITHER_RED_BITS);
|
||||
int num_green = (1 << PNG_DITHER_GREEN_BITS);
|
||||
int num_blue = (1 << PNG_DITHER_BLUE_BITS);
|
||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
|
||||
(png_uint_32)(num_entries * sizeof (png_byte)));
|
||||
@ -502,34 +466,29 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
int r, g, b, ir, ig, ib;
|
||||
|
||||
r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
|
||||
g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
|
||||
b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS));
|
||||
int ir, ig, ib;
|
||||
int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
|
||||
int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
|
||||
int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS));
|
||||
|
||||
for (ir = 0; ir < num_red; ir++)
|
||||
{
|
||||
int dr, index_r;
|
||||
int dr = abs(ir - r);
|
||||
int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS));
|
||||
|
||||
dr = abs(ir - r);
|
||||
index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS));
|
||||
for (ig = 0; ig < num_green; ig++)
|
||||
{
|
||||
int dg, dt, dm, index_g;
|
||||
int dg = abs(ig - g);
|
||||
int dt = dr + dg;
|
||||
int dm = ((dr > dg) ? dr : dg);
|
||||
int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
|
||||
|
||||
dg = abs(ig - g);
|
||||
dt = dr + dg;
|
||||
dm = ((dr > dg) ? dr : dg);
|
||||
index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
|
||||
for (ib = 0; ib < num_blue; ib++)
|
||||
{
|
||||
int d_index, db, dmax, d;
|
||||
|
||||
d_index = index_g | ib;
|
||||
db = abs(ib - b);
|
||||
dmax = ((dm > db) ? dm : db);
|
||||
d = dmax + dt + db;
|
||||
int d_index = index_g | ib;
|
||||
int db = abs(ib - b);
|
||||
int dmax = ((dm > db) ? dm : db);
|
||||
int d = dmax + dt + db;
|
||||
|
||||
if (d < (int)distance[d_index])
|
||||
{
|
||||
@ -617,15 +576,14 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
void
|
||||
png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
int color_type;
|
||||
int color_type = png_ptr->color_type;
|
||||
|
||||
png_debug(1, "in png_init_read_transformations\n");
|
||||
color_type = png_ptr->color_type;
|
||||
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
{
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */
|
||||
{
|
||||
/* expand background chunk. */
|
||||
switch (png_ptr->bit_depth)
|
||||
@ -694,12 +652,10 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int num_palette, i;
|
||||
png_color back, back_1;
|
||||
png_colorp palette;
|
||||
|
||||
palette = png_ptr->palette;
|
||||
num_palette = png_ptr->num_palette;
|
||||
png_colorp palette = png_ptr->palette;
|
||||
int num_palette = png_ptr->num_palette;
|
||||
int i;
|
||||
|
||||
if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
|
||||
{
|
||||
@ -796,11 +752,9 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
else
|
||||
/* color_type != PNG_COLOR_TYPE_PALETTE */
|
||||
{
|
||||
double g, gs, m;
|
||||
|
||||
m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1);
|
||||
g = 1.0;
|
||||
gs = 1.0;
|
||||
double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1);
|
||||
double g = 1.0;
|
||||
double gs = 1.0;
|
||||
|
||||
switch (png_ptr->background_gamma_type)
|
||||
{
|
||||
@ -850,11 +804,9 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int num_palette, i;
|
||||
png_colorp palette;
|
||||
|
||||
palette = png_ptr->palette;
|
||||
num_palette = png_ptr->num_palette;
|
||||
png_colorp palette = png_ptr->palette;
|
||||
int num_palette = png_ptr->num_palette;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@ -873,16 +825,15 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
if (png_ptr->transformations & PNG_BACKGROUND &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int i,istop;
|
||||
int i;
|
||||
int istop = (int)png_ptr->num_trans;
|
||||
png_color back;
|
||||
png_colorp palette;
|
||||
png_colorp palette = png_ptr->palette;
|
||||
|
||||
palette = png_ptr->palette;
|
||||
back.red = (png_byte)png_ptr->background.red;
|
||||
back.green = (png_byte)png_ptr->background.green;
|
||||
back.blue = (png_byte)png_ptr->background.blue;
|
||||
|
||||
istop = (int)png_ptr->num_trans;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
if (png_ptr->trans[i] == 0)
|
||||
@ -891,6 +842,7 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
}
|
||||
else if (png_ptr->trans[i] != 0xff)
|
||||
{
|
||||
/* The png_composite() macro is defined in png.h */
|
||||
png_composite(palette[i].red, palette[i].red,
|
||||
png_ptr->trans[i], back.red);
|
||||
png_composite(palette[i].green, palette[i].green,
|
||||
@ -906,19 +858,18 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
png_uint_16 i,istop;
|
||||
int sr, sg, sb;
|
||||
png_uint_16 i;
|
||||
png_uint_16 istop = png_ptr->num_palette;
|
||||
int sr = 8 - png_ptr->sig_bit.red;
|
||||
int sg = 8 - png_ptr->sig_bit.green;
|
||||
int sb = 8 - png_ptr->sig_bit.blue;
|
||||
|
||||
sr = 8 - png_ptr->sig_bit.red;
|
||||
if (sr < 0 || sr > 8)
|
||||
sr = 0;
|
||||
sg = 8 - png_ptr->sig_bit.green;
|
||||
if (sg < 0 || sg > 8)
|
||||
sg = 0;
|
||||
sb = 8 - png_ptr->sig_bit.blue;
|
||||
if (sb < 0 || sb > 8)
|
||||
sb = 0;
|
||||
istop = png_ptr->num_palette;
|
||||
for (i = 0; i < istop; i++)
|
||||
{
|
||||
png_ptr->palette[i].red >>= sr;
|
||||
@ -1008,23 +959,19 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
{
|
||||
if((info_ptr->color_type & PNG_COLOR_TYPE_RGB) &&
|
||||
info_ptr->channels == 3)
|
||||
info_ptr->channels = 4;
|
||||
if((info_ptr->color_type & PNG_COLOR_TYPE_GRAY) &&
|
||||
info_ptr->channels == 1)
|
||||
info_ptr->channels = 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
info_ptr->channels++;
|
||||
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
|
||||
if (png_ptr->transformations & PNG_FILLER &&
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
|
||||
++info_ptr->channels;
|
||||
#endif
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
|
||||
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
|
||||
}
|
||||
|
||||
@ -1077,6 +1024,44 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
PNG_FLAG_FILLER_AFTER);
|
||||
#endif
|
||||
|
||||
/*
|
||||
From Andreas Dilger e-mail to png-implement, 26 March 1998:
|
||||
|
||||
In most cases, the "simple transparency" should be done prior to doing
|
||||
gray-to-RGB, or you will have to test 3x as many bytes to check if a
|
||||
pixel is transparent. You would also need to make sure that the
|
||||
transparency information is upgraded to RGB.
|
||||
|
||||
To summarize, the current flow is:
|
||||
- Gray + simple transparency -> compare 1 or 2 gray bytes and composite
|
||||
with background "in place" if transparent,
|
||||
convert to RGB if necessary
|
||||
- Gray + alpha -> composite with gray background and remove alpha bytes,
|
||||
convert to RGB if necessary
|
||||
|
||||
To support RGB backgrounds for gray images we need:
|
||||
- Gray + simple transparency -> convert to RGB + simple transparency, compare
|
||||
3 or 6 bytes and composite with background
|
||||
"in place" if transparent (3x compare/pixel
|
||||
compared to doing composite with gray bkgrnd)
|
||||
- Gray + alpha -> convert to RGB + alpha, composite with background and
|
||||
remove alpha bytes (3x float operations/pixel
|
||||
compared with composite on gray background)
|
||||
|
||||
Greg's change will do this. The reason it wasn't done before is for
|
||||
performance, as this increases the per-pixel operations. If we would check
|
||||
in advance if the background was gray or RGB, and position the gray-to-RGB
|
||||
transform appropriately, then it would save a lot of work/time.
|
||||
*/
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* if gray -> RGB, do so now only if background is non-gray; else do later
|
||||
* for performance reasons */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
!(png_ptr->flags & PNG_FLAG_BACKGROUND_IS_GRAY))
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
((png_ptr->num_trans != 0 ) ||
|
||||
@ -1146,7 +1131,9 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
/* if gray -> RGB, do so now only if we did not do so above */
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB &&
|
||||
png_ptr->flags & PNG_FLAG_BACKGROUND_IS_GRAY)
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
@ -1205,17 +1192,16 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth < 8)
|
||||
#endif
|
||||
{
|
||||
png_uint_32 shift, i;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width=row_info->width;
|
||||
png_bytep sp, dp;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = 7 - (int)((row_width + 7) & 7);
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 7);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x1);
|
||||
@ -1234,9 +1220,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
case 2:
|
||||
{
|
||||
|
||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 3)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x3);
|
||||
@ -1254,9 +1240,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_width - 1;
|
||||
shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 1)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0xf);
|
||||
@ -1297,11 +1283,11 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int shift[4];
|
||||
int channels, c;
|
||||
png_uint_16 value;
|
||||
int channels = 0;
|
||||
int c;
|
||||
png_uint_16 value = 0;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
channels = 0;
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->red;
|
||||
@ -1317,8 +1303,6 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->alpha;
|
||||
}
|
||||
|
||||
value = 0;
|
||||
|
||||
for (c = 0; c < channels; c++)
|
||||
{
|
||||
if (shift[c] <= 0)
|
||||
@ -1335,9 +1319,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
case 2:
|
||||
{
|
||||
png_bytep bp;
|
||||
png_uint_32 i,istop;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
|
||||
istop = row_info->rowbytes;
|
||||
for (bp = row, i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
*bp >>= 1;
|
||||
@ -1348,12 +1332,11 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
case 4:
|
||||
{
|
||||
png_bytep bp;
|
||||
png_byte mask;
|
||||
png_uint_32 i,istop;
|
||||
|
||||
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->rowbytes;
|
||||
png_byte mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
(png_byte)((int)0xf >> shift[0]);
|
||||
istop = row_info->rowbytes;
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
*bp >>= shift[0];
|
||||
@ -1365,9 +1348,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_uint_32 i;
|
||||
int cstop;
|
||||
int cstop=(int)row_info->channels;
|
||||
|
||||
cstop=(int)row_info->channels;
|
||||
for (bp = row, i = 0; i < row_width; i++)
|
||||
{
|
||||
for (c = 0; c < cstop; c++, bp++)
|
||||
@ -1381,9 +1363,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
||||
{
|
||||
png_bytep bp;
|
||||
png_size_t i;
|
||||
int cstop;
|
||||
int cstop=(int)row_info->channels;
|
||||
|
||||
cstop=(int)row_info->channels;
|
||||
for (bp = row, i = 0; i < row_width; i++)
|
||||
{
|
||||
for (c = 0; c < cstop; c++, bp += 2)
|
||||
@ -1413,12 +1394,11 @@ png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
if (row_info->bit_depth == 16)
|
||||
#endif
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i, istop;
|
||||
png_bytep sp = row;
|
||||
png_bytep dp = row;
|
||||
png_uint_32 i;
|
||||
png_uint_32 istop = row_info->width * row_info->channels;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
istop = row_info->width * row_info->channels;
|
||||
for (i = 0; i<istop; i++, sp += 2, dp++)
|
||||
{
|
||||
#if defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED)
|
||||
@ -1472,10 +1452,11 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This converts from RGBA to ARGB */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_byte save;
|
||||
png_uint_32 i;
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
save = *(--sp);
|
||||
@ -1488,10 +1469,11 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This converts from RRGGBBAA to AARRGGBB */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_byte save[2];
|
||||
png_uint_32 i;
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
save[0] = *(--sp);
|
||||
@ -1512,10 +1494,11 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This converts from GA to AG */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_byte save;
|
||||
png_uint_32 i;
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
save = *(--sp);
|
||||
@ -1526,11 +1509,11 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This converts from GGAA to AAGG */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_byte save[2];
|
||||
png_uint_32 i;
|
||||
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
save[0] = *(--sp);
|
||||
@ -1561,10 +1544,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This inverts the alpha channel in RGBA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
@ -1576,10 +1559,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This inverts the alpha channel in RRGGBBAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
@ -1598,10 +1581,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This inverts the alpha channel in GA */
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
@ -1611,10 +1594,10 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||
/* This inverts the alpha channel in GGAA */
|
||||
else
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_bytep sp = row + row_info->rowbytes;
|
||||
png_bytep dp = sp;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = dp = row + row_info->rowbytes;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = 255 - *(--sp);
|
||||
@ -1634,7 +1617,6 @@ void
|
||||
png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_uint_32 filler, png_uint_32 flags)
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
@ -1653,8 +1635,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from G to GX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
sp = row + (png_size_t)row_width;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
png_bytep dp = sp + (png_size_t)row_width;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = low_filler;
|
||||
@ -1667,8 +1649,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from G to XG */
|
||||
else
|
||||
{
|
||||
sp = row + (png_size_t)row_width;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
png_bytep dp = sp + (png_size_t)row_width;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = *(--sp);
|
||||
@ -1684,8 +1666,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from GG to GGXX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
sp = row + (png_size_t)row_width;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
png_bytep dp = sp + (png_size_t)row_width;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = hi_filler;
|
||||
@ -1700,8 +1682,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from GG to XXGG */
|
||||
else
|
||||
{
|
||||
sp = row + (png_size_t)row_width;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
png_bytep dp = sp + (png_size_t)row_width;
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = *(--sp);
|
||||
@ -1722,8 +1704,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from RGB to RGBX */
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
{
|
||||
sp = row + (png_size_t)row_width * 3;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width * 3;
|
||||
png_bytep dp = sp + (png_size_t)row_width;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = low_filler;
|
||||
@ -1738,8 +1720,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
/* This changes the data from RGB to XRGB */
|
||||
else
|
||||
{
|
||||
sp = row + (png_size_t)row_width * 3;
|
||||
dp = sp + (png_size_t)row_width;
|
||||
png_bytep sp = row + (png_size_t)row_width * 3;
|
||||