[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.gef] Problem in painting figures.

In our application we have various diagrams. For report generation they are copied to an image (and chopped to parts, as per page size, if required), save it as BMP and inserted in Word doc.

But, resultant image is a BMP file having following code written on it, it means it captured image of Eclipse editor not the image of composite.

How could i capture the image of composite using following code?


// ************** Start Code ****************** shell = new Shell(Display.getCurrent()); shell.setLayout(new FillLayout()); composite = new Composite(shell, SWT.NONE); composite.setLayout(new FillLayout());

renderer.setBase(composite);
renderer.render();                //Render Figures

contents = renderer.getContent(); //it is base figure
bounds = contents.getBounds();
shell.setSize(0, 0); //Hide the shell, I don't want to open shell


gc = new GC(composite, SWT.NONE);
SWTGraphics grap1 = new SWTGraphics(gc);
contents.paint(grap1);            // Paint the composite

// Code to save image of current drawing as BMP
ImageLoader imgLoader = new ImageLoader();
Image img2 = new Image(null, new org.eclipse.swt.graphics.Rectangle(0, 0, 400, 400));


gc.copyArea(img2, 0, 0);

imgLoader.data = new ImageData[] {img2.getImageData()};
imgLoader.save(locationToSave + fileName+"_1"+ getImageExtension(imageType), imageType);


// ************** End Code ******************