You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue after cropping an image on the Android side.
PlatformException(crop_error, y + height must be <= bitmap.height(), java.lang.IllegalArgumentException: y + height must be <= bitmap.height()
at android.graphics.Bitmap.createBitmap(Bitmap.java:924)
at android.graphics.Bitmap.createBitmap(Bitmap.java:880)
at com.yalantis.ucrop.task.BitmapCropTask.crop(BitmapCropTask.java:165)
at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:105)
at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:37)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
, null)
Here are the steps to reproduce the issue:
Set the aspect ratio to 16:9.
Select an image.
Drag the crop box down to the very bottom of the image.
Tap the checkmark button in the top-right corner.
Video footage:
Screen.Recording.Nov.29.2024.mp4
My code:
Future<CroppedFile?> cropImage({
required String sourcePath,
CropAspectRatioPreset preset = CropAspectRatioPreset.original,
}) async {
CroppedFile? croppedFile;
try {
final (int, int)? value = getCropAspectRatioPreset(preset);
final double ratioX = double.parse((value?.$1 ?? "0.0").toString());
final double ratioY = double.parse((value?.$2 ?? "0.0").toString());
croppedFile = await cropper.cropImage(
sourcePath: sourcePath,
aspectRatio: value != null
? CropAspectRatio(ratioX: ratioX, ratioY: ratioY)
: null,
);
AppLogger().info(message: "cropImage() file: ${croppedFile?.path ?? ""}");
} on Exception catch (err, stack) {
AppLogger().error(message: "Exception caught", err: err, stack: stack);
} finally {}
return Future<CroppedFile?>.value(croppedFile);
}
(int, int)? getCropAspectRatioPreset(CropAspectRatioPreset preset) {
(int, int)? value;
switch (preset) {
case CropAspectRatioPreset.square:
value = (1, 1);
break;
case CropAspectRatioPreset.ratio3x2:
value = (3, 2);
break;
case CropAspectRatioPreset.ratio4x3:
value = (4, 3);
break;
case CropAspectRatioPreset.ratio5x3:
value = (5, 3);
break;
case CropAspectRatioPreset.ratio5x4:
value = (5, 4);
break;
case CropAspectRatioPreset.ratio7x5:
value = (7, 5);
break;
case CropAspectRatioPreset.ratio16x9:
value = (16, 9);
break;
case CropAspectRatioPreset.original:
value = null;
break;
}
return value;
}
@hnvn Could you please take a look at this? This library is a critical component of our project.
The text was updated successfully, but these errors were encountered:
I'm encountering an issue after cropping an image on the Android side.
Here are the steps to reproduce the issue:
Video footage:
Screen.Recording.Nov.29.2024.mp4
My code:
@hnvn Could you please take a look at this? This library is a critical component of our project.
The text was updated successfully, but these errors were encountered: