Home » Eclipse Projects » GEF » Exporting to Image (Again)
Exporting to Image (Again) [message #202858] |
Mon, 14 November 2005 12:22 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Fabian Wolf![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Fabian.Wolf%40informatik.uni-ulm.de) Messages: 96 Registered: July 2009 |
Member |
|
|
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 19:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 12:23 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Missing name![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=go.ostling%40gmail.com) Messages: 14 Registered: June 2011 |
Junior Member |
|
|
6 years later... ![Smile](images/smiley_icons/icon_smile.gif)
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 12:23] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Aug 17 13:57:12 GMT 2024
Powered by FUDForum. Page generated in 0.04175 seconds
|