1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- from __future__ import print_function
-
- from PIL import Image
- import sys
-
-
-
-
-
- width = 128
- height = 64
-
- if len(sys.argv) != 2:
- print('Please specify an image to use as the only argument')
- exit(1)
-
- im = Image.open(sys.argv[1])
- im = im.convert('L').resize((width, height))
-
- data = list(im.getdata())
-
- byteblock = [0 for i in range(width)]
- widthblock = [list(byteblock) for i in range(int(height/8))]
- numblock = 0
- pixcount = 0
- i = 0
-
-
- datachunks=[data[x:x+(width*8)] for x in range(0, len(data), (width*8))]
-
-
- while i < len(widthblock):
- pixcount = 0
- for y in datachunks[i]:
- xcoor = pixcount % width
- ycoor = int(pixcount/width)
- blknum = xcoor % len(widthblock)
- blkycoor = ycoor
-
-
- if y > 40:
- widthblock[i][xcoor] |= (1 << blkycoor)
-
- pixcount += 1
- i += 1
-
- flatlist = [y for x in widthblock for y in x]
-
- carray = 'static uint8_t image[] = {\n' + ', '.join(str(x) for x in flatlist)
- print(carray + '\n};')
|