cropImage function
Future<MaskForCameraViewResult>
cropImage(
- Image image, {
- required Rect flutterBoxRect,
- required Size desiredSize,
- MaskForCameraViewInsideLine? insideLine,
Implementation
Future<MaskForCameraViewResult> cropImage(Image image,
{required ui.Rect flutterBoxRect,
required ui.Size desiredSize,
MaskForCameraViewInsideLine? insideLine}) async {
ui.Rect imageRect = flutterToImageRect(flutterBoxRect, image);
Image croppedImage = copyCrop(image, imageRect.left.toInt(),
imageRect.top.toInt(), imageRect.width.toInt(), imageRect.height.toInt());
Image resizedImage =
copyResize(croppedImage, width: desiredSize.width.toInt());
List<int> resizedList = encodeJpg(resizedImage);
Uint8List resizedBytes = Uint8List.fromList(resizedList);
MaskForCameraViewResult res =
MaskForCameraViewResult(croppedImage: resizedBytes);
if (insideLine != null) {
MaskForCameraViewResult halfRes = await _cropHalfImage(
croppedImage, insideLine,
desiredSize: desiredSize);
res.copyFrom(halfRes);
}
return res;
}