from PIL import Image import sys, os from struct import pack as pk SPLASH_SCREEN_WIDTH = 1280 SPLASH_SCREEN_HEIGHT = 720 SPLASH_SCREEN_STRIDE = 768 def convert_image(image_fn): splash = Image.open(image_fn, 'r') w, h = splash.size if w == 1280 and h == 720: splash = splash.transpose(Image.ROTATE_90) w, h = splash.size assert w == 720 assert h == 1280 splash = splash.convert('RGBA') splash_bin = b'' for row in range(SPLASH_SCREEN_WIDTH): for col in range(SPLASH_SCREEN_HEIGHT): r, g, b, a = splash.getpixel((col, row)) splash_bin += pk('