Image of a diagram

Started by Hervé, April 26, 2017, 21:33:29 PM

Previous topic - Next topic


Hi there,

Some people who use my database plugin asked me to add an option to export an image of the diagrams in the database. This way, they will be able to transfer them easily to other applications like web sites or other.

I do not like the way I did it : open the diagram, create an image from it using the DiagramUtils class, and then close the diagram.

I would like to find a way to create the images without showing up the diagrams on the screen. Do you know a way to achieve this ?

Thanks and regards


Ok, I've found a way to export generate views images without showing then.

For reference, here is the code I'm using :

public byte[] createImage(IDiagramModel view, double scale, int margin) throws IOException {
byte[] imageByteArray = null;
Image image = DiagramUtils.createImage(view, scale, margin);

ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream writeOut = new DataOutputStream(out);
ImageLoader saver = new ImageLoader(); = new ImageData[] { image.getImageData() };, SWT.IMAGE_PNG);

imageByteArray =  out.toByteArray();


return imageByteArray ;

The next release of my database plugin will be able to export an image of the views into the database  ;D

Best regards