如何将Flutter画布另存为位图图像? [英] How to save a Flutter canvas as a bitmap image?
本文介绍了如何将Flutter画布另存为位图图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Flutter 画布,我d想将该画布另存为位图图像(例如PNG,但是可以使用任何常见的位图格式).将画布中的位转换为位图图像格式的最佳方法是什么?
I have a Flutter canvas , and I'd like to save that canvas as a bitmap image (e.g. PNG, but any common bitmap format will do). What's the best way to get the bits out of a canvas, converted to a bitmap image format?
非常感谢!
推荐答案
- 创建
PictureRecorder
. - 用
PictureRecorder
创建Canvas
并画东西. - 在
PictureRecorder
上调用endRecording()
来得到Picture
. - 在
Picture
上调用toImage()
. - 在
Image
上调用toByteData()
.糟糕,此功能尚未实现.我提交了问题.
- Create a
PictureRecorder
. - Create a
Canvas
with yourPictureRecorder
and draw stuff. - Call
endRecording()
on thePictureRecorder
to get aPicture
. - Call
toImage()
on thePicture
. - Call
toByteData()
on theImage
. Oops, this isn't implemented yet. I filed an issue.
这篇关于如何将Flutter画布另存为位图图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文