I'm trying to write a method that takes a Bitmap
and the crop values as parameters and returns the cropped Bitmap
.
My code:
public Bitmap applyCrop(Bitmap bitmap, int leftCrop, int topCrop, int rightCrop, int bottomCrop) {
return Bitmap.createBitmap(bitmap, leftCrop, topCrop, bitmap.getWidth() - rightCrop, bitmap.getHeight() - bottomCrop);
}
Using this code i'm receiving the following IllegalArgumentException
:
java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
What is wrong with my code?