Exemplo n.º 1
0
        private static sbyte[] CalculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] numArray1 = new sbyte[256][];
            for (int index = 0; index < 256; ++index)
            {
                numArray1[index] = new sbyte[(int)rsEccCodewords];
            }
            try
            {
                Stream         embeddedFile   = QRCodeEncoder.GetEmbeddedFile(QRCodeEncoder.DATA_PATH + ".rsc" + rsEccCodewords.ToString() + ".dat");
                BufferedStream bufferedStream = new BufferedStream(embeddedFile);
                for (int index = 0; index < 256; ++index)
                {
                    SystemUtils.ReadInput((Stream)bufferedStream, numArray1[index], 0, numArray1[index].Length);
                }
                bufferedStream.Close();
                embeddedFile.Close();
            }
            catch (Exception ex)
            {
                SystemUtils.WriteStackTrace(ex, Console.Error);
            }
            int index1 = 0;
            int index2 = 0;

            sbyte[][] numArray2 = new sbyte[rsBlockOrder.Length][];
            sbyte[]   numArray3 = new sbyte[maxCodewords];
            Array.Copy((Array)codewords, 0, (Array)numArray3, 0, codewords.Length);
            for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3)
            {
                numArray2[index3] = new sbyte[((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords];
            }
            for (int index3 = 0; index3 < maxDataCodewords; ++index3)
            {
                var s = codewords[index3];
                //numArray2[index2][index1] = codewords[index3];
                ++index1;
                if (index1 >= ((int)rsBlockOrder[index2] & (int)byte.MaxValue) - (int)rsEccCodewords)
                {
                    index1 = 0;
                    ++index2;
                }
            }
            for (int index3 = 0; index3 < rsBlockOrder.Length; ++index3)
            {
                sbyte[] numArray4 = new sbyte[numArray2[index3].Length];
                numArray2[index3].CopyTo((Array)numArray4, 0);
                for (int index4 = ((int)rsBlockOrder[index3] & (int)byte.MaxValue) - (int)rsEccCodewords; index4 > 0; --index4)
                {
                    sbyte num = numArray4[0];
                    if ((int)num != 0)
                    {
                        sbyte[] xa = new sbyte[numArray4.Length - 1];
                        Array.Copy((Array)numArray4, 1, (Array)xa, 0, numArray4.Length - 1);
                        sbyte[] xb = numArray1[(int)num & (int)byte.MaxValue];
                        numArray4 = QRCodeEncoder.CalculateByteArrayBits(xa, xb, "xor");
                    }
                    else if ((int)rsEccCodewords < numArray4.Length)
                    {
                        sbyte[] numArray5 = new sbyte[numArray4.Length - 1];
                        Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1);
                        numArray4 = new sbyte[numArray5.Length];
                        numArray5.CopyTo((Array)numArray4, 0);
                    }
                    else
                    {
                        sbyte[] numArray5 = new sbyte[(int)rsEccCodewords];
                        Array.Copy((Array)numArray4, 1, (Array)numArray5, 0, numArray4.Length - 1);
                        numArray5[(int)rsEccCodewords - 1] = (sbyte)0;
                        numArray4 = new sbyte[numArray5.Length];
                        numArray5.CopyTo((Array)numArray4, 0);
                    }
                }
                Array.Copy((Array)numArray4, 0, (Array)numArray3, codewords.Length + index3 * (int)rsEccCodewords, (int)(byte)rsEccCodewords);
            }
            return(numArray3);
        }