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


C# BinaryBitmap类代码示例

本文整理汇总了C#中BinaryBitmap的典型用法代码示例。如果您正苦于以下问题:C# BinaryBitmap类的具体用法?C# BinaryBitmap怎么用?C# BinaryBitmap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BinaryBitmap类属于命名空间,在下文中一共展示了BinaryBitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decode

        public virtual Result decode(BinaryBitmap image, Dictionary<DecodeHintType, Object> hints)
        {
            DecoderResult decoderResult;
            ResultPoint[] points;
            if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
            {
                BitMatrix bits = extractPureBits(image.BlackMatrix);
                decoderResult = decoder.decode(bits);
                points = NO_POINTS;
            }
            else
            {
                DetectorResult detectorResult = new Detector(image.BlackMatrix).detect(hints);
                decoderResult = decoder.decode(detectorResult.Bits);
                points = detectorResult.Points;
            }

            var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);
            if (decoderResult.ByteSegments != null)
            {
                result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments);
            }
            if (decoderResult.ECLevel != null)
            {
                result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString());
            }
            return result;
        }
开发者ID:henningms,项目名称:zxing2.0-wp7,代码行数:28,代码来源:QRCodeReader.cs

示例2: decode

        public virtual Result decode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            DecoderResult decoderResult;
            ResultPoint[] points;
            if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
            {
                BitMatrix bits = extractPureBits(image.BlackMatrix);
                decoderResult = decoder.decode(bits);
                points = NO_POINTS;
            }
            else
            {
                throw new System.NotImplementedException("Detector(image.BlackMatrix).detect(hints) Not Implemented...");

                //DetectorResult detectorResult = new Detector(image.BlackMatrix).detect(hints);
                //decoderResult = decoder.decode(detectorResult.Bits);
                //points = detectorResult.Points;
            }

            Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.MICRO_QR_CODE);
            if (decoderResult.ByteSegments != null)
            {
                result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments);
            }
            if (decoderResult.ECLevel != null)
            {
                result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString());
            }
            return result;
        }
开发者ID:pockees,项目名称:ZXing-CSharp,代码行数:30,代码来源:MicroQRCodeReader.cs

示例3: decodeMultiple

      /// <summary>
      /// Decodes the multiple.
      /// </summary>
      /// <param name="image">The image.</param>
      /// <param name="hints">The hints.</param>
      /// <returns></returns>
      public Result[] decodeMultiple(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         var results = new List<Result>();
         var detectorResults = new MultiDetector(image.BlackMatrix).detectMulti(hints);
         foreach (DetectorResult detectorResult in detectorResults)
         {
            var decoderResult = getDecoder().decode(detectorResult.Bits, hints);
            if (decoderResult == null)
               continue;

            var points = detectorResult.Points;
            var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);
            var byteSegments = decoderResult.ByteSegments;
            if (byteSegments != null)
            {
               result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
            }
            var ecLevel = decoderResult.ECLevel;
            if (ecLevel != null)
            {
               result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
            }
            results.Add(result);
         }
         return results.Count == 0 ? EMPTY_RESULT_ARRAY : results.ToArray();
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:32,代码来源:QRCodeMultiReader.cs

示例4: decode

      public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         int width = image.Width;
         int height = image.Height;
         int halfWidth = width/2;
         int halfHeight = height/2;

         var topLeft = image.crop(0, 0, halfWidth, halfHeight);
         var result = @delegate.decode(topLeft, hints);
         if (result != null)
            return result;

         var topRight = image.crop(halfWidth, 0, halfWidth, halfHeight);
         result = @delegate.decode(topRight, hints);
         if (result != null)
            return result;

         var bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight);
         result = @delegate.decode(bottomLeft, hints);
         if (result != null)
            return result;

         var bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight);
         result = @delegate.decode(bottomRight, hints);
         if (result != null)
            return result;

         int quarterWidth = halfWidth/2;
         int quarterHeight = halfHeight/2;
         var center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
         return @delegate.decode(center, hints);
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:32,代码来源:ByQuadrantReader.cs

