Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FERNANDO-BRASIL

RLE Compression with Bitmaps

This topic is 5954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I''m making my own functions to read BITMAPS, and I don''t understand a thing about RLE COMPRESSION. Ok, the compression says if you encounter a 0, and the next byte were 2, the next two following bytes will be unsigned values indicating horizontal and vertical offsets of the next pixel from the current position. What is it? Is it wanted to say that you have to jump to a new X, Y position, and then continue descompacting the pixels there? Ok.. if what i said were OK, what happen to the pixels I jumped? They will be what color? Transparent? Thank you guys! Any help will be extremely apreciated. Fernando

Share this post


Link to post
Share on other sites
Advertisement
Hi,

let me first point you to a BMP loader I wrote some time ago that implements all these things:

http://www.rolemaker.dk/nonRoleMaker/loader/

Second, don''t confuse RLE compression with the RLE compression mode used in BMP files. Traditional RLE compression has no escape code - it just uses pairs of values: (pixelcount, value).

The escape codes you mention are an extension that was made by Microsoft.

The purpose of the X and Y offset you have have guessed correctly.

quote:

Ok.. if what i said were OK, what happen to the pixels I jumped? They will be what color? Transparent?



The implementation never states what the value should be, so have personally assumed that it must be undefined. If somebody makes a picture in which they do not define some pixels, who can we know their value and we might as well use garbage from memory.

That said, I have yet to come by a BMP image that actually used these X,Y offset encodings so this issue is actually quite hypothetical.

Share this post


Link to post
Share on other sites
Thank you a lot felonius! You cleared my mind!

For me it''s a lot strange that someone could use the X, Y offset.
Because doing a implementation to read this, is easy, but one to write is like undefined, because everyone can do what they want, and the final file will be different, depending on the person who programmed.

An other thing that sounds very strange to me, is the ''End of a Line'' flag...

We don''t need them... we know the end of line by getting the Width of the image... But it''s OK...

Thank you again felonious!
I''ll try to do that.

Fernando

Share this post


Link to post
Share on other sites
rle compression needs escape codes. if you have a string of data that is not redundant, then it does not pay to use rle compression on it. thus you use escape codes to tell the decoder that the next x bytes should be treated as they are read (ie uncompressed). if this were not the case, rle compression could NEVER work well for anything since many times there are large sections in which rle would increase that secrion by 2 (since there are no redundent bytes).

i dont know anything about x,y offsets since thats not something normally found in rle, and being i only wrote a tga rel decompressor it stands to reason that bmps use special techniques compared to the tga format (which uses a more traditional rle).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!