如何将BufferedImage转换为javaxt.io.Image?

时间:2015-06-02 13:51:13

标签: java bufferedimage skew

我需要使用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

1 个答案:

答案 0 :(得分:1)

javaxt.io.Image类有一个构造函数,如:

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

所以你可以这样做:

javaxt.io.Image image = new javaxt.io.Image(bufferedImage);