This is a fork from jsTGALoader to learn more about TGA and JavaScript.
Try the online demo here
- Display tga files on canvas elements
- Decode
- RGB 16/24/32 bits (Uncompressed and RLE compressed)
- Black & White 8/16 bits (Uncompressed and RLE compressed)
- Color Mapped with 8 bits index and 16/24/32 bits depth (Uncompressed and RLE compressed)
- Honors the attribute type and origin fields
- Encode ImageData to tga format (experimental) Only supports RGB 32 bits with optional RLE encoding
Loading a remote tga file
var tga = new TGA();
tga.open("resource.tga", function() {
document.body.appendChild( tga.getCanvas() );
});
Loading a tga from an ArrayBuffer
var tga = new TGA();
tga.load(tga_data);
Create a tga file example
var tga = new TGA({width: canvas.width, height: canvas.height, imageType: TGA.Type.RLE_RGB});
tga.setImageData(imageData);
// get a blob url which can be used to download the file
var url = tga.getBlobURL();