mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-23 00:20:07 +00:00
!4924 【Sample】 Image编译报错修复以及README修正
Merge pull request !4924 from YangXin/master-Image1105
This commit is contained in:
commit
6fa3efc00a
@ -88,7 +88,7 @@ photomodify/src/main/ets/components
|
||||
|
||||
+ 图片编辑功能在EditImage中实现,源码参考[EditImage.ets](photomodify%2Fsrc%2Fmain%2Fets%2Fcomponents%2Fpages%2FEditImage.ets):
|
||||
+ 图片编辑:图片编辑权限需要使用[requestPermissionsFromUser](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9)
|
||||
申请,源码参考[MainAbility.ts](entry/src/main/ets/MainAbility/MainAbility.ts)
|
||||
申请,源码参考[MainAbility.ets](entry/src/main/ets/MainAbility/MainAbility.ets)
|
||||
,首先根据选择图片获取到的uri打开图片文件,fileAsset.open选择‘rw'读写模式,然后使用image.createImageSource创建图片源实例,接下来使用createPixelMap创建PixelMap对象,便于处理图片,最后使用crop对图像进行裁剪处理,使用scale对图像进行缩放处理,rotate进行旋转处理。亮度调节使用effectKit.getHighestSaturationColor()
|
||||
接口实现对图片的高亮调节。图片解码通过createPixelMap(DecodingOptions),并根据DecodingOptions构造参数里面的设定值(0: auto;1: SDR;2 HDR),对应创建不同的PixelMap对象。其中设置值为AUTO时,会根据图片本身结构来判断是否解码为HDR内容。添加文字/贴纸,编辑模式下,使用组件组合(Image、Shape、Text)进行交互完成素材大小和位置选择;编辑确认后,再使用OffscreenCanvasRenderingContext2D进行离屏绘制,保存为新的pixelMap。
|
||||
|
||||
@ -122,9 +122,9 @@ photomodify/src/main/ets/components
|
||||
|
||||
|
||||
|
||||
[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media)
|
||||
[ohos.permission.READ_IMAGEVIDEO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionread_imagevideo)
|
||||
|
||||
[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media)
|
||||
[ohos.permission.WRITE_IMAGEVIDEO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionread_imagevideo)
|
||||
|
||||
[ohos.permission.MEDIA_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmedia_location)
|
||||
|
||||
|
@ -15,12 +15,16 @@
|
||||
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
||||
import { logger } from '../../../../../photomodify/src/main/ets/components/util/Logger';
|
||||
import { logger } from '@ohos/photomodify';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import { AbilityConstant } from '@kit.AbilityKit';
|
||||
import { window } from '@kit.ArkUI';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
const TAG: string = '[Sample_MainAbility]';
|
||||
|
||||
export default class MainAbility extends UIAbility {
|
||||
onCreate(want, launchParam): void {
|
||||
onCreate(want :Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
globalThis.mainContext = this.context;
|
||||
logger.info(TAG, '[Demo] MainAbility onCreate');
|
||||
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
|
||||
@ -29,7 +33,7 @@ export default class MainAbility extends UIAbility {
|
||||
['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO', 'ohos.permission.MEDIA_LOCATION'])
|
||||
.then((data) => {
|
||||
logger.info(TAG, `data: ${JSON.stringify(data)}`);
|
||||
}).catch((err) => {
|
||||
}).catch((err: BusinessError) => {
|
||||
logger.info(TAG, `err: ${JSON.stringify(err)}`);
|
||||
})
|
||||
} catch (err) {
|
||||
@ -41,7 +45,7 @@ export default class MainAbility extends UIAbility {
|
||||
logger.info(TAG, '[Demo] MainAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage): void {
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
logger.info(TAG, '[Demo] MainAbility onWindowStageCreate');
|
||||
|
@ -35,7 +35,7 @@
|
||||
"abilities": [
|
||||
{
|
||||
"name": "MainAbility",
|
||||
"srcEntry": "./ets/MainAbility/MainAbility.ts",
|
||||
"srcEntry": "./ets/MainAbility/MainAbility.ets",
|
||||
"description": "$string:MainAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:MainAbility_label",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -25,7 +25,7 @@
|
||||
"ohos": {
|
||||
"org": ""
|
||||
},
|
||||
"main": "index.ets",
|
||||
"main": "Index.ets",
|
||||
"repository": {},
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
|
@ -16,7 +16,7 @@ import image from '@ohos.multimedia.image';
|
||||
import fs from '@ohos.file.fs';
|
||||
import fileIo from '@ohos.file.fs';
|
||||
import { logger } from '../util/Logger';
|
||||
import { AppLog } from '../Model/log';
|
||||
import { AppLog } from '../model/log';
|
||||
import ndkTest from 'libentry.so'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
|
||||
@ -161,7 +161,7 @@ export class ImageTest {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private logger = new AppLog(`[Sample_Picture_File]`);
|
||||
private logger: AppLog = new AppLog(`[Sample_Picture_File]`);
|
||||
|
||||
// 将rawFile中的文件写到沙箱中
|
||||
async writeFileToBox(fileName: string): Promise<string> {
|
||||
|
Loading…
Reference in New Issue
Block a user