processImageFromRgba function
Implementation
Future<VideoFrame> processImageFromRgba(VideoFrame frame) async {
Completer<ui.Image> callback = Completer<ui.Image>();
ui.PixelFormat? pixelFormat;
if (frame.format == ImageFormat.rgba) {
pixelFormat = ui.PixelFormat.rgba8888;
} else if (frame.format == ImageFormat.bgra) {
pixelFormat = ui.PixelFormat.bgra8888;
} else {
return frame;
}
ui.decodeImageFromPixels(
frame.content, frame.width, frame.height, pixelFormat, (ui.Image im) {
callback.complete(im);
});
frame.content = RawImage(image: await callback.future);
frame.format = ImageFormat.none;
return frame;
}