我的程序需要一点逻辑帮助。我需要将照片围绕点 ( x, y ) 裁剪为 600x600。我需要帮助的是,当该点靠近边缘时,我如何移动裁剪区域以使其适合照片内部。
我有代码:
BufferedImage finalImg = capture.getSubimage(Math.max( 0, x - 300 ), Math.max( 0, y - 300 ), 200, 200 );
据我所知,代码适用于顶部和左侧,但我不知道如何在底部和右侧获得相同的效果。
如果有帮助,我想捕获屏幕并裁剪鼠标周围的照片(x,y)。
谢谢
最佳答案
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);
关于java - 将照片围绕点 (x,y) 裁剪为 600x600,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24983522/