convertImagetoPng function
Implementation
Future<List<int>?> convertImagetoPng(CameraImage image) async {
try {
imglib.Image? img;
if (image.format.group == ImageFormatGroup.yuv420) {
img = _convertToYUV420(image);
} else if (image.format.group == ImageFormatGroup.bgra8888) {
img = _convertToBGRA8888(image);
}
imglib.PngEncoder pngEncoder = imglib.PngEncoder();
// Convert to png
List<int> png = pngEncoder.encodeImage(img!);
return png;
} catch (e) {
if (kDebugMode) {
log(">>>>>>>>>>>> ERROR:" + e.toString());
}
}
return null;
}