Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » generate JPG
generate JPG [message #196590] Fri, 23 September 2005 08:49 Go to next message
Eclipse UserFriend
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 #196614 is a reply to message #196590] Fri, 23 September 2005 13:40 Go to previous messageGo to next message
Jason Kealey is currently offline Jason KealeyFriend
Messages: 22
Registered: July 2009
Junior Member
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);
}
Re: generate JPG [message #196661 is a reply to message #196614] Fri, 23 September 2005 16:47 Go to previous messageGo to next message
Eclipse UserFriend
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);
> }
>
Re: generate JPG [message #196670 is a reply to message #196661] Fri, 23 September 2005 17:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Martijn van Steenbergen" <mvsteenbergen@eljakim.scratch-this.nl> wrote in
message news:dh1bil$ut9$2@news.eclipse.org...
> 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.

YES!
+1!

> Regards,
>
> Martijn.
Re: generate JPG [message #196736 is a reply to message #196661] Mon, 26 September 2005 03:05 Go to previous message
Jason Kealey is currently offline Jason KealeyFriend
Messages: 22
Registered: July 2009
Junior Member
When I implemented that in Eclipse 3.0, both GIF and PNG saving wasn't
supported for my color depth. Furthermore, I did indeed notice that the
compression level used while saving the JPG files wasn't customizable, so
the end result is usually horrible :) However, BMP export works well :)

I just checked out the bugzilla bug about this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=24697


quote:
I would like to realy have PNG saving funkcionality in eclipse.
Current state is horrible, reasons:
1. GIF doesn't support more than 256 colors.
2. JPG has very bad quality, there is no way to adjust it.
3. Conversion from SWT Image to AWT Buffered Image is damn slow.
Previous Topic:Is there a standard/common way to select the last EditPart added to a treeViewer?
Next Topic:MultiPageEditor & GEF
Goto Forum:
  


Current Time: Thu Apr 25 13:25:02 GMT 2024

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

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

Back to the top