コード例 #1
0
ファイル: QRImage.cs プロジェクト: Legoless/QRCode
        /// <summary>
        /// Initializes a new instance of the <see cref="QrImage"/> class.
        /// </summary>
        /// <param name="version">
        /// The version.
        /// </param>
        /// <param name="mask">
        /// The mask.
        /// </param>
        public QrImage(QrVersion version, QrMask mask)
        {
            this.version = version;
            this.mask = mask;

            this.Initialize();
        }
コード例 #2
0
ファイル: QRCodeCreator.cs プロジェクト: Legoless/QRCode
 /// <summary>
 /// The choose versions.
 /// </summary>
 private void ChooseVersions()
 {
     // Automatic setting
     if ((this.version == null) || (this.mask == null))
     {
         this.type = QrType.AlphaNumeric;
         this.version = new QrVersion(1, QrError.Q);
         this.mask = new QrMask(2);
     }
 }
コード例 #3
0
ファイル: QRCodeCreator.cs プロジェクト: Legoless/QRCode
 /// <summary>
 /// Advanced mode wrapper
 /// </summary>
 /// <param name="t">
 /// <c>QR</c> code type
 /// </param>
 /// <param name="v">
 /// <c>QR</c> code version
 /// </param>
 /// <param name="m">
 /// <c>QR</c> code mask
 /// </param>
 public void SetAdvancedMode(QrType t, QrVersion v, QrMask m)
 {
     this.type = t;
     this.version = v;
     this.mask = m;
 }
コード例 #4
0
ファイル: QRImage.cs プロジェクト: Legoless/QRCode
        /// <summary>
        /// Initializes a new instance of the <see cref="QrImage"/> class.
        /// </summary>
        /// <param name="codeVersion">
        /// The version.
        /// </param>
        /// <param name="codeMask">
        /// The mask.
        /// </param>
        /// <param name="codeBreakPoint">
        /// The breakpoint to stop image generation.
        /// </param>
        public QrImage(QrVersion codeVersion, QrMask codeMask, QrBreakPoint codeBreakPoint)
        {
            this.debugData = new StringBuilder();

            this.breakPoint = codeBreakPoint;

            this.version = codeVersion;
            this.mask = codeMask;

            this.Initialize();
        }
コード例 #5
0
ファイル: QRImage.cs プロジェクト: Legoless/QRCode
        /// <summary>
        /// The write version.
        /// </summary>
        /// <param name="codeVersion">
        /// The version.
        /// </param>
        private void WriteVersion(QrVersion codeVersion)
        {
            if (this.debugData != null)
            {
                this.debugData.Append("- Should we write version information bits?\n");
            }

            // Only writing version with versions higher than 6
            if (codeVersion.Version >= 7)
            {
                // Calculate BCH (18, 6) for version information
                int bchVersion = QrBoseChaudhuriHocquenghem.CalculateBch(codeVersion.Version, QrConst.GenPolyVersion);

                int versionInformation = (codeVersion.Version << 12) | bchVersion;

                List<bool> versionInfo = BinaryExtensions.DecToBin(versionInformation, 18);

                versionInfo.Reverse();

                if (this.debugData != null)
                {
                    this.debugData.Append(
                        "- Yes, writing information: " + BinaryExtensions.BinaryToString(versionInfo) + ".\n");
                }

                int iterator = 0;

                // Version bits at upper right corner
                for (int y = 0; y < 6; y++)
                {
                    for (int x = this.picture.GetLength(0) - 8 - 3, j = 0; j < 3; x++, j++)
                    {
                        this.picture[x, y] = versionInfo[iterator] ? QrPixel.Black : QrPixel.White;

                        iterator++;
                    }
                }

                iterator = 0;

                // Version bits at lower left corner
                for (int x = 0; x < 6; x++)
                {
                    for (int y = this.picture.GetLength(0) - 8 - 3, j = 0; j < 3; y++, j++)
                    {
                        this.picture[x, y] = versionInfo[iterator] ? QrPixel.Black : QrPixel.White;

                        iterator++;
                    }
                }

                if (this.debugData != null)
                {
                    this.debugData.Append("- Version information bits successfully written.\n");
                }
            }

            if ((this.debugData != null) && (codeVersion.Version < 7))
            {
                this.debugData.Append("- No, only required for versions higher than 6.\n");
            }
        }