{
  "version": 1,
  "canonical": "https://xaede.net/writing/targa-tga-plug-in-library",
  "title": "Targa (TGA) Plug-in Library",
  "description": "The design of a small C texture loader: RLE decoding, grayscale conversion, alpha handling and a consistent 32-bit RGBA output for the renderer.",
  "language": "en",
  "manifest": "https://xaede.net/representations/index.json",
  "contentHtml": "<article class=\"reading-page\"><header class=\"reading-header\"><nav class=\"page-breadcrumb\" aria-label=\"Breadcrumb\"><ol><li><a href=\"/\">Home</a></li><li><a href=\"/writing\">Writing</a></li><li><span aria-current=\"page\">Targa (TGA) Plug-in Library</span></li></ol></nav><div class=\"article-label\"><span>Archive edition / Legacy Xaede</span><time datetime=\"2009-08-24\">August 24, 2009</time><span>2 MIN READ</span></div><h1>Targa (TGA) Plug-in Library</h1><p class=\"byline\"><a href=\"/about\" rel=\"author\">Josh English</a></p><p class=\"edition-note\">From the original Xaede archive. This is historical writing, preserved in a new reading edition. Technical advice, tools and project status reflect the time of publication.</p></header><div class=\"reading-body prose\"><p class=\"edition-note\">Software links in this reading edition point to the current GitHub repository.</p><p>I found that the TGA file format is quite useful in game development, and is used extensively by a number of modern game-engines, including Unreal Engine 3. There are a number of online examples and tutorials describing how to bang out some C or C++ code to load a TGA file so that it can be used by a DirectX or OpenGL application. However, I wanted to create my own library that solves the following problems:</p>\n<ul>\n<li>It can load the file into a graphics-library compatible format in a single pass (thus being much faster than the online examples I’ve read).</li>\n<li>Handles arbitrary bit-length encoding.</li>\n<li>Handles run-length encoded (RLE) Targa files.</li>\n<li>Automatically converts any TGA file to my desired format – 32-bit RGBA. If an alpha channel is missing, a default one is automatically created. It also converts from black &amp; white encoding.</li>\n<li>Allows me to apply color-channel masking or replacement by modifying the serialized RGBA value, allowing me to manipulate the image prior to creation as a graphics-library texture.</li>\n</ul>\n<p>Given that I’ve never found a real use for Targa color mappings, I dropped support for using them in my reference library. The reference library I created is written in C, and compiles natively on Windows, Linux and Mac OS X. Source code and documentation are available in the <a href=\"https://github.com/josh-english-2k18/tga-loader\" rel=\"noopener noreferrer\">GitHub repository</a>.</p></div><footer class=\"article-footer\"><span class=\"eyebrow\">PUBLICATION RECORD</span><p>Recovered article · Legacy Xaede · August 24, 2009</p><p>Originally published on Xaede. The recovered text is included in this reading edition.</p><p class=\"small\">Original authorship and publication date are preserved. This edition restores the reading layout. Recovered historical images are hosted here; unavailable images are identified where relevant.</p></footer></article>",
  "structuredData": {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "Person",
        "@id": "https://xaede.net/#josh-english",
        "name": "Josh English",
        "url": "https://xaede.net/about",
        "sameAs": [
          "https://github.com/josh-english-2k18",
          "https://medium.com/@jengas",
          "https://www.linkedin.com/in/joshua-s-english",
          "https://x.com/JoshSeriesAI"
        ],
        "jobTitle": "VP of Engineering",
        "description": "Josh English is VP of Engineering at Chronicle Media and was previously CTO of Series Entertainment. His career spans more than twenty-five years of distributed systems, game technology and engineering leadership. At Google he worked as a lead engineer on large-scale services and applied ML; at Big Run Studios he led multidisciplinary technology teams across seven time zones and four countries. At Series he directed engineering, QA, DevOps and infrastructure supporting live commercial games and AI-enabled production. He also builds personal games and developer tools to investigate how emerging capabilities work in practice, and writes about engineering judgment, organisation design and product economics.",
        "mainEntityOfPage": {
          "@id": "https://xaede.net/about#webpage"
        }
      },
      {
        "@type": "WebSite",
        "@id": "https://xaede.net/#website",
        "url": "https://xaede.net/",
        "name": "Xaede",
        "alternateName": [
          "Xaede.net",
          "Josh English — Xaede"
        ],
        "inLanguage": "en",
        "publisher": {
          "@id": "https://xaede.net/#josh-english"
        }
      },
      {
        "@type": "WebPage",
        "@id": "https://xaede.net/writing/targa-tga-plug-in-library#webpage",
        "url": "https://xaede.net/writing/targa-tga-plug-in-library",
        "name": "Targa (TGA) Plug-in Library",
        "description": "The design of a small C texture loader: RLE decoding, grayscale conversion, alpha handling and a consistent 32-bit RGBA output for the renderer.",
        "inLanguage": "en",
        "isPartOf": {
          "@id": "https://xaede.net/#website"
        },
        "about": {
          "@id": "https://xaede.net/#josh-english"
        },
        "mainEntity": {
          "@id": "https://xaede.net/writing/targa-tga-plug-in-library#article"
        },
        "breadcrumb": {
          "@id": "https://xaede.net/writing/targa-tga-plug-in-library#breadcrumbs"
        }
      },
      {
        "@type": "Article",
        "@id": "https://xaede.net/writing/targa-tga-plug-in-library#article",
        "name": "Targa (TGA) Plug-in Library",
        "headline": "Targa (TGA) Plug-in Library",
        "description": "The design of a small C texture loader: RLE decoding, grayscale conversion, alpha handling and a consistent 32-bit RGBA output for the renderer.",
        "author": {
          "@id": "https://xaede.net/#josh-english"
        },
        "inLanguage": "en",
        "mainEntityOfPage": {
          "@id": "https://xaede.net/writing/targa-tga-plug-in-library#webpage"
        },
        "genre": "Archive edition",
        "datePublished": "2009-08-24",
        "wordCount": 221,
        "url": "https://xaede.net/writing/targa-tga-plug-in-library"
      },
      {
        "@type": "BreadcrumbList",
        "@id": "https://xaede.net/writing/targa-tga-plug-in-library#breadcrumbs",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://xaede.net/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "Writing",
            "item": "https://xaede.net/writing"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "Targa (TGA) Plug-in Library",
            "item": "https://xaede.net/writing/targa-tga-plug-in-library"
          }
        ]
      }
    ]
  }
}
