Exemplo n.º 1
0
        public static int WriteUInt32(uint source, int numberOfBits, byte[] destination, int destinationBitOffset)
        {
            int result = destinationBitOffset + numberOfBits;

            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)source, numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)source, 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 8), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 8), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            if (numberOfBits <= 8)
            {
                BytesUtil.WriteByte((byte)(source >> 16), numberOfBits, destination, destinationBitOffset);
                return(result);
            }
            BytesUtil.WriteByte((byte)(source >> 16), 8, destination, destinationBitOffset);
            destinationBitOffset += 8;
            numberOfBits         -= 8;
            BytesUtil.WriteByte((byte)(source >> 24), numberOfBits, destination, destinationBitOffset);
            return(result);
        }
Exemplo n.º 2
0
        public void Write(byte source)
        {
            int num = this.bitLength + 8;

            this.A(num);
            BytesUtil.WriteByte(source, 8, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Exemplo n.º 3
0
        public void Write(byte source, int numberOfBits)
        {
            int num = this.bitLength + numberOfBits;

            this.A(num);
            BytesUtil.WriteByte(source, numberOfBits, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }
Exemplo n.º 4
0
        public void Write(bool source)
        {
            int num = this.bitLength + 1;

            this.A(num);
            BytesUtil.WriteByte((byte)(source ? 1 : 0), 1, this.dataBytes, this.bitLength);
            this.bitLength = num;
        }