Exemplo n.º 1
0
        /// <summary>
        /// インスタンスを初期化します。
        /// </summary>
        /// <param name="parent">親オブジェクト</param>
        internal Symbol(Symbols parent)
        {
            _parent = parent;

            _position = parent.Count;

            _currEncoder      = null;
            _currEncodingMode = EncodingMode.UNKNOWN;
            _currVersion      = parent.MinVersion;

            _dataBitCapacity = 8 * DataCodeword.GetTotalNumber(
                parent.ErrorCorrectionLevel, parent.MinVersion);
            _dataBitCounter = 0;

            _segments       = new List <QRCodeEncoder>();
            _segmentCounter = new Dictionary <EncodingMode, int>()
            {
                { EncodingMode.NUMERIC, 0 },
                { EncodingMode.ALPHA_NUMERIC, 0 },
                { EncodingMode.EIGHT_BIT_BYTE, 0 },
                { EncodingMode.KANJI, 0 }
            };

            if (parent.StructuredAppendAllowed)
            {
                _dataBitCapacity -= StructuredAppend.HEADER_LENGTH;
            }
        }
Exemplo n.º 2
0
        private void WritePadCodewords(BitSequence bs)
        {
            int numDataCodewords = DataCodeword.GetTotalNumber(
                _parent.ErrorCorrectionLevel, _currVersion);

            bool flag = true;

            while (bs.Length < 8 * numDataCodewords)
            {
                bs.Append(flag ? 236 : 17, 8);
                flag = !flag;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 符号化領域のバイトデータを返します。
        /// </summary>
        private byte[] GetEncodingRegionBytes()
        {
            byte[][] dataBlock = BuildDataBlock();
            byte[][] ecBlock   = BuildErrorCorrectionBlock(dataBlock);

            int numCodewords     = Codeword.GetTotalNumber(_currVersion);
            int numDataCodewords = DataCodeword.GetTotalNumber(
                _parent.ErrorCorrectionLevel, _currVersion);

            byte[] ret = new byte[numCodewords];

            int index = 0;
            int n;

            n = 0;
            while (index < numDataCodewords)
            {
                int r = n % dataBlock.Length;
                int c = n / dataBlock.Length;

                if (c <= dataBlock[r].Length - 1)
                {
                    ret[index] = dataBlock[r][c];
                    index++;
                }
                n++;
            }

            n = 0;
            while (index < numCodewords)
            {
                int r = n % ecBlock.Length;
                int c = n / ecBlock.Length;

                if (c <= ecBlock[r].Length - 1)
                {
                    ret[index] = ecBlock[r][c];
                    index++;
                }
                n++;
            }
            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 型番を決定します。
        /// </summary>
        private void SelectVersion()
        {
            foreach (EncodingMode encMode in _segmentCounter.Keys)
            {
                int num = _segmentCounter[encMode];

                _dataBitCounter +=
                    num * CharCountIndicator.GetLength(_currVersion + 1, encMode)
                    - num * CharCountIndicator.GetLength(_currVersion + 0, encMode);
            }

            _currVersion++;
            _dataBitCapacity = 8 * DataCodeword.GetTotalNumber(
                _parent.ErrorCorrectionLevel, _currVersion);
            _parent.MinVersion = _currVersion;

            if (_parent.StructuredAppendAllowed)
            {
                _dataBitCapacity -= StructuredAppend.HEADER_LENGTH;
            }
        }