mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[alpha] Add "depth" parameter to private png_build_gamma_table()
sync with libpng-1.4.0beta109.
This commit is contained in:
5
ANNOUNCE
5
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.5.0alpha01 - December 12, 2009
|
||||
Libpng 1.5.0alpha01 - December 14, 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.
|
||||
@@ -55,8 +55,9 @@ version 1.4.1alpha02 [December 11, 2009]
|
||||
change in version 1.2.41beta08 caused transparency to be handled wrong
|
||||
in some 16-bit datastreams (Yusaku Sugai).
|
||||
|
||||
version 1.5.0alpha01 [December 12, 2009]
|
||||
version 1.5.0alpha01 [December 14, 2009]
|
||||
Bump version to 1.5.0alpha01
|
||||
Add "depth" parameter to private png_build_gamma_table()
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
3
CHANGES
3
CHANGES
@@ -2437,8 +2437,9 @@ version 1.4.1alpha02 [December 11, 2009]
|
||||
change in version 1.2.41beta08 caused transparency to be handled wrong
|
||||
in some 16-bit datastreams (Yusaku Sugai).
|
||||
|
||||
version 1.5.0alpha01 [December 12, 2009]
|
||||
version 1.5.0alpha01 [December 14, 2009]
|
||||
Bump version to 1.5.0alpha01
|
||||
Add "depth" parameter to private png_build_gamma_table()
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH LIBPNGPF 3 "December 12, 2009"
|
||||
.TH LIBPNGPF 3 "December 14, 2009"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0alpha01
|
||||
(private functions)
|
||||
@@ -15,7 +15,9 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.0alpha01
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP
|
||||
\fI\fB
|
||||
|
||||
\fBvoid png_build_gamma_table (png_structp \fP\fIpng_ptr\fP\fB, png_byte \fIbit_depth\fP\fB);\fP
|
||||
|
||||
\fI\fB
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* libpng version 1.5.0alpha01 - December 12, 2009
|
||||
* libpng version 1.5.0alpha01 - December 14, 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)
|
||||
@@ -476,7 +476,8 @@ PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
|
||||
PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
|
||||
PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
|
||||
png_byte bit_depth));
|
||||
#endif
|
||||
|
||||
/* Combine a row of data, dealing with alpha, etc. if requested */
|
||||
|
||||
73
pngrtran.c
73
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.4.0 [December 12, 2009]
|
||||
* Last changed in libpng 1.4.0 [December 14, 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.)
|
||||
@@ -903,7 +903,17 @@ png_init_read_transformations(png_structp png_ptr)
|
||||
#endif
|
||||
PNG_RGB_TO_GRAY )) && png_ptr->gamma != 0.0)
|
||||
{
|
||||
png_build_gamma_table(png_ptr);
|
||||
#ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PREMULTIPLY_ALPHA)
|
||||
png_build_gamma_table(png_ptr, 16);
|
||||
else
|
||||
{
|
||||
#endif
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_build_gamma_table(png_ptr, 8);
|
||||
else
|
||||
png_build_gamma_table(png_ptr, png_ptr->bit_depth);
|
||||
}
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BACKGROUND)
|
||||
{
|
||||
@@ -1296,11 +1306,6 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PREMULTIPLY_ALPHA)
|
||||
info_ptr->bit_depth = 16;
|
||||
#endif
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
|
||||
info_ptr->bit_depth);
|
||||
|
||||
@@ -1432,19 +1437,6 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
# ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
|
||||
/* Do this after the PREMULTIPLY operation */
|
||||
if (!(png_ptr->transformations & PNG_PREMULTIPLY_ALPHA))
|
||||
{
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
}
|
||||
# else
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
@@ -1462,19 +1454,6 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GAMMA) &&
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
!((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
((png_ptr->num_trans != 0) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
|
||||
#endif
|
||||
(png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
|
||||
png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->gamma_table, png_ptr->gamma_16_table,
|
||||
png_ptr->gamma_shift);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||
# ifdef PNG_READ_PREMULTIPLY_ALPHA_SUPPORTED
|
||||
/* Do this after the PREMULTIPLY operation */
|
||||
@@ -1487,6 +1466,20 @@ png_do_read_transformations(png_structp png_ptr)
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GAMMA) &&
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
!((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
((png_ptr->num_trans != 0) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
|
||||
#endif
|
||||
(png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
|
||||
png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
png_ptr->gamma_table, png_ptr->gamma_16_table,
|
||||
png_ptr->gamma_shift);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_DITHER_SUPPORTED
|
||||
@@ -2071,11 +2064,11 @@ png_do_read_premultiply_alpha(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
a = *(--sp); --dp;
|
||||
sp--; *(--dp) = gamma_16_to_1[(int)(*sp)];
|
||||
sp--; *(--dp) = *gamma_16_to_1[(*sp)];
|
||||
*(dp) = PNG_16_BIT_PREMULTIPLY((*dp), a);
|
||||
sp--; *(--dp) = gamma_16_to_1[(int)(*sp)];
|
||||
sp--; *(--dp) = *gamma_16_to_1[(*sp)];
|
||||
*(dp) = PNG_16_BIT_PREMULTIPLY((*dp), a);
|
||||
sp--; *(--dp) = gamma_16_to_1[*sp];
|
||||
sp--; *(--dp) = *gamma_16_to_1[(*sp)];
|
||||
*(dp) = PNG_16_BIT_PREMULTIPLY((*dp), a);
|
||||
}
|
||||
}
|
||||
@@ -2091,7 +2084,7 @@ png_do_read_premultiply_alpha(png_row_infop row_info, png_bytep row,
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
a = *(--sp); --dp;
|
||||
sp--; *(--dp) = gamma_16_to_1[*sp];
|
||||
sp--; *(--dp) = *gamma_16_to_1[*sp];
|
||||
*(dp) = PNG_16_BIT_PREMULTIPLY((*dp), a);
|
||||
}
|
||||
}
|
||||
@@ -4055,12 +4048,13 @@ static PNG_CONST int png_gamma_shift[] =
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_build_gamma_table(png_structp png_ptr)
|
||||
png_build_gamma_table(png_structp png_ptr, png_byte bit_depth)
|
||||
{
|
||||
png_debug(1, "in png_build_gamma_table");
|
||||
|
||||
if (png_ptr->bit_depth <= 8)
|
||||
if (bit_depth <= 8)
|
||||
{
|
||||
/* Build 8-bit gamma tables */
|
||||
int i;
|
||||
double g;
|
||||
|
||||
@@ -4121,6 +4115,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Build 16-bit gamma tables */
|
||||
double g;
|
||||
int i, j, shift, num;
|
||||
int sig_bit;
|
||||
|
||||
Reference in New Issue
Block a user