组件截图:新增getSync接口

Signed-off-by: huqingyun <huqingyun1@huawei.com>
Change-Id: I57c8ab12c7328c0a7ae9c61c7f1bf31c2f5864b4
This commit is contained in:
huqingyun 2024-08-01 01:37:47 +00:00
parent 226c7c4257
commit 6e3449fafc
2 changed files with 42 additions and 0 deletions

View File

@ -2424,6 +2424,27 @@ export class ComponentSnapshot {
*/
createFromBuilder(builder: CustomBuilder, delay?: number,
checkImageStatus?: boolean, options?: componentSnapshot.SnapshotOptions): Promise<image.PixelMap>;
/**
* Take a screenshot of the specified component in synchronous mode,
* this mode will block the main thread, please use it with caution, the maximum
* waiting time of the interface is 3s, if it does not return after 3s, an exception will be thrown.
*
* @param { string } id - Target component ID, set by developer through .id attribute.
* @param { componentSnapshot.SnapshotOptions } [options] - Define the snapshot options.
* @returns { image.PixelMap } The snapshot result in PixelMap format.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* <br> 1. Mandatory parameters are left unspecified.
* <br> 2. Incorrect parameters types.
* <br> 3. Parameter verification failed.
* @throws { BusinessError } 100001 - Invalid ID.
* @throws { BusinessError } 160002 - Timeout.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
getSync(id: string, options?: componentSnapshot.SnapshotOptions): image.PixelMap;
}
/**

View File

@ -209,6 +209,27 @@ declare namespace componentSnapshot {
*/
function createFromBuilder(builder: CustomBuilder, delay?: number,
checkImageStatus?: boolean, options?: SnapshotOptions): Promise<image.PixelMap>;
/**
* Take a screenshot of the specified component in synchronous mode,
* this mode will block the main thread, please use it with caution, the maximum
* waiting time of the interface is 3s, if it does not return after 3s, an exception will be thrown.
*
* @param { string } id - Target component ID, set by developer through .id attribute.
* @param { SnapshotOptions } [options] - Define the snapshot options.
* @returns { image.PixelMap } The snapshot result in PixelMap format.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* <br> 1. Mandatory parameters are left unspecified.
* <br> 2. Incorrect parameters types.
* <br> 3. Parameter verification failed.
* @throws { BusinessError } 100001 - Invalid ID.
* @throws { BusinessError } 160002 - Timeout.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
function getSync(id: string, options?: SnapshotOptions): image.PixelMap;
}
export default componentSnapshot;