imwriteAsync function

Future<bool> imwriteAsync(
  1. String filename,
  2. InputArray img, {
  3. VecI32? params,
})

Implementation

Future<bool> imwriteAsync(String filename, InputArray img, {VecI32? params}) async {
  final fname = filename.toNativeUtf8().cast<ffi.Char>();
  final p = calloc<ffi.Bool>();
  void completeFunc(Completer<bool> c) {
    final rval = p.value;
    calloc.free(p);
    return c.complete(rval);
  }

  if (params == null) {
    return cvRunAsync0(
      (callback) => cimgcodecs.cv_imwrite(fname.cast(), img.ref, p, callback),
      completeFunc,
    );
  }
  return cvRunAsync0(
    (callback) => cimgcodecs.cv_imwrite_1(fname.cast(), img.ref, params.ref, p, callback),
    completeFunc,
  );
}