summaryrefslogtreecommitdiff
path: root/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-11-01 19:41:57 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-11-01 19:41:57 +0100
commitbd2b2541a7b00a2520ea5a3eabcb90a0bbb35b28 (patch)
tree6729d6528abc4a295531ad304f92bde5a72bb294 /src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
parent8668036aeab09b580d19b1113c1ba5450637ccfc (diff)
add pervasive aurora mb bad apple (not really working yet)
Diffstat (limited to 'src/app/pervasive-aurora-mb-bad-apple/frames-to-cc')
-rwxr-xr-xsrc/app/pervasive-aurora-mb-bad-apple/frames-to-cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc b/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
new file mode 100755
index 0000000..d734159
--- /dev/null
+++ b/src/app/pervasive-aurora-mb-bad-apple/frames-to-cc
@@ -0,0 +1,38 @@
+#!/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[x * (h//8) + y // 8] |= 1 << (7 - (y % 8))
+ return buf
+
+
+for i in range(1, len(sys.argv)):
+ buf = (
+ load_image(sys.argv[i])
+ )
+ 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)):
+ frames.append(f"(unsigned char*)frame{i:04d}")
+
+prefix = "unsigned char* const frames[] = {"
+postfix = "};"
+
+print(prefix + ", ".join(frames) + postfix)