Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » From an Image object to an image file
From an Image object to an image file [message #267448] Wed, 18 August 2004 02:44 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
> >
> >
Previous Topic:exporting plugin confusion
Next Topic:Text File Creation Wizard
Goto Forum:
  


Current Time: Fri Oct 18 11:43:53 GMT 2024

Powered by FUDForum. Page generated in 0.03504 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top