提交 59e2d53b 编写于 作者: W wusongqing

update docs against 6666

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 d78f7086
...@@ -68,29 +68,30 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async ...@@ -68,29 +68,30 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses an async
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. | | callback | AsyncCallback&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Yes | Callback used to return a **PixelMap** object. |
**Example** **Example**
```js ```js
var ScreenshotOptions = { var screenshotOptions = {
"screenRect": { "screenRect": {
"left": 200, "left": 200,
"top": 100, "top": 100,
"width": 200, "width": 200,
"height": 200}, "height": 200},
"imageSize": { "imageSize": {
"width": 300, "width": 300,
"height": 300}, "height": 300},
"rotation": 0, "rotation": 0,
"displayId": 0 "displayId": 0
}; };
screenshot.save(ScreenshotOptions, (err, data) => { screenshot.save(screenshotOptions, (err, pixelMap) => {
if (err) { if (err) {
console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err)); console.log('Failed to save screenshot: ' + JSON.stringify(err));
return; return;
} }
console.info('Screenshot saved. Data: ' + JSON.stringify(data)); console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
pixelMap.release(); // Release the memory in time after the PixelMap is used.
}); });
``` ```
...@@ -114,12 +115,12 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis ...@@ -114,12 +115,12 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis
| Type | Description | | Type | Description |
| ----------------------------- | ----------------------------------------------- | | ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return a **PixelMap** object.| | Promise&lt;[image.PixelMap](js-apis-image.md#pixelmap7)&gt; | Promise used to return a **PixelMap** object.|
**Example** **Example**
```js ```js
var ScreenshotOptions = { var screenshotOptions = {
"screenRect": { "screenRect": {
"left": 200, "left": 200,
"top": 100, "top": 100,
...@@ -131,10 +132,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis ...@@ -131,10 +132,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This API uses a promis
"rotation": 0, "rotation": 0,
"displayId": 0 "displayId": 0
}; };
let promise = screenshot.save(ScreenshotOptions); let promise = screenshot.save(screenshotOptions);
promise.then(() => { promise.then((pixelMap) => {
console.log('screenshot save success'); console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
pixelMap.release(); // Release the memory in time after the PixelMap is used.
}).catch((err) => { }).catch((err) => {
console.log('screenshot save fail: ' + JSON.stringify(err)); console.log('Failed to save screenshot: ' + JSON.stringify(err));
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册