Read a QR code in C# using the ZXing.net library
QR codes are all around us, and with a few lines of code you can take an image of a QR code, and interpet it as text. The same code also works with barcodes, and all these formats; UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 93, Code 128, ITF, Codabar, MSI, RSS-14 (all variants), QR Code, Data Matrix, Aztec and PDF-417.
The code is open source at https://github.com/infiniteloopltd/ReadQRCode , but there’s not much to it; just these few lines of code;
const string imageUrl = “https://httpsimage.com/v2/c890b3a2-098b-41ab-bb9a-cc727bfc1a95.png”;
// Install-Package ZXing.Net -Version 0.16.5
var client = new WebClient();
var stream = client.OpenRead(imageUrl);
if (stream == null) return;
var bitmap = new Bitmap(stream);
IBarcodeReader reader = new BarcodeReader();
var result = reader.Decode(bitmap);
Console.WriteLine(result.Text);