• 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
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21import { AsyncCallback } from './@ohos.base';
22import image from './@ohos.multimedia.image'
23
24/**
25 * This module allows developers to export snapshot image from a component or a custom builder.
26 *
27 * @namespace componentSnapshot
28 * @syscap SystemCapability.ArkUI.ArkUI.Full
29 * @crossplatform
30 * @since 10
31 */
32declare namespace componentSnapshot {
33  /**
34   * Take a snapshot of the target component.
35   *
36   * @param { string } id - Target component ID, set by developer through .id attribute.
37   * @param { AsyncCallback<image.PixelMap> } callback - Callback that contains the snapshot in PixelMap format.
38   * @throws { BusinessError } 401 - if parameter check fails.
39   * @throws { BusinessError } 100001 - if id is not valid.
40   * @syscap SystemCapability.ArkUI.ArkUI.Full
41   * @crossplatform
42   * @since 10
43   */
44  function get(id: string, callback: AsyncCallback<image.PixelMap>): void;
45
46  /**
47   * Take a snapshot of the target component.
48   *
49   * @param { string } id - Target component ID, set by developer through .id attribute.
50   * @returns { Promise<image.PixelMap> } A Promise with the snapshot in PixelMap format.
51   * @throws { BusinessError } 401 - if parameter check fails.
52   * @throws { BusinessError } 100001 - if id is not valid.
53   * @syscap SystemCapability.ArkUI.ArkUI.Full
54   * @crossplatform
55   * @since 10
56   */
57  function get(id: string): Promise<image.PixelMap>;
58
59  /**
60   * Generate a snapshot from a custom component builder.
61   *
62   * @param { CustomBuilder } builder - Builder function of a custom component.
63   * @param { AsyncCallback<image.PixelMap> } callback - Callback that contains the snapshot in PixelMap format.
64   * @throws { BusinessError } 401 - if parameter check fails.
65   * @throws { BusinessError } 100001 - if builder is not a valid build function.
66   * @syscap SystemCapability.ArkUI.ArkUI.Full
67   * @crossplatform
68   * @since 10
69   */
70  function createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap>): void;
71
72  /**
73   * Generate a snapshot from a custom component builder.
74   *
75   * @param { CustomBuilder } builder - Builder function of a custom component.
76   * @returns { Promise<image.PixelMap> } A Promise with the snapshot in PixelMap format.
77   * @throws { BusinessError } 401 - if parameter check fails.
78   * @throws { BusinessError } 100001 - if builder is not a valid build function.
79   * @syscap SystemCapability.ArkUI.ArkUI.Full
80   * @crossplatform
81   * @since 10
82   */
83  function createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap>;
84}
85
86export default componentSnapshot;
87