Exemplo n.º 1
0
        public override void Save()
        {
            itemEffects.CopyTo(ParentTable.Data[EntryNumber], 2);
            attack.CopyTo(ParentTable.Data[EntryNumber], 4);
            attackAlt.CopyTo(ParentTable.Data[EntryNumber], 6);
            defense.CopyTo(ParentTable.Data[EntryNumber], 8);
            Convert.ToByte(group).CopyTo(ParentTable.Data[EntryNumber], 10);
            unknown1.CopyTo(ParentTable.Data[EntryNumber], 11);
            resistSlash.CopyTo(ParentTable.Data[EntryNumber], 12);
            resistBlunt.CopyTo(ParentTable.Data[EntryNumber], 13);
            resistPierce.CopyTo(ParentTable.Data[EntryNumber], 14);
            resistFire.CopyTo(ParentTable.Data[EntryNumber], 15);
            resistIce.CopyTo(ParentTable.Data[EntryNumber], 16);
            resistVolt.CopyTo(ParentTable.Data[EntryNumber], 17);
            resistDeath.CopyTo(ParentTable.Data[EntryNumber], 18);
            resistAilment.CopyTo(ParentTable.Data[EntryNumber], 19);
            resistHeadBind.CopyTo(ParentTable.Data[EntryNumber], 20);
            resistArmBind.CopyTo(ParentTable.Data[EntryNumber], 21);
            resistLegBind.CopyTo(ParentTable.Data[EntryNumber], 22);
            strModifier.CopyTo(ParentTable.Data[EntryNumber], 23);
            vitModifier.CopyTo(ParentTable.Data[EntryNumber], 24);
            agiModifier.CopyTo(ParentTable.Data[EntryNumber], 25);
            lucModifier.CopyTo(ParentTable.Data[EntryNumber], 26);
            tecModifier.CopyTo(ParentTable.Data[EntryNumber], 27);
            hpModifier.CopyTo(ParentTable.Data[EntryNumber], 28);
            tpModifier.CopyTo(ParentTable.Data[EntryNumber], 29);
            boostModifier.CopyTo(ParentTable.Data[EntryNumber], 30);
            unknown2.CopyTo(ParentTable.Data[EntryNumber], 31);
            buyPrice.CopyTo(ParentTable.Data[EntryNumber], 32);
            sellPrice.CopyTo(ParentTable.Data[EntryNumber], 36);
            classUsability.CopyTo(ParentTable.Data[EntryNumber], 40);
            unknown3.CopyTo(ParentTable.Data[EntryNumber], 42);

            base.Save();
        }
        public void SByteArrayTestPositive()
        {
            sbyte[] b1 = new sbyte[256];
            sbyte[] b2 = new sbyte[256];
            for (int i = 0; i <= 255; i++)
            {
                b1[i] = (sbyte)i;
            }

            b1.CopyTo(b2, 0);

            ComparisonResult result = _compare.Compare(b1, b2);

            if (!result.AreEqual)
            {
                throw new Exception(result.DifferencesString);
            }
        }
        public void SByteListTestNegative()
        {
            sbyte[] b1 = new sbyte[256];
            sbyte[] b2 = new sbyte[256];
            for (int i = 0; i <= 255; i++)
            {
                b1[i] = (sbyte)i;
            }

            b1.CopyTo(b2, 0);
            b2[5] = 77;

            List <sbyte>     bList1 = new List <sbyte>(b1);
            List <sbyte>     bList2 = new List <sbyte>(b2);
            ComparisonResult result = _compare.Compare(bList1, bList2);

            if (result.AreEqual)
            {
                throw new Exception(result.DifferencesString);
            }
        }
