Skip to main content



      Home
Home » Eclipse Projects » GEF » Problem in painting figures.
Problem in painting figures. [message #249670] Fri, 17 July 2009 03:14
Eclipse UserFriend
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 ******************
Previous Topic:Create editor like PowerPoint
Next Topic:Automatically resize client area when moving editpart
Goto Forum:
  


Current Time: Sat Mar 22 12:45:58 EDT 2025

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

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

Back to the top