diff --git a/assets/experiment1.png b/assets/experiment1.png new file mode 100644 index 0000000000..4e39c9ddcb Binary files /dev/null and b/assets/experiment1.png differ diff --git a/assets/experiment1.toif b/assets/experiment1.toif deleted file mode 100644 index 961bd23576..0000000000 Binary files a/assets/experiment1.toif and /dev/null differ diff --git a/assets/experiment2.png b/assets/experiment2.png new file mode 100644 index 0000000000..045207299e Binary files /dev/null and b/assets/experiment2.png differ diff --git a/assets/experiment2.toif b/assets/experiment2.toif deleted file mode 100644 index c808b1312a..0000000000 Binary files a/assets/experiment2.toif and /dev/null differ diff --git a/assets/experiment3.png b/assets/experiment3.png new file mode 100644 index 0000000000..6fabbd4a3c Binary files /dev/null and b/assets/experiment3.png differ diff --git a/assets/experiment3.toif b/assets/experiment3.toif deleted file mode 100644 index 7634ef6cb5..0000000000 Binary files a/assets/experiment3.toif and /dev/null differ diff --git a/assets/experiment7.png b/assets/experiment7.png new file mode 100644 index 0000000000..c6bc37adaf Binary files /dev/null and b/assets/experiment7.png differ diff --git a/assets/experiment7.toif b/assets/experiment7.toif deleted file mode 100644 index 7663b7b75c..0000000000 Binary files a/assets/experiment7.toif and /dev/null differ diff --git a/tools/png2toi b/tools/png2toi index 8bd6cfe3f2..a160113ad3 100755 --- a/tools/png2toi +++ b/tools/png2toi @@ -18,10 +18,10 @@ def process_rgb(w, h, pix): def process_grayscale(w, h, pix): data = bytes() for j in range(h): - for i in range(w // 2): - l1, l2 = pix[i * 2, j], pix[i * 2 + 1, j] - c = (l1 & 0xF0) | (l2 >> 4) - data += struct.pack('>B', c) + for i in range(w // 2): + l1, l2 = pix[i * 2, j], pix[i * 2 + 1, j] + c = (l1 & 0xF0) | (l2 >> 4) + data += struct.pack('>B', c) return data @@ -55,9 +55,9 @@ def process_image(ifn): with open(ofn, 'wb') as f: if im.mode == 'RGB': - f.write(bytes('TOIf', 'ascii')) + f.write(b'TOIf') else: - f.write(bytes('TOIg', 'ascii')) + f.write(b'TOIg') f.write(struct.pack('> 8 + pix[i * 3 + 1] = (c & 0x07C0) >> 3 + pix[i * 3 + 2] = (c & 0x001F) << 3 + return bytes(pix) + + +def process_grayscale(w, h, data): + pix = bytearray(w * h) + for i in range(w * h // 2): + pix[i * 2 ] = data[i] & 0xF0 + pix[i * 2 + 1] = (data[i] & 0x0F) << 4 + return bytes(pix) + + +def process_image(ifn): + + data = open(ifn, 'rb').read() + + if ifn.endswith('.toif'): + if data[:4] != b'TOIf': + print('Unknown TOIF header') + return 1 + elif ifn.endswith('.toig'): + if data[:4] != b'TOIg': + print('Unknown TOIG header') + return 2 + else: + print('Unsupported format') + return 3 + ofn = '%s.png' % ifn[:-5] + + w, h = struct.unpack('