mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-12 16:16:35 +00:00
utils: add script for inserting custom image into package3
This commit is contained in:
parent
960161741d
commit
5e64460bb9
4 changed files with 45 additions and 1 deletions
|
@ -164,7 +164,7 @@ def main(argc, argv):
|
|||
mesosphere = read_file(os.path.join(ams_dir, 'mesosphere/mesosphere%s.bin' % target))
|
||||
all_kips = get_kips(ams_dir)
|
||||
tsec_keygen = read_file(os.path.join(ams_dir, 'fusee/program/tsec_keygen/tsec_keygen.bin'))
|
||||
splash_bin = read_file(os.path.join(ams_dir, 'fusee/program/splash_screen/splash_screen.bin'))
|
||||
splash_bin = read_file(os.path.join(ams_dir, 'img/splash.bin'))
|
||||
assert len(splash_bin) == 0x3C0000
|
||||
with open(os.path.join(ams_dir, 'fusee/package3%s' % target), 'wb') as f:
|
||||
# Write header
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 MiB |
44
utilities/insert_splash_screen.py
Normal file
44
utilities/insert_splash_screen.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
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('<BBBB', b, g, r, a)
|
||||
splash_bin += b'\x00' * ((SPLASH_SCREEN_STRIDE - SPLASH_SCREEN_HEIGHT) * 4)
|
||||
return splash_bin
|
||||
|
||||
def main(argc, argv):
|
||||
if argc != 3:
|
||||
print('Usage: %s image package3' % argv[0])
|
||||
return 1
|
||||
with open(argv[2], 'rb') as f:
|
||||
package3 = f.read()
|
||||
assert package3[:4] == b'PK31'
|
||||
assert len(package3) == 0x800000
|
||||
splash_bin = convert_image(argv[1])
|
||||
assert len(splash_bin) == 0x3C0000
|
||||
with open(argv[2], 'wb') as f:
|
||||
f.write(package3[:0x400000])
|
||||
f.write(splash_bin)
|
||||
f.write(package3[0x7C0000:])
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(len(sys.argv), sys.argv))
|
Loading…
Reference in a new issue