Hi anirudhp,
Refer below sample.
Refer below article and download the QRcoder dll.
Namespaces
C#
using QRCoder;
using System.IO;
VB.Net
Imports QRCoder
Imports System.IO
Code
C#
private void btnGenerate_Click(object sender, EventArgs e)
{
string code = txtCode.Text;
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
Bitmap bitMap = qrCode.GetGraphic(5);
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
File.WriteAllBytes(@"C:\Users\anand\Desktop\Test.png", byteImage);
pictureBox1.Image = bitMap;
pictureBox1.Height = bitMap.Height;
pictureBox1.Width = bitMap.Width;
}
}
VB.Net
Private Sub btnGenerate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Dim code As String = txtCode.Text
Dim qrGenerator As QRCodeGenerator = New QRCodeGenerator()
Dim qrCode As QRCodeGenerator.QRCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q)
Dim bitMap As Bitmap = qrCode.GetGraphic(5)
Using ms As MemoryStream = New MemoryStream()
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
Dim byteImage As Byte() = ms.ToArray()
File.WriteAllBytes("C:\Users\anand\Desktop\Test.png", byteImage)
pictureBox1.Image = bitMap
pictureBox1.Height = bitMap.Height
pictureBox1.Width = bitMap.Width
End Using
End Sub
Screenshot