I am working on SWF file decompiling according to the swf_file_format_spec_v9.pdf provided by adobe these days. After I decompiled the first 8 bytes data of a sample SWF file. I found that the FrameSize is defined as a RECT structure below:
I have to read the first 5 bits from a ByteArray contains 9 bytes as the Nbits, then read 15 bits each time to get the positions for the rect.
That’s really a hard work for me to get bits from the binary data, I have never do such thing before.
I wrote a lot of codes, and tried many ways to get what I want . But I found all of them are not “beautiful” enough. At last, I got this simple class to catch what I want.
This class is used to read any amount,less than 53, bits from a given ByteArray.
This is a sample of BitsReader, quite easy.
Now, you can have a try with this class :).