Ejemplo n.º 1
0
        /// <summary>
        /// Convert BitArray into Byte
        /// </summary>
        /// <param name="bitArray">Bit Array which converted Byte</param>
        /// <param name="b">Byte converted by BitArray</param>
        /// <param name="position">position for free bits in byte</param>
        /// <returns> rest bits, rest bits in byte</returns>
        private AppendBitResult AppendBitToByte(BitArray bitArray, ref byte b, int position)
        {
            int bitArrayPointer = 0;

            while (position < 8 && bitArrayPointer < bitArray.Length)
            {
                SetBit(ref b, position, bitArray[bitArrayPointer]);
                position++;
                bitArrayPointer++;
            }

            AppendBitResult result = new AppendBitResult();

            if (bitArrayPointer < bitArray.Length)
            {
                result.RestBits = bitArray.CopyToNew(bitArrayPointer);
            }
            if (position < 8)
            {
                result.RestPositionIntoBit = position;
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert BitArray into Byte
        /// </summary>
        /// <param name="bitArray">Bit Array which converted Byte</param>
        /// <param name="b">Byte converted by BitArray</param>
        /// <param name="position">position for free bits in byte</param>
        /// <returns> rest bits, rest bits in byte</returns>
        private AppendBitResult AppendBitToByte(BitArray bitArray, ref byte b, int position)
        {
            int bitArrayPointer = 0;
            while (position < 8 && bitArrayPointer < bitArray.Length)
            {
                SetBit(ref b, position, bitArray[bitArrayPointer]);
                position++;
                bitArrayPointer++;
            }

            AppendBitResult result = new AppendBitResult();

            if (bitArrayPointer < bitArray.Length)
            {
                result.RestBits = bitArray.CopyToNew(bitArrayPointer);
            }
            if (position < 8)
            {
                result.RestPositionIntoBit = position;
            }

            return result;
        }