Exemple #1
0
 public void Write(QRBitBuffer buffer)
 {
     for (int index = 0; index < this.m_data.Length; index++)
     {
         buffer.Put((int)this.m_data[index], 8);
     }
 }
Exemple #2
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());
        }
Exemple #3
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));
        }
Exemple #4
0
        private DataCache CreateBytes(QRBitBuffer buffer, List <QRRSBlock> rsBlocks)
        {
            int num    = 0;
            int val1_  = 0;
            int val1_2 = 0;

            DataCache[] dataCacheArray  = new DataCache[rsBlocks.Count];
            DataCache[] dataCacheArray2 = new DataCache[rsBlocks.Count];
            for (int index = 0; index < rsBlocks.Count; index++)
            {
                int dataCount = rsBlocks[index].DataCount;
                int num2      = rsBlocks[index].TotalCount - dataCount;
                val1_  = Math.Max(val1_, dataCount);
                val1_2 = Math.Max(val1_2, num2);
                dataCacheArray[index] = new DataCache(dataCount);
                for (int index2 = 0; index2 < dataCacheArray[index].Count; index2++)
                {
                    dataCacheArray[index][index2] = (255 & buffer.m_buffer[index2 + num]);
                }
                num += dataCount;
                QRPolynomial correctPolynomial = QRUtil.GetErrorCorrectPolynomial(num2);
                QRPolynomial qrPolynomial      = new QRPolynomial(dataCacheArray[index], correctPolynomial.GetLength() - 1).Mod(correctPolynomial);
                dataCacheArray2[index] = new DataCache(correctPolynomial.GetLength() - 1);
                for (int index3 = 0; index3 < dataCacheArray2[index].Count; index3++)
                {
                    int index4 = index3 + qrPolynomial.GetLength() - dataCacheArray2[index].Count;
                    dataCacheArray2[index][index3] = ((index4 >= 0) ? qrPolynomial.Get(index4) : 0);
                }
            }
            int capacity = 0;

            for (int index5 = 0; index5 < rsBlocks.Count; index5++)
            {
                capacity += rsBlocks[index5].TotalCount;
            }
            DataCache dataCache = new DataCache(capacity);
            int       num3      = 0;

            for (int index6 = 0; index6 < val1_; index6++)
            {
                for (int index7 = 0; index7 < rsBlocks.Count; index7++)
                {
                    bool flag = index6 < dataCacheArray[index7].Count;
                    if (flag)
                    {
                        dataCache[num3++] = dataCacheArray[index7][index6];
                    }
                }
            }
            for (int index8 = 0; index8 < val1_2; index8++)
            {
                for (int index9 = 0; index9 < rsBlocks.Count; index9++)
                {
                    bool flag2 = index8 < dataCacheArray2[index9].Count;
                    if (flag2)
                    {
                        dataCache[num3++] = dataCacheArray2[index9][index8];
                    }
                }
            }
            return(dataCache);
        }