コード例 #1
0
 // copy ctor
 private SymbolTemplate(SymbolTemplate prototype)
 {
     this._modules = prototype._modules.CreateCopy();
     this.ErrorCorrectionLevel = prototype.ErrorCorrectionLevel;
     this.Version = prototype.Version;
     this.Width = prototype.Width;
 }
コード例 #2
0
        private SymbolTemplate(int version)
        {
            // See ISO/IEC 18004:2006(E), Sec. 5.3.1.1 for how versions map to sizes.
            Debug.Assert(1 <= version && version <= 40);
            Version = version;

            Width = 21 + 4 * (version - 1);
            _modules = new ModuleBlock(Width);
            PopulateReservedModuleBits();
        }
コード例 #3
0
 // Draws a square of the specified width whose top-left corner is at the specified coords
 private static void DrawSquare(ModuleBlock modules, int row, int col, int width, ModuleFlag type, bool xor = false)
 {
     DrawRect(modules, row, col, width, width, type, xor);
 }
コード例 #4
0
 // copy ctor
 private ModuleBlock(ModuleBlock original)
 {
     this._buffer = (byte[])(original._buffer.Clone());
     this._width = original._width;
 }
コード例 #5
0
        private uint SelectAndApplyMaskingPattern()
        {
            // Masks the QR code to minimize chance of data transmission error
            // See ISO/IEC 18004:2006(E), Sec. 6.8

            SymbolTemplate[] candidates = new SymbolTemplate[_dataMaskPredicates.Length - 1];
            for (int i = 0; i < candidates.Length; i++)
            {
                SymbolTemplate candidate = new SymbolTemplate(this); // copy ctor
                candidate.ApplyMask(_dataMaskPredicates[i]);
                candidates[i] = candidate;
            }

            int lowestPenaltyScoreValue = candidates[0].CalculatePenaltyScore();
            int lowestPenaltyScoreIndex = 0;
            for (int i = 1; i < candidates.Length; i++)
            {
                int candidatePenaltyScoreValue = candidates[i].CalculatePenaltyScore();
                if (candidatePenaltyScoreValue < lowestPenaltyScoreValue)
                {
                    lowestPenaltyScoreValue = candidatePenaltyScoreValue;
                    lowestPenaltyScoreIndex = i;
                }
            }

            // copy the candidate modules array into me; copy by ref is fine
            this._modules = candidates[lowestPenaltyScoreIndex]._modules;
            return (uint)lowestPenaltyScoreIndex;
        }
コード例 #6
0
 private static void DrawRect(ModuleBlock modules, int row, int col, int width, int height, ModuleFlag type, bool xor = false)
 {
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             modules.Set(row + i, col + j, type, !xor);
         }
     }
 }
コード例 #7
0
 // Draws a square of the specified width whose top-left corner is at the specified coords
 private static void DrawSquare(ModuleBlock modules, int row, int col, int width, ModuleFlag type, bool xor = false)
 {
     DrawRect(modules, row, col, width, width, type, xor);
 }