예제 #1
0
        public virtual bool[][] calQrcode(byte[] qrcodeData)
        {
            int index1  = 0;
            int length1 = qrcodeData.Length;

            int[]   data = new int[length1 + 32];
            sbyte[] bits = new sbyte[length1 + 32];
            if (length1 <= 0)
            {
                return new bool[1][] { new bool[1] }
            }
            ;
            if (this.qrcodeStructureappendN > 1)
            {
                data[0] = 3;

                bits[0] = (sbyte)4;
                data[1] = this.qrcodeStructureappendM - 1;
                bits[1] = (sbyte)4;
                data[2] = this.qrcodeStructureappendN - 1;
                bits[2] = (sbyte)4;
                data[3] = this.qrcodeStructureappendParity;
                bits[3] = (sbyte)8;
                index1  = 4;
            }
            bits[index1] = (sbyte)4;
            int[] numArray1;
            int   index2;
            int   index3;

            switch (this.qrcodeEncodeMode)
            {
            case QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4
                };
                data[index1] = 2;
                int index4 = index1 + 1;
                data[index4] = length1;
                bits[index4] = (sbyte)9;
                index2       = index4;
                int index5 = index4 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    char  ch  = (char)qrcodeData[index6];
                    sbyte num = 0;
                    if ((int)ch >= 48 && (int)ch < 58)
                    {
                        num = (sbyte)((int)ch - 48);
                    }
                    else if ((int)ch >= 65 && (int)ch < 91)
                    {
                        num = (sbyte)((int)ch - 55);
                    }
                    else
                    {
                        if ((int)ch == 32)
                        {
                            num = (sbyte)36;
                        }
                        if ((int)ch == 36)
                        {
                            num = (sbyte)37;
                        }
                        if ((int)ch == 37)
                        {
                            num = (sbyte)38;
                        }
                        if ((int)ch == 42)
                        {
                            num = (sbyte)39;
                        }
                        if ((int)ch == 43)
                        {
                            num = (sbyte)40;
                        }
                        if ((int)ch == 45)
                        {
                            num = (sbyte)41;
                        }
                        if ((int)ch == 46)
                        {
                            num = (sbyte)42;
                        }
                        if ((int)ch == 47)
                        {
                            num = (sbyte)43;
                        }
                        if ((int)ch == 58)
                        {
                            num = (sbyte)44;
                        }
                    }
                    if (index6 % 2 == 0)
                    {
                        data[index5] = (int)num;
                        bits[index5] = (sbyte)6;
                    }
                    else
                    {
                        data[index5] = data[index5] * 45 + (int)num;
                        bits[index5] = (sbyte)11;
                        if (index6 < length1 - 1)
                        {
                            ++index5;
                        }
                    }
                }
                index3 = index5 + 1;
                break;

            case QRCodeEncoder.ENCODE_MODE.NUMERIC:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    2,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4
                };
                data[index1] = 1;
                int index7 = index1 + 1;
                data[index7] = length1;
                bits[index7] = (sbyte)10;
                index2       = index7;
                int index8 = index7 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    if (index6 % 3 == 0)
                    {
                        data[index8] = (int)qrcodeData[index6] - 48;
                        bits[index8] = (sbyte)4;
                    }
                    else
                    {
                        data[index8] = data[index8] * 10 + ((int)qrcodeData[index6] - 48);
                        if (index6 % 3 == 1)
                        {
                            bits[index8] = (sbyte)7;
                        }
                        else
                        {
                            bits[index8] = (sbyte)10;
                            if (index6 < length1 - 1)
                            {
                                ++index8;
                            }
                        }
                    }
                }
                index3 = index8 + 1;
                break;

            default:
                numArray1 = new int[41]
                {
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8
                };
                data[index1] = 4;
                int index9 = index1 + 1;
                data[index9] = length1;
                bits[index9] = (sbyte)8;
                index2       = index9;
                int num1 = index9 + 1;
                for (int index6 = 0; index6 < length1; ++index6)
                {
                    data[index6 + num1] = (int)qrcodeData[index6] & (int)byte.MaxValue;
                    bits[index6 + num1] = (sbyte)8;
                }
                index3 = num1 + length1;
                break;
            }
            int num2 = 0;

            for (int index6 = 0; index6 < index3; ++index6)
            {
                num2 += (int)bits[index6];
            }
            int index10;

            switch (this.qrcodeErrorCorrect)
            {
            case QRCodeEncoder.ERROR_CORRECTION.L:
                index10 = 1;
                break;

            case QRCodeEncoder.ERROR_CORRECTION.Q:
                index10 = 3;
                break;

            case QRCodeEncoder.ERROR_CORRECTION.H:
                index10 = 2;
                break;

            default:
                index10 = 0;
                break;
            }
            int[][] numArray2 = new int[4][]
            {
                new int[41]
                {
                    0,
                    128,
                    224,
                    352,
                    512,
                    688,
                    864,
                    992,
                    1232,
                    1456,
                    1728,
                    2032,
                    2320,
                    2672,
                    2920,
                    3320,
                    3624,
                    4056,
                    4504,
                    5016,
                    5352,
                    5712,
                    6256,
                    6880,
                    7312,
                    8000,
                    8496,
                    9024,
                    9544,
                    10136,
                    10984,
                    11640,
                    12328,
                    13048,
                    13800,
                    14496,
                    15312,
                    15936,
                    16816,
                    17728,
                    18672
                },
                new int[41]
                {
                    0,
                    152,
                    272,
                    440,
                    640,
                    864,
                    1088,
                    1248,
                    1552,
                    1856,
                    2192,
                    2592,
                    2960,
                    3424,
                    3688,
                    4184,
                    4712,
                    5176,
                    5768,
                    6360,
                    6888,
                    7456,
                    8048,
                    8752,
                    9392,
                    10208,
                    10960,
                    11744,
                    12248,
                    13048,
                    13880,
                    14744,
                    15640,
                    16568,
                    17528,
                    18448,
                    19472,
                    20528,
                    21616,
                    22496,
                    23648
                },
                new int[41]
                {
                    0,
                    72,
                    128,
                    208,
                    288,
                    368,
                    480,
                    528,
                    688,
                    800,
                    976,
                    1120,
                    1264,
                    1440,
                    1576,
                    1784,
                    2024,
                    2264,
                    2504,
                    2728,
                    3080,
                    3248,
                    3536,
                    3712,
                    4112,
                    4304,
                    4768,
                    5024,
                    5288,
                    5608,
                    5960,
                    6344,
                    6760,
                    7208,
                    7688,
                    7888,
                    8432,
                    8768,
                    9136,
                    9776,
                    10208
                },
                new int[41]
                {
                    0,
                    104,
                    176,
                    272,
                    384,
                    496,
                    608,
                    704,
                    880,
                    1056,
                    1232,
                    1440,
                    1648,
                    1952,
                    2088,
                    2360,
                    2600,
                    2936,
                    3176,
                    3560,
                    3880,
                    4096,
                    4544,
                    4912,
                    5312,
                    5744,
                    6032,
                    6464,
                    6968,
                    7288,
                    7880,
                    8264,
                    8920,
                    9368,
                    9848,
                    10288,
                    10832,
                    11408,
                    12016,
                    12656,
                    13328
                }
            };
            int num3 = 0;

            if (this.qrcodeVersion == 0)
            {
                this.qrcodeVersion = 1;
                for (int index6 = 1; index6 <= 40; ++index6)
                {
                    if (numArray2[index10][index6] >= num2 + numArray1[this.qrcodeVersion])
                    {
                        num3 = numArray2[index10][index6];
                        break;
                    }
                    ++this.qrcodeVersion;
                }
            }
            else
            {
                num3 = numArray2[index10][this.qrcodeVersion];
            }
            int num4 = num2 + numArray1[this.qrcodeVersion];

            bits[index2] = (sbyte)((int)bits[index2] + numArray1[this.qrcodeVersion]);
            int maxCodewords = new int[41]
            {
                0,
                26,
                44,
                70,
                100,
                134,
                172,
                196,
                242,
                292,
                346,
                404,
                466,
                532,
                581,
                655,
                733,
                815,
                901,
                991,
                1085,
                1156,
                1258,
                1364,
                1474,
                1588,
                1706,
                1828,
                1921,
                2051,
                2185,
                2323,
                2465,
                2611,
                2761,
                2876,
                3034,
                3196,
                3362,
                3532,
                3706
            }[this.qrcodeVersion];
            int num5 = 17 + (this.qrcodeVersion << 2);

            int[] numArray3 = new int[41]
            {
                0,
                0,
                7,
                7,
                7,
                7,
                7,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                3,
                3,
                3,
                3,
                3,
                3,
                3,
                4,
                4,
                4,
                4,
                4,
                4,
                4,
                3,
                3,
                3,
                3,
                3,
                3,
                3,
                0,
                0,
                0,
                0,
                0,
                0
            };
            int length2 = numArray3[this.qrcodeVersion] + (maxCodewords << 3);

            sbyte[] target1 = new sbyte[length2];
            sbyte[] target2 = new sbyte[length2];
            sbyte[] target3 = new sbyte[length2];
            sbyte[] target4 = new sbyte[15];
            sbyte[] target5 = new sbyte[15];
            sbyte[] target6 = new sbyte[1];
            sbyte[] target7 = new sbyte[128];
            try
            {
                // ISSUE: reference to a compiler-generated method
                var            resKey         = "qrv" + Convert.ToString(qrcodeVersion) + "_" + Convert.ToString(index10);
                byte[]         qrdata         = ReadData(resKey);
                MemoryStream   memoryStream   = new MemoryStream(qrdata);
                BufferedStream bufferedStream = new BufferedStream(memoryStream);
                SystemUtils.ReadInput((Stream)bufferedStream, target1, 0, target1.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target2, 0, target2.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target3, 0, target3.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target4, 0, target4.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target5, 0, target5.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target6, 0, target6.Length);
                SystemUtils.ReadInput((Stream)bufferedStream, target7, 0, target7.Length);
                bufferedStream.Close();
                memoryStream.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            sbyte num6 = 1;

            for (sbyte index6 = 1; (int)index6 < 128; ++index6)
            {
                if ((int)target7[(int)index6] == 0)
                {
                    num6 = index6;
                    break;
                }
            }
            sbyte[] rsBlockOrder = new sbyte[(int)num6];
            Array.Copy((Array)target7, 0, (Array)rsBlockOrder, 0, (int)(byte)num6);
            sbyte[] numArray4 = new sbyte[15]
            {
                (sbyte)0,
                (sbyte)1,
                (sbyte)2,
                (sbyte)3,
                (sbyte)4,
                (sbyte)5,
                (sbyte)7,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8
            };
            sbyte[] numArray5 = new sbyte[15]
            {
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)8,
                (sbyte)7,
                (sbyte)5,
                (sbyte)4,
                (sbyte)3,
                (sbyte)2,
                (sbyte)1,
                (sbyte)0
            };
            int maxDataCodewords = num3 >> 3;
            int length3          = 4 * this.qrcodeVersion + 17;

            sbyte[] target8 = new sbyte[length3 * length3 + length3];
            try
            {
                // ISSUE: reference to a compiler-generated method
                byte[]         qrdata         = ReadData("qrvfr" + Convert.ToString(this.qrcodeVersion));
                MemoryStream   memoryStream   = new MemoryStream(qrdata);
                BufferedStream bufferedStream = new BufferedStream((Stream)memoryStream);
                SystemUtils.ReadInput((Stream)bufferedStream, target8, 0, target8.Length);
                bufferedStream.Close();
                memoryStream.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            if (num4 <= num3 - 4)
            {
                data[index3] = 0;
                bits[index3] = (sbyte)4;
            }
            else if (num4 < num3)
            {
                data[index3] = 0;
                bits[index3] = (sbyte)(num3 - num4);
            }
            else if (num4 > num3)
            {
                Console.Out.WriteLine("overflow");
            }
            sbyte[]   rsecc         = QRCodeEncoder.calculateRSECC(QRCodeEncoder.divideDataBy8Bits(data, bits, maxDataCodewords), target6[0], rsBlockOrder, maxDataCodewords, maxCodewords);
            sbyte[][] matrixContent = new sbyte[length3][];
            for (int index6 = 0; index6 < length3; ++index6)
            {
                matrixContent[index6] = new sbyte[length3];
            }
            for (int index6 = 0; index6 < length3; ++index6)
            {
                for (int index11 = 0; index11 < length3; ++index11)
                {
                    matrixContent[index11][index6] = (sbyte)0;
                }
            }
            for (int index6 = 0; index6 < maxCodewords; ++index6)
            {
                sbyte num7 = rsecc[index6];
                for (int index11 = 7; index11 >= 0; --index11)
                {
                    int index12 = index6 * 8 + index11;
                    matrixContent[(int)target1[index12] & (int)byte.MaxValue][(int)target2[index12] & (int)byte.MaxValue] = (sbyte)((int)byte.MaxValue * ((int)num7 & 1) ^ (int)target3[index12]);
                    num7 = (sbyte)SystemUtils.URShift((int)num7 & (int)byte.MaxValue, 1);
                }
            }
            for (int index6 = numArray3[this.qrcodeVersion]; index6 > 0; --index6)
            {
                int index11 = index6 + maxCodewords * 8 - 1;
                matrixContent[(int)target1[index11] & (int)byte.MaxValue][(int)target2[index11] & (int)byte.MaxValue] = (sbyte)((int)byte.MaxValue ^ (int)target3[index11]);
            }
            sbyte num8  = QRCodeEncoder.selectMask(matrixContent, numArray3[this.qrcodeVersion] + maxCodewords * 8);
            sbyte num9  = (sbyte)(1 << (int)num8);
            sbyte num10 = (sbyte)(index10 << 3 | (int)num8);

            string[] strArray = new string[32]
            {
                "101010000010010",
                "101000100100101",
                "101111001111100",
                "101101101001011",
                "100010111111001",
                "100000011001110",
                "100111110010111",
                "100101010100000",
                "111011111000100",
                "111001011110011",
                "111110110101010",
                "111100010011101",
                "110011000101111",
                "110001100011000",
                "110110001000001",
                "110100101110110",
                "001011010001001",
                "001001110111110",
                "001110011100111",
                "001100111010000",
                "000011101100010",
                "000001001010101",
                "000110100001100",
                "000100000111011",
                "011010101011111",
                "011000001101000",
                "011111100110001",
                "011101000000110",
                "010010010110100",
                "010000110000011",
                "010111011011010",
                "010101111101101"
            };
            for (int startIndex = 0; startIndex < 15; ++startIndex)
            {
                sbyte num7 = sbyte.Parse(strArray[(int)num10].Substring(startIndex, startIndex + 1 - startIndex));
                matrixContent[(int)numArray4[startIndex] & (int)byte.MaxValue][(int)numArray5[startIndex] & (int)byte.MaxValue] = (sbyte)((int)num7 * (int)byte.MaxValue);
                matrixContent[(int)target4[startIndex] & (int)byte.MaxValue][(int)target5[startIndex] & (int)byte.MaxValue]     = (sbyte)((int)num7 * (int)byte.MaxValue);
            }
            bool[][] flagArray = new bool[length3][];
            for (int index6 = 0; index6 < length3; ++index6)
            {
                flagArray[index6] = new bool[length3];
            }
            int index13 = 0;

            for (int index6 = 0; index6 < length3; ++index6)
            {
                for (int index11 = 0; index11 < length3; ++index11)
                {
                    int num7 = ((int)matrixContent[index11][index6] & (int)num9) != 0 ? 0 : ((int)target8[index13] != 49 ? 1 : 0);
                    flagArray[index11][index6] = num7 == 0;
                    ++index13;
                }
                ++index13;
            }
            return(flagArray);
        }
