Skip to content

Commit

Permalink
We have restricted the call conditions of png_set_strip_alpha too much
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryforce committed Dec 19, 2024
1 parent 26345f7 commit 3decb94
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/imageio/imageio_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ gboolean dt_imageio_png_read_header(const char *filename, dt_imageio_png_t *png)
png->bit_depth = 8;
}

// strip alpha channel
if(png->color_type & PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha(png->png_ptr);
// To ensure that 4 channels will not be decoded instead of expected 3 we
// need to call png_set_strip_alpha. It wouldn't hurt if we always call
// this function. It just doesn't do anything when it's not needed.
png_set_strip_alpha(png->png_ptr);

// grayscale => rgb
if(png->color_type == PNG_COLOR_TYPE_GRAY || png->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
Expand Down

0 comments on commit 3decb94

Please sign in to comment.