Hi I try to use Barcode Reader by ZXing.
Error:
System.ArgumentException
HResult=0x80070057
Message=Source must be non-null.
Source=zxing
StackTrace:
at ZXing.Binarizer..ctor(LuminanceSource source)
at ZXing.Common.GlobalHistogramBinarizer..ctor(LuminanceSource source)
at ZXing.Common.HybridBinarizer..ctor(LuminanceSource source)
at ZXing.BarcodeReaderGeneric.<>c.<.cctor>b__40_0(LuminanceSource luminanceSource)
at ZXing.BarcodeReaderGeneric.Decode(LuminanceSource luminanceSource)
at ZXing.BarcodeReader.Decode(Byte[] barcodeBitmap)
at FileApi.Controllers.ToolController.BarcodeZXingReader(QrCodeParam inputParam) in C:\Data\GitRepo\FileApi\FileApi\Controllers\ToolController.cs:line 225
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
Code:
Byte[] byteArray = Convert.FromBase64String(inputParam.Input);
// Create an instance of BarcodeReader class
var barcodeReader = new BarcodeReader();
// Set the barcode format you want to read
barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>
{
BarcodeFormat.QR_CODE,
BarcodeFormat.CODE_128,
BarcodeFormat.EAN_13
};
var barcodeResult = barcodeReader.Decode(byteArray);
if (barcodeResult != null)
return barcodeResult;
else return "failed read it";