我有一张图像,想要裁剪给定的角点。 例如
我只想剪切数独谜题。我有角点 (x1, y1)、(x2, y2)、(x3, y3)、(x4, y4)。
尝试过这个:
javaxt.io.Image image = new javaxt.io.Image(bufferedImage);
image.setCorners((float) pointTopLeft.getX(), (float) pointTopLeft.getY(), //UL
(float) pointTopRight.getX(), (float) pointTopRight.getY(), //UR
(float) pointBottomRight.getX(), (float) pointBottomRight.getY(), //LR
(float) pointBottomLeft.getX(), (float) pointBottomLeft.getY()); //LL
但是它返回的结果是这样的(这不是我想要的):
最佳答案
您可以首先通过移动底角和右上角来倾斜图像 - 这将产生更矩形的形状。然后您可以裁剪图像。
我尝试过这个:
Image image = new javaxt.io.Image(bufferedImage);
// skew image
image.setCorners(
// keep the upper left corner as it is
0,0, // UL
// push the upper right corner more to the bottom
image.getWidth(),20, // UR
// push the lower right corner more to the left
image.getWidth()-45,image.getHeight(), // LR
// push the lower left corner more to the right
55,image.getHeight()); // LL
// crop image
image.crop(80, 105, image.getWidth()-150, image.getHeight()-105);
结果是这样的:
希望这有帮助。
关于java - 倾斜缓冲图像 java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28265767/