imencodeVec function

(bool, VecUChar) imencodeVec(
  1. String ext,
  2. InputArray img, {
  3. VecI32? params,
})

Same as imencode but returns VecUChar

Implementation

(bool, VecUChar) imencodeVec(
  String ext,
  InputArray img, {
  VecI32? params,
}) {
  final buffer = VecUChar();
  final pSuccess = calloc<ffi.Bool>();
  final cExt = ext.toNativeUtf8().cast<ffi.Char>();

  params == null
      ? cvRun(() => cimgcodecs.cv_imencode(cExt, img.ref, pSuccess, buffer.ptr, ffi.nullptr))
      : cvRun(() => cimgcodecs.cv_imencode_1(cExt, img.ref, params.ref, pSuccess, buffer.ptr, ffi.nullptr));
  final success = pSuccess.value;
  calloc.free(cExt);
  calloc.free(pSuccess);

  return (success, buffer);
}