Exemplo n.º 1
0
        internal virtual bool[] readFormatInformation()
        {
            bool[] modules = new bool[15];

            //obtain format information from symbol
            for (int i = 0; i <= 5; i++)
            {
                modules[i] = getElement(8, i);
            }

            modules[6] = getElement(8, 7);
            modules[7] = getElement(8, 8);
            modules[8] = getElement(7, 8);

            for (int i = 9; i <= 14; i++)
            {
                modules[i] = getElement(14 - i, 8);
            }

            //unmask Format Information's with given mask pattern. (JIS-X-0510(2004), p65)
            int maskPattern = 0x5412;

            for (int i = 0; i <= 14; i++)
            {
                bool xorBit = false;
                if (((SystemUtils.URShift(maskPattern, i)) & 1) == 1)
                {
                    xorBit = true;
                }
                else
                {
                    xorBit = false;
                }

                // get unmasked format information with bit shift
                if (modules[i] == xorBit)
                {
                    modules[i] = false;
                }
                else
                {
                    modules[i] = true;
                }
            }

            BCH15_5 corrector = new BCH15_5(modules);

            bool[] output            = corrector.correct();
            bool[] formatInformation = new bool[5];
            for (int i = 0; i < 5; i++)
            {
                formatInformation[i] = output[10 + i];
            }

            return(formatInformation);
        }
Exemplo n.º 2
0
        internal virtual bool[] ReadFormatInformation()
        {
            bool[] modules = new bool[15];

            //obtain format information from symbol
            for (int i = 0; i <= 5; i++)
                modules[i] = GetElement(8, i);

            modules[6] = GetElement(8, 7);
            modules[7] = GetElement(8, 8);
            modules[8] = GetElement(7, 8);

            for (int i = 9; i <= 14; i++)
                modules[i] = GetElement(14 - i, 8);

            //unmask Format Information's with given mask pattern. (JIS-X-0510(2004), p65)
            int maskPattern = 0x5412;

            for (int i = 0; i <= 14; i++)
            {
                bool xorBit = false;
                if (((SystemUtils.URShift(maskPattern, i)) & 1) == 1)
                    xorBit = true;
                else
                    xorBit = false;

                // get unmasked format information with bit shift
                if (modules[i] == xorBit)
                    modules[i] = false;
                else
                    modules[i] = true;
            }

            BCH15_5 corrector = new BCH15_5(modules);
            bool[] output = corrector.Correct();
            bool[] formatInformation = new bool[5];
            for (int i = 0; i < 5; i++)
                formatInformation[i] = output[10 + i];

            return formatInformation;
        }