Google Answers Logo
View Question
 
Q: programatically decoding GIF files ( No Answer,   2 Comments )
Question  
Subject: programatically decoding GIF files
Category: Computers > Programming
Asked by: bytanium-ga
List Price: $5.00
Posted: 02 May 2004 03:52 PDT
Expires: 01 Jun 2004 03:52 PDT
Question ID: 339743
I am decoding a very simple gif, which is 5x1 pix 8-bit paletted, and
reads like this ( black, white, red, green, blue)

When I read the binary of this file, I can tell that the LZW min code is 8
And that the block size 8 as well

Then I read the bytes and bits and end up with something like this

0x40 0x40 0xA1 0xE5 0xA3 0x5C 0x01 0x00

Which I can tell that it is read right to left starting with clear
code 0x100000000, and ending with End of Information code 0x100000001
So taking those out I can see that 

0x000000101 is the index for BLUE
0x000011110 is the index for GREEN
0x010110100 is the index for RED
0x011010111 is the index for WHITE
0x000000000 is the index for BLACK


Now , please please please help me understand this, if I read this
value without having an image to look at, how would I know the color
to which each index points to :(

I am sooooo confused and need your help

Thanks in advance

Request for Question Clarification by mmastrac-ga on 02 May 2004 08:05 PDT
Am I correct in assuming that you are reading a GIF file that has no
global or local color maps?

Clarification of Question by bytanium-ga on 06 May 2004 01:27 PDT
Hi mmastrac-ga 
there is not local color map
and I am using the default global color map
the image was created in in Corel

please let me know if you need any more clarification

thanks
Answer  
There is no answer at this time.

Comments  
Subject: Re: programatically decoding GIF files
From: corwin02-ga on 02 May 2004 07:31 PDT
 
The "GIF" format uses an 8 bit Color Look Up Table (sometimes called a
CLUT) to identify its color values. If the original image is an 8 bit,
gray-scale photo, then the "GIF" format produces a compressed lossless
image file. (Lossless means that the image uncompressed from the file
would be identical to the original.) A grey scale image typically has
only 256 levels of gray. This is accomplished by the Run Length
Encoding mechanism of compressing the information while saving a GIF
file.

If the orignal file were a 24 bit color graphic image, then it would
first be mapped to an 8 bit CLUT, and then compressed using RLE (Run
Length Encoding). The loss would be in the remapping of the original
24 bit (16.7 million) colors to the limited 8 bit (256 colors) CLUT.
RLE encoding would reproduce an uncompressed image that was identical
to the remapped 8 bit image, but not the same as the original 24 bit
image.



And here is a (rather lenghty) explanation on how LZW (the encoding
scheme on which gif is based) works and how to decode it

http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/GIF-comp.txt
Subject: Re: programatically decoding GIF files
From: bytanium-ga on 06 May 2004 01:30 PDT
 
hi corwin02-ga
this image is not grey-scale

I am aware of all the stuff u mentioned, I am trying to decipher how
we can find out when I am reading the file, that for example

0x000000101 is the index for BLUE ???

thanks

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy