May 12May 12 Supporter Just curious about those RLE images from old 1997 PC game "My Friend Koo". My Friend Koo RLE samples.zip
May 12May 12 1 hour ago, ikskoks said: Just curious about those RLE images from old 1997 PC game "My Friend Koo". My Friend Koo RLE samples.zip 649.66 kB · 1 download They don't seem overly complicated - it might be useful to have some uncompressed samples from memory (if possible), from running under DosBox, etc. in order to see exactly what the data should be.
May 13May 13 Supporter 14 hours ago, ikskoks said: Just curious about those RLE images from old 1997 PC game "My Friend Koo". My Friend Koo RLE samples.zip 649.66 kB · 5 downloads It's similar to PCX/PackBits, where bytes 0xC0–0xFF indicate a repetition and the remaining ones are literal bytes. PCX-style RLE: bytes >= 0xC0 specify a repetition count (byte & 0x3F) for the following byte. A 256-color RGB palette is located in the last 768 bytes of the file. Standard image size is 640x480, with a short prefix/header preceding the pixel data. Edited May 13May 13 by Rabatini
May 13May 13 Supporter Solution def pcx_style_rle_decode(data): out = bytearray() i = 0 n = len(data) while i < n: b = data[i] i += 1 if b >= 0xC0: count = b & 0x3F value = data[i] i += 1 out.extend([value] * count) else: out.append(b) return bytes(out) def decode_rle_image(filepath, width=640, height=480, offset=None): with open(filepath, 'rb') as f: raw = f.read() palette_size = 768 if len(raw) <= palette_size: raise ValueError("Arquivo muito pequeno, não tem dados de imagem + paleta.") compressed = raw[:-palette_size] palette = raw[-palette_size:] decoded = pcx_style_rle_decode(compressed) expected_pixels = width * height # Gambiarra caso o offset não seja informado: pega o final dos dados descompactados if offset is None: offset = len(decoded) - expected_pixels if offset < 0: offset = 0 pixels = decoded[offset: offset + expected_pixels] return pixels, palette, offset Here the essential! Let me know if you need the complete tool.
May 13May 13 Ah, it was quite simple. I did wonder if the top 2 bits of the byte had any relevance - for example, to indicate alpha pixels.
Create an account or sign in to comment