解决方案:窗口有提供屏幕截图的接口参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-window-0000001820880785\#ZH-CN\_TOPIC\_0000001820880785\_\_snapshot9组件有对应的组件截图的接口参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-arkui-componentsnapshot-0000001774121118返回接口都是PixelMap要将PixelMap保存到系统相册中1.首先对pixelMap进行编码成不同格式的存档图片(当前仅支持打包为JPEG、WebP 和 png 格式)参考https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/image-encoding-0000001630145941-V12.然后获取截屏或录屏的相册对象 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/photoaccesshelper-systemalbum-guidelines-0000001657675725-V1\#ZH-CN\_TOPIC\_0000001666548060\_\_获取截屏和录屏相册对象3.获取编码得到的存档图片 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/photoaccesshelper-resource-guidelines-0000001657835481-V14.用Album.addAssets往相册中添加图片 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-photoaccesshelper-0000001821001585\#ZH-CN\_TOPIC\_0000001821001585\_\_addassets-1
解决方案:
窗口有提供屏幕截图的接口参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-window-0000001820880785\#ZH-CN\_TOPIC\_0000001820880785\_\_snapshot9组件有对应的组件截图的接口参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-arkui-componentsnapshot-0000001774121118
返回接口都是PixelMap
要将PixelMap保存到系统相册中
1.首先对pixelMap进行编码成不同格式的存档图片(当前仅支持打包为JPEG、WebP 和 png 格式)参考https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/image-encoding-0000001630145941-V1
2.然后获取截屏或录屏的相册对象 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/photoaccesshelper-systemalbum-guidelines-0000001657675725-V1\#ZH-CN\_TOPIC\_0000001666548060\_\_获取截屏和录屏相册对象
3.获取编码得到的存档图片 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V1/photoaccesshelper-resource-guidelines-0000001657835481-V1
4.用Album.addAssets往相册中添加图片 参考 https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-photoaccesshelper-0000001821001585\#ZH-CN\_TOPIC\_0000001821001585\_\_addassets-1