Compact barcodes are essential when screen space is limited, especially on mobile devices and embedded panels. Aspose.BarCode for .NET lets you create Micro QR code in .NET with just a few lines of C#. In this guide we walk through the installation, code implementation, and key configuration options. By the end you’ll have a ready‑to‑use Micro QR image optimized for size and readability.
Steps to Generate a Micro QR Code in .NET
- Add the NuGet package - Install Aspose.BarCode via the Package Manager Console:
Install-Package Aspose.BarCode. - Create a generator - Initialize
BarcodeGeneratorwithEncodeTypes.MicroQRand the data you want to encode. - Set QR dimensions - Adjust
XDimensionand optionally the QR version to control the physical size of the code. - Configure error correction - Choose an error‑correction level (L, M, Q, H) to improve readability on low‑contrast surfaces.
- Save the image - Export the barcode to PNG, JPEG, or any supported format using the
Savemethod.
For a deeper look at the API, see the BarcodeGenerator class reference.
Micro QR Code Generation in .NET - Complete Code Example
The following example demonstrates how to generate a Micro QR code, set its size, and save it as a PNG file.
using Aspose.BarCode.Generation;
string qrData = "1234567890"; // Keep it very small
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.MicroQR, qrData))
{
generator.Parameters.Barcode.XDimension.Pixels = 4;
// Lowest error correction gives maximum capacity
generator.Parameters.Barcode.QR.ErrorLevel = QRErrorLevel.LevelL;
// Use largest Micro QR version
generator.Parameters.Barcode.QR.MicroQRVersion = MicroQRVersion.M4;
generator.Save("MicroQR.png", BarCodeImageFormat.Png);
}
Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update the file paths (
"MicroQR.png"), verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.
Installation and Setup in .NET
To start using Aspose.BarCode, follow these steps:
# Install via NuGet
Install-Package Aspose.BarCode
- Download the SDK - Get the latest binaries from the download page.
- Add a reference - Include the
Aspose.BarCode.dllin your project if you are not using NuGet. - Apply a license - For production use, set the license with
License license = new License(); license.SetLicense("Aspose.BarCode.lic");. A temporary license is available on the temporary license page. - Verify the installation - Run a simple “Hello World” barcode generation to ensure everything works.
Create Micro QR Code in .NET with Aspose.BarCode
Micro QR codes are a compact variant of the standard QR code, ideal for applications where space is at a premium. Aspose.BarCode provides native support for Micro QR, allowing you to generate high‑quality images without external dependencies. The library handles encoding, error correction, and rendering, so you can focus on integrating the barcode into your UI or data flow.
Aspose.BarCode Features That Matter for This Task
- Native Micro QR support - Direct
EncodeTypes.MicroQRenumeration. - Fine‑grained size control -
XDimensionand QR version settings let you shrink the code to the smallest readable size. - Multiple output formats - PNG, JPEG, BMP, SVG, and more, all with lossless rendering.
- High performance - Optimized rendering engine capable of generating thousands of codes per second.
- Cross‑platform - Works on .NET Framework, .NET Core, and .NET 5/6+.
Configuring QR Code Parameters
You can tailor the Micro QR code to your specific needs:
- XDimension - Controls the pixel size of each module; lower values produce smaller images.
- ErrorLevel - Choose from
Low,Medium,Quartile, orHighto balance data capacity and resilience. - Margin - Adjust
QuietZoneto add or remove white space around the code. - Encoding - Set
EncodeModetoAutofor automatic data type detection or specifyAlphanumeric,Numeric, etc.
Example configuration snippet:
generator.Parameters.Barcode.XDimension = 1; // 1 pixel per module
generator.Parameters.Barcode.QR.ErrorLevel = QRErrorLevel.High;
generator.Parameters.Barcode.QR.QuietZone = 2; // 2 modules of margin
Performance Considerations
Generating Micro QR codes is fast, but certain settings can impact speed. The table below shows typical rendering times on a standard development machine.
| QR Version | XDimension (px) | Error Level | Avg. Render Time (ms) |
|---|---|---|---|
| Auto | 2 | Medium | 12 |
| 3 | 1 | Low | 9 |
| 5 | 3 | High | 15 |
Keep the XDimension low and avoid unnecessarily high error levels when you need maximum throughput.
Best Practices for Micro QR Code Generation
- Use the smallest viable XDimension to keep the code compact while maintaining readability.
- Select the lowest error correction level that meets your environment’s scanning conditions.
- Test on target devices (mobile cameras, embedded scanners) to ensure the code is readable at the intended size.
- Prefer PNG for lossless output when the barcode will be displayed on screens.
- Cache generated images if the same data is encoded repeatedly to avoid redundant processing.
Conclusion
Creating Micro QR code in .NET is straightforward with Aspose.BarCode for .NET. By following the steps above you can generate compact, high‑quality QR images, fine‑tune size and error correction, and achieve optimal performance for mobile or embedded applications. Remember to acquire a proper license for production use; pricing details are available on the pricing page, and a temporary license can be obtained from the temporary license page. Happy coding!
FAQs
How do I create Micro QR code in .NET with Aspose.BarCode?
Use the BarcodeGenerator class with EncodeTypes.MicroQR, configure size and error correction via the Parameters property, and call Save to export the image. The full process is illustrated in the code example above.
What image formats can I export the Micro QR code to?
Aspose.BarCode supports PNG, JPEG, BMP, GIF, TIFF, SVG, and PDF. PNG is recommended for lossless quality on screens.
Why is my Micro QR code not readable on a low‑resolution display?
Insufficient contrast or a too‑small XDimension can cause readability issues. Increase the module size or lower the error correction level, and ensure a high‑contrast foreground/background.
Do I need a license to generate Micro QR codes in a commercial app?
Yes. While a temporary license is available for evaluation, a full license is required for production deployments. See the pricing page for details.
