Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » 'No more handles' when creating image
'No more handles' when creating image [message #249666] Fri, 17 July 2009 07:13 Go to next message
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) 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
Re: 'No more handles' when creating image [message #249734 is a reply to message #249666] Sat, 25 July 2009 03:09 Go to previous message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

Call Image#dispose() once you have its ImageData to save image to a file.
Increase heap size. If all that doesn't help, then you probably creating
and saving to file a number of images, right? Then ask in SWT newsgroup.

Cheers,
Alex
Previous Topic:Figure truncation when printing on Mac
Next Topic:How to create a label figure that reset height automatically
Goto Forum:
  


Current Time: Thu Mar 28 19:00:12 GMT 2024

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

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

Back to the top