我有一个SWT应用程序,用户可以在其中将图像拖放到画布上。
删除后,我在SWT.graphics.Image实例中跟踪图像。

现在,我想使用im4java编辑图像并将图像显示在画布对象上。
但是我一直坚持将图像放入IMOperation对象中。

Image i = this.image; //image is stored in here
ConvertCmd cmd = new ConvertCmd();
IMOperation op = new IMOperation();
//how can i edit the image data using the op object?


是否可以通过这种方式编辑Image对象?

编辑:我试图在这里更具体:
我知道如何使用以下方法将图像加载到“操作”中:

IMOperation op = new IMOperation();
op.addImage("myimage.jpg");


但就我而言,我不想通过文件名加载图像,但我想改用Image实例。

op.setImageData(i.getImageData()) //does sth like this exist?

最佳答案

可能不是。您可以:


使用BufferedImage并将其显示在嵌入式AWT控件中。
使用BufferedImageconvert them to/from SWT。 (根据我的经验)这很慢,可能不适用于所有图像。
使用ImageLoaderinput/output streams一起使用。

10-07 13:27