News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Weird BMP format?  (Read 1442 times)

Dashman

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Weird BMP format?
« on: July 01, 2014, 08:09:28 pm »
I've run into these files that hint heavily at containing bitmap images (they originally had no extension, I saved them as BM for clarity). The header seems to be 32 bytes long and this is its likely structure:

bytes 0 - 2: "BMP".
byte 3: unknown. either 06 or 09.
bytes 4 - 7: number of colours (?)
bytes 8 - 11: height.
bytes 12 - 15: width.
bytes 16 - 31: all zeroes.

Values are big endian. The rest of the file would be the image data. Here are some examples:

https://www.dropbox.com/sh/ieiibbxvef61vwc/AACuO9Jx-E409qiVftPM414va

I've tried looking at the graphics data in the files with crystaltile (after changing the extension to .bin), but they appear to be garbage no matter the mode I choose. Has anybody run into a similar format before?

Some files (0018.BM in the folder) have byte 3 set to 07 and both height and width set to 0. These could be palette files.

There's other files (0007.BM in the folder) whose byte 3 is set to 0a. The size in the bitmap data of these files is not height * width unless we assume 6bpp, which is a pretty unusual colour format (at least for me).

Any thoughts or suggestions?

Jorpho

  • Hero Member
  • *****
  • Posts: 4059
  • The cat screams with the voice of a man.
    • View Profile
Re: Weird BMP format?
« Reply #1 on: July 02, 2014, 09:05:19 am »
Did they come from a reliable source (as opposed to, say, a decaying floppy disk) ?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

KC

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Weird BMP format?
« Reply #2 on: July 02, 2014, 09:25:16 am »
I assume this is from the GameCube game you are hacking. These obviously aren't bitmaps like Microsoft uses them. Those don't start with BMP anyway.
Check if the image data is in any of these formats: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/VideoCommon/TextureDecoder_Generic.cpp#L631
Probably I8 or C8, whatever the difference.

Dashman

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Re: Weird BMP format?
« Reply #3 on: July 02, 2014, 11:11:17 am »
Kingcom is right, these are all extracted from a .bin file inside a working Gamecube ISO using a custom tool.

The file is packed with graphics files (namely SPR files containing backgrounds) among others, so I'm inclined to believe these BMP files are proper image files with a funny format.

I imagine corrupted image data would look wrong around specific sections of the image, rather than the whole thing looking like pixel confetti. Then again, I've never run into something like that.

I was wondering if Dolphin's code wouldn't have something to deal with these files, thanks for finding it! I'll give it a thorough look later :)

EDIT:

I think I found the format for the files with "type" 06. Images are divided in 8x8 tiles:



(ignore the faulty palette)

It goes like:

bytes 0 - 2: "BMP".
byte 3: type? palette number? 06, 07, 09 or 0a.
bytes 4 - 7: number of colours in palette.
bytes 8 - 11: width (divide by 8 to get number of tiles in a row)
bytes 12 - 15: height (divide by 8 to get number of tiles in a column)
bytes 16 - 31: all zeroes.

I'm beginning to wonder how to edit tiled images...
« Last Edit: July 02, 2014, 07:34:49 pm by Dashman »