import sys, struct def rle_decode_pcx_style(data): """Decode assuming classic PCX RLE over the whole byte stream (no scanline boundary).""" out = bytearray() i = 0 n = len(data) while i < n: b = data[i] if (b & 0xC0) == 0xC0: count = b & 0x3F i += 1 if i >= n: break val = data[i] out.extend([val]*count) i += 1 else: out.append(b) i += 1 return bytes(out) def factor_pairs_near_sqrt(total, tol=0): import math res = [] for w in range(1, int(math.isqrt(total))+50): if w == 0: continue if total % w == 0: h = total // w res.append((w,h)) return res files = ["A.BOB","B.BOB","E.BOB","N.BOB","O.BOB","D.BOB","H.BOB","I.BOB","J.BOB","K.BOB","TONY.BOB"] base = "/home/aria/kellogg_remake/extracted_pre/" for fn in files: path = base+fn data = open(path,"rb").read() dec = rle_decode_pcx_style(data) print(fn, "raw_len=",len(data), "decoded_len=",len(dec))