public IActionResult Post(IFormFile file) { Response.StatusCode = 200; if (file == null) { return(Content("")); } // create a barcode reader instance IBarcodeReader reader = new ZXing.CoreCompat.System.Drawing.BarcodeReader() { AutoRotate = true, Options = new ZXing.Common.DecodingOptions() { TryHarder = true, PossibleFormats = new List <BarcodeFormat>() { BarcodeFormat.All_1D } } }; // load a bitmap Bitmap bitmap = (Bitmap)Image.FromStream(file.OpenReadStream()); BitmapLuminanceSource image = new BitmapLuminanceSource(bitmap); // detect and decode the barcode inside the bitmap Result result = reader.Decode(image); return(Content(result?.Text)); }
private String DecodeQrCode(Byte[] input) { var reader = new BarcodeReader(); using (var stream = new MemoryStream(input)) { using (var image = (Bitmap)Image.FromStream(stream)) { return(reader.Decode(image).Text); } } }