convertBGRA88882RGB method Null safety

RawImageF convertBGRA88882RGB(
  1. RawImageF image,
  2. {required int baseAngle}
)

Implementation

RawImageF convertBGRA88882RGB(RawImageF image, {required int baseAngle}) {
  final exception = _getException();
  final convertBGRA88882RGBConstructor =
      _dll_handle.lookupFunction<_RawImage_convertBGRA88882RGB_c, _RawImage_convertBGRA88882RGB_dart>(
          _c_namespace + 'RawImage_convertBGRA88882RGB');
  int width;
  int height;

  switch (baseAngle) {
    case 1:
    case 2:
      width = image.height;
      height = image.width;

      break;

    default:
      width = image.width;
      height = image.height;

      break;
  }

  NativeDataStruct data = NativeDataStruct();
  final int totalBytes = width * height * 3;

  data.resize(totalBytes);

  RawImageF result = RawImageF(width, height, Format.FORMAT_RGB, data.pointer!.cast());

  convertBGRA88882RGBConstructor(
      image.data.cast(), image.width, image.height, baseAngle, result.data.cast(), exception);

  checkException(exception, _dll_handle);

  return result;
}