I am trying to decode a GIF image file format. The GIF file format using LZW can return negative references. If you simply use absolute value on these references you get the "GIF Negative" of the image. The GIF negative is not what I expected. It is not just 255-x to get the back to normal. The best way to describe this is to try adding the color into ms paint (or any other software) and clicking negative with the file format set to GIF. Here is an example.
NORMAL -> Negative
RRR GGG BBB -> RRR GGG BBB
255 000 000 -> 255 204 102
000 255 000 -> 255 204 051
000 000 255 -> 255 153 255
255 255 255 -> 255 153 102
I am trying to convert the "GIF Negative" back to "GIF Normal".
Any ideas of where I could find the answer?
Edit: I found the answer. I will post it here. You can delete this post or save it for future reference.
The way "GIF Negative" works is, after you decode the image but before you reference it, you do this:
if (Current reference)<0
(new reference)=(total references)+(Current reference(should be negative number only!))
Note: Do this after you decode using LZW (if needed).
0 · ·