当前位置: 首页>>代码示例>>C#>>正文


C# com.google.zxing.common.BitArray.isRange方法代码示例

本文整理汇总了C#中com.google.zxing.common.BitArray.isRange方法的典型用法代码示例。如果您正苦于以下问题:C# com.google.zxing.common.BitArray.isRange方法的具体用法?C# com.google.zxing.common.BitArray.isRange怎么用?C# com.google.zxing.common.BitArray.isRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.BitArray的用法示例。


在下文中一共展示了com.google.zxing.common.BitArray.isRange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decodeRow


//.........这里部分代码省略.........
                    break;
                  case CODE_STOP:
                    done = true;
                    break;
                }
              }
              break;
            case CODE_CODE_C:
              if (code < 100)
              {
                if (code < 10)
                {
                  result.Append('0');
                }
                result.Append(code);
              }
              else
              {
                if (code != CODE_STOP)
                {
                  lastCharacterWasPrintable = false;
                }
                switch (code)
                {
                  case CODE_FNC_1:
                    // do nothing?
                    break;
                  case CODE_CODE_A:
                    codeSet = CODE_CODE_A;
                    break;
                  case CODE_CODE_B:
                    codeSet = CODE_CODE_B;
                    break;
                  case CODE_STOP:
                    done = true;
                    break;
                }
              }
              break;
              }

              // Unshift back to another code set if we were shifted
              if (unshift)
              {
            codeSet = codeSet == CODE_CODE_A ? CODE_CODE_B : CODE_CODE_A;
              }

            }

            // Check for ample whitespace following pattern, but, to do this we first need to remember that
            // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left
            // to read off. Would be slightly better to properly read. Here we just skip it:
            nextStart = row.getNextUnset(nextStart);
            if (!row.isRange(nextStart, Math.Min(row.Size, nextStart + (nextStart - lastStart) / 2), false))
            {
              throw NotFoundException.NotFoundInstance;
            }

            // Pull out from sum the value of the penultimate check code
            checksumTotal -= multiplier * lastCode;
            // lastCode is the checksum then:
            if (checksumTotal % 103 != lastCode)
            {
              throw ChecksumException.ChecksumInstance;
            }

            // Need to pull out the check digits from string
            int resultLength = result.Length;
            if (resultLength == 0)
            {
              // false positive
              throw NotFoundException.NotFoundInstance;
            }

            // Only bother if the result had at least one character, and if the checksum digit happened to
            // be a printable character. If it was just interpreted as a control code, nothing to remove.
            if (resultLength > 0 && lastCharacterWasPrintable)
            {
              if (codeSet == CODE_CODE_C)
              {
            result.Remove(resultLength - 2, 2);
              }
              else
              {
            result.Remove(resultLength - 1, 1);
              }
            }

            float left = (float)(startPatternInfo[1] + startPatternInfo[0]) / 2.0f;
            float right = (float)(nextStart + lastStart) / 2.0f;

            int rawCodesSize = rawCodes.Count;
            sbyte[] rawBytes = new sbyte[rawCodesSize];
            for (int i = 0; i < rawCodesSize; i++)
            {
              rawBytes[i] = rawCodes[i];
            }

            return new Result(result.ToString(), rawBytes, new ResultPoint[]{new ResultPoint(left, (float) rowNumber), new ResultPoint(right, (float) rowNumber)}, BarcodeFormat.CODE_128);
        }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:101,代码来源:Code128Reader.cs

示例2: findAsteriskPattern

        private static int[] findAsteriskPattern(BitArray row)
        {
            int width = row.Size;
            int rowOffset = 0;
            while (rowOffset < width)
            {
                if (row.get_Renamed(rowOffset))
                {
                    break;
                }
                rowOffset++;
            }

            int counterPosition = 0;
            int[] counters = new int[9];
            int patternStart = rowOffset;
            bool isWhite = false;
            int patternLength = counters.Length;

            for (int i = rowOffset; i < width; i++)
            {
                bool pixel = row.get_Renamed(i);
                if (pixel ^ isWhite)
                {
                    counters[counterPosition]++;
                }
                else
                {
                    if (counterPosition == patternLength - 1)
                    {
                        if (toNarrowWidePattern(counters) == ASTERISK_ENCODING)
                        {
                            // Look for whitespace before start pattern, >= 50% of width of start pattern
                            if (row.isRange(System.Math.Max(0, patternStart - (i - patternStart) / 2), patternStart, false))
                            {
                                return new int[]{patternStart, i};
                            }
                        }
                        patternStart += counters[0] + counters[1];
                        for (int y = 2; y < patternLength; y++)
                        {
                            counters[y - 2] = counters[y];
                        }
                        counters[patternLength - 2] = 0;
                        counters[patternLength - 1] = 0;
                        counterPosition--;
                    }
                    else
                    {
                        counterPosition++;
                    }
                    counters[counterPosition] = 1;
                    isWhite = !isWhite;
                }
            }
            throw ReaderException.Instance;
        }
