!182 imageKnife支持heic图片

Merge pull request !182 from 袁莉/master
This commit is contained in:
openharmony_ci 2024-04-12 02:45:04 +00:00 committed by Gitee
commit ab7dd919f3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 27 additions and 2 deletions

View File

@ -32,6 +32,7 @@
<filteritem type="filename" name="*.jpg" desc="jpg图片格式文件,用于展示示例"/> <filteritem type="filename" name="*.jpg" desc="jpg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.jpeg" desc="jpeg图片格式文件,用于展示示例"/> <filteritem type="filename" name="*.jpeg" desc="jpeg图片格式文件,用于展示示例"/>
<filteritem type="filename" name="*.json5" desc="hvigor配置文件"/> <filteritem type="filename" name="*.json5" desc="hvigor配置文件"/>
<filteritem type="filename" name="*.heic" desc="heic图片格式文件,用于展示示例"/>
</filefilter> </filefilter>
<filefilter name="defaultFilter" desc="Files not to check"> <filefilter name="defaultFilter" desc="Files not to check">
<filteritem type="filepath" name="library/src/main/ets/components/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/> <filteritem type="filepath" name="library/src/main/ets/components/3rd_party/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>

View File

@ -45,6 +45,15 @@ struct IndexFunctionDemo {
headerOption: [this.headerOptions1] headerOption: [this.headerOptions1]
}; };
@State imageKnifeOption3: ImageKnifeOption =
{
loadSrc: $r('app.media.yunHeic'),
placeholderSrc: $r('app.media.icon_loading'),
errorholderSrc: $r('app.media.icon_failed'),
};
@State flag: boolean = true;
build() { build() {
Scroll() { Scroll() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
@ -84,6 +93,15 @@ struct IndexFunctionDemo {
router.pushUrl({ url: "pages/imageknifeTestCaseIndex" }); router.pushUrl({ url: "pages/imageknifeTestCaseIndex" });
}).margin({ top: 15 }) }).margin({ top: 15 })
}.width('100%').height(60).backgroundColor(Color.Pink) }.width('100%').height(60).backgroundColor(Color.Pink)
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button("heic图片测试")
.onClick(() => {
this.flag = !this.flag
}).margin({ top: 15 })
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption3 }).width(300).height(300)
.visibility(this.flag ? Visibility.Hidden : Visibility.Visible)
}.width('100%').height(60).backgroundColor(Color.Pink)
} }
} }
.width('100%') .width('100%')

Binary file not shown.

View File

@ -61,6 +61,7 @@ export class ErrorHolderManager<T> {
case SupportFormat.gif: case SupportFormat.gif:
case SupportFormat.tiff: case SupportFormat.tiff:
case SupportFormat.webp: case SupportFormat.webp:
case SupportFormat.heic:
this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue) this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue)
break; break;
default: default:

View File

@ -63,6 +63,7 @@ export class PlaceHolderManager<T> {
case SupportFormat.gif: case SupportFormat.gif:
case SupportFormat.tiff: case SupportFormat.tiff:
case SupportFormat.webp: case SupportFormat.webp:
case SupportFormat.heic:
this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue) this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue)
break; break;
default: default:

View File

@ -60,6 +60,7 @@ export class RetryHolderManager<T> {
case SupportFormat.gif: case SupportFormat.gif:
case SupportFormat.tiff: case SupportFormat.tiff:
case SupportFormat.webp: case SupportFormat.webp:
case SupportFormat.heic:
this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue) this.mediaImageProcess(onComplete, onError, arraybuffer, typeValue)
break; break;
default: default:

View File

@ -26,6 +26,7 @@ export class FileTypeUtil {
'webp': [new Uint8Array([0x52, 0x49, 0x46, 0x46])], '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])], '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])],
}; };
@ -41,7 +42,8 @@ export class FileTypeUtil {
value == SupportFormat.webp || value == SupportFormat.webp ||
value == SupportFormat.bmp || value == SupportFormat.bmp ||
value == SupportFormat.gif || value == SupportFormat.gif ||
value == SupportFormat.svg value == SupportFormat.svg ||
value == SupportFormat.heic
) { ) {
return true; return true;
} }
@ -106,5 +108,6 @@ export enum SupportFormat {
bmp = 'bmp', bmp = 'bmp',
gif = 'gif', gif = 'gif',
svg = 'svg', svg = 'svg',
tiff = 'tiff' tiff = 'tiff',
heic = 'heic'
} }