LensStudio:Preview.Image
ClassFrame captured from a preview by screenshot() or tryScreenshot().
Index
Properties
Methods
Example
Capture a preview frame, save it as a PNG file, and return the encoded bytes, for example to attach to a report. Saving requires the filesystem permission.
import { LensPreview } from 'LensStudio:LensPreview';
export async function captureFrame(preview: LensPreview, pngFile: Editor.Path): Promise<Uint8Array> {
const image = await preview.tryScreenshot(20000);
console.log(`Captured a ${image.width}x${image.height} preview frame`);
image.save(pngFile); // the format follows the file extension
return image.toBytes(); // PNG unless another format is given
}
Extends
Properties
height
readonlyheight:number
Height of the image in pixels.
width
readonlywidth:number
Width of the image in pixels.
Methods
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
save()
save(
filename):void
Saves the image to the given file path, using the image format that matches the file extension. Requires the filesystem permission.
Parameters
| Parameter | Type |
|---|---|
filename | Path |
Returns
void
scaledToFit()
scaledToFit(
width,height):Image
Parameters
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns
Image
toBytes()
toBytes(
format?):Uint8Array
Parameters
| Parameter | Type |
|---|---|
format? | string |
Returns
Uint8Array