當前位置: 首頁>>代碼示例>>C#>>正文


C# BitArray.reverse方法代碼示例

本文整理匯總了C#中ZXing.Common.BitArray.reverse方法的典型用法代碼示例。如果您正苦於以下問題:C# BitArray.reverse方法的具體用法?C# BitArray.reverse怎麽用?C# BitArray.reverse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ZXing.Common.BitArray的用法示例。


在下文中一共展示了BitArray.reverse方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: decodeRow

 /// <summary>
 ///   <p>Attempts to decode a one-dimensional barcode format given a single row of
 /// an image.</p>
 /// </summary>
 /// <param name="rowNumber">row number from top of the row</param>
 /// <param name="row">the black/white pixel data of the row</param>
 /// <param name="hints">decode hints</param>
 /// <returns>
 ///   <see cref="Result"/>containing encoded string and start/end of barcode or null, if an error occurs or barcode cannot be found
 /// </returns>
 override public Result decodeRow(int rowNumber,
                         BitArray row,
                         IDictionary<DecodeHintType, object> hints)
 {
    Pair leftPair = decodePair(row, false, rowNumber, hints);
    addOrTally(possibleLeftPairs, leftPair);
    row.reverse();
    Pair rightPair = decodePair(row, true, rowNumber, hints);
    addOrTally(possibleRightPairs, rightPair);
    row.reverse();
    int lefSize = possibleLeftPairs.Count;
    for (int i = 0; i < lefSize; i++)
    {
       Pair left = possibleLeftPairs[i];
       if (left.Count > 1)
       {
          int rightSize = possibleRightPairs.Count;
          for (int j = 0; j < rightSize; j++)
          {
             Pair right = possibleRightPairs[j];
             if (right.Count > 1)
             {
                if (checkChecksum(left, right))
                {
                   return constructResult(left, right);
                }
             }
          }
       }
    }
    return null;
 }
開發者ID:arumata,項目名稱:zxingnet,代碼行數:42,代碼來源:RSS14Reader.cs

示例2: decodeRow

 /// <summary>
 ///   <p>Attempts to decode a one-dimensional barcode format given a single row of
 /// an image.</p>
 /// </summary>
 /// <param name="rowNumber">row number from top of the row</param>
 /// <param name="row">the black/white pixel data of the row</param>
 /// <param name="hints">decode hints</param>
 /// <returns>
 ///   <see cref="Result"/>containing encoded string and start/end of barcode or null, if an error occurs or barcode cannot be found
 /// </returns>
 override public Result decodeRow(int rowNumber,
                         BitArray row,
                         IDictionary<DecodeHintType, object> hints)
 {
    Pair leftPair = decodePair(row, false, rowNumber, hints);
    addOrTally(possibleLeftPairs, leftPair);
    row.reverse();
    Pair rightPair = decodePair(row, true, rowNumber, hints);
    addOrTally(possibleRightPairs, rightPair);
    row.reverse();
    foreach (Pair left in possibleLeftPairs)
    {
       if (left.Count > 1)
       {
          foreach (Pair right in possibleRightPairs)
          {
             if (right.Count > 1)
             {
                if (checkChecksum(left, right))
                {
                   return constructResult(left, right);
                }
             }
          }
       }
    }
    return null;
 }
開發者ID:GSerjo,項目名稱:Seminars,代碼行數:38,代碼來源:RSS14Reader.cs

示例3: decodeEnd

      /// <summary>
      /// Identify where the end of the middle / payload section ends.
      /// </summary>
      /// <param name="row">row of black/white values to search</param>
      /// <returns>Array, containing index of start of 'end block' and end of 'end
      /// block' or null, if nothing found</returns>
      private int[] decodeEnd(BitArray row)
      {
         // For convenience, reverse the row and then
         // search from 'the start' for the end block
         row.reverse();
         int endStart = skipWhiteSpace(row);
         if (endStart < 0)
            return null;
         int[] endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED);
         if (endPattern == null)
         {
            row.reverse();
            return null;
         }

         // The start & end patterns must be pre/post fixed by a quiet zone. This
         // zone must be at least 10 times the width of a narrow line.
         // ref: http://www.barcode-1.net/i25code.html
         if (!validateQuietZone(row, endPattern[0]))
         {
            row.reverse();
            return null;
         }

         // Now recalculate the indices of where the 'endblock' starts & stops to
         // accommodate
         // the reversed nature of the search
         int temp = endPattern[0];
         endPattern[0] = row.Size - endPattern[1];
         endPattern[1] = row.Size - temp;

         row.reverse();
         return endPattern;
      }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:40,代碼來源:ITFReader.cs

