Mercurial > hg > dmlib
diff src/libgfx.c @ 1300:fd442faa705f
"Fix" the PNG/ILBM decoding to not use actual bitdepths for indexed images, but force 8bits.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 19 Aug 2017 03:57:15 +0300 |
parents | b0c0be4c76f9 |
children | e03f20d0f785 |
line wrap: on
line diff
--- a/src/libgfx.c Sat Aug 19 03:40:49 2017 +0300 +++ b/src/libgfx.c Sat Aug 19 03:57:15 2017 +0300 @@ -601,7 +601,10 @@ dmMsg(2, "PNG: %d x %d, depth=%d, type=%d\n", width, height, bit_depth, color_type); - if ((*pimg = img = dmImageAlloc(width, height, DM_IFMT_PALETTE, bit_depth)) == NULL) + if ((*pimg = img = dmImageAlloc(width, height, + DM_IFMT_PALETTE, + // XXX TODO? When/if we ever handle < 8bit indexed correctly, we can use the actual bpp + -1 /* bit_depth */)) == NULL) { res = dmError(DMERR_MALLOC, "PNG: Could not allocate image data.\n"); @@ -1494,8 +1497,11 @@ // Allocate image if ((*pimg = img = dmImageAlloc(iff->bmhd.w, iff->bmhd.h, - iff->bmhd.nplanes < 8 ? DM_IFMT_PALETTE : DM_IFMT_RGBA, - iff->bmhd.nplanes < 8 ? iff->bmhd.nplanes : -1)) == NULL) + iff->bmhd.nplanes <= 8 ? DM_IFMT_PALETTE : DM_IFMT_RGBA, + // XXX TODO? When/if we ever handle < 8bit indexed correctly, we can use the actual bpp + //iff->bmhd.nplanes <= 8 ? iff->bmhd.nplanes : -1 + -1 + )) == NULL) return DMERR_MALLOC; // Allocate planar decoding buffer @@ -1573,8 +1579,11 @@ // Allocate image if ((*pimg = img = dmImageAlloc(iff->bmhd.w, iff->bmhd.h, - iff->bmhd.nplanes < 8 ? DM_IFMT_PALETTE : DM_IFMT_RGBA, - iff->bmhd.nplanes < 8 ? iff->bmhd.nplanes : -1)) == NULL) + iff->bmhd.nplanes <= 8 ? DM_IFMT_PALETTE : DM_IFMT_RGBA, + // XXX TODO? When/if we ever handle < 8bit indexed correctly, we can use the actual bpp + //iff->bmhd.nplanes <= 8 ? iff->bmhd.nplanes : -1 + -1 + )) == NULL) return DMERR_MALLOC; // Decode the chunk