@nellowtcs/tbmp
v0.1.0
Published
tBMP WebAssembly library - A tiny bitmap format library
Downloads
134
Maintainers
Readme
tbmp
WebAssembly bindings for tBMP - a tiny bitmap format library.
Install
npm install @nellowtcs/tbmpUsage
import TBmp from '@nellowtcs/tbmp';
const response = await fetch('image.tbmp');
const buffer = await response.arrayBuffer();
const data = new Uint8Array(buffer);
const len = TBmp.tbmp_load(data, data.length);
if (len < 0) {
const err = TBmp.tbmp_error();
// handle error
}
const width = TBmp.tbmp_width();
const height = TBmp.tbmp_height();
const pixelsLen = TBmp.tbmp_pixels_len();
const pixels = new Uint8Array(TBmp._malloc(pixelsLen));
TBmp.tbmp_pixels_copy(pixels, pixelsLen);
// Use pixel data...
// RGBA8888 format: 4 bytes per pixelAPI
See the tBMP API Documentation for full details.
Browser
<script type="module">
import TBmp from 'tbmp/tbmp_wasm.js';
await TBmp.default();
// ...
</script>License
Apache-2.0
