From 20c4ea930afa93a8c4a27739c8a137801d16328f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 2 Mar 2025 22:28:41 +0100 Subject: liblss16_optimise: check if it is preferrable to assign an unused colour index 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- liblss16_optimise.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'liblss16_optimise.c') diff --git a/liblss16_optimise.c b/liblss16_optimise.c index 911fcd2..7cb3b5d 100644 --- a/liblss16_optimise.c +++ b/liblss16_optimise.c @@ -51,6 +51,8 @@ liblss16_optimise(struct liblss16_header *header, uint8_t *pixels) least = zero[0] - nonzero[0]; preferred = 0U; + if (ncolours < 16U) + ncolours++; for (x = 1U; x < (unsigned)ncolours; x++) { zero_penalty = zero[x] - nonzero[x]; if (zero_penalty < least) { -- cgit v1.2.3-70-g09d2