Exemplo n.º 4
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] rsCalTableArray = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                rsCalTableArray[i] = new sbyte[rsEccCodewords];
            }
            try
            {
                //String filename = QRCODE_DATA_PATH + @"\rsc" + rsEccCodewords.ToString() + ".dat";
                //StreamReader reader = new StreamReader(filename);
                String fileName = "rsc" + rsEccCodewords.ToString();
                //MemoryStream memoryStream = new MemoryStream(Resources.GetResource(fileName));
                MemoryStream   memoryStream = new MemoryStream();
                BufferedStream bis          = new BufferedStream(memoryStream);
                for (int i = 0; i < 256; i++)
                {
                    SystemUtils.ReadInput(bis, rsCalTableArray[i], 0, rsCalTableArray[i].Length);
                }
                bis.Close();
                //reader.Close();
                memoryStream.Close();
            }
            catch (Exception e)
            {
                SystemUtils.WriteStackTrace(e, Console.Error);
            }


            /* ---- RS-ECC prepare */

            int i2            = 0;
            int j             = 0;
            int rsBlockNumber = 0;

            sbyte[][] rsTemp = new sbyte[rsBlockOrder.Length][];

            /*
             * for (int i = 0; i < rsBlockOrder.Length; i++)
             * {
             *  rsTemp[i] = new sbyte[rsBlockOrder.Length];
             * }
             */
            sbyte[] res = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, res, 0, codewords.Length);

            i2 = 0;
            while (i2 < rsBlockOrder.Length)
            {
                rsTemp[i2] = new sbyte[(rsBlockOrder[i2] & 0xFF) - rsEccCodewords];
                i2++;
            }
            i2 = 0;
            while (i2 < maxDataCodewords)
            {
                rsTemp[rsBlockNumber][j] = codewords[i2];
                j++;
                if (j >= (rsBlockOrder[rsBlockNumber] & 0xFF) - rsEccCodewords)
                {
                    j = 0;
                    rsBlockNumber++;
                }
                i2++;
            }

            /* ---  RS-ECC main --- */

            rsBlockNumber = 0;
            while (rsBlockNumber < rsBlockOrder.Length)
            {
                sbyte[] rsTempData;
                rsTempData = new sbyte[rsTemp[rsBlockNumber].Length];
                rsTemp[rsBlockNumber].CopyTo(rsTempData, 0);

                int rsCodewords     = (rsBlockOrder[rsBlockNumber] & 0xFF);
                int rsDataCodewords = rsCodewords - rsEccCodewords;

                j = rsDataCodewords;
                while (j > 0)
                {
                    sbyte first = rsTempData[0];
                    if (first != 0)
                    {
                        sbyte[] leftChr = new sbyte[rsTempData.Length - 1];
                        Array.Copy(rsTempData, 1, leftChr, 0, rsTempData.Length - 1);
                        sbyte[] cal = rsCalTableArray[(first & 0xFF)];
                        rsTempData = calculateByteArrayBits(leftChr, cal, "xor");
                    }
                    else
                    {
                        if (rsEccCodewords < rsTempData.Length)
                        {
                            sbyte[] rsTempNew = new sbyte[rsTempData.Length - 1];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                        else
                        {
                            sbyte[] rsTempNew = new sbyte[rsEccCodewords];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempNew[rsEccCodewords - 1] = 0;
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                    }
                    j--;
                }

                Array.Copy(rsTempData, 0, res, codewords.Length + rsBlockNumber * rsEccCodewords, (byte)rsEccCodewords);
                rsBlockNumber++;
            }
            return(res);
        }
Exemplo n.º 5
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            int num;

            sbyte[][] numArray = new sbyte[0x100][];
            for (num = 0; num < 0x100; num++)
            {
                numArray[num] = new sbyte[rsEccCodewords];
            }
            try
            {
                string         name         = "rsc" + rsEccCodewords.ToString();
                MemoryStream   stream       = new MemoryStream((byte[])Resources.ResourceManager.GetObject(name));
                BufferedStream sourceStream = new BufferedStream(stream);
                for (num = 0; num < 0x100; num++)
                {
                    SystemUtils.ReadInput(sourceStream, numArray[num], 0, numArray[num].Length);
                }
                sourceStream.Close();
                stream.Close();
            }
            catch (Exception exception)
            {
                SystemUtils.WriteStackTrace(exception, Console.Error);
            }
            int index = 0;
            int num3  = 0;
            int num4  = 0;

            sbyte[][] numArray2        = new sbyte[rsBlockOrder.Length][];
            sbyte[]   destinationArray = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, destinationArray, 0, codewords.Length);
            for (index = 0; index < rsBlockOrder.Length; index++)
            {
                numArray2[index] = new sbyte[(rsBlockOrder[index] & 0xff) - rsEccCodewords];
            }
            for (index = 0; index < maxDataCodewords; index++)
            {
                numArray2[num4][num3] = codewords[index];
                num3++;
                if (num3 >= ((rsBlockOrder[num4] & 0xff) - rsEccCodewords))
                {
                    num3 = 0;
                    num4++;
                }
            }
            for (num4 = 0; num4 < rsBlockOrder.Length; num4++)
            {
                sbyte[] array = new sbyte[numArray2[num4].Length];
                numArray2[num4].CopyTo(array, 0);
                int num5 = rsBlockOrder[num4] & 0xff;
                int num6 = num5 - rsEccCodewords;
                for (num3 = num6; num3 > 0; num3--)
                {
                    sbyte num7 = array[0];
                    if (num7 != 0)
                    {
                        sbyte[] numArray5 = new sbyte[array.Length - 1];
                        Array.Copy(array, 1, numArray5, 0, array.Length - 1);
                        sbyte[] xb = numArray[num7 & 0xff];
                        array = calculateByteArrayBits(numArray5, xb, "xor");
                    }
                    else
                    {
                        sbyte[] numArray7;
                        if (rsEccCodewords < array.Length)
                        {
                            numArray7 = new sbyte[array.Length - 1];
                            Array.Copy(array, 1, numArray7, 0, array.Length - 1);
                            array = new sbyte[numArray7.Length];
                            numArray7.CopyTo(array, 0);
                        }
                        else
                        {
                            numArray7 = new sbyte[rsEccCodewords];
                            Array.Copy(array, 1, numArray7, 0, array.Length - 1);
                            numArray7[rsEccCodewords - 1] = 0;
                            array = new sbyte[numArray7.Length];
                            numArray7.CopyTo(array, 0);
                        }
                    }
                }
                Array.Copy(array, 0, destinationArray, codewords.Length + (num4 * rsEccCodewords), (byte)rsEccCodewords);
            }
            return(destinationArray);
        }
