How to Create a QR Code Image in C# with IronQR

To create a QR code image in C#, use IronQR's QrWriter.Write() method to generate the code, then Save() to get an AnyBitmap object and SaveAs() to export it to your preferred image format like PNG or JPEG.

Quickstart: Create Your First QR Code Image

  1. Install IronQR via NuGet Package Manager
  2. Add using IronQr; and using IronSoftware.Drawing;
  3. Generate QR code: QrCode qrCode = QrWriter.Write("your text");
  4. Save to bitmap: AnyBitmap anyBitmap = qrCode.Save();
  5. Export as image: anyBitmap.SaveAs("myQRCode.png", AnyBitmap.ImageFormat.Png);

Here's a complete example to get you started:

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronQR with NuGet Package Manager

    PM > Install-Package IronQR

  2. Copy and run this code snippet.

    using IronQr;
    using IronSoftware.Drawing;
    
    // Generate a simple QR code
    QrCode myQrCode = QrWriter.Write("Hello, World!");
    
    // Save as an image bitmap
    AnyBitmap qrImage = myQrCode.Save();
    
    // Export to PNG file
    qrImage.SaveAs("hello-world-qr.png", AnyBitmap.ImageFormat.Png);
  3. Deploy to test on your live environment

    Start using IronQR in your project today with a free trial
    arrow pointer

QR codes encode data as visual patterns of black and white squares that cameras and scanners can read. These two-dimensional matrices store URLs, text, or other information in a compact, scannable format. For more advanced examples, check out the QR quickstart guide.

Start using IronQR in your project today with a free trial.

First Step:
green arrow pointer

How Do I Create QR Code as Images?

What Code Do I Need to Generate a QR Code?

Creating QR codes with IronQR requires minimal code. Generate the QR code object with one line, then export it as an image using the Save and SaveAs methods. The QrWriter class provides all the functionality for generating QR codes.

:path=/static-assets/qr/content-code-examples/how-to/create-qr-code-image.cs
using IronQr;
using IronSoftware.Drawing;

// Creating a QR code
QrCode qrCode = QrWriter.Write("12345");

// Save QR code to AnyBitmap
AnyBitmap anyBitmap = qrCode.Save();

// Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png);
Imports IronQr
Imports IronSoftware.Drawing

' Creating a QR code
Private qrCode As QrCode = QrWriter.Write("12345")

' Save QR code to AnyBitmap
Private anyBitmap As AnyBitmap = qrCode.Save()

' Save AnyBitmap to PNG
anyBitmap.SaveAs("simpleQrCode.png", AnyBitmap.ImageFormat.Png)
$vbLabelText   $csharpLabel
Example QR code generated showing the visual output from QR code creation process

Which Image Formats Can I Export To?

The Save method returns an AnyBitmap object that supports multiple export formats:

  • JPEG (.jpg or .jpeg): Compressed format for photos using lossy compression.
  • PNG (.png): Lossless format ideal for web use with transparency support.
  • Bmp (.bmp): Uncompressed Windows format producing large, high-quality files.
  • GIF (.gif): Supports animations and transparency with 256-color limit.
  • TIFF (.tiff or .tif): Flexible format for professional photography.
  • WBMP (.wbmp): Monochrome format for wireless communication.
  • WebP (.webp): Modern format with excellent lossy and lossless compression.
  • Icon (.ico): Small square images for program and file icons.
  • WMF (.wmf): Vector and raster format for Windows graphics.
  • RawFormat (.raw): Unprocessed image data for professional editing.

Why Should I Choose PNG Over JPEG for QR Codes?

PNG provides lossless compression and sharp edges essential for QR code readability. JPEG's lossy compression can blur QR code edges, potentially affecting scan reliability. PNG ensures crisp lines for optimal scanning across all devices and conditions.

PNG's transparency support adds value for styled QR codes with logos or custom colors. Learn more about creating styled QR codes with advanced customization in our advanced guide.

How Can I Control QR Code Size and Quality?

IronQR provides options to control size and quality:

using IronQr;
using IronSoftware.Drawing;

// Create QR code with custom dimensions
QrOptions options = new QrOptions(QrErrorCorrectionLevel.High, 20);
QrCode qrCode = QrWriter.Write("https://ironsoftware.com", options);

// Save with specific dimensions
AnyBitmap qrImage = qrCode.SaveAsPng(500, 500);

// Save to file
qrImage.SaveAs("custom-size-qr.png");
using IronQr;
using IronSoftware.Drawing;

// Create QR code with custom dimensions
QrOptions options = new QrOptions(QrErrorCorrectionLevel.High, 20);
QrCode qrCode = QrWriter.Write("https://ironsoftware.com", options);

// Save with specific dimensions
AnyBitmap qrImage = qrCode.SaveAsPng(500, 500);

// Save to file
qrImage.SaveAs("custom-size-qr.png");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Error correction determines damage tolerance while maintaining readability. Higher levels create complex QR codes with better fault tolerance, detailed in our fault tolerance documentation.


