ClassLibraryWeiBao/QR二维码/Versions/VersionTable.cs

(开头部分) 26KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace Gma.QrCodeNet.Encoding.Versions
{
	public static class VersionTable
	{
		/// <summary>
		/// ISO/IEC 18004/2006 Tabler 9 Page 38
		/// Only include non-micro QRCode
		/// </summary>
		/// <value versionNum>1 to 40, Non-micro QRcode</value>
		internal static QRCodeVersion GetVersionByNum(int versionNum)
		{
			if(versionNum < QRCodeConstantVariable.MinVersion || versionNum > QRCodeConstantVariable.MaxVersion)
				throw new System.InvalidOperationException(string.Format("Unexpected version number: {0}", versionNum));
			return version[versionNum - 1];
		}
		
		/// <summary>
		/// ISO/IEC 18004/2006 Tabler 9 Page 38
		/// Only include non-micro QRCode
		/// </summary>
		/// <value matrixWidth>matrix width for non-micro QRCode</value>
		internal static QRCodeVersion GetVersionByWidth(int matrixWidth)
		{
			if((matrixWidth - 17) % 4 != 0)
				throw new System.ArgumentException("Incorrect matrix width");
			else
				return GetVersionByNum((matrixWidth - 17) / 4);
		}
		
		
		private static QRCodeVersion[] version = initialize();
		
		/// <summary>
		/// We only need totalCodeWords, dataCodewords and number of blocks. Other variable can be calculate through
		/// equation by given that three variables. 
		/// This table try to use original table layout for easier error detection. 
		/// </summary>
		/// <remarks>ISO/IEC 18004/2006 Tabler 9 Page 38
		/// Only include non-micro QRCode</remarks>
		/// <remarks>Sorted list</remarks>
		private static QRCodeVersion[] initialize()
		{
			return new QRCodeVersion[]{
				new QRCodeVersion(1, 26, 
				            new ErrorCorrectionBlocks(7, new ErrorCorrectionBlock(1, 19)),
				            new ErrorCorrectionBlocks(10, new ErrorCorrectionBlock(1, 16)),
				            new ErrorCorrectionBlocks(13, new ErrorCorrectionBlock(1, 13)),
				            new ErrorCorrectionBlocks(17, new ErrorCorrectionBlock(1, 9))),
				new QRCodeVersion(2, 44,
				            new ErrorCorrectionBlocks(10, new ErrorCorrectionBlock(1, 34)),
				            new ErrorCorrectionBlocks(16, new ErrorCorrectionBlock(1, 28)),
				            new ErrorCorrectionBlocks(22, new ErrorCorrectionBlock(1, 22)),
				            new ErrorCorrectionBlocks(28, new ErrorCorrectionBlock(1, 16))),
				new QRCodeVersion(3, 70,
				            new ErrorCorrectionBlocks(15, new ErrorCorrectionBlock(1, 55)),
				            new ErrorCorrectionBlocks(26, new ErrorCorrectionBlock(1, 44)),
				            new ErrorCorrectionBlocks(36, new ErrorCorrectionBlock(2, 17)),
				            new ErrorCorrectionBlocks(44, new ErrorCorrectionBlock(2, 13))),
				new QRCodeVersion(4, 100,
				            new ErrorCorrectionBlocks(20, new ErrorCorrectionBlock(1, 80)),
后面还有 317 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。