/stga

(Simple) TGA image file reader and writer for the Zig programming language.

Primary LanguageZigBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

stga

STGA (Simple-TGA) reads 16-, 24- and 32-bit Truecolor TGA images, and writes 24- and 32-bit Truecolor images.

Read and written images can optionally be RLE-compressed.

Usage

Download the repository into your project's lib/vendor directory and add a reference to it in your build.zig file.

    ...
    exe.addPackagePath("stga", "libs/stga/main.zig");
    ...

To use the library, add an import statement:

const tga = @import("stga");

To read an image from disk.

const img = try tga.Image.readFilepath(allocator, "file.tga");
defer img.deinit();

To read an image from stream.

const img = try tga.Image.readStream(allocator, myreader);
defer img.deinit();

To read an image from a byte buffer. This assumes the buffer holds a full TGA image file.

const img = try tga.Image.readData(allocator, mydata);
defer img.deinit();

To write image to disk -- optionally RLE compressed.

try img.writeFilepath("file.tga", true);

To write image to a stream -- optionally RLE compressed.

try img.writeStream(mywriter, true);

License

Unless otherwise stated, this project and its contents are provided under a 3-Clause BSD license. Refer to the LICENSE file for its contents.