After upgrading ZXing.Net nuget package from 0.16.5 to 0.16.6 the existing source shows the error:
Using the generic type 'BarcodeReader' requires 1 type arguments
public void ReadBarcode(System.Drawing.Bitmap readerBitmap, BarcodeFormat barcodeFormat)
{
// here when instantiate the barcode reader object
// the error occurs with the new updated nuget package 0.16.6
var barcodeReader = new ZXing.BarcodeReader();
barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>();
barcodeReader.Options.PossibleFormats.Add(barcodeFormat);
barcodeReader.AutoRotate = true;
barcodeReader.Options.TryHarder = true;
barcodeReader.Options.PureBarcode = false;
ZXing.Result barcodeResult = null;
try
{
barcodeResult = barcodeReader.Decode(readerBitmap);
}
catch (Exception ex)
{
Log.LogError($"Exception in barcode lib - {ex.Message}");
}
Should I change from BarcodeReader
to BarcodeReaderGeneric
or IBarcodeReader
or IBarcodeReaderGeneric
or should I add a parameter createLuminanceSource
?
I was not able to find existing examples using 0.16.6 and even the documentation still shows the parameterless constructor.
If you use ZXing.Net with.Net Core /.Net Standard you have to use one of the different binding packages. They contain specific BarcodeReader implementations for the different image libraries. https://www.nuget.org/packages?q=zxing.bindings That's by design because.Net core doesn't include a bitmap implementation in the core package.
If you get desperate and can't get the BarcodeReader
which inherits from BarcodeReader<Bitmap>
to be referenced correctly, you could call the base constructor of BarcodeReader<Bitmap>
directly which is called when you create a new BarcodeReader
:
var luminanceSource = (Func<Bitmap, LuminanceSource>) (bitmap => new BitmapLuminanceSource(bitmap));
var barcodeReader = new ZXing.BarcodeReader<Bitmap>(null, luminanceSource, null);
//...so on
barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>();
barcodeReader.Options.PossibleFormats.Add(barcodeFormat);
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.