For cropping images I am using CropImageView of joshholtz (https://github.com/joshdholtz/CropImageView). But I am getting IllegalArgumentException exception (saying: x + width must be <= bitmap.width()) at CreateBitmap function at crop function in the last line right before the return line.
public Bitmap crop(Context context) throws IllegalArgumentException {
// Weird padding cause image size
int weirdSidePadding = this.getWeirdSideMargin();
int weirdVerticalPadding = this.getWeirdVerticalMargin();
FrameLayout.LayoutParams params = (LayoutParams) mDaBox.getLayoutParams();
// Getting crop dimensions
float d = context.getResources().getDisplayMetrics().density;
int x = (int)((params.leftMargin - weirdSidePadding) * d);
int y = (int)((params.topMargin - weirdVerticalPadding) * d);
int width = (int)((this.getWidth() - params.leftMargin - params.rightMargin) * d);
int height = (int)((this.getHeight() - params.topMargin - params.bottomMargin) * d);
Bitmap crooopppppppppppppppeed = Bitmap.createBitmap(mBitmap, x, y, width, height);
return crooopppppppppppppppeed;
}
Actually I had a look at potentially same questions, but unluckily they are not same with my situation to the degree to help me.
Can you please help me to come over this barrier?