1# @ohos.screenshot (Screenshot) 2 3The **Screenshot** module provides the screen capture capability. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import { screenshot } from '@kit.ArkUI'; 13``` 14 15## Rect 16 17Describes the region of the screen to capture. 18 19**Atomic service API**: This API can be used in atomic services since API version 12. 20 21**System capability**: SystemCapability.WindowManager.WindowManager.Core 22 23| Name| Type | Mandatory| Description | 24| ------ | ------ | ---- | ------------------------------------------------------------ | 25| left | number | Yes | Left boundary of the screen region to capture, in px. The value must be an integer.| 26| top | number | Yes | Top boundary of the screen region to capture, in px. The value must be an integer.| 27| width | number | Yes | Width of the screen region to capture, in px. The value must be an integer.| 28| height | number | Yes | Height of the screen region to capture, in px. The value must be an integer.| 29 30## PickInfo 31 32Describes the screenshot options. 33 34**Atomic service API**: This API can be used in atomic services since API version 12. 35 36**System capability**: SystemCapability.WindowManager.WindowManager.Core 37 38 39| Name | Type | Mandatory| Description | 40| -------------------- | ------------- | ---- | ------------------------------------------------------------ | 41| pickRect | [Rect](#rect) | Yes | Region of the screen to capture. | 42| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes | **PixelMap** object of the captured image.| 43 44## screenshot.pick 45 46pick(): Promise<PickInfo> 47 48Takes a screenshot. This API can be used only on 2-in-1 devices. 49 50**Atomic service API**: This API can be used in atomic services since API version 12. 51 52**System capability**: SystemCapability.WindowManager.WindowManager.Core 53 54**Return value** 55 56| Type | Description | 57| ----------------------------- | ----------------------------------------------- | 58| Promise<[PickInfo](#pickinfo)> | Promise used to return the **PickInfo** object.| 59 60**Error codes** 61 62For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md). 63 64| ID| Error Message| 65| ------- | ----------------------- | 66| 801 | Capability not supported on this device. | 67| 1400003 | This display manager service works abnormally. | 68 69**Example** 70 71```ts 72import { BusinessError } from '@kit.BasicServicesKit'; 73 74try { 75 let promise = screenshot.pick(); 76 promise.then((pickInfo: screenshot.PickInfo) => { 77 console.log('pick Pixel bytes number: ' + pickInfo.pixelMap.getPixelBytesNumber()); 78 console.log('pick Rect: ' + pickInfo.pickRect); 79 pickInfo.pixelMap.release(); // Release the memory in time after the PixelMap is no longer needed. 80 }).catch((err: BusinessError) => { 81 console.log('Failed to pick. Code: ' + JSON.stringify(err)); 82 }); 83} catch (exception) { 84 console.error('Failed to pick Code: ' + JSON.stringify(exception)); 85}; 86``` 87