當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。