Home » Eclipse Projects » GEF » Exporting to Image (Again)
Exporting to Image (Again) [message #202858] |
Mon, 14 November 2005 07:22  |
Eclipse User |
|
|
|
Hi all,
I'm facing the problem, that exporting editor content to an image is cut off
at the left coordinate (0,0). Objects dragged beyond that coordinate to the
negative area do not increase the ClientArea.
What am I doing wrong here?
public void doSaveAsJPG(String dir, String filename) {
IFigure figure =
((ScalableFreeformRootEditPart)getGraphicalViewer().getRootE ditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS);
RectangleFigure backgroundFigure = new RectangleFigure();
backgroundFigure.setBounds(new Rectangle(-1, -1,
figure.getClientArea().width, figure.getClientArea().height));
backgroundFigure.setBackgroundColor(ColorConstants.white);
ImageData data = new ImageData(figure.getClientArea().width,
figure.getClientArea().height, 24, new PaletteData(0xFF, 0xFF00, 0xFF000));
Image image = new Image(Display.getCurrent(), data);
GC gc = new GC(image);
Graphics g = new SWTGraphics(gc);
backgroundFigure.paint(g);
figure.paint(g);
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };
loader.save(dir + File.separatorChar + filename, SWT.IMAGE_JPEG);
image.dispose();
gc.dispose();
g.dispose();
}
Thanks a lot!
Fabian
|
|
|
Re: Exporting to Image (Again) [message #203176 is a reply to message #202858] |
Fri, 18 November 2005 14:34   |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
The figure's trying to paint to the negative coordinates of the image, but
since there are none, it gets clipped. You need to translate the graphics
so that the figure's origin () matches the image's origin (0,0). Try
something like:
g.translate(-figure.getBounds().x, -figure.getBounds().y)
"Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
news:dl9vic$v9f$1@news.eclipse.org...
> Hi all,
>
>
> I'm facing the problem, that exporting editor content to an image is cut
off
> at the left coordinate (0,0). Objects dragged beyond that coordinate to
the
> negative area do not increase the ClientArea.
>
> What am I doing wrong here?
>
> public void doSaveAsJPG(String dir, String filename) {
> IFigure figure =
>
((ScalableFreeformRootEditPart)getGraphicalViewer().getRootE ditPart()).getLa
yer(LayerConstants.PRINTABLE_LAYERS);
>
> RectangleFigure backgroundFigure = new RectangleFigure();
> backgroundFigure.setBounds(new Rectangle(-1, -1,
> figure.getClientArea().width, figure.getClientArea().height));
> backgroundFigure.setBackgroundColor(ColorConstants.white);
>
> ImageData data = new ImageData(figure.getClientArea().width,
> figure.getClientArea().height, 24, new PaletteData(0xFF, 0xFF00,
0xFF000));
> Image image = new Image(Display.getCurrent(), data);
> GC gc = new GC(image);
> Graphics g = new SWTGraphics(gc);
>
> backgroundFigure.paint(g);
> figure.paint(g);
>
> ImageLoader loader = new ImageLoader();
> loader.data = new ImageData[] { image.getImageData() };
>
> loader.save(dir + File.separatorChar + filename, SWT.IMAGE_JPEG);
>
> image.dispose();
> gc.dispose();
> g.dispose();
> }
>
>
> Thanks a lot!
>
> Fabian
|
|
| |
Re: Exporting to Image (Again) [message #716442 is a reply to message #203191] |
Wed, 17 August 2011 08:23  |
Eclipse User |
|
|
|
6 years later... 
Can you please explain how you solved this?
Br
Martin
Fabian Wolf wrote on Fri, 18 November 2005 19:18Thanks Pratik!
I solved it by looking at the Thumbnail code Thanks though!
Pratik Shah wrote:
> The figure's trying to paint to the negative coordinates of the image, but
> since there are none, it gets clipped. You need to translate the graphics
> so that the figure's origin () matches the image's origin (0,0). Try
> something like:
> g.translate(-figure.getBounds().x, -figure.getBounds().y)
>
> "Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
> news:dl9vic$v9f$1@news.eclipse.org...
>> Hi all,
>>
>>
>> I'm facing the problem, that exporting editor content to an image is cut
> off
>> at the left coordinate (0,0). Objects dragged beyond that coordinate to
> the
>> negative area do not increase the ClientArea.
>> ...
[Updated on: Wed, 17 August 2011 08:23] by Moderator
|
|
|
Goto Forum:
Current Time: Sun Apr 20 02:07:16 EDT 2025
Powered by FUDForum. Page generated in 0.04115 seconds
|