flightscreen is not a valid bmp file

Any issues with the XWAU or X-Wing Alliance? Please let us know here!
Post Reply

flightscreen is not a valid bmp file

User avatar
JeremyaFr
XWAU Member
Posts: 3989
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Jan 26, 2015 4:24 pm

Using a resolution whose the width is not a multiple of 4 (such as 1366x768), when you take a screenshot via the in-game feature, the generated flightscreen is an invalid bmp file.

Reimar
Cadet 1st Class
Posts: 239
Joined: Mon Jan 19, 2009 11:45 am

Post by Reimar » Mon Jan 26, 2015 5:10 pm

Do you have a sample bmp at hand? Is this in 16 bit or 32 bit mode?
My first theory was that it has to do with the alignment requirements of bmp (line start must be aligned to a multiple of 4 bytes which the game designers probably wouldn't have thought of), however for your resolution that shouldn't happen unless the game writes 3 bytes/pixel data.

User avatar
JeremyaFr
XWAU Member
Posts: 3989
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Jan 26, 2015 5:21 pm

Here is the files:
flightscreens.zip

It happens in 16-bit and 32-bit modes.
I think the game generates a 24-bit RGB bmp file.

Reimar
Cadet 1st Class
Posts: 239
Joined: Mon Jan 19, 2009 11:45 am

Post by Reimar » Mon Jan 26, 2015 5:37 pm

Ok, it's indeed the alignment issue.
GIMP for example can open then though, they are just distorted.
Opening them as RAW files in any image editor should also allow you to see that all the data is there in principle.
What basically needs to be done is to write (width modulo 4) extra bytes at the end of each line.
Or change it to produce RGBA bmps...

Reimar
Cadet 1st Class
Posts: 239
Joined: Mon Jan 19, 2009 11:45 am

Post by Reimar » Mon Jan 26, 2015 5:45 pm

It might be easier to create a small tool to fix it rather than try to patch the binary.
Or convince your favourite image editor to handle these kind of broken files, I suspect they are not that uncommon.

User avatar
JeremyaFr
XWAU Member
Posts: 3989
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Feb 01, 2015 9:11 pm

Hello,

Here is a patch to create bmp in 32 bits instead of 24 bits:

Code: Select all

; properties section
At offset 136CDA, replace 740140 with 909090
At offset 136D00, replace 18 with 20

; 16-bit section
At offset 136B2E, replace 03 with 04
At offset 136B35, replace 0F8C50FFFFFFF6C3017445 with 9090909090909090909090
At offset 136B56, replace 6A0056E8C237FFFF0FBFC083C408 with 8B44245C3BD80F8C29FFFFFFEB21

; 8-bit or 32-bit section
At offset 136C3B, replace 03 with 04
At offset 136C43, replace 7C8CF6C3017447 with 90909090909090
At offset 136C60, replace 6A0056E8B836FFFF0FBFC083C408 with 8B44245C3BD80F8C65FFFFFFEB23
These modifications are compatible with or without the 32bitmode patch.

Post Reply