HarmonyOS 怎么将获取的pixelMap转为图片存入沙箱?

HarmonyOS 怎么将获取的pixelMap转为图片存入沙箱?

HarmonyOS
2024-11-13 10:44:18
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

​使用packToFile 接口,文档参考 :

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-image-V5#ZH-CN_TOPIC_0000001847051024__packtofile11

let imageFile = fs.openSync(getContext().tempDir+"/VID_1716862918_000.jpg", fs.OpenMode.READ_WRITE|fs.OpenMode.CREATE) 
image.createImagePacker().packToFile(this.pixelMap, imageFile.fd, { 
  format: "image/jpeg", 
  quality: 100 
}).then(res => { 
  console.log('asdasdsd') 
}).catch((err: BusinessError) => { 
  console.log("-----"+JSON.stringify(err)) 
}) 
fs.closeSync(imageFile);
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
分享
微博
QQ
微信
回复
2024-11-13 15:39:03
相关问题
HarmonyOS 如何PixelMap保存为沙箱
939浏览 • 1回复 待解决
ets中如何图片转为byte[]?
4256浏览 • 1回复 待解决
HarmonyOS 获取网络图片PixelMap
796浏览 • 1回复 待解决
PixelMap怎么保存成图片文件
1338浏览 • 1回复 待解决
如何图片PixelMap压缩到指定大小
2907浏览 • 1回复 待解决
怎么PixelMap图片转BASE64
10387浏览 • 1回复 待解决
有谁知道沙箱目录怎么获取
3536浏览 • 1回复 待解决