Skip to content

Commit

Permalink
fix validation logic of cropping (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng committed Feb 25, 2024
1 parent c3d6b1c commit 505e12c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/src/logic/cropper/image_image_cropper.dart
Expand Up @@ -24,14 +24,14 @@ class ImageImageCropper extends ImageCropper<Image> {
ImageFormat outputFormat = ImageFormat.jpeg,
ImageShape shape = ImageShape.rectangle,
}) {
if (topLeft.dx < 0 ||
topLeft.dy < 0 ||
bottomRight.dx < 0 ||
bottomRight.dy < 0 ||
topLeft.dx > original.width.toDouble() ||
topLeft.dy > original.height.toDouble() ||
bottomRight.dx > original.width.toDouble() ||
bottomRight.dy > original.height.toDouble()) {
if (topLeft.dx.isNegative ||
topLeft.dy.isNegative ||
bottomRight.dx.isNegative ||
bottomRight.dy.isNegative ||
topLeft.dx.toInt() > original.width ||
topLeft.dy.toInt() > original.height ||
bottomRight.dx.toInt() > original.width ||
bottomRight.dy.toInt() > original.height) {
throw InvalidRectError(topLeft: topLeft, bottomRight: bottomRight);
}
if (topLeft.dx > bottomRight.dx || topLeft.dy > bottomRight.dy) {
Expand Down

0 comments on commit 505e12c

Please sign in to comment.