Bitmap Swapping

Reverse engineering LEGO Island's primary asset packaging format
Post Reply
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Bitmap Swapping

Post by MattKC »

Inserting bitmaps is a relatively straightforward process. The SI files lack the 10-byte header, but that's easy to reconstruct/strip out as necessary. The biggest "gotcha" is that the game only supports paletted 256-color bitmaps. The first BMP chunk must be the palette data. The second is simply the picture data (split by the buffer boundary as necessary).
image1.png
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: Bitmap Swapping

Post by MattKC »

I've reverse engineered the file reading function from MxBitmap and found some interesting things. Firstly MxBitmap always reads and verifies a real bitmap file header, despite the fact that it gets stripped out of SI files. This implies that some class (MxStreamer?) reconstructs it into a complete bitmap file before parsing it with MxBitmap. Seems like a waste of time, though I suppose it makes sense if MxBitmap needs to open any non-SI bitmaps too.

Secondly, the read function specifically only supports 256 color images. It explicitly allocates memory for a 256 color palette and will actually stop reading and return an error code if the bitmap is not 256 colors. This probably explains why reinserting a 24-bit BMP into SI files crashes, some code likely assumes the bitmap loaded successfully and tries to access unallocated data. It seems 256 color paletted bitmaps are fairly entrenched, much of the code is designed specifically around 256 color palettes. It may be very difficult to mod the code to accept higher bit depth images.
Post Reply