This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Writes a single bit as a flag. The bits are accumulated in a byte and flushed to the destination stream when necessary.
/// </summary>
/// <param name="bit">The bit value to write (true for 1, false for 0).</param>
publicvoidWriteBit(boolbit)
{
if(BitsLeft==0)
{
CurrentFlag=0;
BitsLeft=8;
}
if(bit)
{
if(Order== Endian.Little)
CurrentFlag |= (byte)(1<<(8-BitsLeft));
else
CurrentFlag |= (byte)(1<<(BitsLeft-1));
}
BitsLeft--;
if(BitsLeft==0)
{
Base.WriteByte(CurrentFlag);
Buffer.WriteTo(Base);
Buffer.SetLength(0);
}
}
/// <summary>
/// Writes an integer value as a sequence of bits with the specified number of bits. The bits are written from the most significant bit to the least significant bit.
/// </summary>
/// <param name="value">The integer value to write.</param>
/// <param name="bits">The number of bits to write (default is 1).</param>
publicvoidWriteInt(intvalue,intbits=1)
{
for(inti=bits-1;i >= 0;i--)
{
intbit=(value>>i)&1;
WriteBit(bit==1);
}
}
/// <summary>
/// Flushes any remaining bits in the buffer to the underlying stream.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters