Skip to content

Commit

Permalink
Fix BTI "Import Image" failing
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Nov 10, 2023
1 parent 3f525a3 commit ce80474
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gcft_ui/bti_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def import_bti_image_by_path(self, image_path):
try:
if self.bti is None:
# No BTI is already loaded. Create a dummy one from scratch to allow importing this image.
# TODO: this is a hack, should really be handled within the BTI class
data = BytesIO()
image_data = b"\0"*0x20
fs.write_bytes(data, 0x20, image_data)
Expand All @@ -266,12 +267,15 @@ def import_bti_image_by_path(self, image_path):
fs.write_u8(data, 0x09, PaletteFormat.RGB5A3.value) # Palette format
fs.write_u16(data, 0x0A, 1) # Num colors
fs.write_u32(data, 0x0C, 0x20+len(image_data)) # Palette data offset
fs.write_u8(data, 0x18, 1) # Mipmap count
fs.write_u32(data, 0x1C, 0x20) # Image data offset

image_name = os.path.splitext(os.path.basename(image_path))[0]

self.import_bti_by_data(data, image_name)

assert self.bti is not None

self.original_bti_image = Image.open(image_path)

self.bti.replace_image(self.original_bti_image)
Expand Down
2 changes: 1 addition & 1 deletion gclib
Submodule gclib updated 2 files
+2 −0 gclib/bti.py
+25 −13 gclib/gcm.py

0 comments on commit ce80474

Please sign in to comment.