合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
尝试将screenshot.capture 截屏后的 pixelMap 转码为 image再保存到相册,但并未成功,代码如下:
try {
let promise = screenshot.capture(captureOption);
promise.then((pixelMap: image.PixelMap) => {
console.info('Succeeded in saving screenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
console.info(JSON.stringify(pixelMap.getImageInfoSync()));
// 创建图片
let pictureObj: image.Picture = image.createPicture(pixelMap);
if (pictureObj != null) {
console.info('[图片] - 创建成功:' + JSON.stringify(pictureObj));
// 此处 pictureObj 为空 {}
pixelMap.release(); // PixelMap 使用完后及时释放内存
} else {
console.info('[图片] - 创建失败');
pixelMap.release(); // PixelMap 使用完后及时释放内存
}
pixelMap.release(); // PixelMap 使用完后及时释放内存
}).catch((err: BusinessError) => {
console.log('Failed to save screenshot. Code: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to save screenshot. Code: ' + JSON.stringify(exception));
}
我要提问题