Hi counterkin,
Refer below sample code to read multiple QRCode and display the result.
I am making use of ZXing.Net library will be used to read QR code image.
Download ZXing.Net package
You will need to install the ZXing.Net package using the following command.
Install-Package ZXing.Net -Version 0.16.9
HTML
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnRead" runat="server" Text="Read" OnClick="OnRead" /><br />
<br />
<asp:Label runat="server" ID="lblQRCodeText"></asp:Label>
Namespaces
You will need to import the following namespaces.
C#
using System.Drawing;
using ZXing;
using ZXing.Common;
using ZXing.Multi.QrCode;
VB.Net
Imports System.Drawing
Imports ZXing
Imports ZXing.Common
Imports ZXing.Multi.QrCode
Code
C#
protected void OnRead(object sender, EventArgs e)
{
// Create Bitmap from selected file.
using (Bitmap bitMap = (Bitmap)Bitmap.FromStream(FileUpload1.PostedFile.InputStream))
{
// Read the QRCode.
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(bitMap)));
// QRCodeMultiReader object accept BinaryBitmap and decode it.
List<string> results = new QRCodeMultiReader().decodeMultiple(binaryBitmap).Select(x => x.Text).ToList();
foreach (string text in results)
{
lblQRCodeText.Text += text + "<br />";
}
}
}
VB.Net
Protected Sub OnRead(ByVal sender As Object, ByVal e As EventArgs)
' Create Bitmap from selected file.
Using bitMap As Bitmap = CType(Bitmap.FromStream(FileUpload1.PostedFile.InputStream), Bitmap)
' Read the QRCode.
Dim binaryBitmap As BinaryBitmap = New BinaryBitmap(New HybridBinarizer(New BitmapLuminanceSource(bitMap)))
' QRCodeMultiReader object accept BinaryBitmap and decode it.
Dim results As List(Of String) = New QRCodeMultiReader().decodeMultiple(binaryBitmap).Select(Function(x) x.Text).ToList()
For Each text As String In results
lblQRCodeText.Text += text & "<br />"
Next
End Using
End Sub
Screenshots
Sample QR Code Image
After Reading the QR Code