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


C# BitArray.getNextUnset方法代码示例

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


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

示例1: decodeRow


//.........这里部分代码省略.........
                     {
                        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))
         {
            return null;
         }

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

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

         // 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
开发者ID:rfosterfrss,项目名称:ZXing.Net.Mobile,代码行数:67,代码来源:Code128Reader.cs

示例2: findGuardPattern

 /// <summary>
 /// </summary>
 /// <param name="row">row of black/white values to search</param>
 /// <param name="rowOffset">position to start search</param>
 /// <param name="whiteFirst">if true, indicates that the pattern specifies white/black/white/...</param>
 /// pixel counts, otherwise, it is interpreted as black/white/black/...
 /// <param name="pattern">pattern of counts of number of black and white pixels that are being</param>
 /// searched for as a pattern
 /// <param name="counters">array of counters, as long as pattern, to re-use</param>
 /// <returns>start/end horizontal offset of guard pattern, as an array of two ints</returns>
 internal static int[] findGuardPattern(BitArray row,
                               int rowOffset,
                               bool whiteFirst,
                               int[] pattern,
                               int[] counters)
 {
    int patternLength = pattern.Length;
    int width = row.Size;
    bool isWhite = whiteFirst;
    rowOffset = whiteFirst ? row.getNextUnset(rowOffset) : row.getNextSet(rowOffset);
    int counterPosition = 0;
    int patternStart = rowOffset;
    for (int x = rowOffset; x < width; x++)
    {
       if (row[x] ^ isWhite)
       {
          counters[counterPosition]++;
       }
       else
       {
          if (counterPosition == patternLength - 1)
          {
             if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE)
             {
                return new int[] { patternStart, x };
             }
             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;
       }
    }
    return null;
 }
开发者ID:Binjaaa,项目名称:ZXing.Net.Mobile,代码行数:52,代码来源:UPCEANReader.cs

示例3: setCounters

 /// <summary>
 /// Records the size of all runs of white and black pixels, starting with white.
 /// This is just like recordPattern, except it records all the counters, and
 /// uses our builtin "counters" member for storage.
 /// </summary>
 /// <param name="row">row to count from</param>
 private bool setCounters(BitArray row)
 {
     counterLength = 0;
     // Start from the first white bit.
     int i = row.getNextUnset(0);
     int end = row.Size;
     if (i >= end)
     {
         return false;
     }
     bool isWhite = true;
     int count = 0;
     while (i < end)
     {
         if (row[i] ^ isWhite)
         {
             // that is, exactly one is true
             count++;
         }
         else
         {
             counterAppend(count);
             count = 1;
             isWhite = !isWhite;
         }
         i++;
     }
     counterAppend(count);
     return true;
 }
开发者ID:hydrayu,项目名称:imobile-src,代码行数:36,代码来源:CodaBarReader.cs

示例4: parseFoundFinderPattern

      private FinderPattern parseFoundFinderPattern(BitArray row, int rowNumber, bool oddPattern)
      {
         // Actually we found elements 2-5.
         int firstCounter;
         int start;
         int end;

         if (oddPattern)
         {
            // If pattern number is odd, we need to locate element 1 *before* the current block.

            int firstElementStart = startEnd[0] - 1;
            // Locate element 1
            while (firstElementStart >= 0 && !row[firstElementStart])
            {
               firstElementStart--;
            }

            firstElementStart++;
            firstCounter = startEnd[0] - firstElementStart;
            start = firstElementStart;
            end = startEnd[1];

         }
         else
         {
            // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block.
            start = startEnd[0];
            end = row.getNextUnset(startEnd[1] + 1);
            firstCounter = end - startEnd[1];
         }

         // Make 'counters' hold 1-4
         int[] counters = getDecodeFinderCounters();
         Array.Copy(counters, 0, counters, 1, counters.Length - 1);

         counters[0] = firstCounter;
         int value;
         if (!parseFinderValue(counters, FINDER_PATTERNS, out value))
            return null;

         return new FinderPattern(value, new int[] { start, end }, start, end, rowNumber);
      }
开发者ID:GSerjo,项目名称:Seminars,代码行数:43,代码来源:RSSExpandedReader.cs

示例5: getNextSecondBar

 private static int getNextSecondBar(BitArray row, int initialPos)
 {
    int currentPos;
    if (row[initialPos])
    {
       currentPos = row.getNextUnset(initialPos);
       currentPos = row.getNextSet(currentPos);
    }
    else
    {
       currentPos = row.getNextSet(initialPos);
       currentPos = row.getNextUnset(currentPos);
    }
    return currentPos;
 }
开发者ID:GSerjo,项目名称:Seminars,代码行数:15,代码来源:RSSExpandedReader.cs

示例6: decodeMiddle

      int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString)
      {
         int[] counters = decodeMiddleCounters;
         counters[0] = 0;
         counters[1] = 0;
         counters[2] = 0;
         counters[3] = 0;
         int end = row.Size;
         int rowOffset = startRange[1];

         int checkParity = 0;

         for (int x = 0; x < 2 && rowOffset < end; x++)
         {
            int bestMatch;
            if (!UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS, out bestMatch))
               return -1;
            resultString.Append((char)('0' + bestMatch % 10));
            foreach (int counter in counters)
            {
               rowOffset += counter;
            }
            if (bestMatch >= 10)
            {
               checkParity |= 1 << (1 - x);
            }
            if (x != 1)
            {
               // Read off separator if not last
               rowOffset = row.getNextSet(rowOffset);
               rowOffset = row.getNextUnset(rowOffset);
            }
         }

         if (resultString.Length != 2)
         {
            return -1;
         }

         if (int.Parse(resultString.ToString()) % 4 != checkParity)
         {
            return -1;
         }

         return rowOffset;
      }
开发者ID:hydrayu,项目名称:imobile-src,代码行数:46,代码来源:UPCEANExtension2Support.cs

示例7: decodeMiddle

      int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString)
      {
         int[] counters = decodeMiddleCounters;
         counters[0] = 0;
         counters[1] = 0;
         counters[2] = 0;
         counters[3] = 0;
         int end = row.Size;
         int rowOffset = startRange[1];

         int lgPatternFound = 0;

         for (int x = 0; x < 5 && rowOffset < end; x++)
         {
            int bestMatch;
            if (!UPCEANReader.decodeDigit(row, counters, rowOffset, UPCEANReader.L_AND_G_PATTERNS, out bestMatch))
               return -1;
            resultString.Append((char)('0' + bestMatch % 10));
            foreach (int counter in counters)
            {
               rowOffset += counter;
            }
            if (bestMatch >= 10)
            {
               lgPatternFound |= 1 << (4 - x);
            }
            if (x != 4)
            {
               // Read off separator if not last
               rowOffset = row.getNextSet(rowOffset);
               rowOffset = row.getNextUnset(rowOffset);
            }
         }

         if (resultString.Length != 5)
         {
            return -1;
         }

         int checkDigit;
         if (!determineCheckDigit(lgPatternFound, out checkDigit))
            return -1;

         if (extensionChecksum(resultString.ToString()) != checkDigit)
         {
            return -1;
         }

         return rowOffset;
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:50,代码来源:UPCEANExtension5Support.cs


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