ImageProcessConfig.create constructor

ImageProcessConfig.create({
  1. ImageFormat sourceFormat = ImageFormat.RGBA,
  2. ImageFormat destFormat = ImageFormat.RGBA,
  3. Filter filterType = Filter.NEAREST,
  4. Wrap wrap = Wrap.CLAMP_TO_EDGE,
  5. List<double>? mean,
  6. List<double>? normal,
})

Implementation

factory ImageProcessConfig.create({
  ImageFormat sourceFormat = ImageFormat.RGBA,
  ImageFormat destFormat = ImageFormat.RGBA,
  Filter filterType = Filter.NEAREST,
  Wrap wrap = Wrap.CLAMP_TO_EDGE,
  List<double>? mean,
  List<double>? normal,
}) {
  final ptr = calloc<c.mnn_image_process_config_t>()
    ..ref.sourceFormat = sourceFormat.value
    ..ref.destFormat = destFormat.value
    ..ref.filterType = filterType.value
    ..ref.wrap = wrap.value;
  if (mean != null) {
    if (mean.length > 4) {
      throw ArgumentError('mean.length=${mean.length} > 4');
    }
    for (var i = 0; i < mean.length; i++) {
      ptr.ref.mean[i] = mean[i];
    }
  }
  if (normal != null) {
    if (normal.length > 4) {
      throw ArgumentError('normal.length=${normal.length} > 4');
    }
    for (var i = 0; i < normal.length; i++) {
      ptr.ref.normal[i] = normal[i];
    }
  }
  return ImageProcessConfig.fromPointer(ptr.cast());
}