|
| Re: Save view as jpg image [message #511174 is a reply to message #510362] |
Sat, 30 January 2010 08:38  |
Wim Jongman Messages: 417 Registered: July 2009 |
Senior Member |
|
|
Hi Raj,
You should try the SWT newsgroup for this. They can surely help you.
Best regards,
Wim
> hi..
>
> i want to save my view as JPG image iam useing folling code
>
> ScalableFreeformRootEditPart rootEditPart =
(ScalableFreeformRootEditPart)gViewer.getEditPartRegistry().
get(LayerManager.ID);
> IFigure rootFigure = ((LayerManager)
rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
> Rectangle rootFigureBounds = rootFigure.getBounds();
> Control figureCanvas = gViewer.getControl();
> GC figureCanvasGC = new GC(figureCanvas);
>
> Image img = new Image(null, rootFigureBounds.width,
rootFigureBounds.height);
> GC imageGC = new GC(img);
>
> imageGC.setBackground(figureCanvasGC.getBackground());
> imageGC.setForeground(figureCanvasGC.getForeground());
> imageGC.setFont(figureCanvasGC.getFont());
> imageGC.setLineStyle(figureCanvasGC.getLineStyle());
> imageGC.setLineWidth(figureCanvasGC.getLineWidth());
> imageGC.setXORMode(figureCanvasGC.getXORMode());
>
>
> Graphics imgGraphics = new SWTGraphics(imageGC);
> rootFigure.paint(imgGraphics);
> ImageData[] imgData = new ImageData[1];
> imgData[0] = img.getImageData();
> ImageLoader imgLoader = new ImageLoader();
> imgLoader.data = imgData;
> imgLoader.save("c:/View.jpg", SWT.IMAGE_JPEG);
>
> figureCanvasGC.dispose();
> imageGC.dispose();
> img.dispose();
>
> my view gViewer contains - x and - y values...
> i am able to save the image from (0,0) cordinates can any one tell me the
how to get - ve x and y coordinate data
>
> Thanks
> Raj
|
|
|
Powered by
FUDForum. Page generated in 0.01624 seconds