mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng17] Refactored conditional compilation in png_init_row_info().
This commit is contained in:
parent
a3458a6ba0
commit
09c90236f4
2
pngset.c
2
pngset.c
@ -529,7 +529,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0))
|
(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0))
|
||||||
png_error(png_ptr, "Invalid palette");
|
png_error(png_ptr, "Invalid palette");
|
||||||
#else
|
#else
|
||||||
if ((num_palette > 0 && palette == NULL) || (num_palette == 0))
|
if ((num_palette > 0 && palette == NULL) || num_palette == 0)
|
||||||
png_error(png_ptr, "Invalid palette");
|
png_error(png_ptr, "Invalid palette");
|
||||||
#endif /* MNG_FEATURES */
|
#endif /* MNG_FEATURES */
|
||||||
|
|
||||||
|
46
pngtrans.c
46
pngtrans.c
@ -835,37 +835,49 @@ png_init_row_info(png_structrp png_ptr)
|
|||||||
unsigned int max_depth = PNG_PIXEL_DEPTH(*png_ptr);
|
unsigned int max_depth = PNG_PIXEL_DEPTH(*png_ptr);
|
||||||
|
|
||||||
#ifdef PNG_TRANSFORM_MECH_SUPPORTED
|
#ifdef PNG_TRANSFORM_MECH_SUPPORTED
|
||||||
|
# ifdef PNG_PALETTE_MAX_SUPPORTED
|
||||||
/* The palette index check stuff is *on* automatically. To handle this
|
/* The palette index check stuff is *on* automatically. To handle this
|
||||||
* add it here, if it is supported.
|
* add it here, if it is supported.
|
||||||
*/
|
*
|
||||||
# ifdef PNG_PALETTE_MAX_SUPPORTED
|
* The logic here is a little complex because of the plethora of
|
||||||
/* The logic here is a little complex because of the plethora of
|
|
||||||
* #defines controlling this stuff.
|
* #defines controlling this stuff.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE/* fast escape */ && (
|
# undef PNG_READ_CHECK_PALETTE
|
||||||
|
# undef PNG_WRITE_CHECK_PALETTE
|
||||||
|
|
||||||
# if defined(PNG_READ_GET_PALETTE_MAX_SUPPORTED) ||\
|
# if defined(PNG_READ_GET_PALETTE_MAX_SUPPORTED) ||\
|
||||||
defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||||
(png_ptr->read_struct
|
|
||||||
# ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
# ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
&& !png_ptr->palette_index_check_disabled)
|
# define PNG_READ_CHECK_PALETTE \
|
||||||
# endif /* READ_CHECK_FOR_INVALID_INDEX */
|
(png_ptr->read_struct && !png_ptr->palette_index_check_disabled)
|
||||||
|
# else
|
||||||
|
# define PNG_READ_CHECK_PALETTE (png_ptr->read_struct)
|
||||||
|
# endif
|
||||||
# else /* no READ support */
|
# else /* no READ support */
|
||||||
0
|
# define PNG_READ_CHECK_PALETTE 0
|
||||||
# endif /* READ checks */
|
# endif
|
||||||
||
|
|
||||||
# if defined(PNG_WRITE_GET_PALETTE_MAX_SUPPORTED) ||\
|
# if defined(PNG_WRITE_GET_PALETTE_MAX_SUPPORTED) ||\
|
||||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||||
(!png_ptr->read_struct
|
|
||||||
# ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
# ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
&& !png_ptr->palette_index_check_disabled)
|
# define PNG_WRITE_CHECK_PALETTE \
|
||||||
# endif /* WRITE_CHECK_FOR_INVALID_INDEX */
|
(!png_ptr->read_struct && !png_ptr->palette_index_check_disabled)
|
||||||
|
# else
|
||||||
|
# define PNG_WRITE_CHECK_PALETTE (!png_ptr->read_struct)
|
||||||
|
# endif
|
||||||
# else /* no WRITE support */
|
# else /* no WRITE support */
|
||||||
0
|
# define PNG_WRITE_CHECK_PALETTE 0
|
||||||
# endif /* WRITE checks */
|
# endif
|
||||||
))
|
|
||||||
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE/* fast escape */ &&
|
||||||
|
(PNG_READ_CHECK_PALETTE || PNG_WRITE_CHECK_PALETTE))
|
||||||
|
{
|
||||||
png_add_transform(png_ptr, 0/*size*/, palette_max_init,
|
png_add_transform(png_ptr, 0/*size*/, palette_max_init,
|
||||||
PNG_TR_CHECK_PALETTE);
|
PNG_TR_CHECK_PALETTE);
|
||||||
# endif
|
}
|
||||||
|
# undef PNG_READ_CHECK_PALETTE
|
||||||
|
# undef PNG_WRITE_CHECK_PALETTE
|
||||||
|
# endif /* PALETTE_MAX */
|
||||||
|
|
||||||
/* Application transforms may change the format of the data or, when
|
/* Application transforms may change the format of the data or, when
|
||||||
* producing interlaced images, the number of pixels in a line. This code
|
* producing interlaced images, the number of pixels in a line. This code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user