imwrite function

bool imwrite(
  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

bool imwrite(String filename, InputArray img, {VecI32? params}) {
  return using<bool>((arena) {
    final fname = filename.toNativeUtf8(allocator: arena);
    final p = arena<ffi.Bool>();
    if (params == null) {
      cvRun(() => cffi.Image_IMWrite(fname.cast(), img.ref, p));
    } else {
      cvRun(
        () => cffi.Image_IMWrite_WithParams(
          fname.cast(),
          img.ref,
          params.ref,
          p,
        ),
      );
    }
    return p.value;
  });
}