Is there any straightforward way in Flutter that I could display an image each frame whose pixel data is directly controlled by logic in the program? As an analogy, in Java, we have the BufferedImage
whose pixel data can be directly manipulated by the programmer and can be updated in the display each frame. Or in SDL, we can make a surface whose pixel data is a read/write-able region of memory to achieve a similar effect. Is there anything remotely similar in Flutter? The next-best thing I can find so far in Flutter is constructing a BMP image as a Uint8List
and passing it to Image.memory
, but this function seems to take a considerable amount of time (10-20 ms?) to construct even a very small viewable image from the raw data before it appears on-screen. Before this it is simply blank, which would cause flickering in any real application. I am also concerned with how slow it is even for small images, which may render techniques like double-buffering, which may resolve flickering, still unhelpful for larger images. Is there anything like a way to modify the underlying image data of an Image
object, so I can change the raw pixel data without needing to construct a whole new Image
?
Asked
Active
Viewed 129 times
1

user2649681
- 750
- 1
- 6
- 23
1 Answers
0
(note - I would have put this in as a comment but I don't have enough reputation points, sorry about that)
you can also use The dart:ui function decodeImageFromPixels which takes Uint8List as input but for a full screen this is also slow (on iPad 1366 by 1024, generation 4 iPad) it takes around 25mSec. I was hoping to use isolates and then break up the screen into say 4 to increase this time to something usable. decodeImageFromPixels doesn't allow me to do this for an unknown reason, so I have been looking at creating a BMP (as you suggest), but from your comment about Image.memory being slow this also might not be an option.

Paul Cardno
- 41
- 5