Save view as jpg image [message #510362] |
Wed, 27 January 2010 06:04  |
Eclipse User |
|
|
|
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
|
|
|
Re: Save view as jpg image [message #511174 is a reply to message #510362] |
Sat, 30 January 2010 08:38  |
Eclipse User |
|
|
|
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.39425 seconds