Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Save view as jpg image
Save view as jpg image [message #510362] Wed, 27 January 2010 11:04 Go to next message
raj is currently offline raj
Messages: 19
Registered: January 2010
Location: hyderabad
Junior Member

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 13:38 Go to previous message
Wim Jongman is currently offline Wim Jongman
Messages: 418
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
Previous Topic:dynamically changing menu and toolbar icons
Next Topic:Bundle Validation
Goto Forum:
  


Current Time: Wed Oct 01 14:34:39 GMT 2014

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

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