Skip to content

Commit 39c8ebb

Browse files
committed
Fixed handling of grayscale images with alpha
Fixes libsdl-org#460
1 parent 2a27018 commit 39c8ebb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/IMG_png.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@ static void LIBPNG_LoadPNG_IO(SDL_IOStream *src, struct loadpng_vars *vars)
336336
/* more than one transparent index, or translucency */
337337
lib.png_set_expand(vars->png_ptr);
338338
}
339+
} else if (color_type == PNG_COLOR_TYPE_GRAY) {
340+
/* This will be turned into PNG_COLOR_TYPE_GRAY_ALPHA, so expand to RGBA */
341+
lib.png_set_gray_to_rgb(vars->png_ptr);
339342
} else {
340343
ckey = 0; /* actual value will be set later */
341344
}
342345
}
343346

344-
if ( color_type == PNG_COLOR_TYPE_GRAY_ALPHA )
345-
lib.png_set_gray_to_rgb(vars->png_ptr);
346-
347347
lib.png_read_update_info(vars->png_ptr, vars->info_ptr);
348348

349349
lib.png_get_IHDR(vars->png_ptr, vars->info_ptr, &width, &height, &bit_depth,

0 commit comments

Comments
 (0)