I need a bit logical help with my program. I need to crop a photo to be 600x600 around the point ( x, y ). The thing I need help with is when the point is close to the edge, how can I then move the cropped area so it fits inside the photo.
I have the code:
BufferedImage finalImg = capture.getSubimage(Math.max( 0, x - 300 ), Math.max( 0, y - 300 ), 200, 200 );
As far as I can see, the code works for the top and left side, but I have no clue how to get the same effect on the bottom and right side.
If it helps, I want to capture the screen and crop the photo around the mouse ( x, y ).
Thank you
BufferedImage originalImage = readImage(inputFileLocation);
/**
* Image Cropping Parameters
*/
int cropHeight = 600;
int cropWidth = 600;
int cropStartX = 50;
int cropStartY = 50;
BufferedImage processedImage = cropMyImage(originalImage, cropWidth,
cropHeight, cropStartX, cropStartY);