TGA Image Format Flipped?

Started by
2 comments, last by MeshMan 20 years, 4 months ago
Hello All, Ive just wrote a TGA loader following the spec from the Targa PDF documene. The problem is, everytime i load an image, its flipped vertically but the the header bits that specify if the image is flipped is set to 0...i have tried multiple TGA files and made ones exported from Adobe Photoshop and Paintshop Pro and they all come out flipped. I have compared my loading code to no end of TGA loading examples and im not doing anything different... I am applying the loaded image on a 2d projected quad (OpenGL). I have other image loaders such as JPEG which load the images and when applied to the quad, its correct so it cant be my winding order. Ive torn my hair out as to why TGA files are flipped!?!? It doesnt say in the spec that this is standard of TGA files, can anyone englighten me please. Thanks MeshMan
Advertisement
quote:Original post by MeshMan
Hello All,

Ive just wrote a TGA loader following the spec from the Targa PDF documene. The problem is, everytime i load an image, its flipped vertically but the the header bits that specify if the image is flipped is set to 0...i have tried multiple TGA files and made ones exported from Adobe Photoshop and Paintshop Pro and they all come out flipped. I have compared my loading code to no end of TGA loading examples and im not doing anything different...

I am applying the loaded image on a 2d projected quad (OpenGL). I have other image loaders such as JPEG which load the images and when applied to the quad, its correct so it cant be my winding order.

Ive torn my hair out as to why TGA files are flipped!?!? It doesnt say in the spec that this is standard of TGA files, can anyone englighten me please.

Thanks
MeshMan


I have come up with the same conclusion... no solutions that I know of besides either storing it upside down in the file, or loading it upside down.
If bits 4 and 5 in the Image Descriptor field (unpadded it would be offset 11h in the file) are zero then the image is "upside down".

I usually just blit them in reverse (takes the same ammount of time as blitting them forward), instead of loading them in reverse.
"I thought Genius lived in bottles..." - Patrick Star
Brilliant!

Stupid me, im just going through the docs again and like you''ve said i realise its bottom-up reading when bits are not set...

Thanks guys!

- MeshMan

This topic is closed to new replies.

Advertisement