# image/lmp fixtures (tools/fixtures.py): qpic .lmp pictures, a palette.lmp and a colormap.lmp written from wad.h / # draw.c; reference rgba from Pillow (a "P" image with the palette, index 255 transparent for qpics). The palette is # random: Quake's own is GPL and never committed. # tests/gen/lmp.luau { palette, pics = { { name, data, w, h, crc, crcOpaque } }, colormap = { data, crc }, palcrc } import json, struct, zlib CODE = r""" import json, sys, zlib, io from PIL import Image job = json.loads(sys.stdin.read()) out = {} pal = bytes.fromhex(job["pal"]) for k, (w, h, hexpix, key) in job["imgs"].items(): im = Image.frombytes("P", (w, h), bytes.fromhex(hexpix)) im.putpalette(pal) if key is not None: im.info["transparency"] = key out[k] = zlib.crc32(im.convert("RGBA").tobytes()) print(json.dumps(out)) """ def generate(ctx): rng = ctx.rng(31) pal = bytes(rng.randrange(256) for _ in range(768)) imgs, pics = {}, [] for name, w, h in (("disc", 24, 24), ("conback", 64, 40), ("num_0", 24, 24), ("wide", 3, 1)): pix = bytes(rng.randrange(256) for _ in range(w * h)) imgs[name] = [w, h, pix.hex(), 255] imgs[name + "_o"] = [w, h, pix.hex(), None] pics.append({"name": name, "data": struct.pack("