Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » save an IFigure to a gif
save an IFigure to a gif [message #326610] Wed, 26 March 2008 13:30 Go to next message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Hi,

I already posted a similar message in gef and swt newsgroup but didn't
get any response so I'm trying there.

I want to generate a number of gif of a particular figure and it's
children selected from the rootfigure of a diagram.

I want to do this without opening an editor. So I developped the
following method to generate an image from a particular figure

private byte[] createImage(IFigure figure, int format) {

ByteArrayOutputStream result = new ByteArrayOutputStream();
Image image = null;
GC gc = null;
Graphics g = null;
try {
image = new
Image(null,figure.getBounds().width,figure.getBounds().heigh t);
gc = new GC(image);
g = new SWTGraphics(gc);
g.translate(figure.getBounds().x * -1, figure.getBounds().y * -1);
figure.paint(g);
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[1];
ImageData imageData = image.getImageData();
/* If the image depth is 8 bits or less, then we can use the
existing image data. */
if (imageData.depth <= 8) {
loader.data[0] = imageData;
}else {
/* get an 8 bit imageData for the image */
ImageData newImageData =
CreateImageAction.get8BitPaletteImageData(imageData);
loader.data[0] = newImageData;
}
loader.save(result, format);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (g != null) {
g.dispose();
}
if (gc != null) {
gc.dispose();
}
if (image != null) {
image.dispose();
}
}
return result.toByteArray();
}

I've two problems with this method, the first is my figure and it's
children doesn't have the bounds set.

The second problem is when generating the images my figure and it's
children are not paint

What can be the cause ?

Thanks for your help

Alexandre
Re: save an IFigure to a gif [message #326617 is a reply to message #326610] Wed, 26 March 2008 14:42 Go to previous message
Eclipse UserFriend
Originally posted by: alexjaquet.gmail.com

Sorry in fact it's work if the selected figure have been setted as
visible in the model

But if I try to force the property visible to paint it's content the
result is a blank image

condition.setVisible(true);
condition.paint(g);


any idea ?

Thanks
Previous Topic:Using IHandlerService in modal dialog
Next Topic:Need to place a label in toolbar
Goto Forum:
  


Current Time: Thu Jun 27 19:35:22 GMT 2024

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

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

Back to the top