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


C# Result.putAllMetadata方法代码示例

本文整理汇总了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;
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:59,代码来源:MultiFormatUPCEANReader.cs

示例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;
 }
开发者ID:arumata,项目名称:zxingnet,代码行数:16,代码来源:GenericMultipleBarcodeReader(3).cs


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