2022-03-11 05:07:54 +00:00
# ScreenShot
## Introduction
The 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.
### Architecture diagram
2022-03-11 06:33:30 +00:00
![](figures/en_diagram.png)
2022-03-11 05:07:54 +00:00
2022-03-12 03:34:04 +00:00
#### feature
Screen capture management layer, providing screen capture window display control and picture save control.
#### common
A general tool class that provides log printing and external interface management functions.
2022-03-11 05:07:54 +00:00
## content
```
/applications/standard/screenshot
├── entry # entry module directory
├── common # Common tool class directory
├── build.gradle # Global build configuration file
├── settings.gradle # Compile the module configuration file
├── LICENSE # License file
├── signature # Certificate file directory
├── features # subcomponent directory
│ ├── screenshot # screenshot component
│ ├── screenShotModel # Save screenshots, etc.
├── product # ScreenShot general function catalog
```
2022-03-12 03:34:04 +00:00
### Function description
#### features
sub-component directory, provides screen capture window display control, and image save control.
#### product
ScreenShot general function catalog, screenshot service entrance.
2022-03-11 05:07:54 +00:00
## sign
1. For each module under product/phone, configure signingConfigs in build.gradle
2. Put screenshot.p7b in the signature directory on the corresponding path configured in the build.gradle directory.
## Instructions
Create a small screen capture window to display pictures through create, the sample code is as follows
```js
// Create a small screen capture window to display pictures
2022-03-11 06:09:45 +00:00
window.create(context, windowName, WINDOW_TYPE).then((win) => {
2022-03-11 05:07:54 +00:00
win.moveTo(0, WINDOW_Y).then(() => {
win.resetSize(dis.width * ZOOM_RATIO, dis.height * ZOOM_RATIO).then(() => {
win.loadContent(INDEX_PAGE).then(() => {
})
})
})
}, (error) => {
Log.showInfo(TAG, " window createFailed, error.code = " + error.code)
})
// Take a screenshot of the current screen, the return value can be directly displayed on the control
2022-03-11 06:09:45 +00:00
Screenshot.save().then(async (data) => {
2022-03-11 05:07:54 +00:00
if (!!data) {
show();
}
}).catch((err) => {
Log.showInfo(TAG, `save err` );
})
```
## Relevant warehouse
Relevant warehouse
**applications\_screenshot**