Crop Screen Shot
Crop a specified area from the device screenshot and return the cropped image.
Important Note
This method only returns BMP image format, other formats are not supported.
Interface Description
Interface Type
cropScreenShotParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Device ID |
| rect | number[] | Yes | Crop area, format: [x1, y1, x2, y2], unit: pixels |
Return Value
Returns cropped image binary data (BMP format):
Basic Usage
javascript
// Crop screenshot
// rect: [x1, y1, x2, y2] - top-left and bottom-right coordinates
const croppedImage = await apiInvoke('cropScreenShot', {
deviceId: 'P72578581E07',
rect: [100, 100, 300, 400] // Area from (100, 100) to (300, 400)
});
// Save as file (Note: returns BMP format)
const fs = require('fs');
fs.writeFileSync('cropped.bmp', croppedImage);Notes
- Format Limitation: This method always returns BMP format, other formats cannot be specified
- Coordinate Range: Coordinates and dimensions in
rectparameter must not exceed screen bounds - Parameter Format:
rectmust be an array of 4 numbers:[x1, y1, x2, y2], where (x1, y1) is the top-left coordinate and (x2, y2) is the bottom-right coordinate