public virtual QRCodeSymbol getQRCodeSymbol(int[][] image)
        {
            int longSide = (image.Length < image[0].Length)?image[0].Length:image.Length;

            QRCodeImageReader.DECIMAL_POINT = 23 - QRCodeUtility.sqrt(longSide / 256);
            bitmap = filterImage(image);
            canvas.println("Drawing matrix.");
            canvas.drawMatrix(bitmap);

            canvas.println("Scanning Finder Pattern.");
            FinderPattern finderPattern = null;

            try
            {
                finderPattern = FinderPattern.findFinderPattern(bitmap);
            }
            catch (FinderPatternNotFoundException)
            {
                canvas.println("Not found, now retrying...");
                bitmap = applyCrossMaskingMedianFilter(bitmap, 5);
                canvas.drawMatrix(bitmap);
                for (int i = 0; i < 1000000000; i++)
                {
                    ;
                }
                try
                {
                    finderPattern = FinderPattern.findFinderPattern(bitmap);
                }
                catch (FinderPatternNotFoundException e2)
                {
                    throw new SymbolNotFoundException(e2.Message);
                }
                catch (VersionInformationException e2)
                {
                    throw new SymbolNotFoundException(e2.Message);
                }
            }
            catch (VersionInformationException e)
            {
                throw new SymbolNotFoundException(e.Message);
            }


            canvas.println("FinderPattern at");
            String finderPatternCoordinates = finderPattern.getCenter(FinderPattern.UL).ToString() + finderPattern.getCenter(FinderPattern.UR).ToString() + finderPattern.getCenter(FinderPattern.DL).ToString();

            canvas.println(finderPatternCoordinates);
            int[] sincos = finderPattern.getAngle();
            canvas.println("Angle*4098: Sin " + System.Convert.ToString(sincos[0]) + "  " + "Cos " + System.Convert.ToString(sincos[1]));

            int version = finderPattern.Version;

            canvas.println("Version: " + System.Convert.ToString(version));
            if (version < 1 || version > 40)
            {
                throw new InvalidVersionException("Invalid version: " + version);
            }

            AlignmentPattern alignmentPattern = null;

            try
            {
                alignmentPattern = AlignmentPattern.findAlignmentPattern(bitmap, finderPattern);
            }
            catch (AlignmentPatternNotFoundException e)
            {
                throw new SymbolNotFoundException(e.Message);
            }

            int matrixLength = alignmentPattern.getCenter().Length;

            canvas.println("AlignmentPatterns at");
            for (int y = 0; y < matrixLength; y++)
            {
                String alignmentPatternCoordinates = "";
                for (int x = 0; x < matrixLength; x++)
                {
                    alignmentPatternCoordinates += alignmentPattern.getCenter()[x][y].ToString();
                }
                canvas.println(alignmentPatternCoordinates);
            }
            //for(int i = 0; i < 500000; i++) Console.out.println("");

            canvas.println("Creating sampling grid.");
            //[TODO] need all-purpose method
            //samplingGrid = getSamplingGrid2_6(finderPattern, alignmentPattern);
            samplingGrid = getSamplingGrid(finderPattern, alignmentPattern);
            canvas.println("Reading grid.");
            bool[][] qRCodeMatrix = null;
            try
            {
                qRCodeMatrix = getQRCodeMatrix(bitmap, samplingGrid);
            }
            catch (System.IndexOutOfRangeException)
            {
                throw new SymbolNotFoundException("Sampling grid exceeded image boundary");
            }
            //canvas.drawMatrix(qRCodeMatrix);
            return(new QRCodeSymbol(qRCodeMatrix));
        }
