Neos.IdentityServer 3.0/Neos.IdentityServer.QrCodeNet/Versions/VersionControl.cs
/// <summary>
/// Use number of data bits(header + eci header + data bits from EncoderBase) to search for proper version to use
/// between min and max boundary. 
/// Boundary define by DynamicSearchIndicator method. 
/// </summary>
Use number of data bits(header + eci header + data bits from EncoderBase) to search for proper version to use
between min and max boundary.
Boundary define by DynamicSearchIndicator method.
Use number of data bits ( header + eci header + data bits from EncoderBase ) to search for proper version to use between min and max boundary . Boundary define by DynamicSearchIndicator method .
private static int BinarySearch(int numDataBits, ErrorCorrectionLevel level, int lowerVersionNum, int higherVersionNum)
		{
			int middleVersionNumber;
			while(lowerVersionNum <= higherVersionNum)
			{
				middleVersionNumber = (lowerVersionNum + higherVersionNum) / 2;
				QRCodeVersion version = VersionTable.GetVersionByNum(middleVersionNumber);
				int numECCodewords = version.GetECBlocksByLevel(level).NumErrorCorrectionCodewards;
				int dataCodewords = version.TotalCodewords - numECCodewords;
				if(dataCodewords << 3 == numDataBits)
					return middleVersionNumber;
				if(dataCodewords << 3 > numDataBits)
				{
					higherVersionNum = middleVersionNumber - 1;
				}
				else
				{
					lowerVersionNum = middleVersionNumber + 1;
				}
			}
			return lowerVersionNum;
		}
private static int BinarySearch ( int numDataBits , ErrorCorrectionLevel level , int lowerVersionNum , int higherVersionNum ) { int middleVersionNumber ; while ( lowerVersionNum <= higherVersionNum ) { middleVersionNumber = ( lowerVersionNum + higherVersionNum ) / 2 ; QRCodeVersion version = VersionTable . GetVersionByNum ( middleVersionNumber ) ; int numECCodewords = version . GetECBlocksByLevel ( level ) . NumErrorCorrectionCodewards ; int dataCodewords = version . TotalCodewords - numECCodewords ; if ( dataCodewords << 3 == numDataBits ) return middleVersionNumber ; if ( dataCodewords << 3 > numDataBits ) { higherVersionNum = middleVersionNumber - 1 ; } else { lowerVersionNum = middleVersionNumber + 1 ; } } return lowerVersionNum ; }
Use number of data bits(header + eci header + data bits from EncoderBase) to search for proper version to use
between min and max boundary.
Use number of data bits ( header + eci header + data bits from EncoderBase ) to search for proper version to use between min and max boundary .
numDataBits
int
level
ErrorCorrectionLevel
lowerVersionNum
int
higherVersionNum
int