Historical reference library / C

Targa Texture Loader

A direct path from TGA files to RGBA

A small C library for loading Targa textures into 32-bit RGBA, including run-length encoding and channel manipulation.

Targa Texture Loader — explanatory diagram
Illustrative pixels and decoding flow for the C library. · View full size ↗

A consistent texture format at the boundary

The Targa loader grew out of game-engine work with image formats. The library decodes TGA input into 32-bit RGBA so the renderer receives a consistent pixel layout rather than handling each source encoding differently.

The details the loader owns

The C implementation handles uncompressed and run-length-encoded input, different source bit depths and grayscale conversion. It supplies a default alpha channel when one is absent, and allows channel masking or replacement before the texture reaches the graphics API. Color-mapped Targa input was intentionally left out of the original scope.

A small, portable reference library

The repository includes a Make build, a Visual Studio solution, a demonstration program and test images for RLE and non-RLE decoding. The source dates to the 2006–2009 period and was later published on GitHub. The original article’s speed comparisons remain historical observations; the practical focus of this edition is the loader’s behavior and output contract.

Implementation at a glance

  • Handles uncompressed and RLE Targa input.
  • Converts missing alpha and grayscale formats into a consistent output layout.
  • Includes Make and Visual Studio build examples and generated API documentation.

Project status

Historical C reference library. Color-mapped TGA input is outside its documented scope; original performance comparisons were not repeated.