更新代码

Signed-off-by: username <1037761763@qq.com>
This commit is contained in:
username 2022-04-11 10:59:35 +08:00
parent bb24ae5160
commit 31ed642e1a
5 changed files with 8 additions and 6 deletions

View File

@ -30,7 +30,7 @@ ScreenShot应用是OpenHarmony中预置的系统应用为用户提供截取
├── product # ScreenShot总体功能目录 ├── product # ScreenShot总体功能目录
``` ```
###功能描述 ### 功能描述
#### features #### features
子组件目录,提供截屏窗口显示控制,图片保存控制。 子组件目录,提供截屏窗口显示控制,图片保存控制。

View File

@ -26,15 +26,17 @@ const TAG = 'ScreenShot-ScreenShotModel';
const SCREEN_SHOT_PATH = "Screenshots/"; const SCREEN_SHOT_PATH = "Screenshots/";
const SCREENSHOT_PREFIX = "Screenshot"; const SCREENSHOT_PREFIX = "Screenshot";
const PICTURE_TYPE = ".jpg"; const PICTURE_TYPE = ".jpg";
const SAVE_IMAGE_DELAY = 500; const SAVE_IMAGE_DELAY = 300;
const OPTIONS_QUALITY = 100; const OPTIONS_QUALITY = 100;
const CREATE_WINDOW_DELAY = 300;
export class ScreenShotModel { export class ScreenShotModel {
captureImage: any = null; captureImage: any;
imageFilename: string = ''; imageFilename: string = '';
shotScreen() { async shotScreen() {
Log.showInfo(TAG, `shotScreen`) Log.showInfo(TAG, `shotScreen`)
await new Promise((resolve) => setTimeout(resolve, CREATE_WINDOW_DELAY));
ScreenshotManager.save().then(async (data) => { ScreenshotManager.save().then(async (data) => {
Log.showInfo(TAG, `ScreenshotManager.save data:${JSON.stringify(data)}`) Log.showInfo(TAG, `ScreenshotManager.save data:${JSON.stringify(data)}`)
if (!!data) { if (!!data) {
@ -56,7 +58,7 @@ export class ScreenShotModel {
var packer = ImageMar.createImagePacker(); var packer = ImageMar.createImagePacker();
Log.showInfo(TAG, `saveImage packer:${JSON.stringify(packer)}`); Log.showInfo(TAG, `saveImage packer:${JSON.stringify(packer)}`);
this.showWindow(); this.showWindow();
await new Promise((resolve) => setTimeout(resolve, SAVE_IMAGE_DELAY)) await new Promise((resolve) => setTimeout(resolve, SAVE_IMAGE_DELAY));
packer.packingFromPixelMap(pixelMap, options).then((jpegData) => { packer.packingFromPixelMap(pixelMap, options).then((jpegData) => {
Log.showInfo(TAG, `packing jpegData type:` + jpegData.constructor.name + ' value : ' + jpegData); Log.showInfo(TAG, `packing jpegData type:` + jpegData.constructor.name + ' value : ' + jpegData);
media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (err, rp) => { media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (err, rp) => {

View File

@ -21,7 +21,7 @@ const TAG = 'ScreenShot-Index';
@Entry @Entry
@Component @Component
struct Index { struct Index {
@StorageLink("captureImage") captureImage: any = undefined; @StorageLink("captureImage") captureImage: any = "";
@StorageLink("imageFilename") imageFilename: string = ""; @StorageLink("imageFilename") imageFilename: string = "";
build() { build() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.