开发者ID:669754618,项目名称:zxing-iphone,代码行数:57,代码来源:Code39Reader.cs

示例3: findStartPattern

        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static int[] findStartPattern(com.google.zxing.common.BitArray row) throws com.google.zxing.NotFoundException
        private static int[] findStartPattern(BitArray row)
        {
            int width = row.Size;
            int rowOffset = row.getNextSet(0);

            int counterPosition = 0;
            int[] counters = new int[6];
            int patternStart = rowOffset;
            bool isWhite = false;
            int patternLength = counters.Length;

            for (int i = rowOffset; i < width; i++)
            {
              if (row.get(i) ^ isWhite)
              {
            counters[counterPosition]++;
              }
              else
              {
            if (counterPosition == patternLength - 1)
            {
              int bestVariance = MAX_AVG_VARIANCE;
              int bestMatch = -1;
              for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++)
              {
                int variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE);
                if (variance < bestVariance)
                {
                  bestVariance = variance;
                  bestMatch = startCode;
                }
              }
              // Look for whitespace before start pattern, >= 50% of width of start pattern
              if (bestMatch >= 0 && row.isRange(Math.Max(0, patternStart - (i - patternStart) / 2), patternStart, false))
              {
                return new int[]{patternStart, i, bestMatch};
              }
              patternStart += counters[0] + counters[1];
              Array.Copy(counters, 2, counters, 0, patternLength - 2);
              counters[patternLength - 2] = 0;
              counters[patternLength - 1] = 0;
              counterPosition--;
            }
            else
            {
              counterPosition++;
            }
            counters[counterPosition] = 1;
            isWhite = !isWhite;
              }
            }
            throw NotFoundException.NotFoundInstance;
        }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:55,代码来源:Code128Reader.cs

示例4: findStartGuardPattern

 internal static int[] findStartGuardPattern(BitArray row)
 {
     bool foundStart = false;
     int[] startRange = null;
     int nextStart = 0;
     while (!foundStart)
     {
         startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN);
         int start = startRange[0];
         nextStart = startRange[1];
         // Make sure there is a quiet zone at least as big as the start pattern before the barcode.
         // If this check would run off the left edge of the image, do not accept this barcode,
         // as it is very likely to be a false positive.
         int quietStart = start - (nextStart - start);
         if (quietStart >= 0)
         {
             foundStart = row.isRange(quietStart, start, false);
         }
     }
     return startRange;
 }
开发者ID:netbitsolutions,项目名称:phonegap-plugins,代码行数:21,代码来源:UPCEANReader.cs

示例5: decodeRow

        // added by .net follower (http://dotnetfollower.com)
        /// <summary> <p>Like {@link #decodeRow(int, BitArray, java.util.Hashtable)}, but
        /// allows caller to inform method about where the UPC/EAN start pattern is
        /// found. This allows this to be computed once and reused across many implementations.</p>
        /// </summary>
        // public virtual Result decodeRow(int rowNumber, BitArray row, int[] startGuardRange, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public virtual Result decodeRow(int rowNumber, BitArray row, int[] startGuardRange, System.Collections.Generic.Dictionary<Object, Object> hints)
        {
            // ResultPointCallback resultPointCallback = hints == null?null:(ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // commented by .net follower (http://dotnetfollower.com)
            ResultPointCallback resultPointCallback = null; // added by .net follower (http://dotnetfollower.com)
            if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) // added by .net follower (http://dotnetfollower.com)
                resultPointCallback = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // added by .net follower (http://dotnetfollower.com)

            if (resultPointCallback != null)
            {
                resultPointCallback.foundPossibleResultPoint(new ResultPoint((startGuardRange[0] + startGuardRange[1]) / 2.0f, rowNumber));
            }

            System.Text.StringBuilder result = decodeRowStringBuffer;
            result.Length = 0;
            int endStart = decodeMiddle(row, startGuardRange, result);

            if (resultPointCallback != null)
            {
                resultPointCallback.foundPossibleResultPoint(new ResultPoint(endStart, rowNumber));
            }

            int[] endRange = decodeEnd(row, endStart);

            if (resultPointCallback != null)
            {
                resultPointCallback.foundPossibleResultPoint(new ResultPoint((endRange[0] + endRange[1]) / 2.0f, rowNumber));
            }

            // Make sure there is a quiet zone at least as big as the end pattern after the barcode. The
            // spec might want more whitespace, but in practice this is the maximum we can count on.
            int end = endRange[1];
            int quietEnd = end + (end - endRange[0]);
            if (quietEnd >= row.Size || !row.isRange(end, quietEnd, false))
            {
                throw ReaderException.Instance;
            }

            System.String resultString = result.ToString();
            if (!checkChecksum(resultString))
            {
                throw ReaderException.Instance;
            }

            //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 left = (float) (startGuardRange[1] + startGuardRange[0]) / 2.0f;
            //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 right = (float) (endRange[1] + endRange[0]) / 2.0f;
            //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'"
            return new Result(resultString, null, new ResultPoint[]{new ResultPoint(left, (float) rowNumber), new ResultPoint(right, (float) rowNumber)}, BarcodeFormat);
        }
