aboutsummaryrefslogtreecommitdiff
path: root/encoder.py
diff options
context:
space:
mode:
authorAnthony Wang2024-05-07 13:40:44 -0400
committerAnthony Wang2024-05-07 13:40:44 -0400
commit7a2c685c156b3aff30c736ca80765b9e9ba153b8 (patch)
treec1d7a26f44cd23f849b633bba731a33f8e5ed622 /encoder.py
parent49e4564566bbfd8435f390bba602eb97cc214502 (diff)
Space out elements in each size 255 chunk
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))