Expand description
TGA texture-image support. TGA (Targa) reader and writer.
This module provides a Rust-centric TGA API for KotOR texture workflows:
- parse many TGA source variants into a normalized top-left RGBA8 buffer,
- write lossless-passthrough or canonical output.
Parsing is backed by tinytga for robust header/color-map/RLE handling.
§KotOR Notes
- Reader defaults target canonical vanilla KotOR (K1) image types
(
1,2,3,9,10) and reject non-canonical variants such as grayscale RLE (type 11) unless compatibility mode is explicitly enabled. - Writer default: lossless passthrough when pixels are unmodified (the 18-byte
header and raw image sections are re-emitted verbatim). For new files or
edited pixels, output is canonical uncompressed true-color (type
2, 32-bit, top-left origin). K1 ignoresimage_typeandimage_descriptorentirely (confirmed Ghidra evidence – seedocs/notes/texture_formats.md).
§Format Layout
+------------------------------+ 0x0000
| Header (18 bytes) |
+------------------------------+
| Image ID (id_len bytes) |
+------------------------------+
| Optional color map |
+------------------------------+
| Pixel data |
+------------------------------+
| Optional footer/extensions |
+------------------------------+Structs§
- Tga
- In-memory TGA image.
- TgaHeader
- Source TGA header metadata captured during parsing.
- TgaRead
Options - TGA reader option set.
Enums§
- TgaBinary
Error - Errors produced while parsing or serializing TGA data.
- TgaBits
PerPixel - Source TGA bit depth.
- TgaCompression
- Source TGA compression mode.
- TgaData
Type - Parsed TGA data category from the source header.
- TgaOrigin
- Source TGA image origin.
- TgaRead
Mode - TGA reader input policy.
Functions§
- read_
tga - Reads TGA data from a reader.
- read_
tga_ from_ bytes - Reads TGA data from bytes.
- read_
tga_ from_ bytes_ with_ options - Reads TGA data from bytes with explicit options.
- read_
tga_ with_ options - Reads TGA data from a reader with explicit options.
- write_
tga - Writes TGA data to a writer.
- write_
tga_ to_ vec - Serializes TGA data into a byte vector.