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?
Asked
Active
Viewed 7,236 times
9
-
it has been [implemented](https://github.com/flutter/engine/commit/b6f466b344108731e26dbdf44a11a3c98d70f696), you can now follow all the Collin's steps. – RX Labz Apr 09 '18 at 17:11
-
This answer might help https://stackoverflow.com/questions/50320479/flutter-how-would-one-save-a-canvas-custompainter-to-an-image-file/52279202#answer-52279202 – Aravind Vemula Sep 11 '18 at 15:52
-
https://stackoverflow.com/questions/50320479/flutter-how-would-one-save-a-canvas-custompainter-to-an-image-file/52279202#answer-52279202 this answer may help – Aravind Vemula Sep 11 '18 at 15:53
1 Answers
12
- 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
.

Suragch
- 484,302
- 314
- 1,365
- 1,393

Collin Jackson
- 110,240
- 31
- 221
- 152