示例#1
0
        /// <summary>
        /// Method writes format to picture.
        /// </summary>
        /// <param name="error">
        /// The error code information.
        /// </param>
        /// <param name="codeMask">
        /// The mask mask information.
        /// </param>
        private void WriteFormat(QrError error, QrMask codeMask)
        {
            QrFormat format;

            if (this.debugData != null)
            {
                this.debugData.Append("------------------ Step 10 ------------------\n- Writing format ...\n");

                format = new QrFormat(error, codeMask, true);

                this.debugData.Append(format.GetDebugData());
            }
            else
            {
                format = new QrFormat(error, codeMask);
            }

            List <bool> bits = new List <bool>(format.GetFormatBits().ToArray());

            // Write format vertically
            int y = 0;

            for (int i = 0; i < bits.Count; i++)
            {
                if (this.picture[8, y] == QrPixel.Format)
                {
                    this.picture[8, y] = bits[i] ? QrPixel.Black : QrPixel.White;
                }
                else
                {
                    y++;
                    i--;
                }
            }

            // Write format horizontally
            int x = this.picture.GetLength(0) - 1;

            for (int i = 0; i < bits.Count; i++)
            {
                if (this.picture[x, 8] == QrPixel.Format)
                {
                    this.picture[x, 8] = bits[i] ? QrPixel.Black : QrPixel.White;
                }
                else
                {
                    x--;
                    i--;
                }
            }

            if (this.debugData != null)
            {
                this.debugData.Append("- Format successfully written.\n\n");
            }
        }
示例#2
0
        /// <summary>
        /// Method writes format to picture.
        /// </summary>
        /// <param name="error">
        /// The error code information.
        /// </param>
        /// <param name="codeMask">
        /// The mask mask information.
        /// </param>
        private void WriteFormat(QrError error, QrMask codeMask)
        {
            QrFormat format;

            if (this.debugData != null)
            {
                this.debugData.Append("------------------ Step 10 ------------------\n- Writing format ...\n");

                format = new QrFormat(error, codeMask, true);

                this.debugData.Append(format.GetDebugData());
            }
            else
            {
                format = new QrFormat(error, codeMask);
            }

            List<bool> bits = new List<bool>(format.GetFormatBits().ToArray());

            // Write format vertically
            int y = 0;

            for (int i = 0; i < bits.Count; i++)
            {
                if (this.picture[8, y] == QrPixel.Format)
                {
                    this.picture[8, y] = bits[i] ? QrPixel.Black : QrPixel.White;
                }
                else
                {
                    y++;
                    i--;
                }
            }

            // Write format horizontally
            int x = this.picture.GetLength(0) - 1;

            for (int i = 0; i < bits.Count; i++)
            {
                if (this.picture[x, 8] == QrPixel.Format)
                {
                    this.picture[x, 8] = bits[i] ? QrPixel.Black : QrPixel.White;
                }
                else
                {
                    x--;
                    i--;
                }
            }

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