Write a QR code to an image
This guide shows how to generate a QR code and write it to an image.
Use this workflow when you need to:
- Encode URLs or identifiers in QR format
- Generate QR assets for print or digital channels
- Integrate QR creation into automated pipelines
Prepare the project
Register the SDK license before running barcode operations. For setup details, refer to the getting started with .NET SDK guide.
using GdPicture14;
LicenseManager licence = new LicenseManager();licence.RegisterKEY(""); // Set your license keyCreate the image canvas
Create a blank image to host the QR code:
using GdPictureImaging imaging = new GdPictureImaging();
// Create a new image canvas with specified dimensions and color depthint imageId = imaging.CreateNewGdPictureImage(600, 300, 32, imaging.ARGBI(255, 255, 255, 255));Generate the QR code
Write the QR code to the image:
// Generate QR code with specified data and formatting parametersimaging.BarcodeQRWrite(imageId, "https://www.nutrient.io", BarcodeQREncodingMode.BarcodeQREncodingModeUndefined, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelH, 0, 5, 5, 50, 50, 0, GdPicture14.Imaging.GdPictureColor.Black, GdPicture14.Imaging.GdPictureColor.White);This configuration uses high error correction (H) and a black-on-white color scheme for scan reliability.
Save the output image
Export the generated QR code as PNG:
// Save the generated QR code image as PNG formatimaging.SaveAsPNG(imageId, @"output_qr_code.png");QR code options
BarcodeQRWrite accepts the following configurable parameters:
- Error correction level (
L,M,Q,H) - Encoding mode
- Size and position
- Foreground and background colors
Conclusion
This workflow generates a QR code image for use in labels, documents, and digital channels.