Texture File Formats

CS 381 Lecture, Dr. Lawlor


Name
Stores
Compression
Advantages
Disadvantages
jpg
JPEG
RGB
Lossy (DCT)
Amazingly tight compression.
libjpeg is big, and no alpha channel.
png
Portable Network Graphics
RGBA
Lossless
Good compression, can represent alpha channel properly.
libpng is big, and not present by default on Windows machines.
bmp
Windows Bitmap
RGB
None (usually)
Builtin editors on Windows.  Simple format.  Also known as "pcx", which is the same format.
Files are big.  No alpha channel.
tga
TARGA
RGBA
Runlength
Simple format--easy to read.  See C++ ltga library and docs.  Unlike every other format, most tga files store the data from bottom to top, which nicely matches OpenGL's default Y axis.
Not completely standardized.  For example, some targas store un-premultiplied alpha (normal R, G, B, A); others store premultiplied alpha (RA,GA,BA,A).  Files are big.
ppm
Portable Pixel Map
RGB
None
Very simple ASCII header followed by binary data.
ASCII header can include comments.  Files are big.  No alpha channel.

Any decent image editing program, like the GIMP, can read or write all these formats, including the alpha channel.

With a decent image I/O library, reading these formats should be really easy.  For example, you can read a .tga image with the lgta library like this:
	LTGA f("silly_crosseyed.tga");
oglTexture *t=new oglTexture(f.GetPixels(),f.GetImageWidth(),f.GetImageHeight());
That's not bad, right?  Check out the 'texture' example program linked from the front page.