@mbtech-nl/bitmap / floydSteinberg
Function: floydSteinberg()
ts
function floydSteinberg(
luminance: Float32Array,
width: number,
height: number,
invert: boolean,
mask?: Uint8Array): LabelBitmap;Defined in: dither.ts:145
Floyd–Steinberg error-diffusion dither.
Quantises a normalised luminance buffer (values in [0, 1]) to packed 1bpp output. Kept as a public export for v1.0 compatibility; new code should pass dither: 'floyd-steinberg' to renderImage instead, which handles luminance conversion, gamma, and rotation around it.
Parameters
| Parameter | Type | Description |
|---|---|---|
luminance | Float32Array | Normalised luminance, length width * height. |
width | number | Image width in pixels. |
height | number | Image height in pixels. |
invert | boolean | If true, swap black and white in the output. |
mask? | Uint8Array | Optional Uint8Array (length width * height); pixels with mask[i] === 0 neither emit ink nor receive diffused error. Used internally by renderMultiPlaneImage to keep error confined to a plane's classified region. Omit for ordinary single-plane dithering. |
Returns
A 1bpp LabelBitmap of dimensions width × height.
Example
ts
const bmp = floydSteinberg(luminance, 384, 64, false);