Exemplo n.º 6
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] array = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                array[i] = new sbyte[(int)rsEccCodewords];
            }
            try
            {
                string         name           = "rsc" + rsEccCodewords.ToString();
                MemoryStream   memoryStream   = new MemoryStream(Resources.ResourceManager.GetObject(name) as byte[]);
                BufferedStream bufferedStream = new BufferedStream(memoryStream);
                for (int i = 0; i < 256; i++)
                {
                    SystemUtils.ReadInput(bufferedStream, array[i], 0, array[i].Length);
                }
                bufferedStream.Close();
                memoryStream.Close();
            }
            catch (Exception throwable)
            {
                SystemUtils.WriteStackTrace(throwable, Console.Error);
            }
            int j = 0;
            int k = 0;
            int l = 0;

            sbyte[][] array2 = new sbyte[rsBlockOrder.Length][];
            sbyte[]   array3 = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, array3, 0, codewords.Length);
            for (j = 0; j < rsBlockOrder.Length; j++)
            {
                array2[j] = new sbyte[((int)rsBlockOrder[j] & 255) - (int)rsEccCodewords];
            }
            for (j = 0; j < maxDataCodewords; j++)
            {
                array2[l][k] = codewords[j];
                k++;
                if (k >= ((int)rsBlockOrder[l] & 255) - (int)rsEccCodewords)
                {
                    k = 0;
                    l++;
                }
            }
            for (l = 0; l < rsBlockOrder.Length; l++)
            {
                sbyte[] array4 = new sbyte[array2[l].Length];
                array2[l].CopyTo(array4, 0);
                int num  = (int)rsBlockOrder[l] & 255;
                int num2 = num - (int)rsEccCodewords;
                for (k = num2; k > 0; k--)
                {
                    sbyte b = array4[0];
                    if (b != 0)
                    {
                        sbyte[] array5 = new sbyte[array4.Length - 1];
                        Array.Copy(array4, 1, array5, 0, array4.Length - 1);
                        sbyte[] xb = array[(int)b & 255];
                        array4 = QRCodeEncoder.calculateByteArrayBits(array5, xb, "xor");
                    }
                    else
                    {
                        if ((int)rsEccCodewords < array4.Length)
                        {
                            sbyte[] array6 = new sbyte[array4.Length - 1];
                            Array.Copy(array4, 1, array6, 0, array4.Length - 1);
                            array4 = new sbyte[array6.Length];
                            array6.CopyTo(array4, 0);
                        }
                        else
                        {
                            sbyte[] array6 = new sbyte[(int)rsEccCodewords];
                            Array.Copy(array4, 1, array6, 0, array4.Length - 1);
                            array6[(int)(rsEccCodewords - 1)] = 0;
                            array4 = new sbyte[array6.Length];
                            array6.CopyTo(array4, 0);
                        }
                    }
                }
                Array.Copy(array4, 0, array3, codewords.Length + l * (int)rsEccCodewords, (int)((byte)rsEccCodewords));
            }
            return(array3);
        }
