Avoiding conditional directives that break statements
This commit is contained in:
parent
ae794eefaa
commit
c3f4e5fb1a
@ -678,6 +678,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
|
|
||||||
png_debug(1, "in png_write_IHDR");
|
png_debug(1, "in png_write_IHDR");
|
||||||
|
|
||||||
|
int is_invalid_depth;
|
||||||
|
|
||||||
/* Check that we have valid input data from the application info */
|
/* Check that we have valid input data from the application info */
|
||||||
switch (color_type)
|
switch (color_type)
|
||||||
{
|
{
|
||||||
@ -700,11 +702,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
is_invalid_depth = (bit_depth != 8);
|
||||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
if (bit_depth != 8 && bit_depth != 16)
|
is_invalid_depth = (is_invalid_depth && bit_depth != 16);
|
||||||
#else
|
|
||||||
if (bit_depth != 8)
|
|
||||||
#endif
|
#endif
|
||||||
|
if (is_invalid_depth)
|
||||||
png_error(png_ptr, "Invalid bit depth for RGB image");
|
png_error(png_ptr, "Invalid bit depth for RGB image");
|
||||||
|
|
||||||
png_ptr->channels = 3;
|
png_ptr->channels = 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user