未验证 提交 fc510d74 编写于 作者: O openharmony_ci 提交者: Gitee

!6069 翻译完成:5825 3.1Relase分支:screenshot与data-ability一致性问题修改 Cherry-Pick到3.1 release

Merge pull request !6069 from wusongqing/cherry-pick-1656465895
# Screenshot # Screenshot
Provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -17,11 +20,12 @@ Describes screenshot options. ...@@ -17,11 +20,12 @@ Describes screenshot options.
**System capability**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------- | ---- | ------------------------------------------------------------ | | ---------------------- | ------------- | ---- | ------------------------------------------------------------ |
| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.| | screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. |
| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.| | imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. |
| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**.| | rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. |
| displayId<sup>8+</sup> | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured.|
## Rect ## Rect
...@@ -63,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal ...@@ -63,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. | | callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. |
**Example** **Example**
...@@ -78,7 +82,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal ...@@ -78,7 +82,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
"imageSize": { "imageSize": {
"width": 300, "width": 300,
"height": 300}, "height": 300},
"rotation": 0 "rotation": 0,
"displayId": 0
}; };
screenshot.save(ScreenshotOptions, (err, data) => { screenshot.save(ScreenshotOptions, (err, data) => {
if (err) { if (err) {
...@@ -103,13 +108,13 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro ...@@ -103,13 +108,13 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------- | ----------------------------------------------- | | ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.| | Promise&lt;image.PixelMap&gt; | Promise used to return a **PixelMap** object.|
**Example** **Example**
...@@ -123,7 +128,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro ...@@ -123,7 +128,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
"imageSize": { "imageSize": {
"width": 300, "width": 300,
"height": 300}, "height": 300},
"rotation": 0 "rotation": 0,
"displayId": 0
}; };
let promise = screenshot.save(ScreenshotOptions); let promise = screenshot.save(ScreenshotOptions);
promise.then(() => { promise.then(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册