encodeJpg function
Encodes an OpenCV image as a JPG with the given quality (from 0-100).
Implementation
OpenCVImage? encodeJpg(Pointer<Mat> image, {int quality = 100}) {
final bufferAddress = arena<Pointer<Uint8>>(); // (1)
final size = nativeLib.encodeJpg(image, quality, bufferAddress); // (2)
if (size == 0) throw ImageEncodeException();
final Pointer<Uint8> buffer = bufferAddress.value; // (3)
return OpenCVImage(pointer: buffer, length: size);
}