pq scan
C# & VB.NET Demos for Reading QR Code
As stated in .NET guide page for barcode reading, there are nine barcode reading methods that can be used in VB.NET and C# applications, which allows you to recognize certain barcode type (2d QR Code) or total barcode types from image source. And your target raster image source can be in Bitmap object, disk file, or stream mode. Here we supply free C# and VB.NET demo solution for scanning and decoding QR Code from file at the disk, please see as below.
How to Read QR Code Using C# Demo
public void ScanQRCodeFromFile(string filename)
{
// Choose to detect and read QR Code barcode(s) only from a local image file.
BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.QRCode);
// APIs for reading 2D QR Code from Bitmap and Stream objects.
// public static BarcodeResult[] Scan(Bitmap bitmap, BarCodeType barType);
// public static BarcodeResult[] Scan(Stream stream, BarCodeType barType);
foreach (BarcodeResult result in results)
{
Console.WriteLine(result.BarType.ToString() + "-" + result.Data);
}
}
// Used to improve QR Code reader accuracy when there's only one QR Code on your image.
Bitmap bmp = new Bitmap("YourImagePath");
BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp);
Console.WriteLine("barcode data:{0}.", barcode.Data);
How to Read QR Code Using VB.NET Demo
Public Sub ScanAllFromFile(ByVal filename As String)
' Choose to recognize all barcode types including QR Code from a local image file.
Dim results() As BarcodeResult = BarCodeScanner.Scan(filename)
' APIs for decoding all barcode types from Bitmap and Stream objects.
' public static BarcodeResult[] Scan(Bitmap bitmap)
' public static BarcodeResult[] Scan(Stream stream)
Dim result As BarcodeResult
For Each result In results
Console.WriteLine(result.BarType.ToString() + "-" + result.Data)
Next
End Sub
' Used to improve QR Code reader accuracy when there's only one QR Code on your image.
Dim bmp As Bitmap = New Bitmap("YourImagePath")
Dim barcode As BarcodeResult = BarCodeScanner.ScanSingle(bmp)
Console.WriteLine("barcode data:{0}.", barcode.Data)
If you have any other barcode reading questions for our .NET Barcode Scanner SDK, please send an email to us. We are pleased to help you.