ImageProcess.create constructor

ImageProcess.create({
  1. ImageFormat sourceFormat = ImageFormat.RGBA,
  2. ImageFormat destFormat = ImageFormat.RGBA,
  3. List<double>? means,
  4. List<double>? normals,
  5. Filter filterType = Filter.BILINEAR,
  6. Wrap wrap = Wrap.CLAMP_TO_EDGE,
  7. Tensor? dstTendor,
})

Implementation

factory ImageProcess.create({
  ImageFormat sourceFormat = ImageFormat.RGBA,
  ImageFormat destFormat = ImageFormat.RGBA,
  List<double>? means,
  List<double>? normals,
  Filter filterType = Filter.BILINEAR,
  Wrap wrap = Wrap.CLAMP_TO_EDGE,
  Tensor? dstTendor,
}) {
  final pMeans = means == null ? ffi.nullptr : calloc<ffi.Float>(means.length);
  final pNormals = normals == null ? ffi.nullptr : calloc<ffi.Float>(normals.length);
  if (pMeans != ffi.nullptr && means != null) {
    pMeans.asTypedList(means.length).setAll(0, means);
  }
  if (pNormals != ffi.nullptr && normals != null) {
    pNormals.asTypedList(normals.length).setAll(0, normals);
  }
  final dstPtr = dstTendor == null ? ffi.nullptr : dstTendor.ptr;
  final ptr = c.mnn_cv_image_process_create(
    sourceFormat.value,
    destFormat.value,
    pMeans,
    means?.length ?? 0,
    pNormals,
    normals?.length ?? 0,
    filterType.value,
    wrap.value,
    dstPtr,
  );
  calloc.free(pMeans);
  calloc.free(pNormals);
  return ImageProcess.fromPointer(ptr.cast());
}