Bug 115652 - GIF encoding doesn't work for depth 1 images
Summary: GIF encoding doesn't work for depth 1 images
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-09 11:46 EST by Carolyn MacLeod CLA
Modified: 2021-11-12 11:35 EST (History)
1 user (show)

See Also:


Attachments
A Depth 1 GIF (70 bytes, image/gif)
2005-11-09 11:55 EST, Carolyn MacLeod CLA
no flags Details
A Depth 1 PNG (217 bytes, image/png)
2005-11-09 11:56 EST, Carolyn MacLeod CLA
no flags Details
A Yellow/Blue Depth 1 PNG (132 bytes, image/png)
2005-11-09 11:56 EST, Carolyn MacLeod CLA
no flags Details
Another Depth 1 GIF (Red X) (157 bytes, image/gif)
2005-11-09 11:57 EST, Carolyn MacLeod CLA
no flags Details
Another Depth 1 GIF (Harp) (188 bytes, image/gif)
2005-11-09 11:58 EST, Carolyn MacLeod CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carolyn MacLeod CLA 2005-11-09 11:46:42 EST
GIFFileFormat.unloadIntoByteStream does not save 1 bit per pixel images 
correctly. I will attach a few images that should work, but don't.
Comment 1 Carolyn MacLeod CLA 2005-11-09 11:55:16 EST
Created attachment 29610 [details]
A Depth 1 GIF
Comment 2 Carolyn MacLeod CLA 2005-11-09 11:56:00 EST
Created attachment 29611 [details]
A Depth 1 PNG
Comment 3 Carolyn MacLeod CLA 2005-11-09 11:56:59 EST
Created attachment 29612 [details]
A Yellow/Blue Depth 1 PNG
Comment 4 Carolyn MacLeod CLA 2005-11-09 11:57:58 EST
Created attachment 29614 [details]
Another Depth 1 GIF (Red X)
Comment 5 Carolyn MacLeod CLA 2005-11-09 11:58:55 EST
Created attachment 29616 [details]
Another Depth 1 GIF (Harp)
Comment 6 Valentin Schnitzer CLA 2006-03-31 15:27:11 EST
The first thing which came to my mind was that the code size with which 
the decoding is started is wrong.
 From the GIF87a Specification:

Establish Code Size

The first byte of the GIF Raster Data stream is a value indicating the 
minimum number of bits required to represent the set of actual pixel 
values. Normally this will be the same as the number of color bits. 
Because of some algorithmic constraints however, black & white images 
which have one color bit must be indicated as having a code size of 2. 
This code size value also implies that the compression codes must start 
out one bit longer.

After stepping through the code I found the part which needs to be 
altered:
LZWCodec.java in the function initializeForEncoding.
Line 250: codeSize = bitsPerPixel + 1;
In: if (bitsPerPixel==1) codeSize=3 else codeSize = bitsPerPixel + 1;
Or something similar.

I hope this solves the problem.
Greetings, Valentin
Comment 7 Valentin Schnitzer CLA 2006-03-31 15:29:11 EST
The first thing which came to my mind was that the code size with which 
the decoding is started is wrong.
 From the GIF87a Specification:

Establish Code Size

The first byte of the GIF Raster Data stream is a value indicating the 
minimum number of bits required to represent the set of actual pixel 
values. Normally this will be the same as the number of color bits. 
Because of some algorithmic constraints however, black & white images 
which have one color bit must be indicated as having a code size of 2. 
This code size value also implies that the compression codes must start 
out one bit longer.

After stepping through the code I found the part which needs to be 
altered:
LZWCodec.java in the function initializeForEncoding.
Line 250: codeSize = bitsPerPixel + 1;
In: if (bitsPerPixel==1) codeSize=3 else codeSize = bitsPerPixel + 1;
Or something similar.

I hope this solves the problem.
Comment 8 Conny Kreyssel CLA 2007-01-26 05:07:15 EST
Can anyone tell me if a patch is available? I need urgently to write depth 1 gif's!

Thanx
Comment 9 Conny Kreyssel CLA 2007-03-29 04:09:51 EDT
No comments?
Comment 10 Carolyn MacLeod CLA 2007-04-09 17:04:21 EDT
Unfortunately, the patch doesn't work, and I don't have time at this point to spend more time on it. If someone could submit a working patch, then I do have time to retest and commit.
Comment 11 Eclipse Webmaster CLA 2019-09-06 16:06:11 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. 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.