What QR Code Types Are Supported?

Which QR Code Type Should I Use for Standard Applications?

IronQR supports all major QR code formats for diverse application needs:

  • QRCode: Standard QR code storing up to 7,089 numeric or 4,296 alphanumeric characters. Suitable for URLs, contact information, and general data storage.
Example QR code showing standard black and white matrix pattern with corner positioning squares

When Should I Use Micro QR Codes?

  • MicroQRCode: Smaller version for space-limited applications. Stores up to 35 numeric or 21 alphanumeric characters. Ideal for small packaging or tiny labels.
Standard QR code showing typical black and white square pattern with finder corners and data modules

What Are RMQR Codes Best Used For?

  • RMQRCode: Rectangular Micro QR Code with flexible aspect ratio. Stores data similar to Micro QR Code but fits rectangular spaces.
Example QR code showing standard matrix pattern with positioning markers and encoded data squares

Best Practices for QR Code Image Generation

What Are the Key Considerations for Production QR Codes?

Consider these factors for production QR codes:

  1. Error Correction Level: Use High (H) for printed materials that may get damaged. Medium (M) suffices for digital displays.

  2. Quiet Zone: Maintain white space at least 4 modules wide around the QR code for optimal scanning.

  3. Contrast: Black on white provides best results. IronQR's styling features allow creative variations while maintaining readability.

  4. Size: Ensure minimum 2cm x 2cm for printed codes. Digital displays may need larger sizes based on viewing distance.

How Do I Handle Different Use Cases?

Different applications require different approaches:

For Business Cards and Print Materials:

// High error correction for durability
QrOptions printOptions = new QrOptions(QrErrorCorrectionLevel.High, 10);
QrCode businessCard = QrWriter.Write("BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nEND:VCARD", printOptions);
// High error correction for durability
QrOptions printOptions = new QrOptions(QrErrorCorrectionLevel.High, 10);
QrCode businessCard = QrWriter.Write("BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nEND:VCARD", printOptions);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

For Digital Displays and Websites:

// Medium error correction with larger modules for screen display
QrOptions digitalOptions = new QrOptions(QrErrorCorrectionLevel.Medium, 15);
QrCode webQr = QrWriter.Write("https://example.com", digitalOptions);
// Medium error correction with larger modules for screen display
QrOptions digitalOptions = new QrOptions(QrErrorCorrectionLevel.Medium, 15);
QrCode webQr = QrWriter.Write("https://example.com", digitalOptions);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

For Mobile Applications:

// Optimized for mobile scanning
QrOptions mobileOptions = new QrOptions(QrErrorCorrectionLevel.Low, 8);
QrCode appQr = QrWriter.Write("myapp://action", mobileOptions);
// Optimized for mobile scanning
QrOptions mobileOptions = new QrOptions(QrErrorCorrectionLevel.Low, 8);
QrCode appQr = QrWriter.Write("myapp://action", mobileOptions);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Advanced Features and Integration

IronQR's comprehensive features extend beyond basic QR code generation. The library integrates seamlessly with other Iron Software products and supports batch processing, dynamic generation, and web application integration.

For complete QR code solutions, explore our C# QR Code Generator tutorial covering end-to-end implementation patterns and enterprise best practices.

IronQR provides the tools and flexibility for professional .NET development, from simple generators to complex document processing systems. The library's cross-platform compatibility ensures consistent QR code generation across Windows, Linux, macOS, and cloud environments.

Frequently Asked Questions

What is the quickest way to create a QR code image in C#?

The quickest way is to use IronQR's QrWriter.Write() method to generate the QR code, then call Save() to get an AnyBitmap object, and finally use SaveAs() to export it to your preferred image format. With just 5 lines of code, you can create and save a QR code as a PNG or JPEG file.

Which image formats are supported when exporting QR codes?

IronQR supports multiple image formats including JPEG, PNG, BMP, GIF, TIFF, WBMP, WebP, and Icon formats. The Save() method returns an AnyBitmap object that can be exported to any of these formats using the SaveAs() method with the appropriate ImageFormat parameter.

How do I generate a simple QR code and save it as a PNG file?

To generate a QR code and save it as PNG, use: QrCode myQrCode = QrWriter.Write("your text"); then AnyBitmap qrImage = myQrCode.Save(); and finally qrImage.SaveAs("filename.png", AnyBitmap.ImageFormat.Png); IronQR handles all the QR code generation complexity for you.

What namespaces do I need to import for creating QR code images?

You need to import two namespaces: 'using IronQr;' for the QR code generation functionality and 'using IronSoftware.Drawing;' for the image handling capabilities. These provide access to the QrWriter class and AnyBitmap object used in IronQR.

Can I create QR codes with custom styling or just black and white?

While the basic examples show standard black and white QR codes, IronQR's QrWriter class provides extensive functionality for generating customized QR codes. You can explore advanced styling options through the comprehensive API documentation.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 52,761 | Version: 2025.12 just released