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:
- 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
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.

July 15th, 2008
Ntt.cc
Posted in
Tags:
