mirror of
https://gitee.com/openharmony/applications_screenshot
synced 2024-11-23 06:59:48 +00:00
update readme
Signed-off-by: lijinfengde123 <1037761763@qq.com>
This commit is contained in:
parent
c6706d3cfc
commit
e6bdfd251c
39
README.en.md
39
README.en.md
@ -1,39 +0,0 @@
|
||||
# ScreenShot<a name="ZH-CN_TOPIC_0000001103330836"></a>
|
||||
|
||||
- [Introduction](#section11660541593)
|
||||
- [Architecture diagram](#section125101832114213)
|
||||
- [Contents](#section161941989596)
|
||||
- [Signature package](#section1371113476308)
|
||||
- [Related warehouse](#section1371113476307)
|
||||
|
||||
## Introduction<a name="section11660541593"></a>
|
||||
|
||||
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.
|
||||
|
||||
## content<a name="section161941989596"></a>
|
||||
|
||||
```
|
||||
/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
|
||||
|
||||
```
|
||||
|
||||
## Signature package <a name="section1371113476308"></a>
|
||||
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.
|
||||
|
||||
## Related warehouse<a name="section1371113476307"></a>
|
||||
|
||||
system applications
|
||||
|
||||
**applications\_screenshot**
|
65
README_EN.md
Normal file
65
README_EN.md
Normal file
@ -0,0 +1,65 @@
|
||||
# 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
|
||||
|
||||
![](figures/zh-cn_image.png)
|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
## 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
|
||||
windowManager.create(context, windowName, WINDOW_TYPE).then((win) => {
|
||||
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
|
||||
ScreenshotManager.save().then(async (data) => {
|
||||
if (!!data) {
|
||||
show();
|
||||
}
|
||||
}).catch((err) => {
|
||||
Log.showInfo(TAG, `save err`);
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
## Relevant warehouse
|
||||
|
||||
Relevant warehouse
|
||||
|
||||
**applications\_screenshot**
|
@ -1,16 +1,14 @@
|
||||
# ScreenShot<a name="ZH-CN_TOPIC_0000001103330836"></a>
|
||||
# ScreenShot
|
||||
|
||||
- [简介](#section11660541593)
|
||||
- [架构图](#section125101832114213)
|
||||
- [目录](#section161941989596)
|
||||
- [签名打包](#section1371113476308)
|
||||
- [相关仓](#section1371113476307)
|
||||
|
||||
## 简介<a name="section11660541593"></a>
|
||||
## 简介
|
||||
|
||||
ScreenShot应用是OpenHarmony中预置的系统应用,为用户提供截取当前屏幕,并保存当前图片的功能。
|
||||
|
||||
## 目录<a name="section161941989596"></a>
|
||||
### 架构图
|
||||
|
||||
![](figures/zh-cn_image.png)
|
||||
|
||||
## 目录
|
||||
|
||||
```
|
||||
/applications/standard/screenshot
|
||||
@ -26,12 +24,42 @@ ScreenShot应用是OpenHarmony中预置的系统应用,为用户提供截取
|
||||
├── product # ScreenShot总体功能目录
|
||||
```
|
||||
|
||||
## 签名打包<a name="section1371113476308"></a>
|
||||
## 签名
|
||||
1.针对product/phone下的每一个模块,配置build.gradle中的signingConfigs
|
||||
|
||||
2.将signature目录下的screenshot.p7b放在build.gradle目录中配置的相应路径即可
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
## 使用方法
|
||||
|
||||
通过create创建截屏小窗口用于显示图片,示例代码如下
|
||||
|
||||
```js
|
||||
// 创建截屏小窗口用于显示图片
|
||||
windowManager.create(context, windowName, WINDOW_TYPE).then((win) => {
|
||||
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)
|
||||
})
|
||||
|
||||
|
||||
// 截取当前屏幕,返回值可以直接显示控件上
|
||||
ScreenshotManager.save().then(async (data) => {
|
||||
if (!!data) {
|
||||
show();
|
||||
}
|
||||
}).catch((err) => {
|
||||
Log.showInfo(TAG, `save err`);
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
## 相关仓
|
||||
|
||||
系统应用
|
||||
|
@ -23,6 +23,9 @@ import display from '@ohos.display'
|
||||
|
||||
const TAG = 'ScreenShot-ScreenShotModel';
|
||||
|
||||
const SCREEN_SHOT_PATH = "Screenshots/";
|
||||
const SCREENSHOT_PREFIX = "Screenshot";
|
||||
const PICTURE_TYPE = ".jpg";
|
||||
const SAVE_IMAGE_DELAY = 500;
|
||||
const OPTIONS_QUALITY = 100;
|
||||
|
||||
@ -49,7 +52,7 @@ export class ScreenShotModel {
|
||||
async saveImage(pixelMap, options) {
|
||||
const media = mediaLibrary.getMediaLibrary(globalThis.shotScreenContext);
|
||||
Log.showInfo(TAG, `saveImage options:${JSON.stringify(options)}`);
|
||||
this.imageFilename = (new Date()).getTime() + '.jpg';
|
||||
this.imageFilename = SCREENSHOT_PREFIX + "_" + (new Date()).getTime() + PICTURE_TYPE;
|
||||
var packer = ImageMar.createImagePacker();
|
||||
Log.showInfo(TAG, `saveImage packer:${JSON.stringify(packer)}`);
|
||||
this.showWindow();
|
||||
@ -59,7 +62,7 @@ export class ScreenShotModel {
|
||||
media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (err, rp) => {
|
||||
if (rp != undefined) {
|
||||
Log.showInfo(TAG, `getPublicDirectory successfull:${JSON.stringify(rp)}`);
|
||||
media.createAsset(mediaLibrary.MediaType.IMAGE, this.imageFilename, rp, (createAssetErr, fileAsset) => {
|
||||
media.createAsset(mediaLibrary.MediaType.IMAGE, this.imageFilename, rp + SCREEN_SHOT_PATH, (createAssetErr, fileAsset) => {
|
||||
if (fileAsset != undefined) {
|
||||
Log.showInfo(TAG, `createAsset successfull:${JSON.stringify(fileAsset.uri)}`);
|
||||
fileAsset.open('Rw').then((fd) => {
|
||||
|
BIN
figures/zh-cn_image.png
Normal file
BIN
figures/zh-cn_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in New Issue
Block a user