From df9552d471552e49d1ea9cabc8205be4cab5c2da Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
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
(cherry picked from commit ae0b7c4466f32a6ff1d3ead57cecf8b2bd14e2d8)
---
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 bf1f0987..38a76ae2 100644
--- a/src/IMG_png.c
+++ b/src/IMG_png.c
@@ -305,8 +305,11 @@ static void LIBPNG_LoadPNG_RW(SDL_RWops *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