python script to convert .gray to .bin

This commit is contained in:
Charles Mangin 2019-01-05 13:10:25 -05:00 committed by GitHub
parent f97996499d
commit 0eb98b1ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

16
greenscale.py Normal file
View File

@ -0,0 +1,16 @@
import sys
data = sys.stdin.read()
mybytearray=bytearray(data)
import struct
#output = open('output.bin', 'wb')
for row in range(48/2): # because we to 2 rows at a time
for x in range(40):
nibble1 = mybytearray[2*row*40 + x]
nibble2 = mybytearray[(2*row + 1)*40 + x] * 16
pixel = nibble1+nibble2
pixel = struct.pack("B", pixel)
sys.stdout.write(pixel)