Exemplo n.º 1
0
        public void Make()
        {
            bool flag = this.m_typeNumber < 1;

            if (flag)
            {
                int num;
                for (num = 1; num < 40; num++)
                {
                    List <QRRSBlock> rsBlocks = QRRSBlock.GetRSBlocks(num, this.m_errorCorrectLevel);
                    QRBitBuffer      buffer   = new QRBitBuffer();
                    int num2 = 0;
                    for (int index = 0; index < rsBlocks.Count; index++)
                    {
                        num2 += rsBlocks[index].DataCount;
                    }
                    for (int index2 = 0; index2 < this.m_dataList.Count; index2++)
                    {
                        QR8bitByte qr8bitByte = this.m_dataList[index2];
                        buffer.Put((int)qr8bitByte.Mode, 4);
                        buffer.Put(qr8bitByte.Length, QRUtil.GetLengthInBits(qr8bitByte.Mode, num));
                        qr8bitByte.Write(buffer);
                    }
                    bool flag2 = buffer.GetLengthInBits() <= num2 * 8;
                    if (flag2)
                    {
                        break;
                    }
                }
                this.m_typeNumber = num;
            }
            this.MakeImpl(false, this.GetBestMaskPattern());
        }
Exemplo n.º 2
0
        private DataCache CreateData(int typeNumber, QRErrorCorrectLevel errorCorrectLevel, List <QR8bitByte> dataList)
        {
            List <QRRSBlock> rsBlocks = QRRSBlock.GetRSBlocks(typeNumber, errorCorrectLevel);
            QRBitBuffer      buffer   = new QRBitBuffer();

            for (int index = 0; index < dataList.Count; index++)
            {
                QR8bitByte qr8bitByte = dataList[index];
                buffer.Put((int)qr8bitByte.Mode, 4);
                buffer.Put(qr8bitByte.Length, QRUtil.GetLengthInBits(qr8bitByte.Mode, typeNumber));
                qr8bitByte.Write(buffer);
            }
            int num = 0;

            for (int index2 = 0; index2 < rsBlocks.Count; index2++)
            {
                num += rsBlocks[index2].DataCount;
            }
            bool flag = buffer.GetLengthInBits() > num * 8;

            if (flag)
            {
                throw new Error(string.Concat(new object[]
                {
                    "code length overflow. (",
                    buffer.GetLengthInBits(),
                    ">",
                    num * 8,
                    ")"
                }));
            }
            bool flag2 = buffer.GetLengthInBits() + 4 <= num * 8;

            if (flag2)
            {
                buffer.Put(0, 4);
            }
            while (buffer.GetLengthInBits() % 8 != 0)
            {
                buffer.PutBit(false);
            }
            while (true)
            {
                bool flag3 = buffer.GetLengthInBits() < num * 8;
                if (!flag3)
                {
                    break;
                }
                buffer.Put(236, 8);
                bool flag4 = buffer.GetLengthInBits() < num * 8;
                if (!flag4)
                {
                    break;
                }
                buffer.Put(17, 8);
            }
            return(this.CreateBytes(buffer, rsBlocks));
        }