[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,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 */