1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

tools: fix png2toi c export

This commit is contained in:
Pavol Rusnak 2017-06-21 18:18:59 +02:00
parent 27f7a26d6e
commit adafd9bc51
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -68,13 +68,18 @@ def process_image(ifn, savefiles=False):
print('Written %s ... %d bytes' % (ofn, len(data))) print('Written %s ... %d bytes' % (ofn, len(data)))
with open(ofn + '.h', 'wt') as f: with open(ofn + '.h', 'wt') as f:
f.write('static const uint8_t toi_%s[] = {\n' % ifn[:-4]) f.write('static const uint8_t toi_%s[] = {\n' % ifn[:-4])
f.write(' // magic\n')
if im.mode == 'RGB': if im.mode == 'RGB':
f.write(" 'T', 'O', 'I', 'f',\n") f.write(" 'T', 'O', 'I', 'f',\n")
else: else:
f.write(" 'T', 'O', 'I', 'g',\n") f.write(" 'T', 'O', 'I', 'g',\n")
f.write(' (uint16_t)%d, (uint16_t)%d,\n' % (w, h)) f.write(' // width (16-bit), height (16-bit)\n')
f.write(' (uint32_t)%d,\n' % len(zdata)) f.write(' 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n' % (w & 0xFF, w >> 8, h & 0xFF, h >> 8))
f.write(' ') l = len(zdata)
f.write(' // compressed data length (32-bit)\n')
f.write(' 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n' % (l & 0xFF, (l >> 8) & 0xFF, (l >> 16) & 0xFF, l >> 24))
f.write(' // compressed data\n')
f.write(' ')
for b in zdata: for b in zdata:
f.write(' 0x%02x,' % b) f.write(' 0x%02x,' % b)
f.write('\n};\n') f.write('\n};\n')