I am trying to crop image inside bounding box from camera preview and display in a activity. I have a surfaceview and a square imageview on top of it. I have to capture image that appears only inside imageview. Following is my cropping code, No idea as to what is wrong here,Please help
int width = rotatedBitmap.getWidth();
int height = rotatedBitmap.getHeight();
int newWidth = (height > width) ? width : height;
int newHeight = (height > width)? height - ( height - width) : height;
int x = (width - height) / 2;
x = (x < 0)? 0: x;
int y = (height - width) / 2;
y = (y < 0)? 0: y;
Bitmap cropImg = Bitmap.createBitmap(rotatedBitmap, x, y,newWidth, newHeight);
what's wrong with my code?