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:
BufferedImage
s and show them in an embedded AWT control.BufferedImage
s and convert them to/from SWT. This is slow (in my experience) and may not work for all images.ImageLoader
to work with input/output streams.