Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322638

Summary: [Image loading] ImageLoader and Image from stream fail with certain animated gifs
Product: [Eclipse Project] Platform Reporter: Thomas Schindl <tom.schindl>
Component: SWTAssignee: Carolyn MacLeod <carolynmacleod4>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: skovatch
Version: 3.6   
Target Milestone: 4.3 M1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Example project none

Description Thomas Schindl CLA 2010-08-13 06:52:55 EDT
Attached you'll find a project which demonstrates an SWT for an image which opens perfectly in other image programs but fails on SWT.

There's only one image loading implementation which allows to load the image which is the purely native one new Image(Display,String) but because I need to show an animated give this doesn't help me a lot.

You'll have to adjust the path to the image for to make new Image(Display,String) work for you
Comment 1 Thomas Schindl CLA 2010-08-13 06:54:19 EDT
Created attachment 176543 [details]
Example project
Comment 2 Scott Kovatch CLA 2010-08-18 15:00:11 EDT
Carolyn owns image loader bugs. I verified this fails on Cocoa in HEAD. Exception is:

Loading image with stream failed.
org.eclipse.swt.SWTException: Invalid image
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.internal.image.GIFFileFormat.getExtensions(GIFFileFormat.java:156)
	at org.eclipse.swt.internal.image.GIFFileFormat.loadFromByteStream(GIFFileFormat.java:124)
	at org.eclipse.swt.internal.image.FileFormat.loadFromStream(FileFormat.java:48)
	at org.eclipse.swt.internal.image.FileFormat.load(FileFormat.java:84)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:130)
	at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:22)
	at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:331)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:502)
	at ImageLoaderTest.main(ImageLoaderTest.java:19)
Comment 3 Carolyn MacLeod CLA 2010-08-18 16:34:36 EDT
Cool GIF. 74 images. I can comment out one line (the one that throws the error), and get it to (mostly) work. There seems to be an unknown extension in the final image that has an id of "254". I am out of time to look at this today, so I will get back to it on Friday.
Comment 4 Carolyn MacLeod CLA 2012-06-25 14:22:15 EDT
Fixed > 20120625 for 4.3 M1
Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ff9c15961deba7f09d9b58b96d5ee00c19a9ff6f

(Re: comment 3):
OK, "Friday" was a while ago... sorry about that. It turns out that the attached gif does not conform to the GIF spec, and even Firefox and Windows Picture Viewer fail to read the entire file. However, since they both salvage the gif by reading in as much as they can, and they can still animate the images up to the point where it is broken (image #74 of the animation), I decided to do the same thing. So this patch makes our gif loading code a little more lenient, and your gif will (mostly) load.