read a file bit by bit

Shurikn

Well-known member
Joined
Jul 14, 2004
Messages
60
is there a way to do this? because I am trying to read the header of a swf file and there is a part in it that is never the same length in bits. it use the RECT data format
Code:
RECT
Field Type Comment
Nbits: UB[5] //Bits in each rect value field
Xmin: SB[Nbits] //x minimum position for rect
Xmax: SB[Nbits]// x maximum position for rect
Ymin: SB[Nbits] //y minimum position for rect
Ymax: SB[Nbits]// y maximum position for rect
this come from the macromedia website:
http://download.macromedia.com/pub/flash/flash_file_format_specification.pdf
since it use a number of bit, I cant just take the byte, and what is worst is that the number of bits varie for the last 4 data depending on the first value, so is ther anyway to use the reader to read 5 bits, then read xbits(the number in the previous reader)4 time
or is there any workaround?
 
You will probably have to read bytes and process their individual bits yourself. You might want to consider using something like the System.Collections.Specialized.BitVector32 class, which treats four bytes like an array of 32 bits. If you are lucky, maybe someone can provide you with a class that can handle binary data as an array of bits.
 
Writing a BitStream class is no big deal. It took me less than an hour. Id post it, but I dont own the code. :( But feel free to ask any questions.
 
Back
Top