Exemplo n.º 7
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] rsCalTableArray = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                rsCalTableArray[i] = new sbyte[rsEccCodewords];
            }

            {
                byte[] qrdata = ReadData("rsc" + System.Convert.ToString(rsEccCodewords));

                int start = 0;
                for (int i = 0; i < 256; i++)
                {
                    start = ReadByte(qrdata, rsCalTableArray[i], start, rsCalTableArray[i].Length);
                }
            }

            /* ---- RS-ECC prepare */

            int j             = 0;
            int rsBlockNumber = 0;

            sbyte[][] rsTemp = new sbyte[rsBlockOrder.Length][];

            /*
             * for (int i = 0; i < rsBlockOrder.Length; i++)
             * {
             *  rsTemp[i] = new sbyte[rsBlockOrder.Length];
             * }
             */
            sbyte[] res = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, res, 0, codewords.Length);

            int i2 = 0;

            while (i2 < rsBlockOrder.Length)
            {
                rsTemp[i2] = new sbyte[(rsBlockOrder[i2] & 0xFF) - rsEccCodewords];
                i2++;
            }
            i2 = 0;
            while (i2 < maxDataCodewords)
            {
                rsTemp[rsBlockNumber][j] = codewords[i2];
                j++;
                if (j >= (rsBlockOrder[rsBlockNumber] & 0xFF) - rsEccCodewords)
                {
                    j = 0;
                    rsBlockNumber++;
                }
                i2++;
            }

            /* ---  RS-ECC main --- */

            rsBlockNumber = 0;
            while (rsBlockNumber < rsBlockOrder.Length)
            {
                sbyte[] rsTempData;
                rsTempData = new sbyte[rsTemp[rsBlockNumber].Length];
                rsTemp[rsBlockNumber].CopyTo(rsTempData, 0);

                int rsCodewords     = (rsBlockOrder[rsBlockNumber] & 0xFF);
                int rsDataCodewords = rsCodewords - rsEccCodewords;

                j = rsDataCodewords;
                while (j > 0)
                {
                    sbyte first = rsTempData[0];
                    if (first != 0)
                    {
                        sbyte[] leftChr = new sbyte[rsTempData.Length - 1];
                        Array.Copy(rsTempData, 1, leftChr, 0, rsTempData.Length - 1);
                        sbyte[] cal = rsCalTableArray[(first & 0xFF)];
                        rsTempData = calculateByteArrayBits(leftChr, cal, "xor");
                    }
                    else
                    {
                        if (rsEccCodewords < rsTempData.Length)
                        {
                            sbyte[] rsTempNew = new sbyte[rsTempData.Length - 1];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                        else
                        {
                            sbyte[] rsTempNew = new sbyte[rsEccCodewords];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempNew[rsEccCodewords - 1] = 0;
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                    }
                    j--;
                }

                Array.Copy(rsTempData, 0, res, codewords.Length + rsBlockNumber * rsEccCodewords, (byte)rsEccCodewords);
                rsBlockNumber++;
            }
            return(res);
        }
Exemplo n.º 8
0
        sbyte[] CalculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] rsCalTableArray = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                rsCalTableArray[i] = new sbyte[rsEccCodewords];
            }

            String fileName = "rsc" + rsEccCodewords.ToString();
            Stream stream   = GetResourceFile(fileName);

            if (stream == null)
            {
                throw new IOException("can't load rsc file");
            }
            for (int i = 0; i < 256; i++)
            {
                Read(stream, rsCalTableArray[i], 0, rsCalTableArray[i].Length);
            }
            stream.Close();



            /* RS-ECC prepare */

            int i2            = 0;
            int j             = 0;
            int rsBlockNumber = 0;

            sbyte[][] rsTemp = new sbyte[rsBlockOrder.Length][];
            sbyte[]   res    = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, res, 0, codewords.Length);

            i2 = 0;
            while (i2 < rsBlockOrder.Length)
            {
                rsTemp[i2] = new sbyte[(rsBlockOrder[i2] & 0xFF) - rsEccCodewords];
                i2++;
            }
            i2 = 0;
            while (i2 < maxDataCodewords)
            {
                rsTemp[rsBlockNumber][j] = codewords[i2];
                j++;
                if (j >= (rsBlockOrder[rsBlockNumber] & 0xFF) - rsEccCodewords)
                {
                    j = 0;
                    rsBlockNumber++;
                }
                i2++;
            }

            /* RS-ECC main */

            rsBlockNumber = 0;
            while (rsBlockNumber < rsBlockOrder.Length)
            {
                sbyte[] rsTempData;
                rsTempData = new sbyte[rsTemp[rsBlockNumber].Length];
                rsTemp[rsBlockNumber].CopyTo(rsTempData, 0);

                int rsCodewords     = (rsBlockOrder[rsBlockNumber] & 0xFF);
                int rsDataCodewords = rsCodewords - rsEccCodewords;

                j = rsDataCodewords;
                while (j > 0)
                {
                    sbyte first = rsTempData[0];
                    if (first != 0)
                    {
                        sbyte[] leftChr = new sbyte[rsTempData.Length - 1];
                        Array.Copy(rsTempData, 1, leftChr, 0, rsTempData.Length - 1);
                        sbyte[] cal = rsCalTableArray[(first & 0xFF)];
                        rsTempData = CalculateByteArrayBits(leftChr, cal, "xor");
                    }
                    else
                    {
                        if (rsEccCodewords < rsTempData.Length)
                        {
                            sbyte[] rsTempNew = new sbyte[rsTempData.Length - 1];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                        else
                        {
                            sbyte[] rsTempNew = new sbyte[rsEccCodewords];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempNew[rsEccCodewords - 1] = 0;
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                    }
                    j--;
                }

                Array.Copy(rsTempData, 0, res, codewords.Length + rsBlockNumber * rsEccCodewords, (byte)rsEccCodewords);
                rsBlockNumber++;
            }
            return(res);
        }
Exemplo n.º 9
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
            {
                // ISSUE: reference to a compiler-generated method
                byte[]         qrdata         = ReadData("rsc" + rsEccCodewords.ToString());
                MemoryStream   memoryStream   = new MemoryStream(qrdata);
                BufferedStream bufferedStream = new BufferedStream(memoryStream);
                for (int index = 0; index < 256; ++index)
                {
                    SystemUtils.ReadInput((Stream)bufferedStream, numArray1[index], 0, numArray1[index].Length);
                }
                bufferedStream.Close();
                memoryStream.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)
            {
                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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] rsCalTableArray = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                rsCalTableArray[i] = new sbyte[(int)rsEccCodewords];
            }
            try
            {
                string         fileName     = "rsc" + rsEccCodewords.ToString();
                MemoryStream   memoryStream = new MemoryStream((byte[])Resources.ResourceManager.GetObject(fileName));
                BufferedStream bis          = new BufferedStream(memoryStream);
                for (int i = 0; i < 256; i++)
                {
                    SystemUtils.ReadInput(bis, rsCalTableArray[i], 0, rsCalTableArray[i].Length);
                }
                bis.Close();
                memoryStream.Close();
            }
            catch (Exception e)
            {
                SystemUtils.WriteStackTrace(e, Console.Error);
            }
            int j             = 0;
            int rsBlockNumber = 0;

            sbyte[][] rsTemp = new sbyte[rsBlockOrder.Length][];
            sbyte[]   res    = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, res, 0, codewords.Length);
            for (int i2 = 0; i2 < rsBlockOrder.Length; i2++)
            {
                rsTemp[i2] = new sbyte[((int)rsBlockOrder[i2] & 255) - (int)rsEccCodewords];
            }
            for (int i2 = 0; i2 < maxDataCodewords; i2++)
            {
                rsTemp[rsBlockNumber][j] = codewords[i2];
                j++;
                if (j >= ((int)rsBlockOrder[rsBlockNumber] & 255) - (int)rsEccCodewords)
                {
                    j = 0;
                    rsBlockNumber++;
                }
            }
            for (rsBlockNumber = 0; rsBlockNumber < rsBlockOrder.Length; rsBlockNumber++)
            {
                sbyte[] rsTempData = new sbyte[rsTemp[rsBlockNumber].Length];
                rsTemp[rsBlockNumber].CopyTo(rsTempData, 0);
                int rsCodewords     = (int)rsBlockOrder[rsBlockNumber] & 255;
                int rsDataCodewords = rsCodewords - (int)rsEccCodewords;
                for (j = rsDataCodewords; j > 0; j--)
                {
                    sbyte first = rsTempData[0];
                    if (first != 0)
                    {
                        sbyte[] leftChr = new sbyte[rsTempData.Length - 1];
                        Array.Copy(rsTempData, 1, leftChr, 0, rsTempData.Length - 1);
                        sbyte[] cal = rsCalTableArray[(int)first & 255];
                        rsTempData = QRCodeEncoder.calculateByteArrayBits(leftChr, cal, "xor");
                    }
                    else
                    {
                        if ((int)rsEccCodewords < rsTempData.Length)
                        {
                            sbyte[] rsTempNew = new sbyte[rsTempData.Length - 1];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                        else
                        {
                            sbyte[] rsTempNew = new sbyte[(int)rsEccCodewords];
                            Array.Copy(rsTempData, 1, rsTempNew, 0, rsTempData.Length - 1);
                            rsTempNew[(int)(rsEccCodewords - 1)] = 0;
                            rsTempData = new sbyte[rsTempNew.Length];
                            rsTempNew.CopyTo(rsTempData, 0);
                        }
                    }
                }
                Array.Copy(rsTempData, 0, res, codewords.Length + rsBlockNumber * (int)rsEccCodewords, (int)((byte)rsEccCodewords));
            }
            return(res);
        }
