forked from pimoroni/unicorn-hat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_png.py
More file actions
executable file
·33 lines (24 loc) · 773 Bytes
/
Copy pathshow_png.py
File metadata and controls
executable file
·33 lines (24 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
'''
This basic example shows use of the Python Pillow library:
sudo apt-get install pillow
The tiny 8x8 chars in lofi.png are from Oddball:
http://forums.tigsource.com/index.php?topic=8834.0
Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
'''
import unicornhat as unicorn
from PIL import Image
import signal, numpy, time
unicorn.rotation(90)
unicorn.brightness(0.4)
img = Image.open('lofi.png')
for o_x in range(img.size[0]/8):
for o_y in range(img.size[1]/8):
for x in range(8):
for y in range(8):
pixel = img.getpixel(((o_x*8)+y,(o_y*8)+x))
print(pixel)
r, g, b = int(pixel[0]),int(pixel[1]),int(pixel[2])
unicorn.set_pixel(x, y, r, g, b)
unicorn.show()
time.sleep(0.5)