mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-26 08:08:51 +00:00
introduce toi format
This commit is contained in:
parent
fa8fdb683a
commit
ced1a8fdef
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_attic/
|
@ -1,3 +1,3 @@
|
||||
![TREZOR OS](assets/logo.png)
|
||||
![TREZOR OS](docs/logo.png)
|
||||
|
||||
* [Documentation](docs/)
|
||||
|
BIN
assets/colorwheel.toi
Normal file
BIN
assets/colorwheel.toi
Normal file
Binary file not shown.
BIN
assets/font.png
BIN
assets/font.png
Binary file not shown.
Before Width: | Height: | Size: 951 B |
BIN
assets/satoshilabs.png
Normal file
BIN
assets/satoshilabs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
assets/satoshilabs.toi
Normal file
BIN
assets/satoshilabs.toi
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.5 KiB |
BIN
assets/trezor.toi
Normal file
BIN
assets/trezor.toi
Normal file
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
42
tools/png2toi
Executable file
42
tools/png2toi
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
from PIL import Image
|
||||
import sys
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage png2toi image.png')
|
||||
sys.exit(1)
|
||||
|
||||
ifn = sys.argv[1]
|
||||
|
||||
if not ifn.endswith('.png'):
|
||||
print('Must provide PNG file')
|
||||
sys.exit(2)
|
||||
|
||||
im = Image.open(ifn)
|
||||
w, h = im.size
|
||||
print('Opened %s ... %d x %d @ %s' % (ifn, w, h, im.mode))
|
||||
|
||||
if not im.mode == 'RGB':
|
||||
print('PNG file must use RGB mode')
|
||||
sys.exit(3)
|
||||
|
||||
pix = im.load()
|
||||
|
||||
ofn = '%s.toi' % ifn[:-4]
|
||||
with open(ofn, 'wb') as f:
|
||||
f.write(bytes('TOIa', 'ascii'))
|
||||
f.write(struct.pack('>HH', w, h))
|
||||
data = bytes()
|
||||
for j in range(h):
|
||||
for i in range(w):
|
||||
r, g, b = pix[i, j]
|
||||
c = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
|
||||
data += struct.pack('>H', c)
|
||||
z = zlib.compressobj(level=9, wbits=10)
|
||||
zdata = z.compress(data) + z.flush()
|
||||
zdata = zdata[2:-4] # strip header and checksum
|
||||
f.write(zdata)
|
||||
|
||||
print('Written %s ... %d bytes' % (ofn, 4 + 4 + len(zdata)))
|
Loading…
Reference in New Issue
Block a user