本文整理汇总了C#中Result.putAllMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# Result.putAllMetadata方法的具体用法?C# Result.putAllMetadata怎么用?C# Result.putAllMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result.putAllMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
if (startGuardPattern == null)
return null;
foreach (UPCEANReader reader in readers)
{
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
if (result == null)
continue;
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
//
// But, don't return UPC-A if UPC-A was not a requested format!
bool ean13MayBeUPCA =
result.BarcodeFormat == BarcodeFormat.EAN_13 &&
result.Text[0] == '0';
var possibleFormats =
hints == null || !hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS) ? null : (IList<BarcodeFormat>)hints[DecodeHintType.POSSIBLE_FORMATS];
bool canReturnUPCA = possibleFormats == null || possibleFormats.Contains(BarcodeFormat.UPC_A) || possibleFormats.Contains(BarcodeFormat.All_1D);
if (ean13MayBeUPCA && canReturnUPCA)
{
// Transfer the metdata across
var resultUPCA = new Result(result.Text.Substring(1),
result.RawBytes,
result.ResultPoints,
BarcodeFormat.UPC_A);
resultUPCA.putAllMetadata(result.ResultMetadata);
return resultUPCA;
}
return result;
}
return null;
}
示例2: translateResultPoints
private static Result translateResultPoints(Result result, int xOffset, int yOffset)
{
var oldResultPoints = result.ResultPoints;
var newResultPoints = new ResultPoint[oldResultPoints.Length];
for (int i = 0; i < oldResultPoints.Length; i++)
{
var oldPoint = oldResultPoints[i];
if (oldPoint != null)
{
newResultPoints[i] = new ResultPoint(oldPoint.X + xOffset, oldPoint.Y + yOffset);
}
}
var newResult = new Result(result.Text, result.RawBytes, newResultPoints, result.BarcodeFormat);
newResult.putAllMetadata(result.ResultMetadata);
return newResult;
}