Community
Participate
Working Groups
GIFFileFormat.unloadIntoByteStream does not save 1 bit per pixel images correctly. I will attach a few images that should work, but don't.
Created attachment 29610 [details] A Depth 1 GIF
Created attachment 29611 [details] A Depth 1 PNG
Created attachment 29612 [details] A Yellow/Blue Depth 1 PNG
Created attachment 29614 [details] Another Depth 1 GIF (Red X)
Created attachment 29616 [details] Another Depth 1 GIF (Harp)
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
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.
Can anyone tell me if a patch is available? I need urgently to write depth 1 gif's! Thanx
No comments?
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.
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.