aboutsummaryrefslogtreecommitdiff
path: root/encoder.py
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.py')
-rw-r--r--encoder.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/encoder.py b/encoder.py
index 634a166..38d89cb 100644
--- a/encoder.py
+++ b/encoder.py
@@ -45,7 +45,11 @@ print(f"-x {args.height} -y {args.width} -l {args.level} -s {len(data)} -p {len(
def mkframe(packet):
frame = np.array(rsc.encode(bytearray(packet)))
- frame = np.unpackbits(np.pad(frame, (0, frame_bytes - len(frame))) ^ frame_xor)
+ frame = np.pad(frame, (0, frame_bytes - len(frame))) ^ frame_xor
+ reshape_len = frame_bytes // 255 * 255
+ # Space out elements in each size 255 chunk
+ frame[:reshape_len] = np.ravel(frame[:reshape_len].reshape(reshape_len // 255, 255), "F")
+ frame = np.unpackbits(frame)
# Pad to be multiple of 3 so we can reshape into RGB channels
frame = np.pad(frame, (0, (3 - len(frame)) % 3))
frame = np.reshape(frame, (frame_size, 3))