ImageProcess.create constructor
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,
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());
}