Exemplo n.º 2
0
        public virtual QRCodeSymbol getQRCodeSymbol(int[][] image)
        {
            QRCodeImageReader.DECIMAL_POINT = 23 - QRCodeUtility.sqrt((image.Length < image[0].Length ? image[0].Length : image.Length) / 256);
            this.bitmap = this.filterImage(image);
            this.canvas.println("Drawing matrix.");
            this.canvas.drawMatrix(this.bitmap);
            this.canvas.println("Scanning Finder Pattern.");
            FinderPattern finderPattern;

            try
            {
                finderPattern = FinderPattern.findFinderPattern(this.bitmap);
            }
            catch (FinderPatternNotFoundException ex1)
            {
                this.canvas.println("Not found, now retrying...");
                this.bitmap = this.applyCrossMaskingMedianFilter(this.bitmap, 5);
                this.canvas.drawMatrix(this.bitmap);
                int num = 0;
                while (num < 1000000000)
                {
                    ++num;
                }
                try
                {
                    finderPattern = FinderPattern.findFinderPattern(this.bitmap);
                }
                catch (FinderPatternNotFoundException ex2)
                {
                    throw new SymbolNotFoundException(ex2.Message);
                }
                catch (VersionInformationException ex2)
                {
                    throw new SymbolNotFoundException(ex2.Message);
                }
            }
            catch (VersionInformationException ex)
            {
                throw new SymbolNotFoundException(ex.Message);
            }
            this.canvas.println("FinderPattern at");
            this.canvas.println(finderPattern.getCenter(0).ToString() + finderPattern.getCenter(1).ToString() + finderPattern.getCenter(2).ToString());
            int[] angle = finderPattern.getAngle();
            this.canvas.println("Angle*4098: Sin " + Convert.ToString(angle[0]) + "  Cos " + Convert.ToString(angle[1]));
            int version = finderPattern.Version;

            this.canvas.println("Version: " + Convert.ToString(version));
            if (version < 1 || version > 40)
            {
                throw new InvalidVersionException("Invalid version: " + (object)version);
            }
            AlignmentPattern alignmentPattern;

            try
            {
                alignmentPattern = AlignmentPattern.findAlignmentPattern(this.bitmap, finderPattern);
            }
            catch (AlignmentPatternNotFoundException ex)
            {
                throw new SymbolNotFoundException(ex.Message);
            }
            int length = alignmentPattern.getCenter().Length;

            this.canvas.println("AlignmentPatterns at");
            for (int index1 = 0; index1 < length; ++index1)
            {
                string str = "";
                for (int index2 = 0; index2 < length; ++index2)
                {
                    str += alignmentPattern.getCenter()[index2][index1].ToString();
                }
                this.canvas.println(str);
            }
            this.canvas.println("Creating sampling grid.");
            this.samplingGrid = this.getSamplingGrid(finderPattern, alignmentPattern);
            this.canvas.println("Reading grid.");
            bool[][] qrCodeMatrix;
            try
            {
                qrCodeMatrix = this.getQRCodeMatrix(this.bitmap, this.samplingGrid);
            }
            catch (IndexOutOfRangeException ex)
            {
                throw new SymbolNotFoundException("Sampling grid exceeded image boundary");
            }
            return(new QRCodeSymbol(qrCodeMatrix));
        }