예제 #2
0
        public virtual bool[][] calQrcode(byte[] qrcodeData)
        {
            int dataCounter = 0;
            int dataLength  = qrcodeData.Length;

            int[]    dataValue = new int[dataLength + 32];
            sbyte[]  dataBits  = new sbyte[dataLength + 32];
            bool[][] result;
            if (dataLength <= 0)
            {
                bool[][] array    = new bool[1][];
                bool[][] arg_3B_0 = array;
                int      arg_3B_1 = 0;
                bool[]   array2   = new bool[1];
                arg_3B_0[arg_3B_1] = array2;
                bool[][] ret = array;
                result = ret;
            }
            else
            {
                if (this.qrcodeStructureappendN > 1)
                {
                    dataValue[0] = 3;
                    dataBits[0]  = 4;
                    dataValue[1] = this.qrcodeStructureappendM - 1;
                    dataBits[1]  = 4;
                    dataValue[2] = this.qrcodeStructureappendN - 1;
                    dataBits[2]  = 4;
                    dataValue[3] = this.qrcodeStructureappendParity;
                    dataBits[3]  = 8;
                    dataCounter  = 4;
                }
                dataBits[dataCounter] = 4;
                int[] codewordNumPlus;
                int   codewordNumCounterValue;
                switch (this.qrcodeEncodeMode)
                {
                case QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC:
                    codewordNumPlus = new int[]
                    {
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4
                    };
                    dataValue[dataCounter] = 2;
                    dataCounter++;
                    dataValue[dataCounter]  = dataLength;
                    dataBits[dataCounter]   = 9;
                    codewordNumCounterValue = dataCounter;
                    dataCounter++;
                    for (int i = 0; i < dataLength; i++)
                    {
                        char  chr      = (char)qrcodeData[i];
                        sbyte chrValue = 0;
                        if (chr >= '0' && chr < ':')
                        {
                            chrValue = (sbyte)(chr - '0');
                        }
                        else
                        {
                            if (chr >= 'A' && chr < '[')
                            {
                                chrValue = (sbyte)(chr - '7');
                            }
                            else
                            {
                                if (chr == ' ')
                                {
                                    chrValue = 36;
                                }
                                if (chr == '$')
                                {
                                    chrValue = 37;
                                }
                                if (chr == '%')
                                {
                                    chrValue = 38;
                                }
                                if (chr == '*')
                                {
                                    chrValue = 39;
                                }
                                if (chr == '+')
                                {
                                    chrValue = 40;
                                }
                                if (chr == '-')
                                {
                                    chrValue = 41;
                                }
                                if (chr == '.')
                                {
                                    chrValue = 42;
                                }
                                if (chr == '/')
                                {
                                    chrValue = 43;
                                }
                                if (chr == ':')
                                {
                                    chrValue = 44;
                                }
                            }
                        }
                        if (i % 2 == 0)
                        {
                            dataValue[dataCounter] = (int)chrValue;
                            dataBits[dataCounter]  = 6;
                        }
                        else
                        {
                            dataValue[dataCounter] = dataValue[dataCounter] * 45 + (int)chrValue;
                            dataBits[dataCounter]  = 11;
                            if (i < dataLength - 1)
                            {
                                dataCounter++;
                            }
                        }
                    }
                    dataCounter++;
                    break;

                case QRCodeEncoder.ENCODE_MODE.NUMERIC:
                    codewordNumPlus = new int[]
                    {
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        2,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4,
                        4
                    };
                    dataValue[dataCounter] = 1;
                    dataCounter++;
                    dataValue[dataCounter]  = dataLength;
                    dataBits[dataCounter]   = 10;
                    codewordNumCounterValue = dataCounter;
                    dataCounter++;
                    for (int i = 0; i < dataLength; i++)
                    {
                        if (i % 3 == 0)
                        {
                            dataValue[dataCounter] = (int)(qrcodeData[i] - 48);
                            dataBits[dataCounter]  = 4;
                        }
                        else
                        {
                            dataValue[dataCounter] = dataValue[dataCounter] * 10 + (int)(qrcodeData[i] - 48);
                            if (i % 3 == 1)
                            {
                                dataBits[dataCounter] = 7;
                            }
                            else
                            {
                                dataBits[dataCounter] = 10;
                                if (i < dataLength - 1)
                                {
                                    dataCounter++;
                                }
                            }
                        }
                    }
                    dataCounter++;
                    break;

                default:
                    codewordNumPlus = new int[]
                    {
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8,
                        8
                    };
                    dataValue[dataCounter] = 4;
                    dataCounter++;
                    dataValue[dataCounter]  = dataLength;
                    dataBits[dataCounter]   = 8;
                    codewordNumCounterValue = dataCounter;
                    dataCounter++;
                    for (int i = 0; i < dataLength; i++)
                    {
                        dataValue[i + dataCounter] = (int)(qrcodeData[i] & 255);
                        dataBits[i + dataCounter]  = 8;
                    }
                    dataCounter += dataLength;
                    break;
                }
                int totalDataBits = 0;
                for (int i = 0; i < dataCounter; i++)
                {
                    totalDataBits += (int)dataBits[i];
                }
                int ec;
                switch (this.qrcodeErrorCorrect)
                {
                case QRCodeEncoder.ERROR_CORRECTION.L:
                    ec = 1;
                    goto IL_3D0;

                case QRCodeEncoder.ERROR_CORRECTION.Q:
                    ec = 3;
                    goto IL_3D0;

                case QRCodeEncoder.ERROR_CORRECTION.H:
                    ec = 2;
                    goto IL_3D0;
                }
                ec = 0;
IL_3D0:
                int[][] maxDataBitsArray = new int[][]
                {
                    new int[]
                    {
                        0,
                        128,
                        224,
                        352,
                        512,
                        688,
                        864,
                        992,
                        1232,
                        1456,
                        1728,
                        2032,
                        2320,
                        2672,
                        2920,
                        3320,
                        3624,
                        4056,
                        4504,
                        5016,
                        5352,
                        5712,
                        6256,
                        6880,
                        7312,
                        8000,
                        8496,
                        9024,
                        9544,
                        10136,
                        10984,
                        11640,
                        12328,
                        13048,
                        13800,
                        14496,
                        15312,
                        15936,
                        16816,
                        17728,
                        18672
                    },
                    new int[]
                    {
                        0,
                        152,
                        272,
                        440,
                        640,
                        864,
                        1088,
                        1248,
                        1552,
                        1856,
                        2192,
                        2592,
                        2960,
                        3424,
                        3688,
                        4184,
                        4712,
                        5176,
                        5768,
                        6360,
                        6888,
                        7456,
                        8048,
                        8752,
                        9392,
                        10208,
                        10960,
                        11744,
                        12248,
                        13048,
                        13880,
                        14744,
                        15640,
                        16568,
                        17528,
                        18448,
                        19472,
                        20528,
                        21616,
                        22496,
                        23648
                    },
                    new int[]
                    {
                        0,
                        72,
                        128,
                        208,
                        288,
                        368,
                        480,
                        528,
                        688,
                        800,
                        976,
                        1120,
                        1264,
                        1440,
                        1576,
                        1784,
                        2024,
                        2264,
                        2504,
                        2728,
                        3080,
                        3248,
                        3536,
                        3712,
                        4112,
                        4304,
                        4768,
                        5024,
                        5288,
                        5608,
                        5960,
                        6344,
                        6760,
                        7208,
                        7688,
                        7888,
                        8432,
                        8768,
                        9136,
                        9776,
                        10208
                    },
                    new int[]
                    {
                        0,
                        104,
                        176,
                        272,
                        384,
                        496,
                        608,
                        704,
                        880,
                        1056,
                        1232,
                        1440,
                        1648,
                        1952,
                        2088,
                        2360,
                        2600,
                        2936,
                        3176,
                        3560,
                        3880,
                        4096,
                        4544,
                        4912,
                        5312,
                        5744,
                        6032,
                        6464,
                        6968,
                        7288,
                        7880,
                        8264,
                        8920,
                        9368,
                        9848,
                        10288,
                        10832,
                        11408,
                        12016,
                        12656,
                        13328
                    }
                };
                int maxDataBits = 0;
                if (this.qrcodeVersion == 0)
                {
                    this.qrcodeVersion = 1;
                    for (int i = 1; i <= 40; i++)
                    {
                        if (maxDataBitsArray[ec][i] >= totalDataBits + codewordNumPlus[this.qrcodeVersion])
                        {
                            maxDataBits = maxDataBitsArray[ec][i];
                            break;
                        }
                        this.qrcodeVersion++;
                    }
                }
                else
                {
                    maxDataBits = maxDataBitsArray[ec][this.qrcodeVersion];
                }
                totalDataBits += codewordNumPlus[this.qrcodeVersion];
                dataBits[codewordNumCounterValue] = (sbyte)((int)dataBits[codewordNumCounterValue] + codewordNumPlus[this.qrcodeVersion]);
                int[] maxCodewordsArray = new int[]
                {
                    0,
                    26,
                    44,
                    70,
                    100,
                    134,
                    172,
                    196,
                    242,
                    292,
                    346,
                    404,
                    466,
                    532,
                    581,
                    655,
                    733,
                    815,
                    901,
                    991,
                    1085,
                    1156,
                    1258,
                    1364,
                    1474,
                    1588,
                    1706,
                    1828,
                    1921,
                    2051,
                    2185,
                    2323,
                    2465,
                    2611,
                    2761,
                    2876,
                    3034,
                    3196,
                    3362,
                    3532,
                    3706
                };
                int   maxCodewords    = maxCodewordsArray[this.qrcodeVersion];
                int   maxModules1side = 17 + (this.qrcodeVersion << 2);
                int[] matrixRemainBit = new int[]
                {
                    0,
                    0,
                    7,
                    7,
                    7,
                    7,
                    7,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    3,
                    3,
                    3,
                    3,
                    3,
                    3,
                    3,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    4,
                    3,
                    3,
                    3,
                    3,
                    3,
                    3,
                    3,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                };
                int     byte_num            = matrixRemainBit[this.qrcodeVersion] + (maxCodewords << 3);
                sbyte[] matrixX             = new sbyte[byte_num];
                sbyte[] matrixY             = new sbyte[byte_num];
                sbyte[] maskArray           = new sbyte[byte_num];
                sbyte[] formatInformationX2 = new sbyte[15];
                sbyte[] formatInformationY2 = new sbyte[15];
                sbyte[] rsEccCodewords      = new sbyte[1];
                sbyte[] rsBlockOrderTemp    = new sbyte[128];
                try
                {
                    string         fileName     = "qrv" + Convert.ToString(this.qrcodeVersion) + "_" + Convert.ToString(ec);
                    MemoryStream   memoryStream = new MemoryStream((byte[])Resources.ResourceManager.GetObject(fileName));
                    BufferedStream bis          = new BufferedStream(memoryStream);
                    SystemUtils.ReadInput(bis, matrixX, 0, matrixX.Length);
                    SystemUtils.ReadInput(bis, matrixY, 0, matrixY.Length);
                    SystemUtils.ReadInput(bis, maskArray, 0, maskArray.Length);
                    SystemUtils.ReadInput(bis, formatInformationX2, 0, formatInformationX2.Length);
                    SystemUtils.ReadInput(bis, formatInformationY2, 0, formatInformationY2.Length);
                    SystemUtils.ReadInput(bis, rsEccCodewords, 0, rsEccCodewords.Length);
                    SystemUtils.ReadInput(bis, rsBlockOrderTemp, 0, rsBlockOrderTemp.Length);
                    bis.Close();
                    memoryStream.Close();
                }
                catch (Exception e)
                {
                    SystemUtils.WriteStackTrace(e, Console.Error);
                }
                sbyte rsBlockOrderLength = 1;
                sbyte j = 1;
                while ((int)j < 128)
                {
                    if (rsBlockOrderTemp[(int)j] == 0)
                    {
                        rsBlockOrderLength = j;
                        break;
                    }
                    j += 1;
                }
                sbyte[] rsBlockOrder = new sbyte[(int)rsBlockOrderLength];
                Array.Copy(rsBlockOrderTemp, 0, rsBlockOrder, 0, (int)((byte)rsBlockOrderLength));
                sbyte[] formatInformationX3 = new sbyte[]
                {
                    0,
                    1,
                    2,
                    3,
                    4,
                    5,
                    7,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8
                };
                sbyte[] formatInformationY3 = new sbyte[]
                {
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    8,
                    7,
                    5,
                    4,
                    3,
                    2,
                    1,
                    0
                };
                int     maxDataCodewords = maxDataBits >> 3;
                int     modules1Side     = 4 * this.qrcodeVersion + 17;
                int     matrixTotalBits  = modules1Side * modules1Side;
                sbyte[] frameData        = new sbyte[matrixTotalBits + modules1Side];
                try
                {
                    string         fileName     = "qrvfr" + Convert.ToString(this.qrcodeVersion);
                    MemoryStream   memoryStream = new MemoryStream((byte[])Resources.ResourceManager.GetObject(fileName));
                    BufferedStream bis          = new BufferedStream(memoryStream);
                    SystemUtils.ReadInput(bis, frameData, 0, frameData.Length);
                    bis.Close();
                    memoryStream.Close();
                }
                catch (Exception e)
                {
                    SystemUtils.WriteStackTrace(e, Console.Error);
                }
                if (totalDataBits <= maxDataBits - 4)
                {
                    dataValue[dataCounter] = 0;
                    dataBits[dataCounter]  = 4;
                }
                else
                {
                    if (totalDataBits < maxDataBits)
                    {
                        dataValue[dataCounter] = 0;
                        dataBits[dataCounter]  = (sbyte)(maxDataBits - totalDataBits);
                    }
                    else
                    {
                        if (totalDataBits > maxDataBits)
                        {
                            Console.Out.WriteLine("overflow");
                        }
                    }
                }
                sbyte[]   dataCodewords = QRCodeEncoder.divideDataBy8Bits(dataValue, dataBits, maxDataCodewords);
                sbyte[]   codewords     = QRCodeEncoder.calculateRSECC(dataCodewords, rsEccCodewords[0], rsBlockOrder, maxDataCodewords, maxCodewords);
                sbyte[][] matrixContent = new sbyte[modules1Side][];
                for (int i2 = 0; i2 < modules1Side; i2++)
                {
                    matrixContent[i2] = new sbyte[modules1Side];
                }
                for (int i = 0; i < modules1Side; i++)
                {
                    for (int k = 0; k < modules1Side; k++)
                    {
                        matrixContent[k][i] = 0;
                    }
                }
                for (int i = 0; i < maxCodewords; i++)
                {
                    sbyte codeword_i = codewords[i];
                    for (int k = 7; k >= 0; k--)
                    {
                        int codewordBitsNumber = i * 8 + k;
                        matrixContent[(int)matrixX[codewordBitsNumber] & 255][(int)matrixY[codewordBitsNumber] & 255] = (sbyte)(255 * (int)(codeword_i & 1) ^ (int)maskArray[codewordBitsNumber]);
                        codeword_i = (sbyte)SystemUtils.URShift((int)codeword_i & 255, 1);
                    }
                }
                for (int matrixRemain = matrixRemainBit[this.qrcodeVersion]; matrixRemain > 0; matrixRemain--)
                {
                    int remainBitTemp = matrixRemain + maxCodewords * 8 - 1;
                    matrixContent[(int)matrixX[remainBitTemp] & 255][(int)matrixY[remainBitTemp] & 255] = (sbyte)(255 ^ (int)maskArray[remainBitTemp]);
                }
                sbyte    maskNumber             = QRCodeEncoder.selectMask(matrixContent, matrixRemainBit[this.qrcodeVersion] + maxCodewords * 8);
                sbyte    maskContent            = (sbyte)(1 << (int)maskNumber);
                sbyte    formatInformationValue = (sbyte)(ec << 3 | (int)maskNumber);
                string[] formatInformationArray = new string[]
                {
                    "101010000010010",
                    "101000100100101",
                    "101111001111100",
                    "101101101001011",
                    "100010111111001",
                    "100000011001110",
                    "100111110010111",
                    "100101010100000",
                    "111011111000100",
                    "111001011110011",
                    "111110110101010",
                    "111100010011101",
                    "110011000101111",
                    "110001100011000",
                    "110110001000001",
                    "110100101110110",
                    "001011010001001",
                    "001001110111110",
                    "001110011100111",
                    "001100111010000",
                    "000011101100010",
                    "000001001010101",
                    "000110100001100",
                    "000100000111011",
                    "011010101011111",
                    "011000001101000",
                    "011111100110001",
                    "011101000000110",
                    "010010010110100",
                    "010000110000011",
                    "010111011011010",
                    "010101111101101"
                };
                for (int i = 0; i < 15; i++)
                {
                    sbyte content = sbyte.Parse(formatInformationArray[(int)formatInformationValue].Substring(i, i + 1 - i));
                    matrixContent[(int)formatInformationX3[i] & 255][(int)formatInformationY3[i] & 255] = (sbyte)((int)content * 255);
                    matrixContent[(int)formatInformationX2[i] & 255][(int)formatInformationY2[i] & 255] = (sbyte)((int)content * 255);
                }
                bool[][] out_Renamed = new bool[modules1Side][];
                for (int i3 = 0; i3 < modules1Side; i3++)
                {
                    out_Renamed[i3] = new bool[modules1Side];
                }
                int c = 0;
                for (int i = 0; i < modules1Side; i++)
                {
                    for (int k = 0; k < modules1Side; k++)
                    {
                        if ((matrixContent[k][i] & maskContent) != 0 || frameData[c] == 49)
                        {
                            out_Renamed[k][i] = true;
                        }
                        else
                        {
                            out_Renamed[k][i] = false;
                        }
                        c++;
                    }
                    c++;
                }
                result = out_Renamed;
            }
            return(result);
        }