Skip to content

image-js/fast-bmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fast-bmp

Zakodium logo

Maintained by Zakodium

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);