diff --git a/src/IMG_png.c b/src/IMG_png.c index 3d211d4c..d5bfebff 100644 --- a/src/IMG_png.c +++ b/src/IMG_png.c @@ -336,14 +336,14 @@ static void LIBPNG_LoadPNG_IO(SDL_IOStream *src, struct loadpng_vars *vars) /* more than one transparent index, or translucency */ lib.png_set_expand(vars->png_ptr); } + } else if (color_type == PNG_COLOR_TYPE_GRAY) { + /* This will be turned into PNG_COLOR_TYPE_GRAY_ALPHA, so expand to RGBA */ + lib.png_set_gray_to_rgb(vars->png_ptr); } else { ckey = 0; /* actual value will be set later */ } } - if ( color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) - lib.png_set_gray_to_rgb(vars->png_ptr); - lib.png_read_update_info(vars->png_ptr, vars->info_ptr); lib.png_get_IHDR(vars->png_ptr, vars->info_ptr, &width, &height, &bit_depth,