ClassLibraryWeiBao/QR二维码/EncodingRegion/FormatInformation.cs

(开头部分) 3KB

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

using System;
using Gma.QrCodeNet.Encoding.Positioning;
using Gma.QrCodeNet.Encoding.Masking;

namespace Gma.QrCodeNet.Encoding.EncodingRegion
{
    /// <summary>
    /// 6.9 Format information
    /// The Format Information is a 15 bit sequence containing 5 data bits, with 10 error correction bits calculated using the (15, 5) BCH code.
    /// </summary>
    /// <remarks>ISO/IEC 18004:2000 Chapter 8.9 Page 53</remarks>
    internal static class FormatInformation
    {
    	/// <summary>
    	/// Embed format information to tristatematrix. 
    	/// Process combination of create info bits, BCH error correction bits calculation, embed towards matrix. 
    	/// </summary>
    	/// <remarks>ISO/IEC 18004:2000 Chapter 8.9 Page 53</remarks>
    	internal static void EmbedFormatInformation(this TriStateMatrix triMatrix,  ErrorCorrectionLevel errorlevel, Pattern pattern)
    	{
    		BitList formatInfo = GetFormatInfoBits(errorlevel, pattern);
    		int width = triMatrix.Width;
    		for(int index = 0; index < 15; index++)
    		{
    			MatrixPoint point = PointForInfo1(index);
    			bool bit = formatInfo[index];
    			triMatrix[point.X, point.Y, MatrixStatus.NoMask] = bit;
    			
    			if(index < 7)
    			{
    				triMatrix[8, width - 1 - index, MatrixStatus.NoMask] = bit;
    			}
    			else
    			{
    				triMatrix[width - 8 + (index - 7), 8, MatrixStatus.NoMask] = bit;
    			}
    			
    		}
    	}
    	
    	private static MatrixPoint PointForInfo1(int bitsIndex)
    	{
    		if(bitsIndex <= 7)
    		{
    			return bitsIndex >= 6 ? new MatrixPoint( bitsIndex + 1, 8 )
    				: new MatrixPoint( bitsIndex, 8 );
    		}
    		else
    		{
    			return bitsIndex == 8 ? new MatrixPoint( 8, 8 - (bitsIndex - 7))
    				: new MatrixPoint( 8, 8 - (bitsIndex - 7) - 1);
    		}
    	}

    	/// <summary>
    	/// From Appendix C in JISX0510:2004 (p.65).
    	/// </summary>
		private const int s_FormatInfoPoly = 0x537;
		/// <summary>
    	/// From Appendix C in JISX0510:2004 (p.65).
后面还有 55 行代码,购买后查看完整代码

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

AI 解读 AI

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

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