2015-06-02 66 views
2

我需要使用image.setCorners()倾斜图像,这可以使用JavaXT库来完成。 但是我有BufferedImage窗体中的图像,而不是保存的文件。如何将BufferedImage转换为javaxt.io.Image?

那么如何将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 

回答

1

javaxt.io.Image类有类似的构造:

public Image(java.awt.image.BufferedImage bufferedImage) 

所以你可以做:

javaxt.io.Image image = new javaxt.io.Image(bufferedImage); 
相关问题