• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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, ErrorCallback } from './basic';
17import image from './@ohos.multimedia.image';
18
19/**
20 * interface for screenshot
21 * @syscap SystemCapability.WindowManager.WindowManager.Core
22 * @systemapi Hide this for inner system use.
23 * @since 7
24 */
25declare namespace screenshot {
26    /**
27     * Takes a screenshot and saves it as a PixelMap object
28     * @param options Screenshot options, which consist of screenRect, imageSize, and rotation. You need to set these parameters
29     * @permission ohos.permission.CAPTURE_SCREEN
30     * @since 7
31     */
32    function save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void;
33
34    /**
35     * Takes a screenshot and saves it as a PixelMap object
36     * @param options Screenshot options, which consist of screenRect, imageSize, and rotation. You need to set these parameters
37     * @permission ohos.permission.CAPTURE_SCREEN
38     * @since 7
39     */
40    function save(options?: ScreenshotOptions): Promise<image.PixelMap>;
41
42    /**
43     * Describes the region of the screen to capture
44     * @since 7
45     */
46    interface Rect {
47        left: number;
48        top: number;
49        width: number;
50        height: number;
51    }
52
53    /**
54     * Describes the size of the screen region to capture
55     * @since 7
56     */
57    interface Size {
58        width: number;
59        height: number;
60    }
61
62    /**
63     * Describes screenshot options
64     * @since 7
65     */
66    interface ScreenshotOptions {
67        /**
68         * Region of the screen to capture. If this parameter is null, the full screen will be captured
69         */
70        screenRect?: Rect;
71        /**
72         * Region of the screen to capture. If this parameter is null, the full screen will be captured
73         */
74        imageSize?: Size;
75        /**
76         * Rotation angle of the screenshot. The value can be 0, 90, 180, or 270. The default value is 0
77         */
78        rotation?: number;
79        /**
80         * The specify screen to be captured.
81         * @since 8
82         */
83        displayId?: number;
84    }
85}
86
87export default screenshot;
88