Types
Exported by nitro-view-shot
ViewShotViewRef
The value a ViewShotView ref receives.
| Field | Type | Description |
|---|---|---|
capture() | () => Promise<Image> | Captures this view and its children. Rejects when unmounted or with an empty size. |
ViewShotViewProps
type ViewShotViewProps = ViewProps & { ref?: Ref<ViewShotViewRef> }
Every NitroUI ViewProps, plus a ref typed as ViewShotViewRef.
From nitro-ui-renderer
These come from nitro-ui-renderer/hybrids and are listed as of nitro-ui-renderer 0.3.0.
Image
| Member | Type | Description |
|---|---|---|
width | number | Width in pixels. |
height | number | Height in pixels. |
toRawPixelData(allowGpu?) / toRawPixelDataAsync | RawPixelData | Raw pixel bytes and their byte order. |
toEncodedImageData(format, quality?) / …Async | EncodedImageData | Encoded file bytes. |
toBase64Async(format, quality?) | Promise<string> | Encoded bytes as padded Base64, no data-URL prefix. |
saveToFileAsync(path, format, quality?) | Promise<void> | Writes an encoded file to path. |
saveToTemporaryFileAsync(format, quality?) | Promise<string> | Writes a temporary file and returns its path. |
resize, crop, rotate, mirrorHorizontally, renderInto | Image | Return a new Image; each has an Async variant. |
RawPixelData
| Field | Type | Description |
|---|---|---|
buffer | ArrayBuffer | Pixel bytes. |
width | number | Width in pixels. |
height | number | Height in pixels. |
pixelFormat | PixelFormat | Byte order in memory, e.g. 'BGRA'. |
EncodedImageData
| Field | Type | Description |
|---|---|---|
buffer | ArrayBuffer | Encoded file bytes. |
width | number | Width in pixels. |
height | number | Height in pixels. |
imageFormat | ImageFormat | Container format. |
ImageFormat and PixelFormat
type ImageFormat = 'jpg' | 'png' | 'heic'
type PixelFormat =
'ARGB' | 'BGRA' | 'ABGR' | 'RGBA' | 'XRGB' | 'BGRX' | 'XBGR' | 'RGBX' | 'RGB' | 'BGR' | 'unknown'
X marks a skipped alpha byte.