示例5: decode

      /// <summary>
      /// Locates and decodes a barcode in some format within an image. This method also accepts
      /// hints, each possibly associated to some data, which may help the implementation decode.
      /// </summary>
      /// <param name="image">image of barcode to decode</param>
      /// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}"/> from <see cref="DecodeHintType"/>
      /// to arbitrary data. The
      /// meaning of the data depends upon the hint type. The implementation may or may not do
      /// anything with these hints.</param>
      /// <returns>
      /// String which the barcode encodes
      /// </returns>
      public Result decode(BinaryBitmap image,
                           IDictionary<DecodeHintType, object> hints)
      {
         DecoderResult decoderResult;
         ResultPoint[] points;
         if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
         {
            BitMatrix bits = extractPureBits(image.BlackMatrix);
            if (bits == null)
               return null;
            decoderResult = decoder.decode(bits);
            points = NO_POINTS;
         }
         else
         {
            DetectorResult detectorResult = new Detector(image).detect(hints);
            if (detectorResult == null || detectorResult.Bits == null)
               return null;
            decoderResult = decoder.decode(detectorResult.Bits);
            points = detectorResult.Points;
         }
         if (decoderResult == null)
            return null;

         return new Result(decoderResult.Text, decoderResult.RawBytes, points,
             BarcodeFormat.PDF_417);
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:39,代码来源:PDF417Reader.cs

示例6: assertCorrectImage2result

      private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected)
      {
         RSSExpandedReader rssExpandedReader = new RSSExpandedReader();

         if (!File.Exists(path))
         {
            // Support running from project root too
            path = Path.Combine("..\\..\\..\\Source", path);
         }

#if !SILVERLIGHT
         var image = new Bitmap(Image.FromFile(path));
#else
         var image = new WriteableBitmap(0, 0);
         image.SetSource(File.OpenRead(path));
#endif
         BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BitmapLuminanceSource(image)));
         int rowNumber = binaryMap.Height / 2;
         BitArray row = binaryMap.getBlackRow(rowNumber, null);

         Result theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
         Assert.IsNotNull(theResult);

         Assert.AreEqual(BarcodeFormat.RSS_EXPANDED, theResult.BarcodeFormat);

         ParsedResult result = ResultParser.parseResult(theResult);

         Assert.AreEqual(expected, result);
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:29,代码来源:RSSExpandedImage2resultTestCase.cs

示例7: decode

      /// <summary>
      ///  Locates and decodes a Data Matrix code in an image.
      /// </summary>
      /// <param name="image">image of barcode to decode</param>
      /// <param name="hints">passed as a {@link java.util.Hashtable} from {@link com.google.zxing.DecodeHintType}
      /// to arbitrary data. The
      /// meaning of the data depends upon the hint type. The implementation may or may not do
      /// anything with these hints.</param>
      /// <returns>
      /// String which the barcode encodes
      /// </returns>
      public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         var blackmatrix = image.BlackMatrix;
         if (blackmatrix == null)
            return null;

         Detector detector = new Detector(blackmatrix);
         ResultPoint[] points = null;
         DecoderResult decoderResult = null;

         var detectorResult = detector.detect(false);
         if (detectorResult != null)
         {
            points = detectorResult.Points;

            decoderResult = new Decoder().decode(detectorResult);
         }
         if (decoderResult == null)
         {
            detectorResult = detector.detect(true);
            if (detectorResult == null)
               return null;
               
            points = detectorResult.Points;
            decoderResult = new Decoder().decode(detectorResult);
            if (decoderResult == null)
               return null;
         }

         if (hints != null &&
             hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
         {
            var rpcb = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];
            if (rpcb != null)
            {
               foreach (var point in points)
               {
                  rpcb(point);
               }
            }
         }

         var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.AZTEC);

         IList<byte[]> byteSegments = decoderResult.ByteSegments;
         if (byteSegments != null)
         {
            result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
         }
         var ecLevel = decoderResult.ECLevel;
         if (ecLevel != null)
         {
            result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
         }

         result.putMetadata(ResultMetadataType.AZTEC_EXTRA_METADATA,
                            new AztecResultMetadata(detectorResult.Compact, detectorResult.NbDatablocks, detectorResult.NbLayers));

         return result;
      }
开发者ID:n1rvana,项目名称:ZXing.NET,代码行数:71,代码来源:AztecReader.cs

