ArkUI(eTS)如何实现本地图片保存?
ArkUI(eTS)如何实现本地图片保存?
鸿蒙java端代码
ImagePacker imagePacker = ImagePacker.create();
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "new.jpeg");
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(file);
} catch (FileNotFoundException e) {
}
ImagePacker.PackingOptions packingOptions = new ImagePacker.PackingOptions();
packingOptions.format = "image/jpeg";
packingOptions.quality = 100;// 设置图片质量
boolean result = imagePacker.initializePacking(outputStream, packingOptions);
result = imagePacker.addImage(pixelMap);
long dataSize = imagePacker.finalizePacking();
但是我想在ets上实现要怎么写???
可以参考一下接口:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-file-storag-0000000000629445#section979814398616