daiybh / tgajs

Load and display .tga files with JavaScript

Home Page:http://schmittl.github.io/tgajs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tgajs

This is a fork from jsTGALoader to learn more about TGA and JavaScript.

Try the online demo here

Features

  • 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

How to Use

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();

About

Load and display .tga files with JavaScript

http://schmittl.github.io/tgajs/

License:zlib License


Languages

Language:JavaScript 98.9%Language:HTML 1.1%