Docs

Bitmap

The Bitmap class represents a bitmap image with RGBA pixel data.

Constructor

constructor

Static Methods

Prototype Properties

Examples

// Create a 2x2 bitmap with red and green pixels
let pixels = new Uint8Array([
  255, 0, 0, 255,    // red pixel
  0, 255, 0, 255     // green pixel
])
let bitmap = new Bitmap(pixels, 2, 1)
bitmap.width
2
// Create a scaled version
let original = new Bitmap(new Uint8Array([255, 0, 0, 255]), 1, 1)
let scaled = original.scaled(2)
scaled.scale
2
// Access pixel data
let bitmap = new Bitmap(new Uint8Array([255, 128, 0, 255]), 1, 1)
bitmap.pixels[0]  // Red component
255

See also