cropImageDataWithNativeLibrary function
Crop image data using a native library.
This function crops image data using a native library for platforms other than web and desktop.
Parameters:
- Various parameters for image cropping and editing.
Returns: A Future that resolves to a Uint8List containing the cropped image data.
Example Usage: Not typically used directly; it's an internal implementation for specific platforms.
Implementation
Future<Uint8List?> cropImageDataWithNativeLibrary({
required Uint8List rawImage,
required EditActionDetails editAction,
required Rect cropRect,
required int imageWidth,
required int imageHeight,
required bool isExtendedResizeImage,
}) async {
if (isExtendedResizeImage) {
cropRect = await _getCropRect(
cropRect: cropRect,
imageHeight: imageHeight,
imageWidth: imageWidth,
rawImage: rawImage,
);
}
final EditActionDetails action = editAction;
final int rotateAngle = action.rotateAngle.toInt();
final bool flipHorizontal = action.flipY;
final bool flipVertical = action.flipX;
final Uint8List img = rawImage;
final ImageEditorOption option = ImageEditorOption();
if (action.needCrop) {
option.addOption(ClipOption.fromRect(cropRect));
}
if (action.needFlip) {
option.addOption(
FlipOption(horizontal: flipHorizontal, vertical: flipVertical));
}
if (action.hasRotateAngle) {
option.addOption(RotateOption(rotateAngle));
}
final Uint8List? result = await ImageEditor.editImage(
image: img,
imageEditorOption: option,
);
return result;
}