diff --git a/gen/k_means/python/decode_pvrt.py b/gen/k_means/python/decode_pvrt.py index b525c8d..f83f596 100644 --- a/gen/k_means/python/decode_pvrt.py +++ b/gen/k_means/python/decode_pvrt.py @@ -36,19 +36,39 @@ def parse_pvrt_header(buf): data, ) -def rgb24(color): +def argb1555(color): + a = (color >> 15) & 1 + r = (color >> 10) & 31 + g = (color >> 5) & 31 + b = (color >> 0) & 31 + return r << 4, g << 4, b << 4, a * 255 + +def rgb565(color): r = (color >> 11) & 31 g = (color >> 5) & 63 b = (color >> 0) & 31 return r << 3, g << 2, b << 3 -def get_colors(buf, codebook_ix): +def argb4444(color): + a = (color >> 12) & 15 + r = (color >> 8) & 15 + g = (color >> 4) & 15 + b = (color >> 0) & 15 + return r << 4, g << 4, b << 4, (a << 4) | 0b1111 + +def get_colors(buf, codebook_ix, decode_pixel): codeword = buf[codebook_ix * 2 * 4:][:2 * 4] assert len(codeword) == 2 * 4 colors = struct.unpack('