Saving an Image to GIF [message #457500] |
Mon, 27 June 2005 10:07 |
Jason Grant Messages: 77 Registered: July 2009 |
Member |
|
|
I'm having no joy saving an o.e.s.g.Image to GIF, because SWT will only
save an Image of depth 8 to GIF, and my Image always returns an ImageData
that is 24 bits deep. (I'm running under linux)
How should I go about creating and saving an Image as a GIF? Here's my
code:
Display display = Workbench.getInstance().getDisplay();
// The palette is an indexed palette with a few colors
ImageData iData = new ImageData(width, height, 8, CommonColors.INDEXED_PALETTE);
Image histoImage = new org.eclipse.swt.graphics.Image(display, iData);
// The following assertion always fails
// ImageData temp = histoImage.getImageData();
// assert temp.depth == 8 : "Depth not 8";
// Code omitted - draw stuff on the image using a GC
// Now save the image
ImageData data = histoImage.getImageData();
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] {data};
// The line below fails because the data is 24 bit
loader.save(getHistogramFileName(), SWT.IMAGE_GIF);
|
|
|
Powered by
FUDForum. Page generated in 0.02007 seconds