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.
- Install IronQR via NuGet Package Manager
- Add
using IronQr;andusing IronSoftware.Drawing; - Generate QR code:
QrCode qrCode = QrWriter.Write("your text"); - Save to bitmap:
AnyBitmap anyBitmap = qrCode.Save(); - Export as image:
anyBitmap.SaveAs("myQRCode.png", AnyBitmap.ImageFormat.Png);
Here's a complete example to get you started:
-
1Install IronQR with NuGet Package Manager
-
2Copy 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");C# -
3Deploy to test on your live environment
Start using IronQR in your project today with a free trial
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.
How to Create a QR Code as an Image
- Download the C# library to create QR code as an image
- Create the QR code as an object
- Use the
Savemethod to obtain theAnyBitmap - Use the
SaveAsmethod to export to an image file - Explore the various supported formats
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.
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)
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.Save(new QrStyleOptions { Dimensions = 500 });
// Save to file
qrImage.SaveAs("custom-size-qr.png");
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.

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.

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.

Best Practices for QR Code Image Generation
What Are the Key Considerations for Production QR Codes?
Consider these factors for production QR codes:
- Error Correction Level: Use High (H) for printed materials that may get damaged. Medium (M) suffices for digital displays.
- Quiet Zone: Maintain white space at least 4 modules wide around the QR code for optimal scanning.
- Contrast: Black on white provides best results. IronQR's styling features allow creative variations while maintaining readability.
- 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
Dim printOptions As New QrOptions(QrErrorCorrectionLevel.High, 10)
Dim businessCard As QrCode = QrWriter.Write("BEGIN:VCARD" & vbLf & "VERSION:3.0" & vbLf & "FN:John Doe" & vbLf & "END:VCARD", printOptions)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
Dim digitalOptions As New QrOptions(QrErrorCorrectionLevel.Medium, 15)
Dim webQr As QrCode = QrWriter.Write("https://example.com", digitalOptions)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
Dim mobileOptions As New QrOptions(QrErrorCorrectionLevel.Low, 8)
Dim appQr As QrCode = QrWriter.Write("myapp://action", mobileOptions)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
How can I generate a QR code image using IronQR in C#?
To create a QR code image in C#, you can use IronQR's `QrWriter.Write()` method to generate the QR code, and then the `Save()` method to get an `AnyBitmap` object. You can then use the `SaveAs()` method to export the QR code into your preferred image format like PNG or JPEG.
What are the steps to create my first QR code image with IronQR?
To create your first QR code using IronQR, install IronQR via NuGet, add `using IronQr;`, generate a QR code object with `QrCode qrCode = QrWriter.Write("your text");`, save it to a bitmap with `AnyBitmap anyBitmap = qrCode.Save();`, and export the image using `anyBitmap.SaveAs("myQRCode.png");`.
Which image formats are supported for exporting QR codes with IronQR?
IronQR allows exporting QR codes in multiple image formats including PNG, JPEG, BMP, GIF, TIFF, WBMP, WebP, Icon, WMF, and RawFormat.
Why is PNG preferred over JPEG for QR code images?
PNG is preferred over JPEG for QR codes because it provides lossless compression, which maintains sharp edges essential for readability. JPEG's lossy compression can cause blurring and affect the QR code's scannability.
How do I adjust the size and quality of a QR code generated with IronQR?
IronQR allows you to control QR code size and quality using `QrOptions` for error correction levels and dimensions. For example, set custom dimensions by creating a QR code with `QrOptions options` and use `qrCode.Save()` with `QrStyleOptions` to define the size.
What types of QR codes does IronQR support?
IronQR supports various QR code types including the standard QRCode, MicroQRCode for space-limited applications, and RMQRCode for rectangular spaces, accommodating diverse application needs.
What are some best practices for generating QR code images for production use?
Best practices include using a high error correction level for printed materials, maintaining a white quiet zone around the QR code, ensuring high contrast, and setting an appropriate size to ensure scan reliability.
Which QR code type should I use for a small label?
For small labels, MicroQR codes are ideal due to their compact size. They are designed for space-limited applications and can store up to 35 numeric or 21 alphanumeric characters.
Can I create styled QR codes with IronQR?
Yes, with IronQR you can create styled QR codes offering options for advanced customization, including custom dimensions, error correction levels, and integrating logos or custom colors.
Does IronQR integrate with other Iron Software products?
Yes, IronQR integrates seamlessly with other Iron Software products, supporting batch processing, dynamic generation, web application integration, and more for comprehensive .NET development.

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.