HarmonyOS heif图片无法显示?

版本:"@ohos/imageknife": "3.0.0"通过以下demo可以发现图片无法显示,但是使用image可以显示。

imgurl: string = 'heif网络图片资源地址'
@State
option: ImageKnifeOption = {
  loadSrc: this.imgurl
}

build() {
  Row() {
    Column() {
      Text(this.message)
        .fontSize(50)
        .fontWeight(FontWeight.Bold)
      ImageKnifeComponent({ imageKnifeOption: this.option })
        .width(100)
        .height(100)
      Image(this.imgurl)
        .objectFit(ImageFit.Contain)
        .width(100)
        .height(100)
    }
    .width('100%')
  }
  .height('100%')
}
阅读 514
1 个回答

网络下载成功后在获取图片格式时,拿到的格式是null之后直接返回了错误信息。FileTypeUtil.ets文件文件头部魔数匹配那块,heic格式未匹配成功,这张图片的前四位是0,0,0,28,在heic后面复制一个unit8;将第四位改成0x1C之后能加载成功。