简体   繁体   English

ZXing.Net 0.16.8 条码阅读器<bitmap>和 BitmapLuminanceSource 初始化</bitmap>

[英]ZXing.Net 0.16.8 BarcodeReader<Bitmap> and BitmapLuminanceSource initialisation

I'm using C#.Net6, and ZXing.Net 0.16.8 to try and read a barcode, but I'm having trouble initialising the "reader".我正在使用 C#.Net6 和 ZXing.Net 0.16.8 来尝试读取条形码,但我在初始化“阅读器”时遇到了问题。

The following don't work, or give me null results:以下不起作用,或者给我空结果:

BarcodeReader reader = new BarcodeReader();

BarcodeReaderGeneric reader = new BarcodeReaderGeneric();

Later I found ZXing.Net 0.16.8 requires the reader to be initialised as:后来发现ZXing.Net 0.16.8要求读卡器初始化为:

BarcodeReader<Bitmap> reader;

Now this is where I struggle.现在这就是我挣扎的地方。 That reader cannot be null before use, but I don't know how to initialise it.该阅读器在使用前不能为空,但我不知道如何初始化它。 It seems it needs to be initialised with a function.看来它需要用一个函数来初始化。

BarcodeReader<Bitmap> reader = new BarcodeReader<Bitmap>(what do I put in here?);

It seems it needs to in a format such as Func<Bitmap, LuminanceSource> , but I have no clue how to do this.它似乎需要采用Func<Bitmap, LuminanceSource>之类的格式,但我不知道该怎么做。 I believe I will also get stuck initialising the LuminanceSource.我相信我也会在初始化 LuminanceSource 时遇到困难。

Hopefully, initialising the reader as BarcodeReader<Bitmap> will return something other than null.希望将读取器初始化为BarcodeReader<Bitmap>将返回 null 以外的内容。

The main ZXing.Net nuget package for .net 6 doesn't contain a specific barcode reader implementation for the Bitmap class or something else. .net 6 的主要 ZXing.Net nuget 包不包含 Bitmap 类或其他内容的特定条形码阅读器实现。 You have to add one of the ZXing.Net binding packages which fit your needs.您必须添加适合您需要的 ZXing.Net 绑定包之一。 That means you should select one of them for your preferred image manipulation library: https://www.nuget.org/packages?q=ZXing.Net.Bindings In your case, I think, would be the following the best choice: https://www.nuget.org/packages/ZXing.Net.Bindings.Windows.Compatibility Then you can initialize your reader instance with the following snippet:这意味着您应该为您的首选图像处理库选择其中之一: https ://www.nuget.org/packages?q=ZXing.Net.Bindings 在您的情况下,我认为以下是最佳选择: https ://www.nuget.org/packages/ZXing.Net.Bindings.Windows.Compatibility然后您可以使用以下代码片段初始化您的阅读器实例:

var reader = new ZXing.Windows.Compatibility.BarcodeReader();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM