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 #196614 is a reply to message #196590] |
Fri, 23 September 2005 13:40   |
Eclipse User |
|
|
|
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   |
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);
> }
>
|
|
|
|
Re: generate JPG [message #196736 is a reply to message #196661] |
Mon, 26 September 2005 03:05  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03139 seconds