blob: 1e54bd4cccc85786a7317437df5b1110c6ec2ad5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/usr/bin/env python3
# Render a PPM screenshot as ASCII so we can "read" the GB LCD.
import sys
def load(path):
f=open(path,'rb'); assert f.readline().strip()==b'P6'
w,h=map(int,f.readline().split()); f.readline()
d=f.read(w*h*3); return w,h,d
w,h,d=load(sys.argv[1] if len(sys.argv)>1 else 'shot.ppm')
y0=int(sys.argv[2]) if len(sys.argv)>2 else 0
y1=int(sys.argv[3]) if len(sys.argv)>3 else h
for y in range(y0,min(y1,h)):
row=[]
for x in range(w):
i=(y*w+x)*3; b=(d[i]+d[i+1]+d[i+2])//3
row.append('#' if b<128 else '.')
print(''.join(row))
|