private void TestOneCase(string inputString, ErrorCorrectionLevel eclevel, IEnumerable <bool> expected)
        {
            EncodationStruct encodeStruct = DataEncode.Encode(inputString, eclevel);

            IEnumerable <bool> actualResult = ECGenerator.FillECCodewords(encodeStruct.DataCodewords, encodeStruct.VersionDetail);

            BitVectorTestExtensions.CompareIEnumerable(actualResult, expected, "string");
        }
Example #2
0
        private void TestOneCase(IEnumerable <bool> dataCodewords, VersionDetail vc, IEnumerable <bool> expected)
        {
            BitList dcList = new BitList();

            dcList.Add(dataCodewords);

            IEnumerable <bool> actualResult = ECGenerator.FillECCodewords(dcList, vc);

            BitVectorTestExtensions.CompareIEnumerable(actualResult, expected, "string");
        }
Example #3
0
        private static BitMatrix ProcessEncodationResult(EncodationStruct encodeStruct, ErrorCorrectionLevel errorLevel)
        {
            BitList codewords = ECGenerator.FillECCodewords(encodeStruct.DataCodewords, encodeStruct.VersionDetail);

            TriStateMatrix 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));
        }
Example #4
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));
        }
        public void PerformanceTest()
        {
            Random    randomizer     = new Random();
            BitVector dataCodewordsV = GenerateDataCodewords(s_vcInfo.NumDataBytes, randomizer);

            BitList dataCodewordsL = new BitList();

            dataCodewordsL.Add(dataCodewordsV);

            Stopwatch sw          = new Stopwatch();
            int       timesofTest = 1000;

            string[] timeElapsed = new string[2];

            sw.Start();
            for (int i = 0; i < timesofTest; i++)
            {
                ECGenerator.FillECCodewords(dataCodewordsL, s_vcInfo);
            }
            sw.Stop();

            timeElapsed[0] = sw.ElapsedMilliseconds.ToString();

            sw.Reset();

            sw.Start();
            for (int i = 0; i < timesofTest; i++)
            {
                BitVector finalBits = new BitVector();
                EncoderInternal.interleaveWithECBytes(dataCodewordsV, s_vcInfo.NumTotalBytes, s_vcInfo.NumDataBytes, s_vcInfo.NumECBlocks, finalBits);
            }
            sw.Stop();

            timeElapsed[1] = sw.ElapsedMilliseconds.ToString();


            Assert.Pass("ErrorCorrection performance {0} Tests~ QrCode.Net: {1} ZXing: {2}", timesofTest, timeElapsed[0], timeElapsed[1]);
        }
Example #6
0
        private void Encode(string content, int option)
        {
            ErrorCorrectionLevel errorLevel = ErrorCorrectionLevel.H;

            EncodationStruct encodeStruct = DataEncode.Encode(content, errorLevel);

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

            if (option == 3)
            {
                return;
            }

            TriStateMatrix 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);

            triMatrix.GetLowestPenaltyMatrix(errorLevel);
        }