# HG changeset patch # User Matti Hamalainen # Date 1503104235 -10800 # Node ID fd442faa705fd6453208a6e7b8c3ceed7f789ebf # Parent b0c0be4c76f90da26fa24b51156beac3ab0629d8 "Fix" the PNG/ILBM decoding to not use actual bitdepths for indexed images, but force 8bits. diff -r b0c0be4c76f9 -r fd442faa705f src/libgfx.c --- 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