[devel] Removed premultiplied alpha feature.

It will be replaced in the future with a function that accounts for gamma.
This commit is contained in:
Glenn Randers-Pehrson 2009-11-27 00:24:42 -06:00
parent 4cfdb3c095
commit 5876b850b2
11 changed files with 29 additions and 211 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.4.0beta106 - November 26, 2009
Libpng 1.4.0beta106 - November 27, 2009
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.
@ -714,8 +714,8 @@ version 1.4.0beta105 [November 25, 2009]
Changed "/255" to "/255.0" in background calculations to make it clear
that the 255 is used as a double.
version 1.4.0beta106 [November 26, 2009]
Moved the PNG_DIVIDE_* and PNG_*_PREMULTIPLY macros from png.h to pngpriv.h.
version 1.4.0beta106 [November 27, 2009]
Removed premultiplied alpha feature.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -2401,8 +2401,8 @@ version 1.4.0beta105 [November 25, 2009]
Changed "/255" to "/255.0" in background calculations to make it clear
that the 255 is used as a double.
version 1.4.0beta106 [November 26, 2009]
Moved the PNG_DIVIDE_* and PNG_*_PREMULTIPLY macros from png.h to pngpriv.h.
version 1.4.0beta106 [November 27, 2009]
Removed premultiplied alpha feature.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng
libpng version 1.4.0beta106 - November 26, 2009
libpng version 1.4.0beta106 - November 27, 2009
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@ -11,7 +11,7 @@ libpng.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.4.0beta106 - November 26, 2009
libpng versions 0.97, January 1998, through 1.4.0beta106 - November 27, 2009
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@ -938,15 +938,6 @@ images) is fully transparent, with
png_set_invert_alpha(png_ptr);
The PNG format only supports pixels with postmultiplied alpha.
If you want to replace the pixels, after reading them, with pixels
that have premultiplied color samples, you can do this with
png_set_premultiply_alpha(png_ptr);
If you do this, any input with a tRNS chunk will be expanded to
have an alpha channel.
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
they can, resulting in, for example, 8 pixels per byte for 1 bit
files. This code expands to 1 pixel per byte without changing the
@ -3035,9 +3026,6 @@ after the png_malloc() to set the pointers to NULL.
We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
input transforms.
We added the png_set_premultiply_alpha and
png_do_read_premultiply_alpha() functions.
The call to png_do_chop() in pngrtran.c, which reduces 16-bit input
files to 8-bit bit depth, was relocated ahead of the building
of gamma tables. This allows us to build 8-bit tables instead
@ -3225,7 +3213,7 @@ Other rules can be inferred by inspecting the libpng source.
XIII. Y2K Compliance in libpng
November 26, 2009
November 27, 2009
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.

View File

@ -1,4 +1,4 @@
.TH LIBPNG 3 "November 26, 2009"
.TH LIBPNG 3 "November 27, 2009"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.4.0beta106
.SH SYNOPSIS
@ -566,10 +566,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.4.0beta106
\fI\fB
\fBvoid png_set_premultiply_alpha (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP
\fI\fB
@ -781,7 +777,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.4.0beta106 - November 26, 2009
libpng version 1.4.0beta106 - November 27, 2009
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@ -792,7 +788,7 @@ libpng.txt - A description on how to use and modify libpng
Based on:
libpng versions 0.97, January 1998, through 1.4.0beta106 - November 26, 2009
libpng versions 0.97, January 1998, through 1.4.0beta106 - November 27, 2009
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2009 Glenn Randers-Pehrson
@ -1719,15 +1715,6 @@ images) is fully transparent, with
png_set_invert_alpha(png_ptr);
The PNG format only supports pixels with postmultiplied alpha.
If you want to replace the pixels, after reading them, with pixels
that have premultiplied color samples, you can do this with
png_set_premultiply_alpha(png_ptr);
If you do this, any input with a tRNS chunk will be expanded to
have an alpha channel.
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
they can, resulting in, for example, 8 pixels per byte for 1 bit
files. This code expands to 1 pixel per byte without changing the
@ -3816,9 +3803,6 @@ after the png_malloc() to set the pointers to NULL.
We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
input transforms.
We added the png_set_premultiply_alpha and
png_do_read_premultiply_alpha() functions.
The call to png_do_chop() in pngrtran.c, which reduces 16-bit input
files to 8-bit bit depth, was relocated ahead of the building
of gamma tables. This allows us to build 8-bit tables instead
@ -4006,7 +3990,7 @@ Other rules can be inferred by inspecting the libpng source.
.SH XIII. Y2K Compliance in libpng
November 26, 2009
November 27, 2009
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
@ -4238,7 +4222,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.4.0beta106 - November 26, 2009:
Libpng version 1.4.0beta106 - November 27, 2009:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -4261,7 +4245,7 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.4.0beta106, November 26, 2009, are
libpng versions 1.2.6, August 15, 2004, through 1.4.0beta106, November 27, 2009, are
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@ -4360,7 +4344,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
November 26, 2009
November 27, 2009
.\" end of man page

