Neos.IdentityServer 3.0/Neos.IdentityServer.QrCodeNet/Terminate/Terminator.cs
/// <summary>
/// This method will create BitList that contain 
/// terminator, padding and pad codewords for given datacodewords.
/// Use it to full fill the data codewords capacity. Thus avoid massive empty bits.
/// </summary>
/// <remarks>ISO/IEC 18004:2006 P. 32 33. 
/// Terminator / Bit stream to codeword conversion</remarks>
/// <param name="baseList">Method will add terminator bits at end of baseList</param>
/// <param name="dataCount">Num of bits for datacodewords without terminator</param>
/// <param name="numTotalDataCodewords">Total number of datacodewords for specific version.
/// Receive it under Version/VersionTable</param>
/// <returns>Bitlist that contain Terminator, padding and padcodewords</returns>
This method will create BitList that contain
terminator, padding and pad codewords for given datacodewords.
Use it to full fill the data codewords capacity. Thus avoid massive empty bits.
This method will create BitList that contain terminator padding and pad codewords for given datacodewords . Use it to full fill the data codewords capacity . Thus avoid massive empty bits .
internal static void TerminateBites(this BitList baseList, int dataCount, int numTotalDataCodewords)
		{
			int numTotalDataBits = numTotalDataCodewords << 3;
			int numDataBits = dataCount;
			int numFillerBits = numTotalDataBits - numDataBits;
			int numBitsNeedForLastByte = numFillerBits & 0x7;
			int numFillerBytes = numFillerBits >> 3;
			if(numBitsNeedForLastByte >= QRCodeConstantVariable.TerminatorLength)
			{
				baseList.TerminatorPadding(numBitsNeedForLastByte);
				baseList.PadeCodewords(numFillerBytes);
			}
			else if(numFillerBytes == 0)
			{
				baseList.TerminatorPadding(numBitsNeedForLastByte);
			}
			else if(numFillerBytes > 0)
			{
				baseList.TerminatorPadding(numBitsNeedForLastByte + NumBitsForByte);
				baseList.PadeCodewords(numFillerBytes - 1);
			}
			if(baseList.Count != numTotalDataBits)
				throw new ArgumentException(
					string.Format("Generate terminator and Padding fail. Num of bits need: {0}, Actually length: {1}", numFillerBytes, baseList.Count - numDataBits));
		}
internal static void TerminateBites ( this BitList baseList , int dataCount , int numTotalDataCodewords ) { int numTotalDataBits = numTotalDataCodewords << 3 ; int numDataBits = dataCount ; int numFillerBits = numTotalDataBits - numDataBits ; int numBitsNeedForLastByte = numFillerBits & 0x7 ; int numFillerBytes = numFillerBits >> 3 ; if ( numBitsNeedForLastByte >= QRCodeConstantVariable . TerminatorLength ) { baseList . TerminatorPadding ( numBitsNeedForLastByte ) ; baseList . PadeCodewords ( numFillerBytes ) ; } else if ( numFillerBytes == 0 ) { baseList . TerminatorPadding ( numBitsNeedForLastByte ) ; } else if ( numFillerBytes > 0 ) { baseList . TerminatorPadding ( numBitsNeedForLastByte + NumBitsForByte ) ; baseList . PadeCodewords ( numFillerBytes - 1 ) ; } if ( baseList . Count != numTotalDataBits ) throw new ArgumentException ( string . Format ( " " , numFillerBytes , baseList . Count - numDataBits ) ) ; }
This method will create BitList that contain
terminator, padding and pad codewords for given datacodewords.
This method will create BitList that contain terminator padding and pad codewords for given datacodewords .
//BitList result = new BitList();
Bitlist that contain Terminator, padding and padcodewords
Bitlist that contain Terminator padding and padcodewords
BitList
this
dataCount
int
Num of bits for datacodewords without terminator
Num of bits for datacodewords without terminator
numTotalDataCodewords
int
Total number of datacodewords for specific version.
Receive it under Version/VersionTable
Total number of datacodewords for specific version . Receive it under Version / VersionTable
baseList
Method will add terminator bits at end of baseList
Method will add terminator bits at end of baseList
remarks
None