#!/usr/bin/env python3 """B9A read-only: render the 128x128 RGB565 (little-endian u16) default splash embedded in stock LK (imageBuffer @0x8f64b004, used by display_image_on_screen() when the splash partition has no 'SPLASH!!' header) to a 2x-scaled PNG. usage: render-lk-logo.py lk.bin out.png""" import struct, sys, zlib d = open(sys.argv[1], 'rb').read(); o = 0x8f64b004 - 0x8f600000; W = H = 128 rows = [] for y in range(H): r = bytearray() for x in range(W): v = struct.unpack_from('> 11 & 31) * 255 // 31, (v >> 5 & 63) * 255 // 63, (v & 31) * 255 // 31)) * 2 rows += [bytes(r)] * 2 def ch(t, b): return struct.pack('>I', len(b)) + t + b + struct.pack('>I', zlib.crc32(t + b) & 0xffffffff) open(sys.argv[2], 'wb').write(b'\x89PNG\r\n\x1a\n' + ch(b'IHDR', struct.pack('>IIBBBBB', W * 2, H * 2, 8, 2, 0, 0, 0)) + ch(b'IDAT', zlib.compress(b''.join(b'\0' + r for r in rows))) + ch(b'IEND', b''))