Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am used a library to read qr code, but i have an error with an exception in An exception of type 'com.google.zxing.ReaderException' occurred in zxing.dll but was not handled in user code

If there is a handler for this exception, the program may be safely continued.


the code is:

C#
private FinderPattern[] selectBestPatterns()
        {

            int startSize = possibleCenters.Count;
            if (startSize < 3)
            {
                // Couldn't find enough finder patterns
                throw ReaderException.Instance;
            }

            // Filter outlier possibilities whose module size is too different
            if (startSize > 3)
            {
                // But we can only afford to do so if we have at least 4 possibilities to choose from
                float totalModuleSize = 0.0f;
                for (int i = 0; i < startSize; i++)
                {
                    totalModuleSize += ((FinderPattern) possibleCenters[i]).EstimatedModuleSize;
                }
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                float average = totalModuleSize / (float) startSize;
                for (int i = 0; i < possibleCenters.Count && possibleCenters.Count > 3; i++)
                {
                    FinderPattern pattern = (FinderPattern) possibleCenters[i];
                    if (System.Math.Abs(pattern.EstimatedModuleSize - average) > 0.2f * average)
                    {
                        possibleCenters.RemoveAt(i);
                        i--;
                    }
                }
            }

            if (possibleCenters.Count > 3)
            {
                // Throw away all but those first size candidate points we found.
                Collections.insertionSort(possibleCenters, new CenterComparator());
                SupportClass.SetCapacity(possibleCenters, 3);
            }

            return new FinderPattern[]{(FinderPattern) possibleCenters[0], (FinderPattern) possibleCenters[1], (FinderPattern) possibleCenters[2]};
        }

        /// <summary> <p>Orders by {@link FinderPattern#getCount()}, descending.</p></summary>
        private class CenterComparator : Comparator
        {
            public virtual int compare(System.Object center1, System.Object center2)
            {
                return ((FinderPattern) center2).Count - ((FinderPattern) center1).Count;
            }
        }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900