Jump to content
  • Advertisement


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


Run Length Encoding

This topic is 5979 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

How do we find sequences of repeating characters inside a file, is there a specialized algorithm for this purpose? (its obvious how to find them, but is there a good algo for this purpose?) I would like a link or an explanation, if possible, thanks all,

[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Redundant book title: "Windows For Dummies".
"Camouflage condoms: So they won''t see you coming".

Share this post

Link to post
Share on other sites
I jsut so happen to have made a RLE program on the weekend

Basically you look through each byte and cound the length of the run by looking at all the bytes after that and stopping when it is different. If it is more than 2 bytes, add a ''run'' packet with the length followed by the byte. If the run is too short put a ''raw'' packet that just tells it to copy x number of bytes directly. Read the document on TGA file format on wotsits'' site, it had a good description on how the packets work and how to decode it

Im afraid you will have to make your own algorythm though good luck!

Share this post

Link to post
Share on other sites
Maybe I don''t understand your question, but you are going to have to scan trought the file at least ONCE, so why not just test if the current character is the same as the last one.
If so increment a repeat counter for that character.

This is about as simple as its going to get!
In other words there''s no ''trick'' that you''re missing.

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!