diff options
author | Anthony Wang | 2024-05-07 13:40:44 -0400 |
---|---|---|
committer | Anthony Wang | 2024-05-07 13:40:44 -0400 |
commit | 7a2c685c156b3aff30c736ca80765b9e9ba153b8 (patch) | |
tree | c1d7a26f44cd23f849b633bba731a33f8e5ed622 /encoder.py | |
parent | 49e4564566bbfd8435f390bba602eb97cc214502 (diff) |
Space out elements in each size 255 chunk
Diffstat (limited to 'encoder.py')
-rw-r--r-- | encoder.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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)) |