captureRawImageF method Null safety

List<RawSample> captureRawImageF(
  1. RawImageF image
)

Implementation

List<RawSample> captureRawImageF(RawImageF image) {
  final cap = _dll_handle.lookupFunction<_CapCap_c, _CapCap_dart>(_c_namespace + 'Capturer_capture_raw_image_with_crop');
  Pointer<Pointer<Void>> _emptyPointerList = malloc.allocate(sizeOf<Pointer<Pointer<Void>>>() * 100);
  Pointer<Pointer<Void>> exception = _getException();

  List<int> addressBefore = new List<int>.generate(100, (i) => _emptyPointerList[i].address);

  cap(
      _impl,
      image.data.cast(),
      image.width,
      image.height,
      image.format.index,
      image.with_crop,
      image.crop_info_offset_x,
      image.crop_info_offset_y,
      image.crop_info_data_image_width,
      image.crop_info_data_image_height,
      _emptyPointerList.cast(),
      Pointer.fromFunction(_assign_pointers_vector_func),
      exception);
  checkException(exception, _dll_handle);

  List<RawSample> rss = [];

  for (var i = 0; i < 100; i++) {
    if (addressBefore[i] != _emptyPointerList[i].address)
      rss.add(RawSample(_dll_handle, _emptyPointerList[i]));
    else
      break;
  }

  malloc.free(_emptyPointerList);

  return rss;
}