Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pylab import *
- import sys
- fd = open('screen_data.bin', 'rb')
- data = fd.read()
- fd.close()
- frames = data.split('\x1E\x00')
- print len(frames), 'frames'
- colors = {0: '#000000', 1: '#555555', 2: '#CCCCCC', 3: '#FFFFFF'}
- # Reversed color scheme just in case
- #colors = {3: '#000000', 2: '#555555', 1: '#CCCCCC', 0: '#FFFFFF'}
- # How many frames to skip from the beginning of the transmission
- skip = 30
- for frame in frames:
- pixels = []
- # First and last frames can be smaller than that (because there's small chance we start capture right at the beginning of the frame)
- if len(frame)!=5760:
- continue
- # Skipe frames if needed
- if skip!=0:
- skip-=1
- continue
- # Restore pixels from byte array
- for y in range(144):
- for x in range(160):
- bit_offset = y*320+x*2
- array_offset = bit_offset/8
- byte_offset = bit_offset%8
- byte = ord(frame[array_offset])
- pixel = (byte>>byte_offset)&0b11
- c = colors[pixel]
- scatter(x, y, color = c, s=1)
- show()
- break
Advertisement
Add Comment
Please, Sign In to add comment