From bda6e74fe4dec830f4fc7620aca3d84f68099b94 Mon Sep 17 00:00:00 2001 From: yangfei Date: Fri, 23 Sep 2022 11:11:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9screenshot.save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangfei Change-Id: I80a8cb93547347e58b80c7d617cc2373673e8328 --- .../reference/apis/js-apis-screenshot.md | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index c0126a92a3..903b57b281 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -55,7 +55,7 @@ import screenshot from '@ohos.screenshot'; ## screenshot.save -save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void +save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void 获取屏幕截图。 @@ -67,7 +67,7 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | 否 | 该类型的参数包含screenRect,imageSize,rotation, displayId四个参数,可以分别设置这四个参数。 | +| options | [ScreenshotOptions](#screenshotoptions) | 是 | 该类型的参数包含screenRect、imageSize、rotation、displayId四个参数,可以分别设置这四个参数。 | | callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。返回一个PixelMap对象。 | **示例:** @@ -97,6 +97,35 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) ## screenshot.save +save(callback: AsyncCallback<image.PixelMap>): void + +获取屏幕截图。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**需要权限**:ohos.permission.CAPTURE_SCREEN,仅系统应用可用。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。返回一个PixelMap对象。 | + +**示例:** + + ```js + screenshot.save((err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完后及时释放内存 + }); + ``` + +## screenshot.save + save(options?: ScreenshotOptions): Promise<image.PixelMap> 获取屏幕截图。 -- GitLab