Create a BMP (w/ alpha channel) binary from RGBA raw bytes like ImageData.
npm install @3846masa/bmp[![npm-badge]][npm]
[![mit-license-badge]][mit-license]
Create a BMP (w/ alpha channel) binary from RGBA raw bytes like ImageData.
- faster than other libraries (e.g. bmp-js)
- tiny size (basic: ~ 500 bytes, webworker: ~ 700 bytes)
- supports alpha channel
- Usage
- CDN
- Using via bundler
- API
- convert({ width, height, data })
- HTMLCanvasElement.prototype.toBlob(callback, type)
- Contributing
- License
#### Basic
!basic
[![codesandbox-badge]](https://codesandbox.io/s/github/3846masa/bmp/tree/main/examples/basic)
See ./examples/basic.
``html`
#### WebWorker
!webworker
[![codesandbox-badge]](https://codesandbox.io/s/github/3846masa/bmp/tree/main/examples/webworker)
See ./examples/webworker.
`html`
#### No module
!no-module
[![codesandbox-badge]](https://codesandbox.io/s/github/3846masa/bmp/tree/main/examples/canvas-to-blob)
See ./examples/canvas-to-blob.
`html`
`sh`
npm i @3846masa/bmp
`js`
import { convert } from '@3846masa/bmp';
Convert RGBA raw bytes like ImageData to a BMP binary.
In worker.mjs, this function returns Promise.
| | |
| :--------------- | :------------------------------------ |
| width | number |height
| | number |data
| | Uint8Array \| Uint8ClampedArray |options.strict
| | boolean |Uint8Array
| Returns | \| Promise |
| | |
| :--------- | :-------------------- |
| callback | (blob: Blob) => any |type
| | 'image/bmp'` |
PRs accepted.
[MIT (c) 3846masa][mit-license]
[npm-badge]: https://flat.badgen.net/npm/v/@3846masa/bmp?icon=npm
[npm]: https://www.npmjs.com/package/@3846masa/bmp
[mit-license-badge]: https://flat.badgen.net/badge/license/MIT/blue
[mit-license]: https://3846masa.mit-license.org
[codesandbox-badge]: https://flat.badgen.net/badge/codesandbox/try%20it/black