本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}