Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem in painting figures.
Problem in painting figures. [message #249670] Fri, 17 July 2009 07:14
vicky is currently offline vickyFriend
Messages: 2
Registered: July 2009
Junior Member
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: Thu Apr 25 20:06:11 GMT 2024

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

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

Back to the top