示例4: doDecode

      /// <summary>
      /// We're going to examine rows from the middle outward, searching alternately above and below the
      /// middle, and farther out each time. rowStep is the number of rows between each successive
      /// attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then
      /// middle + rowStep, then middle - (2 * rowStep), etc.
      /// rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily
      /// decided that moving up and down by about 1/16 of the image is pretty good; we try more of the
      /// image if "trying harder".
      /// </summary>
      /// <param name="image">The image to decode</param>
      /// <param name="hints">Any hints that were requested</param>
      /// <returns>The contents of the decoded barcode</returns>
      virtual protected Result doDecode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         int width = image.Width;
         int height = image.Height;
         BitArray row = new BitArray(width);

         int middle = height >> 1;
         bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
         int rowStep = Math.Max(1, height >> (tryHarder ? 8 : 5));
         int maxLines;
         if (tryHarder)
         {
            maxLines = height; // Look at the whole image, not just the center
         }
         else
         {
            maxLines = 15; // 15 rows spaced 1/32 apart is roughly the middle half of the image
         }

         for (int x = 0; x < maxLines; x++)
         {

            // Scanning from the middle out. Determine which row we're looking at next:
            int rowStepsAboveOrBelow = (x + 1) >> 1;
            bool isAbove = (x & 0x01) == 0; // i.e. is x even?
            int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow);
            if (rowNumber < 0 || rowNumber >= height)
            {
               // Oops, if we run off the top or bottom, stop
               break;
            }

            // Estimate black point for this row and load it:
            row = image.getBlackRow(rowNumber, row);
            if (row == null)
               continue;

            // While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
            // handle decoding upside down barcodes.
            for (int attempt = 0; attempt < 2; attempt++)
            {
               if (attempt == 1)
               { 
                  // trying again?
                  row.reverse(); // reverse the row and continue
                  // This means we will only ever draw result points *once* in the life of this method
                  // since we want to avoid drawing the wrong points after flipping the row, and,
                  // don't want to clutter with noise from every single row scan -- just the scans
                  // that start on the center line.
                  if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
                  {
                     IDictionary<DecodeHintType, Object> newHints = new Dictionary<DecodeHintType, Object>();
                     foreach (var hint in hints)
                     {
                        if (hint.Key != DecodeHintType.NEED_RESULT_POINT_CALLBACK)
                           newHints.Add(hint.Key, hint.Value);
                     }
                     hints = newHints;
                  }
               }
               // Look for a barcode
               Result result = decodeRow(rowNumber, row, hints);
               if (result == null)
                  continue;

               // We found our barcode
               if (attempt == 1)
               {
                  // But it was upside down, so note that
                  result.putMetadata(ResultMetadataType.ORIENTATION, 180);
                  // And remember to flip the result points horizontally.
                  ResultPoint[] points = result.ResultPoints;
                  if (points != null)
                  {
                     points[0] = new ResultPoint(width - points[0].X - 1, points[0].Y);
                     points[1] = new ResultPoint(width - points[1].X - 1, points[1].Y);
                  }
               }
               return result;
            }
         }

         return null;
      }
開發者ID:arumata,項目名稱:zxingnet,代碼行數:96,代碼來源:OneDReader(4).cs

示例5: rotate180

 /// <summary>
 /// Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees
 /// </summary>
 public void rotate180()
 {
     var width = Width;
     var height = Height;
     var topRow = new BitArray(width);
     var bottomRow = new BitArray(width);
     for (int i = 0; i < (height + 1) / 2; i++)
     {
         topRow = getRow(i, topRow);
         bottomRow = getRow(height - 1 - i, bottomRow);
         topRow.reverse();
         bottomRow.reverse();
         setRow(i, bottomRow);
         setRow(height - 1 - i, topRow);
     }
 }
開發者ID:hydrayu,項目名稱:imobile-src,代碼行數:19,代碼來源:BitMatrix.cs


注:本文中的ZXing.Common.BitArray.reverse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。