From ca551c1700cf982fe96388491a096b515365894f Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 5 May 2023 21:39:32 +0100 Subject: Use the MSB of the index to mark a transparent color Because we use 1 byte to store 4bpp, we don't need a mask and we can encode a "transparent" color in the bits we don't use. --- tr8as.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tr8as.c') diff --git a/tr8as.c b/tr8as.c index 1a83b97..38b327d 100644 --- a/tr8as.c +++ b/tr8as.c @@ -495,12 +495,11 @@ static uint8_t parse_incpng(As *as, char **c) goto exit_parseinc; } - /* TODO: mask */ - uint16_t addr = as->addr; uint8_t index; - /* map RGB values to the palette indexes */ + /* map RGB values to the palette indexes; + * any index over 15 is "transparent" with index 128 */ for (int i = 0; i < x * y * 3; i += 3) { for (index = 0; index < 16; index++) @@ -512,7 +511,7 @@ static uint8_t parse_incpng(As *as, char **c) break; } if (index == 16) - as->out[addr++] = 0; + as->out[addr++] = 128; } as->addr = addr; -- cgit v1.2.3