Jump to content
  • Advertisement
Sign in to follow this  
_mycoplasma_

how to tell if a targa is direct color

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

hello. i am using C++ to make a library that loads targas and uses OpenGL to display them. I was looking at the official targa 2.0 specs and could not figure out how to tell if a targa uses direct color or not (the image type at offset 2 in the header only tells you whether it is pseudo color or true color, and not if it is direct color). can anyone please help me?

Share this post


Link to post
Share on other sites
Advertisement
I've never come across a direct-color tga. In fact the tga spec discourages their use, since a true-color image would normally work just as well (since Direct-color images use a 24 or 32 bit color map anyway) and with less complexity. The specification document does not clearly outline how you would determine the difference between a pseudo-color and direct-color image, but my best guess would be that it could be determined by looking at the number of color map entries, and the pixel depth of the image data, i.e. if the pixel depth is 24 or 32 bits, and the image is a color mapped file, then it would only sensibly be a direct-color file, as it is impossible to have a color-map that could span that size, since the color-map size is a 16 bit word.

Share this post


Link to post
Share on other sites
As an interesting test, I hand created a 1 pixel direct-color tga file, i.e. uncompressed color mapped, with 256 color-map entries, each 24 bits, with a image pixel depth of 24 bits. For the color map values I simply used all black except for the first 3 entries, those being {(255,0,0),(0,255,0),(0,0,255)}. For the one pixel in the image I used (0,1,2). So the color of the pixel should be (255,255,255) if it is correctly loaded. I opened the tga in Paint Shop Pro 8, but it opened it as a true color image, the pixel had the color (0,1,2). I then tried opening the image in the DirectX Texture Tool and it failed to load at all. The format was not supported. Changing it to a true color image, by simply changing the image type from 1 to 2, allowed the texture tool to load it with no problem, but of course as a true color image, so the pixel had the color (0,1,2). Caligari gameSpace loaded it as a pseudo-color image instead of as a direct-color image. gMax loaded it without reporting any error, but the result was all black so there was obviously an error. I don't have Photoshop or any other image editor so I couldn't try any others. Though this experiment clearly illustrates that tga files are not supported very well by a variety of applications.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!