getCropRect method
Implementation
Rect? getCropRect() {
if (widget.extendedImageState.extendedImageInfo?.image == null ||
_editActionDetails == null) {
return null;
}
Rect? cropScreen = _editActionDetails!.screenCropRect;
Rect? imageScreenRect = _editActionDetails!.screenDestinationRect;
if (cropScreen == null || imageScreenRect == null) {
return null;
}
imageScreenRect = _editActionDetails!.paintRect(imageScreenRect);
cropScreen = _editActionDetails!.paintRect(cropScreen);
//move to zero
cropScreen = cropScreen.shift(-imageScreenRect.topLeft);
imageScreenRect = imageScreenRect.shift(-imageScreenRect.topLeft);
final ui.Image image = widget.extendedImageState.extendedImageInfo!.image;
// var size = _editActionDetails.isHalfPi
// ? Size(image.height.toDouble(), image.width.toDouble())
// : Size(image.width.toDouble(), image.height.toDouble());
final Rect imageRect =
Offset.zero & Size(image.width.toDouble(), image.height.toDouble());
final double ratioX = imageRect.width / imageScreenRect.width;
final double ratioY = imageRect.height / imageScreenRect.height;
final Rect cropImageRect = Rect.fromLTWH(
cropScreen.left * ratioX,
cropScreen.top * ratioY,
cropScreen.width * ratioX,
cropScreen.height * ratioY);
return cropImageRect;
}