Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/magicien/tgaimage
TGA Image Loader for Web browsers
https://github.com/magicien/tgaimage
javascript tga tga-image
Last synced: 2 days ago
JSON representation
TGA Image Loader for Web browsers
- Host: GitHub
- URL: https://github.com/magicien/tgaimage
- Owner: magicien
- License: mit
- Created: 2017-08-04T17:15:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-13T02:09:03.000Z (over 7 years ago)
- Last Synced: 2024-05-02T04:00:07.392Z (7 months ago)
- Topics: javascript, tga, tga-image
- Language: JavaScript
- Size: 972 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/tgaimage.svg)](https://www.npmjs.com/package/tgaimage)
# TGAImage
TGA Image Loader for Web browsers## Install
### npm
```
npm install tgaimage --save
```### without npm
```
```
tgaimage.min.js looks like this;
```
var TGAImage = (function(modules){ ... })()
```
so once you have loaded tgaimage.min.js, you can use TGAImage as a class object.## Usage
```
// You can load a TGA image with imageWithURL function.
const tga1 = TGAImage.imageWithURL('lena_std.tga')// didLoad is Promise.
tga1.didLoad.then(() => {// You can get an img tag with 'image' property.
document.getElementById('colorImgTag').appendChild(tga1.image)// You can get a canvas tag with 'canvas' property.
document.getElementById('colorCanvasTag').appendChild(tga1.canvas)
})// You can also use src and onload properties like HTMLImageElement.
const tga2 = new TGAImage()
tga2.onload = () => {
document.getElementById('grayscaleImgTag').appendChild(tga2.image)
document.getElementById('grayscaleCanvasTag').appendChild(tga2.canvas)
}
tga2.src = 'lena_std_grayscale.tga'
```## Sample
[Sample Page](https://magicien.github.io/TGAImage/sample/)