Skip to content

Instantly share code, notes, and snippets.

@North-West-Wind
Created November 18, 2023 05:41
Show Gist options
  • Select an option

  • Save North-West-Wind/78659c0935600d91942a8b377c52194e to your computer and use it in GitHub Desktop.

Select an option

Save North-West-Wind/78659c0935600d91942a8b377c52194e to your computer and use it in GitHub Desktop.
Extract splash screen from Atmosphere's package3
from PIL import Image
import sys, os
from struct import pack as pk
from math import floor
SPLASH_SCREEN_WIDTH = 1280
SPLASH_SCREEN_HEIGHT = 720
SPLASH_SCREEN_STRIDE = 768
def convert_bytes(data):
mutable = bytearray()
pixel_length = 4 + ((SPLASH_SCREEN_STRIDE - SPLASH_SCREEN_HEIGHT) * 4)
row_length = 4 * SPLASH_SCREEN_HEIGHT + ((SPLASH_SCREEN_STRIDE - SPLASH_SCREEN_HEIGHT) * 4)
for ii in range(SPLASH_SCREEN_WIDTH):
for jj in range(SPLASH_SCREEN_HEIGHT):
mutable += pk('<BBBB', data[ii*row_length+jj*4+2], data[ii*row_length+jj*4+1], data[ii*row_length+jj*4], data[ii*row_length+jj*4+3])
splash = Image.frombytes('RGBA', (SPLASH_SCREEN_HEIGHT, SPLASH_SCREEN_WIDTH), mutable)
# splash = splash.transpose(Image.ROTATE_270)
splash.save('splash.bmp')
def main(argc, argv):
if argc != 2:
print('Usage: %s package3' % argv[0])
return 1
with open(argv[1], 'rb') as f:
package3 = f.read()
assert package3[:4] == b'PK31'
assert len(package3) == 0x800000
convert_bytes(package3[0x400000:0x7C0000])
return 0
if __name__ == '__main__':
sys.exit(main(len(sys.argv), sys.argv))
@laleeroy
Copy link
Copy Markdown

How can we convert our custom bmp logos into .bin file so that we can Include it in the source and build it inline?

@North-West-Wind
Copy link
Copy Markdown
Author

I have no idea. This script is just the reversed version of insert_splash_screen.py from Atmosphere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment