1

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?
McFarlane
  • 1,777
  • 2
  • 22
  • 39

1 Answers1

0

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.
Community
  • 1
  • 1
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • Thanks. I am now using ImageLoader to save a temporary image which I use as input image for the image operation. – McFarlane Feb 06 '13 at 13:59