Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gef-dev] How to save draw2d elements in a file?


Hi Nicolas,
 
I think first we need to get the figure from the root editpart, fill the image with that figure data and then save the image.
 
As you were creating just an image and not filling the data into it, you were getting a blank image.
 
try this way...
----------------------------------------------------------------------------------------------------------------------
GraphicalViewer viewer = editor.getGraphicalViewer();
 
Editpart editPart = viewer.getRootEditPart();
 
Figure figure =  (Figure)editPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
 
Image img = new Image(Display.getDefault(),2000, 2000);
 
GC gc = new GC(img);
 
Graphics grap = new SWTGraphics(gc);
 
figure.paint(grap);
 
ImageLoader loader = new ImageLoader(); 

loader.data = "" ImageData[]{img.getImageData()}; 

loader.save("/home/me/Desktop/toto.jpeg", SWT.IMAGE_JPEG);

------------------------------------------------------------------------------------------------------------------------
 
hope this helps,
 
Thanks
A. Vijay Kumar

Back to the top