示例8: Decode

      /// <summary>
      /// Locates and decodes a MaxiCode within an image. This method also accepts
      /// hints, each possibly associated to some data, which may help the implementation decode.
      /// </summary>
      /// <param name="image">image of barcode to decode</param>
      /// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}"/> from <see cref="DecodeHintType"/>
      /// to arbitrary data. The
      /// meaning of the data depends upon the hint type. The implementation may or may not do
      /// anything with these hints.</param>
      /// <returns>
      /// String which the barcode encodes
      /// </returns>
      public Result Decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         DecoderResult decoderResult;
         if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
         {
            BitMatrix bits = extractPureBits(image.BlackMatrix);
            if (bits == null)
               return null;
            decoderResult = decoder.decode(bits, hints);
            if (decoderResult == null)
               return null;
         }
         else
         {
            return null;
         }

         ResultPoint[] points = NO_POINTS;
         Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.MAXICODE);

         var ecLevel = decoderResult.ECLevel;
         if (ecLevel != null)
         {
            result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
         }
         return result;
      }
开发者ID:sfurlani,项目名称:ZXing.Net.Mobile,代码行数:39,代码来源:MaxiCodeReader.cs

示例9: Decode

 /// <summary>
 /// Locates and decodes a barcode in some format within an image. This method also accepts
 /// hints, each possibly associated to some data, which may help the implementation decode.
 /// **Note** this will return the FIRST barcode discovered if there are many.
 /// </summary>
 /// <param name="image">image of barcode to decode</param>
 /// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}"/> from <see cref="DecodeHintType"/>
 /// to arbitrary data. The
 /// meaning of the data depends upon the hint type. The implementation may or may not do
 /// anything with these hints.</param>
 /// <returns>
 /// String which the barcode encodes
 /// </returns>
 public Result Decode(BinaryBitmap image,
     IDictionary<DecodeHintType, object> hints)
 {
     Result[] results = Decode(image, hints, false);
     if (results.Length == 0)
     {
         return null;
     } else
     {
         return results[0]; // First barcode discovered.
     }
 }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:25,代码来源:PDF417Reader.cs

示例10: decode

      /// <summary>
      /// Locates and decodes a barcode in some format within an image. This method also accepts
      /// hints, each possibly associated to some data, which may help the implementation decode.
      /// </summary>
      /// <param name="image">image of barcode to decode</param>
      /// <param name="hints">passed as a <see cref="IDictionary{TKey, TValue}"/> from <see cref="DecodeHintType"/>
      /// to arbitrary data. The
      /// meaning of the data depends upon the hint type. The implementation may or may not do
      /// anything with these hints.</param>
      /// <returns>
      /// String which the barcode encodes
      /// </returns>
      public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
      {
         DecoderResult decoderResult;
         ResultPoint[] points;
         if (image == null || image.BlackMatrix == null)
         {
            // something is wrong with the image
            return null;
         }
         if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE))
         {
            var bits = extractPureBits(image.BlackMatrix);
            if (bits == null)
               return null;
            decoderResult = decoder.decode(bits, hints);
            points = NO_POINTS;
         }
         else
         {
            var detectorResult = new Detector(image.BlackMatrix).detect(hints);
            if (detectorResult == null)
               return null;
            decoderResult = decoder.decode(detectorResult.Bits, hints);
            points = detectorResult.Points;
         }
         if (decoderResult == null)
            return null;

         // If the code was mirrored: swap the bottom-left and the top-right points.
         var data = decoderResult.Other as QRCodeDecoderMetaData;
         if (data != null)
         {
            data.applyMirroredCorrection(points);
         }

         var result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE);
         var byteSegments = decoderResult.ByteSegments;
         if (byteSegments != null)
         {
            result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
         }
         var ecLevel = decoderResult.ECLevel;
         if (ecLevel != null)
         {
            result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
         }
         if (decoderResult.StructuredAppend)
         {
            result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, decoderResult.StructuredAppendSequenceNumber);
            result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, decoderResult.StructuredAppendParity);
         }
         return result;
      }
开发者ID:arumata,项目名称:zxingnet,代码行数:65,代码来源:QRCodeReader(2).cs

