Skip to content

@mbtech-nl/bitmap

Interfaces

InterfaceDescription
FontMetrics-
ImageRenderOptions-
LabelBitmapA 1-bit-per-pixel bitmap. Row-major, MSB-first within each byte.
MultiPlaneRenderOptions-
PaletteEntryOne ink/foil colour the printer can place on the substrate.
PlaneRenderOptionsPer-plane pre-quantisation overrides. Each field, if omitted, falls back to MultiPlaneRenderOptions.defaults, then to that field's hard default (e.g. threshold: 128, dither: false, gamma: 1).
RawImageDataRaw RGBA image data, compatible with browser ImageData and @napi-rs/canvas ImageData.
TextRenderOptions-

Type Aliases

Type AliasDescription
BuiltinFont-
DitherMethod-
LuminanceWeights-

Functions

FunctionDescription
bitmapEqualsCompare two bitmaps for byte-equal equality.
bytesPerRowNumber of packed bytes used to store one row of widthPx pixels.
createBitmapAllocate an empty (all-white) bitmap.
cropBitmapExtract a rectangular sub-region from a bitmap.
flipHorizontalMirror a bitmap left-to-right.
flipVerticalMirror a bitmap top-to-bottom.
floydSteinbergFloyd–Steinberg error-diffusion dither.
getPixelRead a single pixel from a packed 1bpp bitmap.
getRowCopy one packed row of a bitmap.
invertBitmapSwap black and white pixels.
iterRowsIterate packed rows of a bitmap top-to-bottom.
measureTextCompute the dimensions a renderText call would produce, without allocating a bitmap. Empty strings return { widthPx: 0, heightPx }.
padBitmapAdd white margins around an existing bitmap.
renderImageConvert RGBA pixel data to a packed 1bpp bitmap.
renderMultiPlaneImageConvert RGBA pixel data into one 1bpp LabelBitmap per palette entry.
renderTextRender an ASCII string into a packed 1bpp bitmap using the bundled font.
rotateBitmapRotate a bitmap clockwise by 90, 180, or 270 degrees.
scaleBitmapResize a bitmap to a target height while preserving aspect ratio.
stackBitmapsConcatenate bitmaps horizontally or vertically.

Released under the MIT License.