View File

@ -1,4 +1,4 @@
.TH LIBPNGPF 3 "November 26, 2009"
.TH LIBPNGPF 3 "November 27, 2009"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.4.0beta106
(private functions)
@ -211,10 +211,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.4.0beta106
\fI\fB
\fBvoid png_do_read_premultiply_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
\fI\fB
\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
\fI\fB

6
png.c
View File

@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.4.0 [November 26, 2009]
* Last changed in libpng 1.4.0 [November 27, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -547,13 +547,13 @@ png_get_copyright(png_structp png_ptr)
#else
#ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.4.0beta106 - November 26, 2009" PNG_STRING_NEWLINE \
"libpng version 1.4.0beta106 - November 27, 2009" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2009 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE);
#else
return ((png_charp) "libpng version 1.4.0beta106 - November 26, 2009\
return ((png_charp) "libpng version 1.4.0beta106 - November 27, 2009\
Copyright (c) 1998-2009 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");

15
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.4.0beta106 - November 26, 2009
* libpng version 1.4.0beta106 - November 27, 2009
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.4.0beta106 - November 26, 2009: Glenn
* libpng versions 0.97, January 1998, through 1.4.0beta106 - November 27, 2009: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -131,7 +131,7 @@
* 1.4.0beta15-36 14 10400 14.so.0.0[.0]
* 1.4.0beta37-87 14 10400 14.so.14.0[.0]
* 1.4.0rc01 14 10400 14.so.14.0[.0]
* 1.4.0beta88-105 14 10400 14.so.14.0[.0]
* 1.4.0beta88-106 14 10400 14.so.14.0[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -163,7 +163,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.4.0beta106, November 26, 2009, are
* libpng versions 1.2.6, August 15, 2004, through 1.4.0beta106, November 27, 2009, are
* Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -339,7 +339,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.4.0beta106"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.4.0beta106 - November 26, 2009\n"
" libpng version 1.4.0beta106 - November 27, 2009\n"
#define PNG_LIBPNG_VER_SONUM 14
#define PNG_LIBPNG_VER_DLLNUM 14
@ -1523,11 +1523,6 @@ extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
#endif
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
extern PNG_EXPORT(void,png_set_premultiply_alpha)
PNGARG((png_structp png_ptr));
#endif
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.4.0beta106 - November 26, 2009
* libpng version 1.4.0beta106 - November 27, 2009
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -523,9 +523,6 @@
# ifndef PNG_NO_READ_INVERT_ALPHA
# define PNG_READ_INVERT_ALPHA_SUPPORTED
# endif
# ifndef PNG_NO_READ_PREMULTIPLY_ALPHA
# define PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
# endif
# ifndef PNG_NO_READ_STRIP_ALPHA
# define PNG_READ_STRIP_ALPHA_SUPPORTED
# endif

View File

@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng
*
* libpng version 1.4.0beta106 - November 26, 2009
* libpng version 1.4.0beta106 - November 27, 2009
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -127,8 +127,7 @@
/* 0x800000L Unused */
#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
#define PNG_PREMULTIPLY_ALPHA 0x4000000L /* Added to libpng-1.4.0 */
/* by volker */
/* 0x4000000L unused */
/* 0x8000000L unused */
/* 0x10000000L unused */
/* 0x20000000L unused */
@ -552,11 +551,6 @@ PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
png_bytep row, png_uint_32 flags));
#endif
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
PNG_EXTERN void png_do_read_premultiply_alpha
PNGARG((png_row_infop row_info, png_bytep row));
#endif
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
#endif
@ -831,25 +825,6 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type));
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
# ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
# define PNG_DIVIDE_BY_255(v) \
((png_byte)(((png_uint_16)(v) + \
(((png_uint_16)(v) + 128) >> 8) + 128) >> 8))
# define PNG_DIVIDE_BY_65535(v) \
((png_byte)(((png_uint_32)(v) + \
(((png_uint_32)(v) + 32768L) >> 16) + 32768L) >> 16))
# else
# define PNG_DIVIDE_BY_255(v) (((png_uint_16)(v))/255)
# define PNG_DIVIDE_BY_65535(v) (((png_uint_32)(v))/65535L)
# endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
# define PNG_8_BIT_PREMULTIPLY(color,alpha) \
PNG_DIVIDE_BY_255((color)*(alpha))
# define PNG_16_BIT_PREMULTIPLY(color,alpha)\
PNG_DIVIDE_BY_65535((color)*(alpha))
#endif /* PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED */
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
png_infop end_info_ptr));

