'No more handles' when creating image [message #249666] |
Fri, 17 July 2009 07:13 |
vicky 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) and inserted in Word doc or PDF.
All was working fine but we have now encountered cases where the diagram
is very large.
The first image we create is equal to the size of the diagram - so in very
long diagrams the initial image generation fails.
When diagram is very long, then initial image(at line no 11) is of large
size, and exception 'No More Handles' occurs.
How could we get page size images for the diagram, without creating the
initial image (which is of the same size as diagram)?
Note: We are creating BMP images.
Any help will be appreciated.
//*****Code for creating image from Composite.*****
1. shell = new Shell(Display.getCurrent());
2. shell.setLayout(new FillLayout());
3. composite = new Composite(shell, SWT.NONE);
4. composite.setLayout(new FillLayout());
5. renderer.setBase(composite);
//Render the draw2d figures/diagram
6. renderer.render();
// contents is org.eclipse.draw2d.Figure
// the base figure of draw2d diagram
8. contents = renderer.getContent();
9. bounds = contents.getBounds();
//Hide shell
10. shell.setSize(0, 0);
// Create a blank image, equal to the size of diagram
// 'No more handles' prob is reported on this line
11. img1 = new Image(null, new Rectangle(0, 0, bounds.width,
bounds.height));
12. gc = new GC(img1);
13. Graphics grap1 = new SWTGraphics(gc);
14. contents.paint(grap1);
// ...
// ...
// ...
// ...
// later we chop the single image to various images as per the page size
//Code for chopping the image, this code executes in loop
Image pageSizeImg = new Image(null, new Rectangle(0, 0, imageWidth,
heightToCrop));
gc.copyArea(pageSizeImg, 0, yPos); // the same gc created above
imgLoader.data = new ImageData[] {pageSizeImg.getImageData()};
imgLoader.save(locationToSave + fileName + getImageExtension(imageType),
imageType);//imageType is SWT.IMAGE_BMP
|
|
|
|
Powered by
FUDForum. Page generated in 0.02957 seconds