read this 3MF Project GIF and all subsections there is everything you need with stepping examples and the rest is in the spec file.
now the image data
Stream data starts with 1 Byte block size and then goes the bit stream. At the end goes another block size. It stops when you draw entire frame then set pointer after the last readed block.
if you found block size 0
then it means the end of frame data. If there is terminator 0x3b
after then the end of file is reached.
The local color bits tells you how many bits you have per code in the stream at start.
I read LSB of actual processed BYTE, then shift it right then shift the code right and add this bit as MSB of it. After you reach the needed bit count of index process it by LZW decompressing and also add new code to dictionary.
if dictionary cross 2^bits boundary increase the code bitsize and continue. Do not forget to handle the clear and end special codes ...
So you have: 06 6b 40 86 70 48 2c 1a
06h
is initial bit size - 1 so the real bit size is 7
!!!
6bh
is block size in bytes
40h
is clear code (meaning 64 colors present in color[]
table, and first free index is 66)
86 70 48 2c 1a [hex]= |1 0000110|01 110000|010 01000|0010 1100|00011 010| [bin]
so the codes are:
|0000110|110000 1|01000 01|1100 010|010 0010| [bin]
|0000110|1100001 |0100001 |11000010|0100010 | [bin]
06,61,21,c2,22 [hex]
the 61h
suggest error in data is this really start of image data (or I made a mistake somewhere)? The code can be only one bigger then max index in dictionary. The dictionary is increased by each code except the first so while processing 61h
the dictionary is only 42h
in size. Try the example in the linked page they works ...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…