Reputation: 348
I have some numbers, encoded in byte array using variable-length code. Actually it's GIF89a image data, whith I have to decode.
Because the LZW compression used for GIF creates a series of variable length codes, of between 3 and 12 bits each, these codes must be reformed into a series of 8-bit bytes that will be the characters actually stored or transmitted. The codes are formed into a stream of bits as if they were packed right to left and then picked off 8 bits at a time to be output. Assuming a character array of 8 bits per character and using 5 bit codes to be packed, an example layout would be similar to:
+---------------+
0 | | bbbaaaaa
+---------------+
1 | | dcccccbb
+---------------+
2 | | eeeedddd
+---------------+
3 | | ggfffffe
+---------------+
4 | | hhhhhggg
+---------------+
. . .
+---------------+
N | |
+---------------+
How I can convert it to common [ex. integer] format using c#. Some features?
Also, I can't understand how to recognize - when size(in bits) of this numbers is increasing (+1 to size)? I just know size of the first number?
Upvotes: 2
Views: 726
Reputation: 35477
You want to use a BitStream. See http://www.codeproject.com/KB/cs/bitstream.aspx for a good example.
Upvotes: 2