简体   繁体   中英

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".

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:

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. I believe I will also get stuck initialising the LuminanceSource.

Hopefully, initialising the reader as BarcodeReader<Bitmap> will return something other than 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. You have to add one of the ZXing.Net binding packages which fit your needs. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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