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 * Declares the screenshot APIs. 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 * @throws DM_ERROR_INVALID_PARAM If param is not valid 31 * @since 7 32 */ 33 function save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void; 34 35 /** 36 * Takes a screenshot and saves it as a PixelMap object. 37 * @param options Screenshot options, which consist of screenRect, imageSize, and rotation. You need to set these parameters 38 * @permission ohos.permission.CAPTURE_SCREEN 39 * @throws DM_ERROR_INVALID_PARAM If param is not valid 40 * @since 7 41 */ 42 function save(options?: ScreenshotOptions): Promise<image.PixelMap>; 43 44 /** 45 * Describes the region of the screen to capture. 46 * @since 7 47 */ 48 interface Rect { 49 left: number; 50 top: number; 51 width: number; 52 height: number; 53 } 54 55 /** 56 * Describes the size of the screen region to capture. 57 * @since 7 58 */ 59 interface Size { 60 width: number; 61 height: number; 62 } 63 64 /** 65 * Describes screenshot options. 66 * @since 7 67 */ 68 interface ScreenshotOptions { 69 /** 70 * Region of the screen to capture. If this parameter is null, the full screen will be captured. 71 */ 72 screenRect?: Rect; 73 /** 74 * Region of the screen to capture. If this parameter is null, the full screen will be captured. 75 */ 76 imageSize?: Size; 77 /** 78 * Rotation angle of the screenshot. The value can be 0, 90, 180, or 270. The default value is 0. 79 */ 80 rotation?: number; 81 /** 82 * ID of the screen to be captured. 83 * @since 8 84 */ 85 displayId?: number; 86 } 87} 88 89export default screenshot; 90