View File

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.0 [November 26, 2009]
* Last changed in libpng 1.4.0 [November 27, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -426,23 +426,6 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
png_warning(png_ptr,
"Ignoring extra png_read_update_info() call; row buffer not reallocated");
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_PREMULTIPLY_ALPHA)
{
/* TO DO:
* Check for linear colorspace and if not, issue a warning.
* If gAMA is present with gamma == 1.0, it's linear.
* If iCCP is present, assume user knows what they are doing
* and it's linear.
* If gAMA is present with gamma != 1.0, it's not linear.
* If no gAMA or iCCP, assume not linear.
* If not linear do:
* png_warning(png_ptr,
* "Premultiply should only be used with gamma == 1.0");
*/
}
#endif
png_read_transform_info(png_ptr, info_ptr);
}

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.0 [November 26, 2009]
* Last changed in libpng 1.4.0 [November 27, 2009]
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -140,22 +140,6 @@ png_set_strip_alpha(png_structp png_ptr)
}
#endif
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
void PNGAPI
png_set_premultiply_alpha(png_structp png_ptr)
{
png_debug(1, "in png_set_premultiply_alpha");
if(png_ptr == NULL)
return;
png_ptr->transformations |=
(PNG_PREMULTIPLY_ALPHA | PNG_EXPAND_tRNS);
png_ptr->transformations |=
PNG_EXPAND; /* This shouldn't be necessary */
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
}
#endif
#ifdef PNG_READ_DITHER_SUPPORTED
/* Dither file to 8 bit. Supply a palette, the current number
* of elements in the palette, the maximum number of elements
@ -1508,12 +1492,6 @@ png_do_read_transformations(png_structp png_ptr)
(png_uint_32)png_ptr->filler, png_ptr->flags);
#endif
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_PREMULTIPLY_ALPHA)
png_do_read_premultiply_alpha(&(png_ptr->row_info),
png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
if (png_ptr->transformations & PNG_INVERT_ALPHA)
png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
@ -2000,84 +1978,6 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
}
#endif
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
void /* PRIVATE */
png_do_read_premultiply_alpha(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_premultiply_alpha");
{
png_uint_32 row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
/* This premultiplies the pixels with the alpha channel in RGBA */
if (row_info->bit_depth == 8)
{
png_bytep sp = row + row_info->rowbytes;
png_bytep dp = sp;
png_uint_16 a = 0;
png_uint_32 i;
for (i = 0; i < row_width; i++)
{
a = *(--sp); --dp;
sp--; *(--dp) = PNG_8_BIT_PREMULTIPLY((*sp), a);
sp--; *(--dp) = PNG_8_BIT_PREMULTIPLY((*sp), a);
sp--; *(--dp) = PNG_8_BIT_PREMULTIPLY((*sp), a);
}
}
/* This premultiplies the pixels with the alpha channel in RRGGBBAA */
else
{
png_uint_16p sp = (png_uint_16p)(row + row_info->rowbytes);
png_uint_16p dp = sp;
png_uint_32 a = 0;
png_uint_32 i;
for (i = 0; i < row_width; i++)
{
a = *(--sp); --dp;
sp--; *(--dp) = PNG_16_BIT_PREMULTIPLY((*sp), a);
sp--; *(--dp) = PNG_16_BIT_PREMULTIPLY((*sp), a);
sp--; *(--dp) = PNG_16_BIT_PREMULTIPLY((*sp), a);
}
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
/* This premultiplies the pixels with the alpha channel in GA */
if (row_info->bit_depth == 8)
{
png_bytep sp = row + row_info->rowbytes;
png_bytep dp = sp;
png_uint_16 a = 0;
png_uint_32 i;
for (i = 0; i < row_width; i++)
{
a = *(--sp); --dp;
sp--; *(--dp) = PNG_8_BIT_PREMULTIPLY((*sp), a);
}
}
/* This premultiplies the pixels with the alpha channel in GGAA */
else
{
png_uint_16p sp = (png_uint_16p) (row + row_info->rowbytes);
png_uint_16p dp = sp;
png_uint_32 a = 0;
png_uint_32 i;
for (i = 0; i < row_width; i++)
{
a = *(--sp); --dp;
sp--; *(--dp) = PNG_16_BIT_PREMULTIPLY((*sp), a);
}
}
}
}
}
#endif
#ifdef PNG_READ_FILLER_SUPPORTED
/* Add filler channel if we have RGB color */
void /* PRIVATE */