Converting a plain Uint8List to image widget

470 views
Skip to first unread message

bimBamBom

unread,
Jun 7, 2021, 7:39:44 AM6/7/21
to Flutter Development (flutter-dev)

I'm new to Flutter and I have a question regarding a small project of mine.

I'm trying to show an image I'm receiving through a socket. I have an Uint8List representing the image matrix (not encoded in any way), and I have succeded transforming it into an Image widget with the following code:

Image im = Image.fromBytes(1280, 1024, frameData, format: Format.luminance); var jpgImage = encodeJpg(im); . . //In Widget: return Image.memory(jpgImage, gaplessPlayback: true);

and it works, but it takes too much time. I see that the encodeJpg function takes at least 150ms, which is too much for me because each such image is a part of a streaming video.

My question is, how can I transform a plain(not encoded) Uint8List - representing a regular matrix, 0-256 values, to an Image widget, in the most efficient way?

Thank you!

Reply all
Reply to author
Forward
0 new messages