Jump to content

Bmp Files


dead_name
 Share

Recommended Posts

They're not standard bitmaps. Stop trying to tweak them into being parseable, because it won't work. I've figured most of it out.


// all multi-byte types, unless stated otherwise, are little-endian.

struct lr1_bmp {

	byte bit_depth; // the bit-depth of the [paletted] image. 0x04, 0x08, or 0x98

    // where bit_depth is 0x98, IDK what the format is.

	byte palette_length; // length of the palette -1. i.e. For a palette with 37 entries, this would be 36.

	u16 width; // Width of the image in pixels.

	u16 height; // Height of the image in pixels.

	color[palette_length+1] palette; // zero-indexed color palette

	block[] blocks; // image data blocks. keep reading these from the file until you hit the end-of-file.

}

struct color {

	byte B;

	byte G;

	byte R;

}

struct block {

	u16 raw_length; // length of the decompressed block data. seems to have a maximum of 1000.

	u16 length; // length of the compressed block data

	byte[length] data; // block data. If length != raw_length, the data is compressed, and we have yet to figure out the algorithm used. If length == raw_length, the data is not compressed.

}

if you add together the raw_length of every block, you get the same value as width * height (or half if the image is 4bits per pixel), so we know all this is probably correct. Decompress each block in turn and append the raw data into a buffer. That buffer now contains the bitmap data.

All we have to do now is to figure out the decompression algorithm.

  • Like 1
Link to comment
Share on other sites

Okay, so. last 2 bytes of each (compressed) block are constant 0, and the preceding 2 bytes seem to be a checksum of some sort.

Link to comment
Share on other sites

Nice! I can confirm the structure is correct, my Dad and I got that far when we took a crack at these, but we never noticed the few files with no compressed blocks.

We were also able to get them to open by adding the correct header, but the image comes out garbled because (of course) we don't know the compression.

However, the two images you posted with no compressed blocks got me thinking. There's no pure white or black in either of them (infact both images only have shades of one color) The compression algorythm may have something to with do with either pure black or white. Seeing as the game seems to treat pure black as transparent, a simple compression algorythm would be to compresss all the black pixels out of the image. Of course, it could be something completely different and entirely more complex, but it's worth looking in to.

Link to comment
Share on other sites

Nice! I can confirm the structure is correct, my Dad and I got that far when we took a crack at these, but we never noticed the few files with no compressed blocks.

We <i>were </i>also able to get them to open by adding the correct header, but the image comes out garbled because (of course) we don't know the compression.

However, the two images you posted with no compressed blocks got me thinking. There's no pure white or black in either of them (infact both images only have shades of one color) The compression algorythm may have something to with do with either pure black or white. Seeing as the game seems to treat pure black as transparent, a simple compression algorythm would be to compresss all the black pixels out of the image. Of course, it could be something completely different and entirely more complex, but it's worth looking in to.

Interesting theory on the compression. Personally I'm thinking it's just some sort of run-length encoding, so that a long strip of identical pixels gets compressed down into storing the palette entry index and the length.

Something like that.

Unrelated: here's what happens if I tell it to render the Dark Forest Dash map, showing only the uncompressed blocks. I then overlay the actual map at 10% opacity. Perfect match :)

http://dl.dropbox.com/u/3770169/screens/2011/09/2011_09_06_00_15_03.png

Link to comment
Share on other sites

  • 1 month later...

How has the progress on the BMP's been going?

http://will.loadingchunks.net/rru/lr1/bmp/

He sent me this link a little bit back. Figured it out, I believe.

Link to comment
Share on other sites

Figured it out, I believe.

Not quite. Lot of work to do on a) the compression and b) the 0x98 variant.

Ah, that stuff...well, good work so far.

Link to comment
Share on other sites

  • 4 weeks later...

I've left RRU in general to one side recently, as University work has been taking priority (...and I got sidetracked looking at Portal 2 files...).

I'll get back to this soon.

Link to comment
Share on other sites

I know someone got textures recently.

That would be origamiguy and he only can get some textures, not all. Compressed images haven't been figured out.

He was mainly working on the track viewer at the moment. But I heard he is also working on a tool that can convert a number of LR files since they all use similar formats.

EDIT: Origami beat me.

Link to comment
Share on other sites

  • 3 months later...

I've been reading this topic, but I can't find the answer to my question. This topic says that we are looking for the compression algorithm, but on the other topics, it's being said that we are looking for the compression code, as if we know the algorithm. So which one is it? If it's the code, I have an idea on how it might be found.

Link to comment
Share on other sites

  • 2 months later...
lol username

Cirevam, Lair, myself, and origamiguy were all on a voice chat when that happened. I mentioned that I wanted to mod the rolling rocks in Adventure Temple Trail to have awesomefaces, which origamiguy then did. Then a while later he bumped it up a few notches and made a batch script to replace EVERY TEXTURE IN THE GAME with awesomefaces, and, well... Yeah. That was one heck of a night. Pretty sure he just used TGA textures, by the way.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.