• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-2119

common/12-May-2024-11489

features/screenshot/12-May-2024-276243

figures/12-May-2024-

product/phone/12-May-2024-458383

signature/12-May-2024-

.gitignoreD12-May-202457 65

LICENSED12-May-20249.9 KiB177150

OAT.xmlD12-May-20244.8 KiB7024

README.mdD12-May-20242.2 KiB7958

README_EN.mdD12-May-20242.4 KiB7757

build-profile.json5D12-May-2024442 2727

hvigorfile.jsD12-May-2024778 171

package-lock.jsonD12-May-202453.1 KiB1,2181,217

package.jsonD12-May-2024284 1616

README.md

1# ScreenShot
2
3## 简介
4
5### 内容介绍
6ScreenShot应用是OpenHarmony中预置的系统应用,为用户提供截取当前屏幕并保存图片的功能。
7
8### 架构图
9
10![](figures/cn_diagram.png)
11
12#### feature
13    截屏管理层,提供截屏窗口显示控制,图片保存控制。
14#### common
15    通用工具类,提供日志打印,外部接口管理功能。
16
17## 目录
18
19```
20/applications/standard/screenshot
21    ├── entry                           # entry模块目录
22    ├── common                          # 通用工具类目录
23    ├── build.gradle                    # 全局编译配置文件
24    ├── settings.gradle                 # 编译模块配置文件
25    ├── LICENSE                         # 许可文件
26    ├── signature                       # 证书文件目录
27    ├── features                        # 子组件目录
28    │   ├── screenshot                  # 截屏组件
29    │       ├── screenShotModel         # 截屏图片保存等
30    ├── product                         # ScreenShot总体功能目录
31```
32
33### 功能描述
34#### features
35    子组件目录,提供截屏窗口显示控制,图片保存控制。
36
37#### product
38    ScreenShot总体功能目录,截屏服务入口。
39
40## 签名
411.针对product/phone下的每一个模块,配置build.gradle中的signingConfigs
42
432.将signature目录下的screenshot.p7b放在build.gradle目录中配置的相应路径即可
44
45
46## 使用方法
47
48通过create创建截屏小窗口用于显示图片,示例代码如下
49
50```js
51// 创建截屏小窗口用于显示图片
52window.create(context, windowName, WINDOW_TYPE).then((win) => {
53  win.moveTo(0, WINDOW_Y).then(() => {
54    win.resetSize(dis.width * ZOOM_RATIO, dis.height * ZOOM_RATIO).then(() => {
55      win.loadContent(INDEX_PAGE).then(() => {
56      })
57    })
58  })
59}, (error) => {
60  Log.showInfo(TAG, " window createFailed, error.code = " + error.code)
61})
62
63
64// 截取当前屏幕,返回值可以直接显示控件上
65Screenshot.save().then(async (data) => {
66  if (!!data) {
67    show();
68  }
69}).catch((err) => {
70  Log.showInfo(TAG, `save err`);
71})
72
73```
74
75## 相关仓
76
77系统应用
78
79**applications\_screenshot**

README_EN.md

1# ScreenShot
2
3## Introduction
4
5The ScreenShot application is a preset system application in OpenHarmony, which provides users with the function of capturing the current screen and saving the current picture.
6
7### Architecture diagram
8
9![](figures/en_diagram.png)
10
11#### feature
12    Screen capture management layer, providing screen capture window display control and picture save control.
13#### common
14   A general tool class that provides log printing and external interface management functions.
15
16## content
17
18```
19/applications/standard/screenshot
20     ├── entry             # entry module directory
21     ├── common            # Common tool class directory
22     ├── build.gradle      # Global build configuration file
23     ├── settings.gradle   # Compile the module configuration file
24     ├── LICENSE           # License file
25     ├── signature         # Certificate file directory
26     ├── features          # subcomponent directory
27     │ ├── screenshot      # screenshot component
28     │ ├── screenShotModel # Save screenshots, etc.
29     ├── product           # ScreenShot general function catalog
30```
31
32### Function description
33#### features
34    sub-component directory, provides screen capture window display control, and image save control.
35
36#### product
37    ScreenShot general function catalog, screenshot service entrance.
38
39## sign
401. For each module under product/phone, configure signingConfigs in build.gradle
41
422. Put screenshot.p7b in the signature directory on the corresponding path configured in the build.gradle directory.
43
44## Instructions
45
46Create a small screen capture window to display pictures through create, the sample code is as follows
47
48```js
49// Create a small screen capture window to display pictures
50window.create(context, windowName, WINDOW_TYPE).then((win) => {
51  win.moveTo(0, WINDOW_Y).then(() => {
52    win.resetSize(dis.width * ZOOM_RATIO, dis.height * ZOOM_RATIO).then(() => {
53      win.loadContent(INDEX_PAGE).then(() => {
54      })
55    })
56  })
57}, (error) => {
58  Log.showInfo(TAG, " window createFailed, error.code = " + error.code)
59})
60
61
62// Take a screenshot of the current screen, the return value can be directly displayed on the control
63Screenshot.save().then(async (data) => {
64  if (!!data) {
65    show();
66  }
67}).catch((err) => {
68  Log.showInfo(TAG, `save err`);
69})
70
71```
72
73## Relevant warehouse
74
75Relevant warehouse
76
77**applications\_screenshot**