Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte BitRead = 0;
- byte ValRead = 0;
- private byte[] And = new byte[] { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF };
- private byte[] IAnd = new byte[] { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00 };
- public byte ReadBit(byte Bits)
- {
- Bit = 0;
- if (BitRead > 7)
- { BitRead -= 8; if (BitRead != 0) Bit = (byte)((ValRead << BitRead) & And[Bits]);
- else Bit = 0; ValRead = (byte)stream.ReadByte(); }
- Bit = (byte)((Bit | (ValRead >> (8 - BitRead - Bits))) & And[Bits]);
- BitRead += Bits;
- ValRead = (byte)((byte)(ValRead << BitRead) >> BitRead);
- return Bit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement