Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Saving an Image to GIF
Saving an Image to GIF [message #457500] Mon, 27 June 2005 10:07
Jason Grant is currently offline Jason GrantFriend
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);
Previous Topic:TextCellEditor and context menu
Next Topic:Viewers and ISafeRunnable
Goto Forum:
  


Current Time: Sat Apr 27 02:20:12 GMT 2024

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

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

Back to the top