From ae0b7c4466f32a6ff1d3ead57cecf8b2bd14e2d8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 26 Dec 2024 12:28:58 -0800 Subject: [PATCH] Expand PNG_COLOR_TYPE_GRAY_ALPHA to RGBA Fixes https://github.com/libsdl-org/SDL_image/issues/494 --- src/IMG_png.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/IMG_png.c b/src/IMG_png.c index 6947be39..c667b90a 100644 --- a/src/IMG_png.c +++ b/src/IMG_png.c @@ -306,8 +306,11 @@ static void LIBPNG_LoadPNG_IO(SDL_IOStream *src, struct loadpng_vars *vars) lib.png_set_packing(vars->png_ptr); /* scale greyscale values to the range 0..255 */ - if (color_type == PNG_COLOR_TYPE_GRAY) + if (color_type == PNG_COLOR_TYPE_GRAY) { lib.png_set_expand(vars->png_ptr); + } else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + lib.png_set_gray_to_rgb(vars->png_ptr); + } /* For images with a single "transparent colour", set colour key; if more than one index has transparency, or if partially transparent