Implementation
RawImageF convertYUV2RGB(RawImageF image, {required int baseAngle, NativeDataStruct? reusableData}) {
final exception = _getException();
final convertYUV2RGBConstructor =
_dll_handle.lookupFunction<_RawImage_convertYUV2RGB_c, _RawImage_convertYUV2RGB_dart>(
_c_namespace + 'RawImage_convertYUV2RGB');
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;
if (reusableData != null) {
if (reusableData.size != totalBytes) {
reusableData.resize(totalBytes);
}
} else {
data.resize(totalBytes);
}
RawImageF result =
RawImageF(width, height, Format.FORMAT_RGB, (reusableData == null ? data : reusableData).pointer!.cast());
convertYUV2RGBConstructor(
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,
0,
baseAngle,
result.data.cast(),
exception);
checkException(exception, _dll_handle);
return result;
}