开发者ID:netbitsolutions,项目名称:phonegap-plugins,代码行数:56,代码来源:UPCEANReader.cs

示例6: decodeRow


//.........这里部分代码省略.........
                            if (code != CODE_STOP)
                            {
                                lastCharacterWasPrintable = false;
                            }
                            switch (code)
                            {

                                case CODE_FNC_1:
                                    // do nothing?
                                    break;

                                case CODE_CODE_A:
                                    codeSet = CODE_CODE_A;
                                    break;

                                case CODE_CODE_B:
                                    codeSet = CODE_CODE_B;
                                    break;

                                case CODE_STOP:
                                    done = true;
                                    break;
                                }
                        }
                        break;
                    }

                // Unshift back to another code set if we were shifted
                if (unshift)
                {
                    switch (codeSet)
                    {

                        case CODE_CODE_A:
                            codeSet = CODE_CODE_C;
                            break;

                        case CODE_CODE_B:
                            codeSet = CODE_CODE_A;
                            break;

                        case CODE_CODE_C:
                            codeSet = CODE_CODE_B;
                            break;
                        }
                }
            }

            // Check for ample whitespace following pattern, but, to do this we first need to remember that
            // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left
            // to read off. Would be slightly better to properly read. Here we just skip it:
            int width = row.Size;
            while (nextStart < width && row.get_Renamed(nextStart))
            {
                nextStart++;
            }
            if (!row.isRange(nextStart, System.Math.Min(width, nextStart + (nextStart - lastStart) / 2), false))
            {
                throw ReaderException.Instance;
            }

            // Pull out from sum the value of the penultimate check code
            checksumTotal -= multiplier * lastCode;
            // lastCode is the checksum then:
            if (checksumTotal % 103 != lastCode)
            {
                throw ReaderException.Instance;
            }

            // Need to pull out the check digits from string
            int resultLength = result.Length;
            // Only bother if the result had at least one character, and if the checksum digit happened to
            // be a printable character. If it was just interpreted as a control code, nothing to remove.
            if (resultLength > 0 && lastCharacterWasPrintable)
            {
                if (codeSet == CODE_CODE_C)
                {
                    result.Remove(resultLength - 2, resultLength - (resultLength - 2));
                }
                else
                {
                    result.Remove(resultLength - 1, resultLength - (resultLength - 1));
                }
            }

            System.String resultString = result.ToString();

            if (resultString.Length == 0)
            {
                // Almost surely a false positive
                throw ReaderException.Instance;
            }

            //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 left = (float) (startPatternInfo[1] + startPatternInfo[0]) / 2.0f;
            //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 right = (float) (nextStart + lastStart) / 2.0f;
            //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'"
            return new Result(resultString, null, new ResultPoint[]{new ResultPoint(left, (float) rowNumber), new ResultPoint(right, (float) rowNumber)}, BarcodeFormat.CODE_128);
        }
开发者ID:Jan7,项目名称:phonegap-plugins,代码行数:101,代码来源:Code128Reader.cs

示例7: findStartPattern

        private static int[] findStartPattern(BitArray row)
        {
            int width = row.Size;
            int rowOffset = 0;
            while (rowOffset < width)
            {
                if (row.get_Renamed(rowOffset))
                {
                    break;
                }
                rowOffset++;
            }

            int counterPosition = 0;
            int[] counters = new int[6];
            int patternStart = rowOffset;
            bool isWhite = false;
            int patternLength = counters.Length;

            for (int i = rowOffset; i < width; i++)
            {
                bool pixel = row.get_Renamed(i);
                if (pixel ^ isWhite)
                {
                    counters[counterPosition]++;
                }
                else
                {
                    if (counterPosition == patternLength - 1)
                    {
                        int bestVariance = MAX_AVG_VARIANCE;
                        int bestMatch = - 1;
                        for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++)
                        {
                            int variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE);
                            if (variance < bestVariance)
                            {
                                bestVariance = variance;
                                bestMatch = startCode;
                            }
                        }
                        if (bestMatch >= 0)
                        {
                            // Look for whitespace before start pattern, >= 50% of width of start pattern
                            if (row.isRange(System.Math.Max(0, patternStart - (i - patternStart) / 2), patternStart, false))
                            {
                                return new int[]{patternStart, i, bestMatch};
                            }
                        }
                        patternStart += counters[0] + counters[1];
                        for (int y = 2; y < patternLength; y++)
                        {
                            counters[y - 2] = counters[y];
                        }
                        counters[patternLength - 2] = 0;
                        counters[patternLength - 1] = 0;
                        counterPosition--;
                    }
                    else
                    {
                        counterPosition++;
                    }
                    counters[counterPosition] = 1;
                    isWhite = !isWhite;
                }
            }
            throw ReaderException.Instance;
        }
开发者ID:Jan7,项目名称:phonegap-plugins,代码行数:68,代码来源:Code128Reader.cs


注:本文中的com.google.zxing.common.BitArray.isRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。