Пример #1
0
        /// <summary>
        /// Encodes the specified content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="errorLevel">The error level.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        internal static BitMatrix Encode(string content, ErrorCorrectionLevel errorLevel)
        {
            EncodationStruct encodeStruct = DataEncode.Encode(content, errorLevel);

            BitList codewords = ECGenerator.FillECCodewords(encodeStruct.DataCodewords, encodeStruct.VersionDetail);

            var triMatrix = new TriStateMatrix(encodeStruct.VersionDetail.MatrixWidth);
            PositioninngPatternBuilder.EmbedBasicPatterns(encodeStruct.VersionDetail.Version, triMatrix);

            triMatrix.EmbedVersionInformation(encodeStruct.VersionDetail.Version);
            triMatrix.EmbedFormatInformation(errorLevel, new Pattern0());
            triMatrix.TryEmbedCodewords(codewords);

            return triMatrix.GetLowestPenaltyMatrix(errorLevel);
        }
Пример #2
0
        /// <summary>
        /// Encodes the specified content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="errorLevel">The error level.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        internal static BitMatrix Encode(string content, ErrorCorrectionLevel errorLevel)
        {
            EncodationStruct encodeStruct = DataEncode.Encode(content, errorLevel);

            BitList codewords = ECGenerator.FillECCodewords(encodeStruct.DataCodewords, encodeStruct.VersionDetail);

            var triMatrix = new TriStateMatrix(encodeStruct.VersionDetail.MatrixWidth);

            PositioninngPatternBuilder.EmbedBasicPatterns(encodeStruct.VersionDetail.Version, triMatrix);

            triMatrix.EmbedVersionInformation(encodeStruct.VersionDetail.Version);
            triMatrix.EmbedFormatInformation(errorLevel, new Pattern0());
            triMatrix.TryEmbedCodewords(codewords);

            return(triMatrix.GetLowestPenaltyMatrix(errorLevel));
        }
Пример #3
0
        /// <summary>
        /// Creates the tri state matrix.
        /// </summary>
        /// <param name="internalArray">The internal array.</param>
        /// <param name="triStateMatrix">The tri state matrix.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static bool CreateTriStateMatrix(bool[,] internalArray, out TriStateMatrix triStateMatrix)
        {
            triStateMatrix = null;
            if (internalArray == null)
            {
                return(false);
            }

            if (internalArray.GetLength(0) == internalArray.GetLength(1))
            {
                triStateMatrix = new TriStateMatrix(internalArray);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Creates the tri state matrix.
        /// </summary>
        /// <param name="internalArray">The internal array.</param>
        /// <param name="triStateMatrix">The tri state matrix.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static bool CreateTriStateMatrix(bool[,] internalArray, out TriStateMatrix triStateMatrix)
        {
            triStateMatrix = null;
            if (internalArray == null)
                return false;

            if (internalArray.GetLength(0) == internalArray.GetLength(1))
            {
                triStateMatrix = new TriStateMatrix(internalArray);
                return true;
            }
            else
            {
                return false;
            }
        }