Exemplo n.º 3
0
        public virtual QRCodeSymbol getQRCodeSymbol(int[][] image)
        {
            int num = ((image.Length < image[0].Length) ? image[0].Length : image.Length);

            DECIMAL_POINT = 23 - QRCodeUtility.sqrt(num / 256);
            bitmap        = filterImage(image);
            canvas.println("Drawing matrix.");
            canvas.drawMatrix(bitmap);
            canvas.println("Scanning Finder Pattern.");
            FinderPattern finderPattern = null;

            try
            {
                finderPattern = FinderPattern.findFinderPattern(bitmap);
            }
            catch (FinderPatternNotFoundException)
            {
                canvas.println("Not found, now retrying...");
                bitmap = applyCrossMaskingMedianFilter(bitmap, 5);
                canvas.drawMatrix(bitmap);
                for (int i = 0; i < 1000000000; i++)
                {
                }
                try
                {
                    finderPattern = FinderPattern.findFinderPattern(bitmap);
                }
                catch (FinderPatternNotFoundException ex)
                {
                    throw new SymbolNotFoundException(ex.Message);
                }
                catch (VersionInformationException ex2)
                {
                    throw new SymbolNotFoundException(ex2.Message);
                }
            }
            catch (VersionInformationException ex4)
            {
                throw new SymbolNotFoundException(ex4.Message);
            }
            canvas.println("FinderPattern at");
            string str = finderPattern.getCenter(0).ToString() + finderPattern.getCenter(1).ToString() + finderPattern.getCenter(2).ToString();

            canvas.println(str);
            int[] angle = finderPattern.getAngle();
            canvas.println("Angle*4098: Sin " + Convert.ToString(angle[0]) + "  Cos " + Convert.ToString(angle[1]));
            int version = finderPattern.Version;

            canvas.println("Version: " + Convert.ToString(version));
            if (version < 1 || version > 40)
            {
                throw new InvalidVersionException("Invalid version: " + version);
            }
            AlignmentPattern alignmentPattern = null;

            try
            {
                alignmentPattern = AlignmentPattern.findAlignmentPattern(bitmap, finderPattern);
            }
            catch (AlignmentPatternNotFoundException ex5)
            {
                throw new SymbolNotFoundException(ex5.Message);
            }
            int num2 = alignmentPattern.getCenter().Length;

            canvas.println("AlignmentPatterns at");
            for (int j = 0; j < num2; j++)
            {
                string text = "";
                for (int k = 0; k < num2; k++)
                {
                    text += alignmentPattern.getCenter()[k][j].ToString();
                }
                canvas.println(text);
            }
            canvas.println("Creating sampling grid.");
            samplingGrid = getSamplingGrid(finderPattern, alignmentPattern);
            canvas.println("Reading grid.");
            bool[][] array = null;
            try
            {
                array = getQRCodeMatrix(bitmap, samplingGrid);
            }
            catch (IndexOutOfRangeException)
            {
                throw new SymbolNotFoundException("Sampling grid exceeded image boundary");
            }
            return(new QRCodeSymbol(array));
        }
Exemplo n.º 4
0
        public virtual QRCodeSymbol getQRCodeSymbol(int[][] image)
        {
            int num = (image.Length < image[0].Length) ? image[0].Length : image.Length;

            DECIMAL_POINT = 0x17 - QRCodeUtility.sqrt(num / 0x100);
            this.bitmap   = this.filterImage(image);
            this.canvas.println("Drawing matrix.");
            this.canvas.drawMatrix(this.bitmap);
            this.canvas.println("Scanning Finder Pattern.");
            FinderPattern finderPattern = null;

            try
            {
                finderPattern = FinderPattern.findFinderPattern(this.bitmap);
            }
            catch (FinderPatternNotFoundException)
            {
                this.canvas.println("Not found, now retrying...");
                this.bitmap = this.applyCrossMaskingMedianFilter(this.bitmap, 5);
                this.canvas.drawMatrix(this.bitmap);
                int num2 = 0;
                while (true)
                {
                    if (num2 >= 0x3b9aca00)
                    {
                        break;
                    }
                    num2++;
                }
                try
                {
                    finderPattern = FinderPattern.findFinderPattern(this.bitmap);
                }
                catch (FinderPatternNotFoundException exception2)
                {
                    throw new SymbolNotFoundException(exception2.Message);
                }
                catch (VersionInformationException exception3)
                {
                    throw new SymbolNotFoundException(exception3.Message);
                }
            }
            catch (VersionInformationException exception4)
            {
                throw new SymbolNotFoundException(exception4.Message);
            }
            this.canvas.println("FinderPattern at");
            string str = finderPattern.getCenter(0).ToString() + finderPattern.getCenter(1).ToString() + finderPattern.getCenter(2).ToString();

            this.canvas.println(str);
            int[] numArray = finderPattern.getAngle();
            this.canvas.println("Angle*4098: Sin " + Convert.ToString(numArray[0]) + "  Cos " + Convert.ToString(numArray[1]));
            int version = finderPattern.Version;

            this.canvas.println("Version: " + Convert.ToString(version));
            if ((version < 1) || (version > 40))
            {
                throw new InvalidVersionException("Invalid version: " + version);
            }
            AlignmentPattern alignmentPattern = null;

            try
            {
                alignmentPattern = AlignmentPattern.findAlignmentPattern(this.bitmap, finderPattern);
            }
            catch (AlignmentPatternNotFoundException exception5)
            {
                throw new SymbolNotFoundException(exception5.Message);
            }
            int length = alignmentPattern.getCenter().Length;

            this.canvas.println("AlignmentPatterns at");
            for (int i = 0; i < length; i++)
            {
                string str2 = "";
                for (int j = 0; j < length; j++)
                {
                    str2 = str2 + alignmentPattern.getCenter()[j][i].ToString();
                }
                this.canvas.println(str2);
            }
            this.canvas.println("Creating sampling grid.");
            this.samplingGrid = this.getSamplingGrid(finderPattern, alignmentPattern);
            this.canvas.println("Reading grid.");
            bool[][] moduleMatrix = null;
            try
            {
                moduleMatrix = this.getQRCodeMatrix(this.bitmap, this.samplingGrid);
            }
            catch (IndexOutOfRangeException)
            {
                throw new SymbolNotFoundException("Sampling grid exceeded image boundary");
            }
            return(new QRCodeSymbol(moduleMatrix));
        }
