TgaLoader

TgaLoader

Constructor

new TgaLoader()

Methods

checkHeader()

Check the header of TGA file to detect errors

Throws:

Error

getCanvas() → {canvas}

Return a canvas with the TGA render on it

getDataURL(type) → {canvas}

Return a dataURI of the TGA file

Parameters:
Name Type Description
type string

Optional image content-type to output (default: image/png)

getImageData(imageData) → {imageData}

Return a ImageData object from a TGA file

Parameters:
Name Type Description
imageData imageData

Optional ImageData to work with

getImageData8bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (8bits)
NOTE: we do not support 16bit or 32bit color map. We only support 24bit.

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

getImageData16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (16bits)

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

getImageData24bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (24bits)

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

getImageData32bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (32bits)

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

getImageDataGrey8bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (8bits grey)

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

getImageDataGrey16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end) → {imageData}

Return a ImageData object from a TGA file (16bits grey)

Parameters:
Name Type Description
imageData imageData

ImageData to bind

y_start number

start at y pixel.

y_step number

increment y pixel each time.

y_end number

stop at pixel y.

x_start number

start at x pixel.

x_step number

increment x pixel each time.

x_end number

stop at pixel x.

load()

Load and parse a TGA file

loadData(data)

Parse TGA data

Parameters:
Name Type Description
data Uint8Array

Binary data of the TGA file

parse(data)

Parse data from TGA file

Parameters:
Name Type Description
data Uint8Array

Binary data of the TGA file