如何将Flutter画布另存为位图图像? [英] How to save a Flutter canvas as a bitmap image?

查看:91
本文介绍了如何将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?

非常感谢!

推荐答案

  1. 创建 PictureRecorder .
  2. PictureRecorder创建 Canvas 并画东西.
  3. PictureRecorder上调用 endRecording() 来得到 Picture .
  4. Picture上调用 toImage() .
  5. Image 上调用toByteData().糟糕,此功能尚未实现.我提交了问题.
  1. Create a PictureRecorder.
  2. Create a Canvas with your PictureRecorder and draw stuff.
  3. Call endRecording() on the PictureRecorder to get a Picture.
  4. Call toImage() on the Picture.
  5. Call toByteData() on the Image. Oops, this isn't implemented yet. I filed an issue.

这篇关于如何将Flutter画布另存为位图图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