Exemplo n.º 5
0
        public virtual QRCodeSymbol getQRCodeSymbol(int[][] image)
        {
            int longSide = (image.Length < image[0].Length) ? image[0].Length : image.Length;

            QRCodeImageReader.DECIMAL_POINT = 23 - QRCodeUtility.sqrt(longSide / 256);
            this.bitmap = this.filterImage(image);
            this.canvas.println("Drawing matrix.");
            this.canvas.drawMatrix(this.bitmap);
            this.canvas.println("Scanning Finder Pattern.");
            FinderPattern finderPattern = null;

            try
            {
                finderPattern = FinderPattern.findFinderPattern(this.bitmap);
            }
            catch (FinderPatternNotFoundException e_80)
            {
                this.canvas.println("Not found, now retrying...");
                this.bitmap = this.applyCrossMaskingMedianFilter(this.bitmap, 5);
                this.canvas.drawMatrix(this.bitmap);
                for (int i = 0; i < 1000000000; i++)
                {
                }
                try
                {
                    finderPattern = FinderPattern.findFinderPattern(this.bitmap);
                }
                catch (FinderPatternNotFoundException e2)
                {
                    throw new SymbolNotFoundException(e2.Message);
                }
                catch (VersionInformationException e3)
                {
                    throw new SymbolNotFoundException(e3.Message);
                }
            }
            catch (VersionInformationException e4)
            {
                throw new SymbolNotFoundException(e4.Message);
            }
            this.canvas.println("FinderPattern at");
            string finderPatternCoordinates = finderPattern.getCenter(0).ToString() + finderPattern.getCenter(1).ToString() + finderPattern.getCenter(2).ToString();

            this.canvas.println(finderPatternCoordinates);
            int[] sincos = finderPattern.getAngle();
            this.canvas.println("Angle*4098: Sin " + Convert.ToString(sincos[0]) + "  Cos " + Convert.ToString(sincos[1]));
            int version = finderPattern.Version;

            this.canvas.println("Version: " + Convert.ToString(version));
            if (version < 1 || version > 40)
            {
                throw new InvalidVersionException("Invalid version: " + version);
            }
            AlignmentPattern alignmentPattern = null;

            try
            {
                alignmentPattern = AlignmentPattern.findAlignmentPattern(this.bitmap, finderPattern);
            }
            catch (AlignmentPatternNotFoundException e5)
            {
                throw new SymbolNotFoundException(e5.Message);
            }
            int matrixLength = alignmentPattern.getCenter().Length;

            this.canvas.println("AlignmentPatterns at");
            for (int y = 0; y < matrixLength; y++)
            {
                string alignmentPatternCoordinates = "";
                for (int x = 0; x < matrixLength; x++)
                {
                    alignmentPatternCoordinates += alignmentPattern.getCenter()[x][y].ToString();
                }
                this.canvas.println(alignmentPatternCoordinates);
            }
            this.canvas.println("Creating sampling grid.");
            this.samplingGrid = this.getSamplingGrid(finderPattern, alignmentPattern);
            this.canvas.println("Reading grid.");
            bool[][] qRCodeMatrix = null;
            try
            {
                qRCodeMatrix = this.getQRCodeMatrix(this.bitmap, this.samplingGrid);
            }
            catch (IndexOutOfRangeException e_2D5)
            {
                throw new SymbolNotFoundException("Sampling grid exceeded image boundary");
            }
            return(new QRCodeSymbol(qRCodeMatrix));
        }