示例11: decode

        public Result decode(BinaryBitmap image, Dictionary<DecodeHintType, Object> hints)
        {
            int width = image.Width;
            int height = image.Height;
            int halfWidth = width/2;
            int halfHeight = height/2;

            BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight);
            try
            {
                return delegate_Renamed.decode(topLeft, hints);
            }
            catch (ReaderException)
            {
                // continue
            }

            BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight);
            try
            {
                return delegate_Renamed.decode(topRight, hints);
            }
            catch (ReaderException)
            {
                // continue
            }

            BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight);
            try
            {
                return delegate_Renamed.decode(bottomLeft, hints);
            }
            catch (ReaderException)
            {
                // continue
            }

            BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight);
            try
            {
                return delegate_Renamed.decode(bottomRight, hints);
            }
            catch (ReaderException)
            {
                // continue
            }

            int quarterWidth = halfWidth/2;
            int quarterHeight = halfHeight/2;
            BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
            return delegate_Renamed.decode(center, hints);
        }
开发者ID:henningms,项目名称:zxing2.0-wp7,代码行数:52,代码来源:ByQuadrantReader.cs

示例12: Detect

 /// <summary>
 /// <p>Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.</p>
 /// </summary>
 /// <param name="image">Image.</param>
 /// <param name="hints">Hints.</param>
 /// <param name="multiple">If set to <c>true</c> multiple.</param>
 /// <returns><see cref="PDF417DetectorResult"/> encapsulating results of detecting a PDF417 code </returns>
 public static PDF417DetectorResult Detect(BinaryBitmap image,IDictionary<DecodeHintType,object> hints, bool multiple) {
     // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even 
     // different binarizers (SF: or different Skipped Row Counts/Steps?)
     //boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
     
     BitMatrix bitMatrix = image.BlackMatrix;
     
     List<ResultPoint[]> barcodeCoordinates = Detect(multiple, bitMatrix);
     if (barcodeCoordinates.Count == 0) {
         bitMatrix.Rotate180();
         barcodeCoordinates = Detect(multiple, bitMatrix);
     }
     return new PDF417DetectorResult(bitMatrix, barcodeCoordinates);
 }
开发者ID:sfurlani,项目名称:ZXing.Net.Mobile,代码行数:21,代码来源:Detector.cs

示例13: decodeMultiple

 /// <summary>
 /// Decodes the multiple.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <param name="hints">The hints.</param>
 /// <returns></returns>
 public Result[] decodeMultiple(BinaryBitmap image, IDictionary<DecodeHintType, object> hints)
 {
    var results = new List<Result>();
    doDecodeMultiple(image, hints, results, 0, 0, 0);
    if ((results.Count == 0))
    {
       return null;
    }
    int numResults = results.Count;
    Result[] resultArray = new Result[numResults];
    for (int i = 0; i < numResults; i++)
    {
       resultArray[i] = (Result)results[i];
    }
    return resultArray;
 }
开发者ID:rfosterfrss,项目名称:ZXing.Net.Mobile,代码行数:22,代码来源:GenericMultipleBarcodeReader.cs

示例14: Recognize

        public IEnumerable<RecognitionResult> Recognize(BitmapSource bitmap, ZoneConfiguration config)
        {
            var binaryBitmap  = new BinaryBitmap(new HybridBinarizer(new BitmapSourceLuminanceSource(bitmap)));

            var recognizer = Task.Run(() => barcodeReader.Decode(binaryBitmap, new Dictionary<DecodeOptions, object>()))
                .ToObservable();

            var result = recognizer
                .Timeout(TimeSpan.FromSeconds(2))
                .Catch<Result, TimeoutException>(arg => Observable.Return<Result>(null))
                .Catch<Result, NotFoundException>(arg => Observable.Return<Result>(null));

            var text = result.ToTask().Result?.Text;

            yield return new RecognitionResult(text, 1D);
        }
开发者ID:SuperJMN,项目名称:Glass,代码行数:16,代码来源:MessagingToolkitZoneBasedBarcodeReader.cs

示例15: decodeMultiple

		public Result[] decodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints)
		{
			System.Collections.ArrayList results = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			doDecodeMultiple(image, hints, results, 0, 0);
			if ((results.Count == 0))
			{
				throw ReaderException.Instance;
			}
			int numResults = results.Count;
			Result[] resultArray = new Result[numResults];
			for (int i = 0; i < numResults; i++)
			{
				resultArray[i] = (Result) results[i];
			}
			return resultArray;
		}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:16,代码来源:GenericMultipleBarcodeReader.cs


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