forked from CRImier/pyLCI
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathsplash.py
29 lines (26 loc) · 986 Bytes
/
splash.py
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
from PIL import ImageOps, Image
def splash(i, o):
if (o.width, o.height) == (128, 64):
image = Image.open("resources/splash.png").convert('L')
image = ImageOps.invert(image)
elif o.width >= 128 and o.height >= 64:
image = Image.open("resources/splash_big.png").convert('L')
image = ImageOps.invert(image)
size = o.width, o.height
image.thumbnail(size, Image.ANTIALIAS)
left = top = right = bottom = 0
width, height = image.size
if o.width > width:
delta = o.width - width
left = delta // 2
right = delta - left
if o.height > height:
delta = o.height - height
top = delta // 2
bottom = delta - top
image = ImageOps.expand(image, border=(left, top, right, bottom), fill="black")
else:
o.display_data("Welcome to", "ZPUI")
return
image = image.convert(o.device_mode)
o.display_image(image)