From 9ad0c6da0817b596ae295e981cc2845bae2537a0 Mon Sep 17 00:00:00 2001 From: wiidev Date: Sun, 12 Apr 2020 19:34:05 +0100 Subject: [PATCH] Support paletted images --- source/gui/pngu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/gui/pngu.c b/source/gui/pngu.c index b93617e6..ff54a11f 100644 --- a/source/gui/pngu.c +++ b/source/gui/pngu.c @@ -1114,8 +1114,12 @@ int pngu_decode (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stripAlph if ( (ctx->prop.imgWidth != width) || (ctx->prop.imgHeight != height) ) return PNGU_INVALID_WIDTH_OR_HEIGHT; + // Support paletted images + if (ctx->prop.imgColorType == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(ctx->png_ptr); + // Check if color type is supported by PNGU - if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_PALETTE) || (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN) ) + if ( (ctx->prop.imgColorType == PNGU_COLOR_TYPE_UNKNOWN) ) return PNGU_UNSUPPORTED_COLOR_TYPE; // error handling