What are the advantages of TGA over bitmap.

I currently doing some nehe tutes that use TGA textures instead of BMP textures. The load texture function is infinately more complex than for BMPS.

My question is why would I want to use tga over bmp.


alpha channel?


Try writing a BMP loader on your own, without using any Windows functions, and you will find that loading a TGA image is much simpler than loading a BMP image.

[This message has been edited by marcus256 (edited 09-23-2001).]

I’d have to agree that BMPs have fewer arguments/flags in their headers, thus making them easier to load than TGAs. However, TGAs do have alpha channel support, so that counts for something.

In any event, the formats are not radically different. Writing a loader for one or the other isn’t that difficult.

Have you considered using PNG? You can use alpha as well and have a nice compressed format without loss of quality. There’s libpng and a lot of helper librarys to make loading png painless.

…you can compress TGAs too…

PNG decompression is superior to TGA’s.
Bitmap compression is crap.
But I have to disagree in some point. I actually find bmp to be read more easily since it doesn’t have so many informations to be parsed.
On the other hand TGA supports alpha. Best format remains PNG but it’s hard to code a reader for that. But there’s a libpng (or was it another name?) that handles this for you.

Note that the MSDN bitmap documentation is crap. If you need support with this call me.

For loading BMP, TGA (including compressed) and 3DS meshes from 3D Studio MAX, check out Mesh3DS; a Visual C++/MFC class that should simplify your work.

The routines LoadBMPfile and LoadTGAfile particularly.

If you don’t use MFC, the texture loading routines should still be useful.


TGA basically uses the same compression method as bitmaps do, run-length encoding. Supporting that is just a waste of time unless you have textures that could benefit of it. They are quite rare, especially photographies or any other type of wall textures are not really good for run length encoding…

TGA’s are very suitable for fonts.

Yes! One of the cases where RLE is effective (did you mean compression at all DFrey?)! Anyways, I’m using TGA most of the times too, I don’t compress them but could read compressed ones. I don’t see any sense in compressed textures BTW, since you have to decompress them upon loading… It’s just that PNG compression is best of the one you’ve been talking about, and it is lossless, in spite of jpg for example!

Yep, that’s what I meant. Fonts typically compress extremely well with RLE. One reason to use compressed textures is that it is often faster to load and decompress a texture than it is to load the equivalent uncompressed texture. (Of course I am not talking about memory resident compressed textures, e.g. DXTn.

[This message has been edited by DFrey (edited 09-24-2001).]

Ahhh, someone said that it is impossible to write a BMP loader without using windows functions… errr, no it isnt… its actually quite easy, around 1 page of C code…

MrShoe: I burn to see your reader that only takes a page with all possible formats. But you are right, you don’t need any windows functions for that. BUT you need to copy the structure definitions to the header file of course.

DFrey! Gonna benchmark the decompression and an uncompressed pic!