質問

I have a SWT application where the user can drag and drop images onto a canvas. After dropping I keep track of the image in an SWT.graphics.Image Instance.

Now I want to edit the image using im4java and display the Image on the canvas object. But I am stuck at getting the Image into the IMOperation Object.

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?

Is it possible to edit the Image object this way?

Edit: I am trying to be more specific here: I know how to load an image into the Operation using:

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

But in my case I do not want to load the image via filename but I want to use the Image instance instead.

op.setImageData(i.getImageData()) //does sth like this exist?
役に立ちましたか?

解決

Probably not. You can:

  1. Use BufferedImages and show them in an embedded AWT control.
  2. Use BufferedImages and convert them to/from SWT. This is slow (in my experience) and may not work for all images.
  3. Use ImageLoader to work with input/output streams.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top