imwriteAsync function

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

IMWrite writes a Mat to an image file.

For further details, please see: http://docs.opencv.org/master/d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce

Implementation

Future<bool> imwriteAsync(String filename, InputArray img, {VecI32? params}) async {
  final cname = filename.toNativeUtf8().cast<ffi.Char>();
  final rval = cvRunAsync<bool>(
    (callback) => params == null
        ? cffi.Image_IMWrite_Async(cname, img.ref, callback)
        : cffi.Image_IMWrite_WithParams_Async(cname, img.ref, params.ref, callback),
    (c, p) {
      final rval = p.cast<ffi.Bool>().value;
      calloc.free(p);
      return c.complete(rval);
    },
  );
  calloc.free(cname);
  return rval;
}