Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
In this tutorial, we delve into generating QR codes using the ZXing (a.k.a. Z Crossing) and IronBarcode libraries in Visual Studio 2022. The process starts with setting up the environment by installing necessary packages via the NuGet Package Manager. Initially, we use the ZXing library to create a QR code by configuring its options, generating pixel data, and saving the QR code as a PNG file. This method allows us to encode URLs like apkzombie.com into QR codes. Next, we explore the IronBarcode library, which offers advanced customization features such as styling, color changes, and logo addition. The IronBarcode library requires setting a license key and provides the ability to read and decode QR codes with ease. The tutorial compares both libraries, highlighting IronBarcode’s superior customization options and ease of use. Finally, viewers are encouraged to subscribe for more tutorials and reach out to Iron Software's support team for assistance.
// Using ZXing to generate a simple QR code
using System;
using ZXing;
using ZXing.Common;
using ZXing.Rendering;
using System.Drawing;
using System.Drawing.Imaging;
namespace QRCodeExample
{
class Program
{
static void Main(string[] args)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = 250,
Width = 250
},
Renderer = new BitmapRenderer()
};
// Encode sample text into a QR code
Bitmap qrCodeBitmap = writer.Write("https://apkzombie.com");
// Save the QR code as a PNG file
qrCodeBitmap.Save("QRCode.png", ImageFormat.Png);
Console.WriteLine("QR code generated and saved as QRCode.png.");
}
}
}
// Using ZXing to generate a simple QR code
using System;
using ZXing;
using ZXing.Common;
using ZXing.Rendering;
using System.Drawing;
using System.Drawing.Imaging;
namespace QRCodeExample
{
class Program
{
static void Main(string[] args)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = 250,
Width = 250
},
Renderer = new BitmapRenderer()
};
// Encode sample text into a QR code
Bitmap qrCodeBitmap = writer.Write("https://apkzombie.com");
// Save the QR code as a PNG file
qrCodeBitmap.Save("QRCode.png", ImageFormat.Png);
Console.WriteLine("QR code generated and saved as QRCode.png.");
}
}
}
' Using ZXing to generate a simple QR code
Imports System
Imports ZXing
Imports ZXing.Common
Imports ZXing.Rendering
Imports System.Drawing
Imports System.Drawing.Imaging
Namespace QRCodeExample
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim writer = New BarcodeWriter With {
.Format = BarcodeFormat.QR_CODE,
.Options = New EncodingOptions With {
.Height = 250,
.Width = 250
},
.Renderer = New BitmapRenderer()
}
' Encode sample text into a QR code
Dim qrCodeBitmap As Bitmap = writer.Write("https://apkzombie.com")
' Save the QR code as a PNG file
qrCodeBitmap.Save("QRCode.png", ImageFormat.Png)
Console.WriteLine("QR code generated and saved as QRCode.png.")
End Sub
End Class
End Namespace
// Using IronBarcode for enhanced QR code features
using System;
using IronBarCode;
namespace QRCodeExample
{
class Program
{
static void Main(string[] args)
{
// License key setup for IronBarcode (replace with your license key)
// License.LicenseKey = "YOUR-LICENSE-KEY";
// Create a simple QR code
var qrCode = QRCodeWriter.CreateQrCode("https://apkzombie.com", 250);
// Customize the QR code (e.g., adding a logo, changing colors)
qrCode.ChangeBarCodeColor(System.Drawing.Color.FromArgb(0, 0, 128)); // Dark blue code color
qrCode.ChangeBackgroundColor(System.Drawing.Color.FromArgb(255, 255, 255)); // White background
// Save the QR code as an image
qrCode.SaveAsPng("CustomQRCode.png");
Console.WriteLine("Custom QR code generated and saved as CustomQRCode.png.");
}
}
}
// Using IronBarcode for enhanced QR code features
using System;
using IronBarCode;
namespace QRCodeExample
{
class Program
{
static void Main(string[] args)
{
// License key setup for IronBarcode (replace with your license key)
// License.LicenseKey = "YOUR-LICENSE-KEY";
// Create a simple QR code
var qrCode = QRCodeWriter.CreateQrCode("https://apkzombie.com", 250);
// Customize the QR code (e.g., adding a logo, changing colors)
qrCode.ChangeBarCodeColor(System.Drawing.Color.FromArgb(0, 0, 128)); // Dark blue code color
qrCode.ChangeBackgroundColor(System.Drawing.Color.FromArgb(255, 255, 255)); // White background
// Save the QR code as an image
qrCode.SaveAsPng("CustomQRCode.png");
Console.WriteLine("Custom QR code generated and saved as CustomQRCode.png.");
}
}
}
' Using IronBarcode for enhanced QR code features
Imports System
Imports IronBarCode
Namespace QRCodeExample
Friend Class Program
Shared Sub Main(ByVal args() As String)
' License key setup for IronBarcode (replace with your license key)
' License.LicenseKey = "YOUR-LICENSE-KEY";
' Create a simple QR code
Dim qrCode = QRCodeWriter.CreateQrCode("https://apkzombie.com", 250)
' Customize the QR code (e.g., adding a logo, changing colors)
qrCode.ChangeBarCodeColor(System.Drawing.Color.FromArgb(0, 0, 128)) ' Dark blue code color
qrCode.ChangeBackgroundColor(System.Drawing.Color.FromArgb(255, 255, 255)) ' White background
' Save the QR code as an image
qrCode.SaveAsPng("CustomQRCode.png")
Console.WriteLine("Custom QR code generated and saved as CustomQRCode.png.")
End Sub
End Class
End Namespace
Further Reading: A comparison of IronBarcode and the ZXing Net library