GIF Negative? (Solved) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

GIF Negative? (Solved)

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
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).
Sign In or Register to comment.