diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-02-03 18:10:30 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-02-03 18:10:30 +0100 |
commit | 30431427adbf05a3e5cc17f6fb4b1b1cbc105b39 (patch) | |
tree | 7f18fcf31cecd520ca0a4d6515df5a08bafe564a /src/app/sharp96-bad-apple/frames-to-cc | |
parent | 31a918533ce2b5a2796a671b14c82b9f2c1dd5df (diff) |
bad apple: increase frame rate to 7 FPS. now running at actual speed.
Diffstat (limited to 'src/app/sharp96-bad-apple/frames-to-cc')
-rwxr-xr-x | src/app/sharp96-bad-apple/frames-to-cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/app/sharp96-bad-apple/frames-to-cc b/src/app/sharp96-bad-apple/frames-to-cc new file mode 100755 index 0000000..fa12c6f --- /dev/null +++ b/src/app/sharp96-bad-apple/frames-to-cc @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +from PIL import Image +import sys +import zlib + + +def load_image(filename): + im = Image.open(filename) + w, h = im.size + buf = [0 for i in range(w * h // 8)] + for y in range(h): + for x in range(w): + if im.getpixel((x, y)): + buf[y * 12 + x // 8] |= 1 << (7 - (x % 8)) + return buf + + +for i in range(1, len(sys.argv) - 2, 3): + buf = ( + load_image(sys.argv[i]) + + load_image(sys.argv[i + 1]) + + load_image(sys.argv[i + 2]) + ) + c_buf = ",".join(map(str, buf)) + z_buf = zlib.compress(bytes(buf), 9) + z_buf = z_buf[2:-4] + out_buf = ",".join(map(str, z_buf)) + print( + f'__attribute__((section(".text"))) unsigned char const frame{i:04d}[] = {{ {out_buf} }};' + ) + +frames = list() +for i in range(1, len(sys.argv) - 2, 3): + frames.append(f"(unsigned char*)frame{i:04d}") + +prefix = "unsigned char* const frames[] = {" +postfix = "};" + +print(prefix + ", ".join(frames) + postfix) |