Neos.IdentityServer 3.0/Neos.IdentityServer.QrCodeNet/Versions/VersionControl.cs
/// <summary>
/// Decide which version group it belong to
/// </summary>
/// <param name="numBits">number of bits for bitlist where it contain DataBits encode from input content and ECI header</param>
/// <param name="level">Error correction level</param>
/// <param name="mode">Mode</param>
/// <returns>Version group index for VERSION_GROUP</returns>
Decide which version group it belong to
Decide which version group it belong to
private static int DynamicSearchIndicator(int numBits, ErrorCorrectionLevel level, Mode mode)
		{
			int[] charCountIndicator = CharCountIndicatorTable.GetCharCountIndicatorSet(mode);
			int totalBits = 0;
			int loopLength = VERSION_GROUP.Length;
			for(int i = 0; i < loopLength; i++)
			{
				totalBits = numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[i];
				QRCodeVersion version = VersionTable.GetVersionByNum(VERSION_GROUP[i]);
				int numECCodewords = version.GetECBlocksByLevel(level).NumErrorCorrectionCodewards;
				int dataCodewords = version.TotalCodewords - numECCodewords;
				if(totalBits <= dataCodewords * 8)
				{
					return i;
				}
			}
			throw new InputOutOfBoundaryException(string.Format("QRCode do not have enough space for {0} bits", (numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[2])));
		}
private static int DynamicSearchIndicator ( int numBits , ErrorCorrectionLevel level , Mode mode ) { int [ ] charCountIndicator = CharCountIndicatorTable . GetCharCountIndicatorSet ( mode ) ; int totalBits = 0 ; int loopLength = VERSION_GROUP . Length ; for ( int i = 0 ; i < loopLength ; i ++ ) { totalBits = numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator [ i ] ; QRCodeVersion version = VersionTable . GetVersionByNum ( VERSION_GROUP [ i ] ) ; int numECCodewords = version . GetECBlocksByLevel ( level ) . NumErrorCorrectionCodewards ; int dataCodewords = version . TotalCodewords - numECCodewords ; if ( totalBits <= dataCodewords * 8 ) { return i ; } } throw new InputOutOfBoundaryException ( string . Format ( " " , ( numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator [ 2 ] ) ) ) ; }
Decide which version group it belong to
Decide which version group it belong to
Version group index for VERSION_GROUP
Version group index for VERSION_GROUP
numBits
int
number of bits for bitlist where it contain DataBits encode from input content and ECI header
number of bits for bitlist where it contain DataBits encode from input content and ECI header
level
ErrorCorrectionLevel
Error correction level
Error correction level
mode
Mode
None