2.0.1 • Published 2 years ago

fast-bmp v2.0.1

Weekly downloads
2,323
License
MIT
Repository
github
Last release
2 years ago

fast-bmp

NPM version Test coverage npm download

A library for encoding bmp image file format.

Supported features

For now there is only support for 1-bit image encoding.

Usage

const bmp = require('fast-bmp');

// 0 0 0 0 0
// 0 1 1 1 0
// 0 1 0 1 0
// 0 1 1 1 0
// 0 0 0 0 0
const imageData = {
  width: 5,
  height: 5,
  data: new Uint8Array([0b00000011, 0b10010100, 0b11100000, 0b00000000]),
  bitDepth: 1,
  components: 1,
  channels: 1,
};
// Encode returns a Uint8Array.
const encoded = bmp.encode(imageData);
fs.writeFileSync('image.bmp', encoded);