GIF LZW数据分析
GIF LZW数据分析 Author:zfive5(zhaozidong)
Email :zfive5@yahoo.com.cn
点阵(16X16)
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
压缩数据
00 FF 09 1C 48 B0 A0 C1 83 08 12 2A 5C C8 B0 A1
C3 87 10 23 4A 9C 48 B1 A2 C5 81 01 01
00 0000 0000
FF 1111 1111 1 0000 0000
09 0000 1001 0 1111 1111
1C 0001 1100 0 1000 0010
48 0100 1000 1 0000 0011
B0 1011 0000 1 0000 0100
A0 1010 0000 1 0000 0101
C1 1100 0001 1 0000 0110
83 1000 0011 1 0000 0111
08 0000 1000 1 0000 1000
13 0001 0011
2A 0010 1010 1 0000 1001
5C 0101 1100 1 0000 1010
C8 1100 1000 1 0000 1011
B0 1011 0000 1 0000 1100
A1 1010 0001 1 0000 1101
C3 1100 0011 1 0000 1110
87 1000 0111 1 0000 1111
10 0001 0000
23 0010 0011 1 0001 0000
4a 0100 1010 1 0001 0001
9c 1001 1100 1 0001 0010
48 0100 1000 1 0001 0011
b1 1011 0001 1 0001 0100
a2 1010 0010 1 0001 0101
c5 1100 0101 1 0001 0110
81 1000 0001 1 0000 0011
01 0000 0001
01 0000 0001 1 0000 0001
(1+22)/2*22+3=256
参考
压缩算法
[1] initialize string table;
[2] [.c.] <- empty;
[3] k <- next character in charstream;
[4] is [.c.]k in string table?
(yes:
[.c.] <- [.c.]k;
go to [3];
)
(no:
add [.c.]k to the string table;
output the code for [.c.] to the codestream;
[.c.] <- k;
go to [3];
)
解压算法
[1] initialize string table;
[2] get first code: <code>;
[3] output the string for <code> to the charstream;
[4] <old> = <code>;
[5] <code> <- next code in codestream;
[6] does <code> exist in the string table?
(yes:
output the string for <code> to the charstream;
[...] <- translation for <old>;
k <- first character of translation for <code>;
add [...]k to the string table;
<old> <- <code>;
)
(no:
[...] <- translation for <old>;
k <- first character of [...];
output [...]k to charstream and add it to string table;
<old> <- <code>
)
[7] go to [5];