|
import sys
from PIL import Image
prn = lambda *args: print(*args,end='')
img = Image.open(sys.argv[1])
w,h = img.size
img.convert('RGB')
prn('int aaa[%d][%d] = {\n' %(h,w))
for y in range(h):
prn("{")
for x in range(w):
r,g,b=img.getpixel((x,y))
c=((r>>5)<<6)+((g>>5)<<3)+(b>>5);
prn(f'{c:>3}')
if x ==w-1: prn('}')
elif x%50==49: prn(',\n ')
else: prn(',')
if y!=h-1: prn(',\n')
else: prn('};\n')
img.close() |
|