imencode function
imencode encodes an image Mat into a memory buffer. This function compresses the image and stores it in the returned memory buffer, using the image format passed in in the form of a file extension string.
For further details, please see: http://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga461f9ac09887e47797a54567df3b8b63
Implementation
(bool, Uint8List) imencode(
String ext,
InputArray img, {
VecI32? params,
}) {
final (success, vec) = imencodeVec(ext, img, params: params);
final u8List = vec.toU8List(); // will copy data
vec.dispose();
return (success, u8List);
}