Michael Bolin's GIF Loader
- Posted by Charles Rector <fist1000 at YAHOO.COM> Jun 09, 2000
- 499 views
Hey all, I'm porting Michael's GIF loader to C++, and as my Euphoria knowledge is not as comprehensive as I would like, I'm having a little trouble divining the meaning of certain parts of the meat of his decompression code. Below is the code snippet I'm dealing w/, commented here and there with my guess as to the meaning of particular parts. For any parties familiar w/ his code, any wisdom you could impart would be most appreciated. if code=end_of_info then exit elsif code=clear_code then -- this part just recalcs the 'strings' -- table? strings=repeat({},n_colors+2) for t=1 to n_colors do strings[t]={t-1} end for num_bits=code_size+1 work_bits=bits[1..num_bits] code=bits_to_int(work_bits)+1 -- this is very confusing for me... -- 'strings' is basically a sequence of -- sequences, yes? and if this is true, -- then up above when we recalculated -- the table, every sequence in the -- table is further comprised of a one- -- element sequence. and so, following -- that line of reasoning, it would -- appear as if this loop is effectively -- equivalent to -- 'output=output & strings[code][1]' -- atleast, that's all i've figured on -- so far. how hot/cold am i?for t=1 to length(strings[code]) do output=append(output,strings[code][t]) end for old=code bits=bits[num_bits+1..length(bits)] else if code<=length(strings) then -- 'string' points to 'strings[code]' string=strings[code] -- add all elements in sequence -- 'string' to sequence 'output' -- basically the same as adding all -- elements from 'strings[code]'? for t=1 to length(string) do output=append(output,string[t]) end for -- same as -- 'work=strings[old] & strings[code][1]'? work=strings[old] & string[1] -- attach sequence 'work' to the -- end of 'strings' strings=append(strings,work) -- so the entire point of this if-block -- is to build a sequence, which gets -- tacked onto the end of 'strings'? old=code else -- tack a copy of the first element onto -- the end of its own sequence? work=strings[old] & strings[old][1] -- add all elements in sequence 'work' to -- sequences 'output' for t=1 to length(work) do output=append(output,work[t]) end for -- and attach the sequence 'work' to -- the end of 'strings' just like in the -- if-block strings=append(strings,work) -- so this else-block seems like a -- variation on the if-block old=code end if end if __________________________________________________ Do You Yahoo!? Yahoo! Photos -- now, 100 FREE prints! http://photos.yahoo.com