Jump to content
  • Advertisement
Sign in to follow this  
PineBark

OpenGL How is data stored in compressed TGA's?

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

I've implemented a basic compressed targa image reader in OpenGL. Although it works I'm still not sure how the data is stored in targa images (or in any image files for that matter). First I read a byte from the image (after skipping the header) and store it in an unsigned char ID, then, if ID is more than 128 I substract 127 from that number, read the next 3 bytes (r, g, b) from the image and write it down that many times (ID - 127). If ID is less than 128 I just read that many bytes x3 normaly (ID + 1). My guess is that there's 1 ID byte before any run of compressed or uncompressed pixels that tells how many of those pixels there are. Am I right on this? How does this differ from uncompressed targas? - are there no ID bytes on them? What about other image types?

Share this post


Link to post
Share on other sites
Advertisement
TGA images are run-length encoded (file types 9, 10, 11).
http://en.wikipedia.org/wiki/Run-length_encoding
http://en.wikipedia.org/wiki/Truevision_TGA
http://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!