From db8735129a9025406e7473085288a8c0132f483f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Mon, 6 Jan 2020 21:02:25 -0300 Subject: [PATCH] Don't force 16bpp if the bit depth was already higher! --- src/r_picformats.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index bb3abcf6a..b55dac5ad 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -925,16 +925,21 @@ void *Picture_PNGConvert( png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, insize); png_uint_32 width = *w, height = *h; + // Find the output format's bits per pixel amount + outbpp = Picture_FormatBPP(outformat); + // Hack for patches because you'll want to preserve transparency. if (Picture_IsPatchFormat(outformat)) - outbpp = 16; - else { - outbpp = Picture_FormatBPP(outformat); - if (!outbpp) - I_Error("Picture_PNGConvert: unknown output bits per pixel?!"); + // Force a higher bit depth + if (outbpp == 8) + outbpp = 16; } + // Shouldn't happen. + if (!outbpp) + I_Error("Picture_PNGConvert: unknown output bits per pixel?!"); + // Figure out the size flatsize = (width * height) * (outbpp / 8); if (outsize)