Object Creation
To create a screenshot object, first load the brightsign/screenshot
module using the require()
method. Then create an instance of the screenshot class.
Code Block | ||
---|---|---|
| ||
var ScreenshotClass = require("@brightsign/screenshot");
var screenshot = new ScreenshotClass(); |
Screenshot
Use this interface to take screenshots.
syncCapture()
Code Block | ||
---|---|---|
| ||
void syncCapture(ScreenshotParams params) |
Takes a screenshot at nearly the exact moment that it is called. Because this method might interrupt on-screen operations, it is more appropriate for debugging applications.
asyncCapture()
Code Block | ||
---|---|---|
| ||
Promise<void> asyncCapture(ScreenshotParams params) |
Takes a screenshot without interrupting other operations. This method is appropriate for production environments–where the timing of the capture is less important than seamless operation.
ScreenshotParams
This interface contains screenshot settings.
[String] destinationFileName:
The native path and filename that will be saved.[String] fileName
: The name and path of the image file that will be saved (e.g. "SD:/myscreenshots/screen.jpg"). If the specified directory does not exist, the screenshot will fail. This is deprecated in favor ofdestinationFileName
, but is still supported.[String]
fileType
: The file type of the image ("JPEG" or "BMP"). The default file type is "JPEG". Note that the file extension (".jpg" or ".bmp") is not appended to the filename by default and, if needed, should be included in thefileName
string.[String]
description
: An optional description.[int] width
: The width of the image file. The default value is 640.[int]
height
: The height of the image file. The default value is 480.[int]
quality
: The image quality of the screenshot (between 0 and 100). The default value is 50.[int] rotation
: The rotation of the screenshot image (in degrees). The default value is 0. Accepted values are 0, 90, 180, and 270.
Example
This script takes a screenshot asynchronously every five minutes, saving it to the root of the SD card. Note that the previous image is erased with each new screenshot.
Code Block | ||
---|---|---|
| ||
var ScreenshotClass = require("@brightsign/screenshot");
var screenshot = new ScreenshotClass();
function takeAsyncScreenshot(args) {
screenshot.asyncCapture(args).then().catch();
};
screenshotParams = {};
screenshotParams.fileName = "SD:/screen.jpg";
screenshotParams.quality = 75;
setInterval(takeAsyncScreenshot(screenshotParams), 10000); |