generate JPG [message #196590] |
Fri, 23 September 2005 08:49 |
Eclipse User |
|
|
|
Originally posted by: claudio.campisi.libero.it
i realized a graphical editor in GEF and I'd like to print the content of
my diagram; how can i do to translate the content in a JPG image?Are there
some API that perform it?
Thank you
|
|
|
|
Re: generate JPG [message #196661 is a reply to message #196614] |
Fri, 23 September 2005 16:47 |
Eclipse User |
|
|
|
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl
You might want to use GIF or PNG instead of JPEG, because JPEG is lossy
and designed for photographs, not screenshots. JPEG often produces ugly
screenshots.
Regards,
Martijn.
Jason Kealey wrote:
> Here is a method in one of my applications; it may be a good starting
> point for you. public void export(IFigure pane, FileOutputStream fos) {
> // generate image
> Image image = new Image(Display.getCurrent(),
> pane.getSize().width, pane.getSize().height);
> GC gc = new GC(image);
> SWTGraphics graphics = new SWTGraphics(gc);
> // if the bounds are in the negative x/y, we don't see them
> without a translation
> graphics.translate(-pane.getBounds().x, -pane.getBounds().y);
> pane.paint(graphics);
>
> ImageLoader loader = new ImageLoader();
> loader.data = new ImageData[] { image.getImageData() };
> loader.save(fos, SWT.IMAGE_JPEG);
> }
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04704 seconds