The Solution Explorer shows the ZXing package after its installation.
The UI design of the form is as shown below.
The complete code is as follows.using System;
using System.Windows.Forms;
using System.IO;
namespace BarcodeAppWF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void WordsTextBox_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(WordsTextBox.Text))
{
BarcodePictureBox.Image = null;
}
}
private void DecodeBarcodeButton_Click(object sender, EventArgs e)
{
ZXing.BarcodeReader bcReader = new ZXing.BarcodeReader();
MemoryStream memoryStream = new MemoryStream();
BarcodePictureBox.Image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
//byte[] bytes = memoryStream.ToArray();
ZXing.Result result= bcReader.Decode(new System.Drawing.Bitmap(memoryStream));
MessageBox.Show(result.ToString(),"QRCode Decoded",MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void QRGeneratorButton_Click(object sender, EventArgs e)
{
ZXing.BarcodeWriter bcWriter = new ZXing.BarcodeWriter();
bcWriter.Format = ZXing.BarcodeFormat.QR_CODE;
System.Drawing.Bitmap bitmap= bcWriter.Write(WordsTextBox.Text);
BarcodePictureBox.Image = bitmap;
}
}
}
INPUT DATA
OUTPUT
OUTPUT
No comments:
Post a Comment