Bug 38186 - Problems loading JPGs and saving GIFs and PNGs
Summary: Problems loading JPGs and saving GIFs and PNGs
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P4 normal (vote)
Target Milestone: ---   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-28 08:23 EDT by Li-Te Cheng CLA
Modified: 2019-10-06 11:51 EDT (History)
4 users (show)

See Also:


Attachments
Example JPEG image that raises loading exception (539.79 KB, image/jpeg)
2003-05-28 08:30 EDT, Li-Te Cheng CLA
no flags Details
Example GIF that raises exception when saving (8.40 KB, image/gif)
2003-05-28 08:31 EDT, Li-Te Cheng CLA
no flags Details
Example PNG image that raises saving exception (2.42 KB, image/png)
2003-05-28 08:31 EDT, Li-Te Cheng CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Li-Te Cheng CLA 2003-05-28 08:23:45 EDT
I seem to have some problems loading and saving certain types of images in
SWT.  I'm running Eclipse 2.1 on Windows XP.

I have a set of JPEGs taken from the same digital camera and at the same
resolution (1600x1200) and compression settings, and most of these
pictures can be loaded with

Image image = new Image( Display.getCurrent(), filename );

but a small number of them raise this exception:

org.eclipse.swt.SWTException: Invalid image
	at org.eclipse.swt.SWT.error(SWT.java:2316)
	at org.eclipse.swt.SWT.error(SWT.java:2246)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.nextBit(JPEGFileFormat.java:1567)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.decodeUsingTable
(JPEGFileFormat.java:748)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.decodeDCCoefficient
(JPEGFileFormat.java:597)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.decodeMCUAtXAndY
(JPEGFileFormat.java:673)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.decodeScan
(JPEGFileFormat.java:736)
	at
org.eclipse.swt.internal.image.JPEGFileFormat.loadFromByteStream
(JPEGFileFormat.java:1450)
	at
org.eclipse.swt.internal.image.FileFormat.loadFromStream(FileFormat.java:43)
	at org.eclipse.swt.internal.image.FileFormat.load(FileFormat.java:71)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:120)
	at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:146)
	at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:350)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:774)
...

All of the pictures can be loaded by other apps, including Corel
Photopaint which says they are all JPEGs... 

When I try to load (using the same method as above) and save the same GIF
images, loading works and I can see the images, but saving fails.  The GIF
images are 8-bit images.

The code:

ImageLoader saver = new ImageLoader();
saver.data = new ImageDat[a] { image.getImageData() };
saver.save( filename, SWT.IMAGE_GIF );

The exception:

org.eclipse.swt.SWTException: Unsupported color depth
	at org.eclipse.swt.SWT.error(SWT.java:2316)
	at org.eclipse.swt.SWT.error(SWT.java:2246)
	at
org.eclipse.swt.internal.image.GIFFileFormat.unloadIntoByteStream
(GIFFileFormat.java:428)
	at
org.eclipse.swt.internal.image.FileFormat.unloadIntoStream(FileFormat.java:103)
	at org.eclipse.swt.internal.image.FileFormat.save(FileFormat.java:95)
	at org.eclipse.swt.graphics.ImageLoader.save(ImageLoader.java:190)
	at org.eclipse.swt.graphics.ImageLoader.save(ImageLoader.java:230)
...

I also get an exception when loading and saving 24-bit PNGs (using
SWT.IMAGE_PNG):

org.eclipse.swt.SWTError: Not implemented
at org.eclipse.swt.SWT.error(SWT.java:2342)
at org.eclipse.swt.SWT.error(SWT.java:2246)
at
org.eclipse.swt.internal.image.PNGFileFormat.unloadIntoByteStream
(PNGFileFormat.java:123)
at
org.eclipse.swt.internal.image.FileFormat.unloadIntoStream(FileFormat.java:103)
at org.eclipse.swt.internal.image.FileFormat.save(FileFormat.java:95)
at org.eclipse.swt.graphics.ImageLoader.save(ImageLoader.java:190)
at org.eclipse.swt.graphics.ImageLoader.save(ImageLoader.java:230)

I seem to be having no problems with BMP files, thankfully.
Comment 1 Li-Te Cheng CLA 2003-05-28 08:30:41 EDT
Created attachment 4985 [details]
Example JPEG image that raises loading exception
Comment 2 Li-Te Cheng CLA 2003-05-28 08:31:11 EDT
Created attachment 4986 [details]
Example GIF that raises exception when saving
Comment 3 Li-Te Cheng CLA 2003-05-28 08:31:34 EDT
Created attachment 4987 [details]
Example PNG image that raises saving exception
Comment 4 Felipe Heidrich CLA 2003-05-28 11:07:51 EDT
CC to investigate and advise.
Comment 5 Christophe Cornu CLA 2003-05-29 09:17:32 EDT
This PR will only deal with the JPEG loading problem.
For the other savings issues, I have opened bug 38232. Please add yourself to 
the CC list.

Comment 6 Carolyn MacLeod CLA 2005-12-02 12:16:46 EST
The JPEG from comment #1 can now be loaded using new Image(Device, String);
See bug 24451 comment 51 for details.

This is not a fix, but it will most likely be a suitable work-around.
I will leave this bug open, but I will reduce the priority to P4.

Note that the GIF saving problem is covered in bug 38232, and the PNG saving problem is covered in bug 24697.
Comment 7 Lars Vogel CLA 2019-09-04 03:01:50 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it and remove the stalebug whiteboard tag. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--