HarmonyOS PixelMap加载图片

我把网络地址转成PixelMap之后,gif不是动态的了,要怎么处理?

HarmonyOS
2024-12-27 16:12:49
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

方式一:直接使用本地uri展示 – 可以展示gif动态效果

this.imageUrl = fileUri.getUriFromPath(tempPath);
  • 1.

方式二:本地文件转为pixelMap展示

let file = fileIo.openSync(tempPath, fileIo.OpenMode.READ_ONLY);
let imageSource: image.ImageSource = image.createImageSource(file.fd);
let opts: image.InitializationOptions = {
  editable: false,
  pixelFormat: image.PixelMapFormat.RGBA_8888,
  alphaType: 0,
  size: { height: 100, width: 100 }
}
this.imageUrl1 = await imageSource.createPixelMap(opts);
}).catch((err: BusinessError) => {
  console.error(`Invoke downloadTask failed, code is ${err.code}, message is ${err.message}`);
});
} catch (error) {
  console.error(`Invoke downloadFile failed, error is ${JSON.stringify(error)}`);
}
}
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
分享
微博
QQ
微信
回复
2024-12-27 19:09:32


相关问题
HarmonyOS 获取网络图片PixelMap
773浏览 • 1回复 待解决
如何用PixelMap处理图片
3179浏览 • 1回复 待解决
PixelMap怎么保存成图片文件
1309浏览 • 1回复 待解决
HarmonyOS 网络图片如何转换成PixelMap
712浏览 • 1回复 待解决
HarmonyOS 图片资源加载
561浏览 • 1回复 待解决
HarmonyOS Image加载图片
650浏览 • 1回复 待解决
HarmonyOS 图片加载问题
702浏览 • 1回复 待解决
HarmonyOS WebView 延迟加载图片
747浏览 • 1回复 待解决
HarmonyOS Image图片无法加载
952浏览 • 1回复 待解决
怎么把PixelMap图片转BASE64
10379浏览 • 1回复 待解决
HarmonyOS图片加载框架ImageKnife
1159浏览 • 1回复 待解决
如何将图片PixelMap压缩到指定大小
2901浏览 • 1回复 待解决