array-to-image

1.0.0 • Public • Published

array-to-image

Convert an Uint8ClampedArray to an image.

Installation

$ npm install --save array-to-image

Usage

import { getImgFromArr } from 'array-to-image';
 
const data = new Uint8ClampedArray(256 * 256 * 4);
 
for(let i = 0; i < data.length; i += 4) {
  data[i] = 255; // r
  data[+ 1] = 0; // g
  data[+ 2] = 0; // b
  data[+ 3] = 255; // a
}
 
const img = getImgFromArr(data);

API

dataUrl = getDataUrlFromArr(arr, w, h)

Get a data url string from the given Uint8ClampedArray arr. If w and h are ommitted, the image is considered to be squared.

img = getImgFromDataUrl(data)

Get an image from the given url string data.

img = getImgFromArr(arr, w, h)

Get an image from the given Uint8ClampedArray arr. If w and h are ommitted, the image is considered to be squared.

License

MIT, see LICENSE.md for more details.

Readme

Keywords

none

Package Sidebar

Install

npm i array-to-image

Weekly Downloads

325

Version

1.0.0

License

MIT

Last publish

Collaborators

  • vaalentin