From 1dee5f345b732fbd8c143580d8624fbf93922b1c Mon Sep 17 00:00:00 2001 From: zgf Date: Tue, 23 Jul 2024 16:34:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8E=BB=E9=99=A4READ=5FIMAGEVIDEO?= =?UTF-8?q?=E5=92=8CWRITE=5FIMAGEVIDEO=E6=9D=83=E9=99=90=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86heif=E5=9B=BE=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- CHANGELOG.md | 1 + .../main/ets/entryability/EntryAbility.ets | 22 +++++++------- .../main/ets/pages/dataShareUriLoadPage.ets | 29 +++++++------------ entry/src/main/module.json5 | 20 ------------- .../imageknife/utils/FileTypeUtil.ets | 2 +- 5 files changed, 23 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2d845..2a69d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 2.3.0-rc.2 - 加载优先级Priority类型改为taskpool.Priority类型 +- 修复部分heif图无法解码 ## 2.3.0-rc.1 - 修复file://格式图片无法显示 diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index ed07677..c460bb3 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -23,17 +23,17 @@ import { BusinessError } from '@ohos.base' export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage: window.WindowStage) { // Main window is created, set main page for this ability - let list: Array = ['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO']; - let permissionRequestResult: Object; - let atManager = abilityAccessCtrl.createAtManager(); - atManager.requestPermissionsFromUser(this.context, list, (err: BusinessError, result: Object) => { - if (err) { - - } else { - permissionRequestResult = result; - - } - }) + // let list: Array = ['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO']; + // let permissionRequestResult: Object; + // let atManager = abilityAccessCtrl.createAtManager(); + // atManager.requestPermissionsFromUser(this.context, list, (err: BusinessError, result: Object) => { + // if (err) { + // + // } else { + // permissionRequestResult = result; + // + // } + // }) windowStage.loadContent('pages/index', (err: BusinessError, data: void) => { }); diff --git a/entry/src/main/ets/pages/dataShareUriLoadPage.ets b/entry/src/main/ets/pages/dataShareUriLoadPage.ets index 75b0482..26cd7f7 100644 --- a/entry/src/main/ets/pages/dataShareUriLoadPage.ets +++ b/entry/src/main/ets/pages/dataShareUriLoadPage.ets @@ -36,25 +36,16 @@ struct DataShareUriLoadPage { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button("点击加载Uri并展示") .onClick(async () => { - const context = getContext(this) - let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context) - let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates - let fetchOptions: photoAccessHelper.FetchOptions = { - fetchColumns:[], - predicates:predicates - } - let fetchResult = await phAccessHelper.getAssets(fetchOptions) - if(fetchResult != undefined) { - console.info("fetchResult success") - let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject() - if(photoAsset != undefined) { - console.info("photoAsset.displayName :"+photoAsset.displayName) - this.imageKnifeOption1 = { - loadSrc: photoAsset.uri, - placeholderSrc:$r('app.media.icon_loading'), - errorholderSrc: $r('app.media.icon_failed') - } - } + let photoSelectOptions = new photoAccessHelper.PhotoSelectOptions(); + photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; + photoSelectOptions.maxSelectNumber = 1; + let uris: Array = []; + let photoViewPicker = new photoAccessHelper.PhotoViewPicker(); + let photoSelectResult: photoAccessHelper.PhotoSelectResult = await photoViewPicker.select(photoSelectOptions); + uris = photoSelectResult.photoUris; + this.imageKnifeOption1 = { + loadSrc: uris[0], + placeholderSrc:$r('app.media.loading') } }).margin({ top: 5, left: 3 }) ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(300).height(300) diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 4604944..c83bbef 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -50,26 +50,6 @@ ], "when": "always" } - }, - { - "name": "ohos.permission.READ_IMAGEVIDEO", - "reason": "$string:app_permission_READ_IMAGEVIDEO", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "always" - } - }, - { - "name": "ohos.permission.WRITE_IMAGEVIDEO", - "reason": "$string:app_permission_WRITE_IMAGEVIDEO", - "usedScene": { - "abilities": [ - "EntryAbility" - ], - "when": "always" - } } ] } diff --git a/library/src/main/ets/components/imageknife/utils/FileTypeUtil.ets b/library/src/main/ets/components/imageknife/utils/FileTypeUtil.ets index 78e1cd7..991d837 100644 --- a/library/src/main/ets/components/imageknife/utils/FileTypeUtil.ets +++ b/library/src/main/ets/components/imageknife/utils/FileTypeUtil.ets @@ -26,7 +26,7 @@ export class FileTypeUtil { 'webp': [new Uint8Array([0x52, 0x49, 0x46, 0x46])], 'tiff': [new Uint8Array([0x49, 0x20, 0x49]), new Uint8Array([0x49, 0x49, 0x2A, 0x00]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2A]), new Uint8Array([0x4D, 0x4D, 0x00, 0x2B])], // 添加更多的文件类型和特征 - 'heic': [new Uint8Array([0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00])], + 'heic': [new Uint8Array([0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00]),new Uint8Array([0x00, 0x00, 0x00, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00])], }; From 7101a262673a8f3fdfbb6ea97cb7e5ba9f29bb79 Mon Sep 17 00:00:00 2001 From: zgf Date: Wed, 24 Jul 2024 10:01:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E9=99=A4READ=5FIMAGEVIDEO?= =?UTF-8?q?=E5=92=8CWRITE=5FIMAGEVIDEO=E6=9D=83=E9=99=90=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86heif=E5=9B=BE=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- entry/src/main/ets/pages/dataShareUriLoadPage.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/dataShareUriLoadPage.ets b/entry/src/main/ets/pages/dataShareUriLoadPage.ets index 26cd7f7..b3fe696 100644 --- a/entry/src/main/ets/pages/dataShareUriLoadPage.ets +++ b/entry/src/main/ets/pages/dataShareUriLoadPage.ets @@ -45,7 +45,7 @@ struct DataShareUriLoadPage { uris = photoSelectResult.photoUris; this.imageKnifeOption1 = { loadSrc: uris[0], - placeholderSrc:$r('app.media.loading') + placeholderSrc:$r('app.media.icon_loading') } }).margin({ top: 5, left: 3 }) ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(300).height(300)