mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to
"if (x !== 0)"
This commit is contained in:
286
pngrtran.c
286
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.11 [June 5, 2014]
|
||||
* Last changed in libpng 1.6.15 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
@@ -98,7 +98,7 @@ png_rtran_ok(png_structrp png_ptr, int need_IHDR)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||
if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
png_app_error(png_ptr,
|
||||
"invalid after png_start_read_image or png_read_update_info");
|
||||
|
||||
@@ -127,7 +127,7 @@ png_set_background_fixed(png_structrp png_ptr,
|
||||
{
|
||||
png_debug(1, "in png_set_background_fixed");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
|
||||
if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL)
|
||||
return;
|
||||
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
@@ -171,7 +171,7 @@ png_set_scale_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_scale_16");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_SCALE_16_TO_8;
|
||||
@@ -185,7 +185,7 @@ png_set_strip_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_16");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
@@ -198,7 +198,7 @@ png_set_strip_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_strip_alpha");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||
@@ -279,7 +279,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
|
||||
png_debug(1, "in png_set_alpha_mode");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
@@ -371,7 +371,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
png_error(png_ptr,
|
||||
"conflicting calls to set alpha mode and background");
|
||||
|
||||
@@ -415,7 +415,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
{
|
||||
png_debug(1, "in png_set_quantize");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_QUANTIZE;
|
||||
@@ -802,7 +802,7 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
{
|
||||
png_debug(1, "in png_set_gamma_fixed");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
@@ -855,7 +855,7 @@ png_set_expand(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
@@ -885,7 +885,7 @@ png_set_palette_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_palette_to_rgb");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
@@ -897,7 +897,7 @@ png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
@@ -909,7 +909,7 @@ png_set_tRNS_to_alpha(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_tRNS_to_alpha");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
@@ -925,7 +925,7 @@ png_set_expand_16(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_expand_16");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||
@@ -938,7 +938,7 @@ png_set_gray_to_rgb(png_structrp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_set_gray_to_rgb");
|
||||
|
||||
if (!png_rtran_ok(png_ptr, 0))
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
/* Because rgb must be 8 bits or more: */
|
||||
@@ -956,7 +956,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
|
||||
/* Need the IHDR here because of the check on color_type below. */
|
||||
/* TODO: fix this */
|
||||
if (!png_rtran_ok(png_ptr, 1))
|
||||
if (png_rtran_ok(png_ptr, 1) == 0)
|
||||
return;
|
||||
|
||||
switch (error_action)
|
||||
@@ -1153,8 +1153,8 @@ png_init_palette_transformations(png_structrp png_ptr)
|
||||
/* The following code cannot be entered in the alpha pre-multiplication case
|
||||
* because PNG_BACKGROUND_EXPAND is cancelled below.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND))
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
{
|
||||
{
|
||||
png_ptr->background.red =
|
||||
@@ -1165,9 +1165,9 @@ png_init_palette_transformations(png_structrp png_ptr)
|
||||
png_ptr->palette[png_ptr->background.index].blue;
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
{
|
||||
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
{
|
||||
/* Invert the alpha channel (in tRNS) unless the pixels are
|
||||
* going to be expanded, in which case leave it for later
|
||||
@@ -1220,9 +1220,9 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
||||
/* The following code cannot be entered in the alpha pre-multiplication case
|
||||
* because PNG_BACKGROUND_EXPAND is cancelled below.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
(png_ptr->transformations & PNG_EXPAND) &&
|
||||
!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) != 0 &&
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
/* i.e., GRAY or GRAY_ALPHA */
|
||||
{
|
||||
{
|
||||
@@ -1260,7 +1260,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
||||
png_ptr->background.red = png_ptr->background.green =
|
||||
png_ptr->background.blue = (png_uint_16)gray;
|
||||
|
||||
if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
|
||||
{
|
||||
png_ptr->trans_color.red = png_ptr->trans_color.green =
|
||||
png_ptr->trans_color.blue = (png_uint_16)trans_gray;
|
||||
@@ -1374,8 +1374,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* 23) PNG_USER_TRANSFORM [must be last]
|
||||
*/
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
!(png_ptr->transformations & PNG_COMPOSE))
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) == 0)
|
||||
{
|
||||
/* Stripping the alpha channel happens immediately after the 'expand'
|
||||
* transformations, before all other transformation, so it cancels out
|
||||
@@ -1401,7 +1401,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
/* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA
|
||||
* settings will have no effect.
|
||||
*/
|
||||
if (!png_gamma_significant(png_ptr->screen_gamma))
|
||||
if (png_gamma_significant(png_ptr->screen_gamma) == 0)
|
||||
{
|
||||
png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
|
||||
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
|
||||
@@ -1412,7 +1412,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
/* Make sure the coefficients for the rgb to gray conversion are set
|
||||
* appropriately.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||
#endif
|
||||
|
||||
@@ -1433,23 +1433,23 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* png_set_background, along with the bit depth, then the code has a record
|
||||
* of exactly what color space the background is currently in.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
|
||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0)
|
||||
{
|
||||
/* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
|
||||
* the file was grayscale the background value is gray.
|
||||
*/
|
||||
if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
||||
}
|
||||
|
||||
else if (png_ptr->transformations & PNG_COMPOSE)
|
||||
else if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
{
|
||||
/* PNG_COMPOSE: png_set_background was called with need_expand false,
|
||||
* so the color is in the color space of the output or png_set_alpha_mode
|
||||
* was called and the color is black. Ignore RGB_TO_GRAY because that
|
||||
* happens before GRAY_TO_RGB.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
|
||||
{
|
||||
if (png_ptr->background.red == png_ptr->background.green &&
|
||||
png_ptr->background.red == png_ptr->background.blue)
|
||||
@@ -1481,10 +1481,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
defined(PNG_READ_EXPAND_16_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
png_ptr->bit_depth != 16)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
|
||||
png_ptr->bit_depth != 16)
|
||||
{
|
||||
/* TODO: fix this. Because the expand_16 operation is after the compose
|
||||
* handling the background color must be 8, not 16, bits deep, but the
|
||||
@@ -1508,10 +1508,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
|
||||
(defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
|
||||
defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||
png_ptr->bit_depth == 16)
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
|
||||
png_ptr->bit_depth == 16)
|
||||
{
|
||||
/* On the other hand, if a 16-bit file is to be reduced to 8-bits per
|
||||
* component this will also happen after PNG_COMPOSE and so the background
|
||||
@@ -1554,25 +1554,24 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
|
||||
* tables.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GAMMA)
|
||||
|| ((png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma) ||
|
||||
png_gamma_significant(png_ptr->screen_gamma)))
|
||||
|| ((png_ptr->transformations & PNG_COMPOSE)
|
||||
&& (png_gamma_significant(png_ptr->colorspace.gamma)
|
||||
|| png_gamma_significant(png_ptr->screen_gamma)
|
||||
if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
|
||||
((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
|
||||
((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
|
||||
&& png_gamma_significant(png_ptr->background_gamma))
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
|
||||
png_gamma_significant(png_ptr->background_gamma) != 0)
|
||||
# endif
|
||||
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
|
||||
&& png_gamma_significant(png_ptr->screen_gamma))
|
||||
)
|
||||
)) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0))
|
||||
{
|
||||
png_build_gamma_table(png_ptr, png_ptr->bit_depth);
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
{
|
||||
/* Issue a warning about this combination: because RGB_TO_GRAY is
|
||||
* optimized to do the gamma transform if present yet do_background has
|
||||
@@ -1580,11 +1579,11 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* double-gamma-correction happens. This is true in all versions of
|
||||
* libpng to date.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
png_warning(png_ptr,
|
||||
"libpng does not support gamma+background+rgb_to_gray");
|
||||
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0)
|
||||
{
|
||||
/* We don't get to here unless there is a tRNS chunk with non-opaque
|
||||
* entries - see the checking code at the start of this function.
|
||||
@@ -1632,7 +1631,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if (png_gamma_significant(gs))
|
||||
if (png_gamma_significant(gs) != 0)
|
||||
{
|
||||
back.red = png_gamma_8bit_correct(png_ptr->background.red,
|
||||
gs);
|
||||
@@ -1649,7 +1648,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
back.blue = (png_byte)png_ptr->background.blue;
|
||||
}
|
||||
|
||||
if (png_gamma_significant(g))
|
||||
if (png_gamma_significant(g) != 0)
|
||||
{
|
||||
back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
|
||||
g);
|
||||
@@ -1832,7 +1831,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
|
||||
#ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
/* No GAMMA transformation (see the hanging else 4 lines above) */
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) &&
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
@@ -1870,8 +1869,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
!(png_ptr->transformations & PNG_EXPAND) &&
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND) == 0 &&
|
||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||
{
|
||||
int i;
|
||||
@@ -1926,7 +1925,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_debug(1, "in png_read_transform_info");
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_EXPAND)
|
||||
if ((png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
{
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
@@ -1948,9 +1947,9 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (png_ptr->num_trans)
|
||||
if (png_ptr->num_trans != 0)
|
||||
{
|
||||
if (png_ptr->transformations & PNG_EXPAND_tRNS)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
if (info_ptr->bit_depth < 8)
|
||||
@@ -1966,7 +1965,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
/* The following is almost certainly wrong unless the background value is in
|
||||
* the screen space!
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
info_ptr->background = png_ptr->background;
|
||||
#endif
|
||||
|
||||
@@ -1987,12 +1986,12 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
# ifdef PNG_READ_16BIT_SUPPORTED
|
||||
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) != 0)
|
||||
info_ptr->bit_depth = 8;
|
||||
# endif
|
||||
|
||||
@@ -2022,23 +2021,23 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_GRAY_TO_RGB)
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type |
|
||||
PNG_COLOR_MASK_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
|
||||
{
|
||||
if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
|
||||
png_ptr->palette_lookup && info_ptr->bit_depth == 8)
|
||||
png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8)
|
||||
{
|
||||
info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
|
||||
}
|
||||
@@ -2046,29 +2045,31 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_EXPAND_16_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
|
||||
info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
|
||||
info_ptr->bit_depth == 8 &&
|
||||
info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
info_ptr->bit_depth = 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0 &&
|
||||
(info_ptr->bit_depth < 8))
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info_ptr->channels = 1;
|
||||
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
info_ptr->channels = 3;
|
||||
|
||||
else
|
||||
info_ptr->channels = 1;
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_STRIP_ALPHA)
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
|
||||
{
|
||||
info_ptr->color_type = (png_byte)(info_ptr->color_type &
|
||||
~PNG_COLOR_MASK_ALPHA);
|
||||
@@ -2076,25 +2077,25 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
info_ptr->channels++;
|
||||
|
||||
#ifdef 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)))
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0 &&
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
|
||||
{
|
||||
info_ptr->channels++;
|
||||
/* If adding a true alpha channel not just filler */
|
||||
if (png_ptr->transformations & PNG_ADD_ALPHA)
|
||||
if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
|
||||
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
|
||||
info_ptr->bit_depth = png_ptr->user_transform_depth;
|
||||
@@ -2245,7 +2246,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
int channels = 0;
|
||||
int bit_depth = row_info->bit_depth;
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
shift[channels++] = bit_depth - sig_bits->red;
|
||||
shift[channels++] = bit_depth - sig_bits->green;
|
||||
@@ -2257,7 +2258,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
shift[channels++] = bit_depth - sig_bits->gray;
|
||||
}
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
shift[channels++] = bit_depth - sig_bits->alpha;
|
||||
}
|
||||
@@ -2671,7 +2672,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
{
|
||||
/* This changes the data from G to GX */
|
||||
png_bytep sp = row + (png_size_t)row_width;
|
||||
@@ -2706,7 +2707,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
{
|
||||
/* This changes the data from GG to GGXX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 2;
|
||||
@@ -2748,7 +2749,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
{
|
||||
/* This changes the data from RGB to RGBX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 3;
|
||||
@@ -2787,7 +2788,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
if (flags & PNG_FLAG_FILLER_AFTER)
|
||||
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
|
||||
{
|
||||
/* This changes the data from RRGGBB to RRGGBBXX */
|
||||
png_bytep sp = row + (png_size_t)row_width * 6;
|
||||
@@ -2848,7 +2849,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
png_debug(1, "in png_do_gray_to_rgb");
|
||||
|
||||
if (row_info->bit_depth >= 8 &&
|
||||
!(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) == 0)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
@@ -2986,8 +2987,8 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
png_debug(1, "in png_do_rgb_to_gray");
|
||||
|
||||
if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
@@ -3086,15 +3087,15 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red == green && red == blue)
|
||||
{
|
||||
if (png_ptr->gamma_16_table != NULL)
|
||||
w = png_ptr->gamma_16_table[(red&0xff)
|
||||
>> png_ptr->gamma_shift][red>>8];
|
||||
w = png_ptr->gamma_16_table[(red & 0xff)
|
||||
>> png_ptr->gamma_shift][red >> 8];
|
||||
|
||||
else
|
||||
w = red;
|
||||
@@ -3137,9 +3138,9 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
|
||||
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
@@ -3150,7 +3151,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
*/
|
||||
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
|
||||
15);
|
||||
*(dp++) = (png_byte)((gray16>>8) & 0xff);
|
||||
*(dp++) = (png_byte)((gray16 >> 8) & 0xff);
|
||||
*(dp++) = (png_byte)(gray16 & 0xff);
|
||||
|
||||
if (have_alpha != 0)
|
||||
@@ -4127,7 +4128,7 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
png_debug(1, "in png_do_encode_alpha");
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
@@ -4353,7 +4354,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
|
||||
{
|
||||
unsigned int gray = trans_color ? trans_color->gray : 0;
|
||||
unsigned int gray = trans_color != NULL ? trans_color->gray : 0;
|
||||
|
||||
if (row_info->bit_depth < 8)
|
||||
{
|
||||
@@ -4497,7 +4498,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
row_width);
|
||||
}
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
trans_color != NULL)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
@@ -4715,7 +4717,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
* demand, if necessary.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
|
||||
{
|
||||
/* Application has failed to call either png_read_start_image() or
|
||||
* png_read_update_info() after setting transforms that expand pixels.
|
||||
@@ -4725,7 +4727,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_EXPAND)
|
||||
if ((png_ptr->transformations & PNG_EXPAND) != 0)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
@@ -4735,8 +4737,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->num_trans &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||
if (png_ptr->num_trans != 0 &&
|
||||
(png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
|
||||
png_do_expand(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->trans_color));
|
||||
|
||||
@@ -4748,16 +4750,16 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
!(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) == 0 &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_RGB_TO_GRAY)
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
{
|
||||
int rgb_error =
|
||||
png_do_rgb_to_gray(png_ptr, row_info,
|
||||
@@ -4812,22 +4814,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
/* 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->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0)
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_COMPOSE)
|
||||
if ((png_ptr->transformations & PNG_COMPOSE) != 0)
|
||||
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_GAMMA) &&
|
||||
if ((png_ptr->transformations & PNG_GAMMA) != 0 &&
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Because RGB_TO_GRAY does the gamma transform. */
|
||||
!(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
|
||||
(png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 &&
|
||||
#endif
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
@@ -4846,22 +4848,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
|
||||
(png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
0 /* at_start == false, because SWAP_ALPHA happens later */);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA))
|
||||
if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SCALE_16_TO_8)
|
||||
if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
|
||||
png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
@@ -4870,12 +4872,12 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
* by putting the 'scale' option first if the app asks for scale (either by
|
||||
* calling the API or in a TRANSFORM flag) this is what happens.
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) != 0)
|
||||
png_do_chop(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_QUANTIZE)
|
||||
if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
|
||||
{
|
||||
png_do_quantize(row_info, png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup, png_ptr->quantize_index);
|
||||
@@ -4891,35 +4893,35 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
* is efficient (particularly true in the case of gamma correction, where
|
||||
* better accuracy results faster!)
|
||||
*/
|
||||
if (png_ptr->transformations & PNG_EXPAND_16)
|
||||
if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
|
||||
png_do_expand_16(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
/* NOTE: moved here in 1.5.4 (from much later in this list.) */
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
|
||||
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
|
||||
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0)
|
||||
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INVERT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
|
||||
png_do_invert(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_INVERT_ALPHA)
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
|
||||
png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SHIFT_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SHIFT)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) != 0)
|
||||
png_do_unshift(row_info, png_ptr->row_buf + 1,
|
||||
&(png_ptr->shift));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACK_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
if ((png_ptr->transformations & PNG_PACK) != 0)
|
||||
png_do_unpack(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
@@ -4931,35 +4933,35 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_BGR_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_BGR)
|
||||
if ((png_ptr->transformations & PNG_BGR) != 0)
|
||||
png_do_bgr(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_PACKSWAP)
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
png_do_packswap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_FILLER_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_FILLER)
|
||||
if ((png_ptr->transformations & PNG_FILLER) != 0)
|
||||
png_do_read_filler(row_info, png_ptr->row_buf + 1,
|
||||
(png_uint_32)png_ptr->filler, png_ptr->flags);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_ALPHA)
|
||||
if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
|
||||
png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
#ifdef PNG_READ_SWAP_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_SWAP_BYTES)
|
||||
if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
|
||||
png_do_swap(row_info, png_ptr->row_buf + 1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if (png_ptr->transformations & PNG_USER_TRANSFORM)
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
if (png_ptr->read_user_transform_fn != NULL)
|
||||
(*(png_ptr->read_user_transform_fn)) /* User read transform function */
|
||||
@@ -4973,10 +4975,10 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
||||
/* png_byte pixel_depth; bits per pixel (depth*channels) */
|
||||
png_ptr->row_buf + 1); /* start of pixel data for row */
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
if (png_ptr->user_transform_depth)
|
||||
if (png_ptr->user_transform_depth != 0)
|
||||
row_info->bit_depth = png_ptr->user_transform_depth;
|
||||
|
||||
if (png_ptr->user_transform_channels)
|
||||
if (png_ptr->user_transform_channels != 0)
|
||||
row_info->channels = png_ptr->user_transform_channels;
|
||||
#endif
|
||||
row_info->pixel_depth = (png_byte)(row_info->bit_depth *
|
||||
|
||||
Reference in New Issue
Block a user