• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './@ohos.base';
17import image from './@ohos.multimedia.image'
18
19/**
20 * This module allows developers to export snapshot image from a component or a custom builder.
21 *
22 * @namespace componentSnapshot
23 * @syscap SystemCapability.ArkUI.ArkUI.Full
24 * @crossplatform
25 * @since 10
26 */
27declare namespace componentSnapshot {
28  /**
29   * Take a snapshot of the target component.
30   *
31   * @param { string } id - Target component ID, set by developer through .id attribute.
32   * @param { AsyncCallback<image.PixelMap> } callback - Callback that contains the snapshot in PixelMap format.
33   * @throws { BusinessError } 401 - if parameter check fails.
34   * @throws { BusinessError } 100001 - if id is not valid.
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @crossplatform
37   * @since 10
38   */
39  function get(id: string, callback: AsyncCallback<image.PixelMap>): void;
40
41  /**
42   * Take a snapshot of the target component.
43   *
44   * @param { string } id - Target component ID, set by developer through .id attribute.
45   * @returns { Promise<image.PixelMap> } A Promise with the snapshot in PixelMap format.
46   * @throws { BusinessError } 401 - if parameter check fails.
47   * @throws { BusinessError } 100001 - if id is not valid.
48   * @syscap SystemCapability.ArkUI.ArkUI.Full
49   * @crossplatform
50   * @since 10
51   */
52  function get(id: string): Promise<image.PixelMap>;
53
54  /**
55   * Generate a snapshot from a custom component builder.
56   *
57   * @param { CustomBuilder } builder - Builder function of a custom component.
58   * @param { AsyncCallback<image.PixelMap> } callback - Callback that contains the snapshot in PixelMap format.
59   * @throws { BusinessError } 401 - if parameter check fails.
60   * @throws { BusinessError } 100001 - if builder is not a valid build function.
61   * @syscap SystemCapability.ArkUI.ArkUI.Full
62   * @crossplatform
63   * @since 10
64   */
65  function createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap>): void;
66
67  /**
68   * Generate a snapshot from a custom component builder.
69   *
70   * @param { CustomBuilder } builder - Builder function of a custom component.
71   * @returns { Promise<image.PixelMap> } A Promise with the snapshot in PixelMap format.
72   * @throws { BusinessError } 401 - if parameter check fails.
73   * @throws { BusinessError } 100001 - if builder is not a valid build function.
74   * @syscap SystemCapability.ArkUI.ArkUI.Full
75   * @crossplatform
76   * @since 10
77   */
78  function createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap>;
79}
80
81export default componentSnapshot;
82