Exemplo n.º 12
0
        private static sbyte[] calculateRSECC(sbyte[] codewords, sbyte rsEccCodewords, sbyte[] rsBlockOrder, int maxDataCodewords, int maxCodewords)
        {
            sbyte[][] array = new sbyte[256][];
            for (int i = 0; i < 256; i++)
            {
                array[i] = new sbyte[rsEccCodewords];
            }
            try
            {
                string         name           = "rsc" + rsEccCodewords;
                MemoryStream   memoryStream   = new MemoryStream((byte[])Resources.ResourceManager.GetObject(name));
                BufferedStream bufferedStream = new BufferedStream(memoryStream);
                for (int i = 0; i < 256; i++)
                {
                    SystemUtils.ReadInput(bufferedStream, array[i], 0, array[i].Length);
                }
                bufferedStream.Close();
                memoryStream.Close();
            }
            catch (Exception throwable)
            {
                SystemUtils.WriteStackTrace(throwable, Console.Error);
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            sbyte[][] array2 = new sbyte[rsBlockOrder.Length][];
            sbyte[]   array3 = new sbyte[maxCodewords];
            Array.Copy(codewords, 0, array3, 0, codewords.Length);
            for (num = 0; num < rsBlockOrder.Length; num++)
            {
                array2[num] = new sbyte[(rsBlockOrder[num] & 0xFF) - rsEccCodewords];
            }
            for (num = 0; num < maxDataCodewords; num++)
            {
                array2[num3][num2] = codewords[num];
                num2++;
                if (num2 >= (rsBlockOrder[num3] & 0xFF) - rsEccCodewords)
                {
                    num2 = 0;
                    num3++;
                }
            }
            for (num3 = 0; num3 < rsBlockOrder.Length; num3++)
            {
                sbyte[] array4 = new sbyte[array2[num3].Length];
                array2[num3].CopyTo(array4, 0);
                int num4 = rsBlockOrder[num3] & 0xFF;
                int num5 = num4 - rsEccCodewords;
                for (num2 = num5; num2 > 0; num2--)
                {
                    sbyte b = array4[0];
                    if (b != 0)
                    {
                        sbyte[] array5 = new sbyte[array4.Length - 1];
                        Array.Copy(array4, 1, array5, 0, array4.Length - 1);
                        sbyte[] xb = array[b & 0xFF];
                        array4 = calculateByteArrayBits(array5, xb, "xor");
                    }
                    else if (rsEccCodewords < array4.Length)
                    {
                        sbyte[] array6 = new sbyte[array4.Length - 1];
                        Array.Copy(array4, 1, array6, 0, array4.Length - 1);
                        array4 = new sbyte[array6.Length];
                        array6.CopyTo(array4, 0);
                    }
                    else
                    {
                        sbyte[] array6 = new sbyte[rsEccCodewords];
                        Array.Copy(array4, 1, array6, 0, array4.Length - 1);
                        array6[rsEccCodewords - 1] = 0;
                        array4 = new sbyte[array6.Length];
                        array6.CopyTo(array4, 0);
                    }
                }
                Array.Copy(array4, 0, array3, codewords.Length + num3 * rsEccCodewords, (byte)rsEccCodewords);
            }
            return(array3);
        }