From an Image object to an image file [message #267448] |
Wed, 18 August 2004 02:44 |
Eclipse User |
|
|
|
Originally posted by: gupolet.ulb.ac.be
Hi,
I was wondering how I could get from an object of class
org.eclipse.swt.graphics.Image to a file. I have seen that ImageLoader can
load and save image but how do I get and InputStream so that I can do as
follows:
Image myImage;
...
InputStream myImageInAnInputStream;
...
ImageLoader loader= new ImageLoader();
loader.load(myImageInAnInputStream);
loader.save("c:\temp\MyImage.bmp",SWT.IMAGE_BMP);
thank you very much
Guillaume
|
|
|
Re: From an Image object to an image file [message #267589 is a reply to message #267448] |
Wed, 18 August 2004 15:39 |
Eclipse User |
|
|
|
Originally posted by: Chris_Laffra.ca.ibm.com
FAQ 103, http://eclipsefaq.org
Chris
"Guillaume" <gupolet@ulb.ac.be> wrote in message
news:cfufqi$2n7$1@eclipse.org...
> Hi,
>
> I was wondering how I could get from an object of class
> org.eclipse.swt.graphics.Image to a file. I have seen that ImageLoader can
> load and save image but how do I get and InputStream so that I can do as
> follows:
>
> Image myImage;
> ..
> InputStream myImageInAnInputStream;
> ..
> ImageLoader loader= new ImageLoader();
> loader.load(myImageInAnInputStream);
> loader.save("c:\temp\MyImage.bmp",SWT.IMAGE_BMP);
>
> thank you very much
>
> Guillaume
>
>
|
|
|
Re: From an Image object to an image file [message #267702 is a reply to message #267589] |
Thu, 19 August 2004 01:09 |
Eclipse User |
|
|
|
Originally posted by: gupolet.ulb.ac.be
After research, this is what I found (and it works):
Image img = new Image(null, root.getFigure().getPreferredSize().width,
root.getFigure().getPreferredSize().height);
GC gc = new GC(img);
Graphics graphics = new SWTGraphics(gc);
root.getFigure().paint(graphics);
graphics.dispose();
gc.dispose();
ImageData data=img.getImageData();
ImageLoader loader=new ImageLoader();
loader.data= new ImageData[]{data};
loader.save("c:\\test.bmp",SWT.IMAGE_BMP);
Where root is the RootFigure of my editor (RootEditPart.getFigure())
Chris Laffra wrote:
> FAQ 103, http://eclipsefaq.org
> Chris
> "Guillaume" <gupolet@ulb.ac.be> wrote in message
> news:cfufqi$2n7$1@eclipse.org...
> > Hi,
> >
> > I was wondering how I could get from an object of class
> > org.eclipse.swt.graphics.Image to a file. I have seen that ImageLoader can
> > load and save image but how do I get and InputStream so that I can do as
> > follows:
> >
> > Image myImage;
> > ..
> > InputStream myImageInAnInputStream;
> > ..
> > ImageLoader loader= new ImageLoader();
> > loader.load(myImageInAnInputStream);
> > loader.save("c:tempMyImage.bmp",SWT.IMAGE_BMP);
> >
> > thank you very much
> >
> > Guillaume
> >
> >
|
|
|
Powered by
FUDForum. Page generated in 0.03504 seconds