我需要使用image.setCorners()
来扭曲图像,这可以使用JavaXT库来完成。
但是我有BufferedImage
形式的图像,而不是保存的文件。
那么如何将BufferedImage
转换为javaxt.io.Image
,以便我可以对其执行倾斜操作。
以下是我用来扭曲图像的代码:
javaxt.io.Image image = new javaxt.io.Image("image1.jpg");
System.out.println(image.getWidth() + "x" + image.getHeight());
int width = image.getWidth();
int height = image.getHeight();
image.setCorners(0, 0, //UL
width, 10, //UR
width, height-10, //LR
0, height); //LL
答案 0 :(得分:1)
javaxt.io.Image
类有一个构造函数,如:
public Image(java.awt.image.BufferedImage bufferedImage)
所以你可以这样做:
javaxt.io.Image image = new javaxt.io.Image(bufferedImage);