cutFaceImage method Null safety
- ImageFormatCode imageFormat,
- FaceCutType cutType
Crop the face and save in the specified format.
imageFormat
- Image encoding format.
cutType
- Face cropping types.
Implementation
Uint8List cutFaceImage(ImageFormatCode imageFormat, FaceCutType cutType) {
final exception = _getException();
Pointer<Int32> widthPtr = malloc.allocate(sizeOf<Pointer<Int32>>());
Pointer<Int32> heightPtr = malloc.allocate(sizeOf<Pointer<Int32>>());
PointerBuffer<Uint8> buffer = PointerBuffer<Uint8>.empty(sizeOf<Uint8>());
if(widthPtr.address == nullptr.address || heightPtr.address == nullptr.address)
throw Exception("RawSample.cutFaceImage: Failed to allocate a ${sizeOf<Pointer<Int32>>()} bytes");
final get = _dll_handle.lookupFunction<_RScutFaceImage_c, _RScutFaceImage_dart>
(_c_namespace + 'RawSample_cutFaceImage');
get(
this._impl,
buffer.ptr.cast(),
Pointer.fromFunction(WrapBytesWrite.writeByteListFunc),
widthPtr,
heightPtr,
imageFormat.index,
-1,
cutType.index,
exception);
checkException(exception, _dll_handle);
// int width = widthPtr.value;
// int height = heightPtr.value;
Uint8List list = buffer.dataPtr<Uint8>().asTypedList(buffer.length);
Uint8List outData = Uint8List.fromList(list);
buffer.dispose();
malloc.free(widthPtr);
malloc.free(heightPtr);
return outData;
}