TGA Encoder

Description

tga_encoder 🔗

A TGA Encoder written in Lua without the use of external Libraries.

Created by fleckenstein for MineClone2, then improved by erle.

May be used as a Minetest mod.

See examples.lua for example code and usage hints.

Use Cases for tga_encoder 🔗

Encoding Textures for Editing 🔗

TGA images of types 1/2/3 consist of header data followed by a pixel array.

This makes it trivial to parse TGA files – and even edit pixels in-place.

No checksums need to be updated on any kind of in-place texture editing.

Tip: When storing an editable image in item meta, use zlib compression.

Legacy Minetest Texture Encoding 🔗

Minetest 5.4 did not include minetest.encode_png() (or any equvivalent).

Since tga_encoder is written in pure Lua, it does not need engine support.

Tip: Look at examples.lua and the Minetest mod mcl_maps for guidance.

Advanced Texture Format Control 🔗

The function minetest.encode_png() always encodes images as 32bpp RGBA.

tga_encoder allows saving images as grayscale, 16bpp RGBA and 24bpp RGB.

For generating maps from terrain, color-mapped formats can be more useful.

Encoding Very Small Textures 🔗

Images of size 8×8 or below are often smaller than an equivalent PNG file.

Note that on many filesystems files use at least 4096 bytes (i.e. 64×64).

Therefore, saving bytes on files up to a few 100 bytes is often useless.

Encoding Reference Textures 🔗

TGA is a simple format, which makes it easy to create reference textures.

Using a hex editor, one can trivially see how all the pixels are stored.

Supported Image Types 🔗

For all types, images are encoded in a fast single pass (i.e. append-only).

Color-Mapped Images (Type 1) 🔗

These images contain a palette, followed by pixel data.

  • A1R5G5B5 (8bpp RGB)
  • B8G8R8 (8bpp RGB)

True-Color Images (Type 2) 🔗

These images contain uncompressed RGB(A) pixel data.

  • A1R5G5B5 (16bpp RGBA)
  • B8G8R8 (24bpp RGB)
  • B8G8R8A8 (32bpp RGBA)

Grayscale Images (Type 3) 🔗

  • Y8 (8bpp grayscale)

Run-Length Encoded (RLE), True-Color Images (Type 10) 🔗

These images contain compressed RGB(A) pixel data.

  • A1R5G5B5 (16bpp RGBA)
  • B8G8R8 (24bpp RGB)
  • B8G8R8A8 (32bpp RGBA)

TODO 🔗

  • Actually support R8G8B8A8 input for A1R5G5B5 output
  • Add both zoomable and explorable maps to mcl_maps.

Reviews

Review

Do you recommend this mod?

  • No reviews, yet.

Releases

2024-11-21

Download

2024-11-24 22:01 UTC

2024-11-21 🔗

  • Add script to generate TGA test textures
  • Adjust TGA test texture file names
  • Add code to generate TGA type 1 test textures
  • Make 3D rendered donut appear solid
  • Partially slice 3D rendered donut along its torodial direction
  • Partially slice 3D rendered donut along its polodial direction
  • Add hashbang to script to generate TGA test textures
  • Allow encoding with top-bottom scanline order
  • Explicitly state scanline order in test texture script
  • Generate test textures with scanline order “top-bottom”
  • Add features table
  • Generate TGA type 1 test textures using loops
  • Generate TGA type 3 test textures using loops
  • Encode alpha channel for uncompressed A1R5G5B5 images
  • Encode alpha channel for compressed A1R5G5B5 images
  • Generate TGA type 2 and type 10 test textures using loops
  • Refactor encoding of compressed A1R5G5B5 images
  • Refactor encoding of uncompressed A1R5G5B5 images
  • Generate TGA type 3 test textures from RGB input
  • Use keys with truthy values in features table
  • Change scanline order names
  • Use hyphen-minus to separate test texture filename parts
  • Encode number of attribute/alpha bits in image descriptor
  • Add 2×2 white square to bottom left corner of test textures
  • Encode alpha channel for colormapped A1R5G5B5 images
  • Do not deadname myself

2023-09-22

Download

2023-09-23 02:12 UTC

2023-09-22 🔗

No release notes

2023-09-18

Download

2023-09-19 02:12 UTC

2023-09-18 🔗

No release notes

2023-08-27

Download

2023-08-28 02:12 UTC

2023-08-27 🔗

No release notes

2022-07-31

Download

2022-07-30 22:29 UTC

2022-07-31 🔗

No release notes

All releases

Information

Provides

tga_encoder

Dependencies

Required
No required dependencies

Information

Type
Mod
Technical Name
tga_encoder
Languages
English
License
GPL-3.0-or-later
Maintenance State
Actively Developed
Added
2022-05-16 20:38 UTC
Maintainers
erle

Used By