-
Notifications
You must be signed in to change notification settings - Fork 14
/
make_logo.py
executable file
·52 lines (39 loc) · 956 Bytes
/
make_logo.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/python2
from __future__ import print_function
import sys, pygame, binascii
pygame.init()
size_x = 96/2
size_y = 16/2
def usage():
print("Usage:", sys.argv[0], "boot_logo.png boot_logo.bin")
def binarify(b):
if b == 0:
return '1'
else:
return '0'
###
if len(sys.argv) < 3:
usage()
sys.exit(1)
logo_img = pygame.image.load(sys.argv[1])
logo_img = logo_img.convert(8)
logo = pygame.surfarray.pixels2d(logo_img)
for y in range(0, size_y):
for x in range(0, size_x):
if logo[x,y] == 0:
print("*", sep="", end="")
else:
print(" ", sep="", end="")
print()
logo_s = ['0'] * size_x * size_y
x = 0
y = 0
for i in range(0, 24):
x = (i * 4) % size_x
y = ((i * 4) / size_x) * 4
for j in range(0, 16):
logo_s[i*16+j] = binarify(logo[x + (j%4), y + (j/4)])
#print(logo_s)
with open(sys.argv[2], 'wb') as file_logo_bin:
for i in range(0, len(logo_s) / 8):
file_logo_bin.write(chr(int(''.join(logo_s[i*8:i*8+8]), 2)))