A simple library for QR code encoding/decoding
- Decode a QR code (using the excellent ZXing.Net library, Windows only) from a high quality render or a photo with a QR code somewhere in the image.
- Encode data in a QR code (using the excellent QRCoder library) supporting several graphic formats (some Windows only) and even as ASCII art.
There are lots of options for customizing QR codes including style, image in the center, colors, and output image format. Following is a basic example.
using QRCoder;
QREncoder encoder = new();
QRCodeGenerator generator = new();
QRCodeData data = generator.CreateQrCode("https://some.url", encoder.ECCLevel);
encoder.Encode(data, "some.png", traceSource: null);
Decoding a QR code is very straightforward.
using Bitmap bitmap = (Bitmap)Image.FromFile("some.jpg");
if (QRDecoder.TryDecode(bitmap, out string? data))
{
Console.WriteLine(data);
}
Today this requires running on Windows.