@mbtech-nl/bitmap / cropBitmap
Function: cropBitmap()
ts
function cropBitmap(
bitmap: LabelBitmap,
x: number,
y: number,
widthPx: number,
heightPx: number): LabelBitmap;Defined in: transform.ts:206
Extract a rectangular sub-region from a bitmap.
Parameters
| Parameter | Type | Description |
|---|---|---|
bitmap | LabelBitmap | Source bitmap. |
x | number | Left edge of crop, in pixels. |
y | number | Top edge of crop, in pixels. |
widthPx | number | Crop width in pixels (≥ 1). |
heightPx | number | Crop height in pixels (≥ 1). |
Returns
A new bitmap containing the cropped region.
Throws
If the region is out of bounds or has non-positive dimensions.
Example
ts
const header = cropBitmap(label, 0, 0, label.widthPx, 32);