March 4, 2025 | blog, Tutorial

How to Create and Read Aztec Barcodes


Aztec barcode generator is widely used in various industries, including transportation, healthcare, and secure document processing. Unlike QR codes, Aztec codes do not require a quiet zone, making them highly efficient for space-constrained applications.

For developers working with .NET applications, GdPicture.NET provides a powerful and flexible solution for generating and reading Aztec barcodes. This guide will walk you through how to create and decode Aztec barcodes using GdPicture.NET.


1. What is an Aztec Barcode?

Aztec Codes are a type of 2D barcode that efficiently encodes data in a compact space. Unlike QR Codes, Aztec Codes do not require a quiet zone, making them ideal for applications with limited space.

Comparison with Other 2D Barcodes

  • QR Code: Requires a quiet zone; more commonly used in marketing.
  • Data Matrix: Often used in industrial applications; slightly less compact.
  • Aztec Code: More space-efficient and robust, often used in transportation and secure applications.

Common Uses

  • Boarding passes for airlines and railways.
  • Secure government documents.
  • Inventory and logistics tracking.
  • Electronic ticketing systems.

2. Why Use GdPicture.NET for Aztec Barcodes?

GdPicture.NET is a powerful imaging SDK that provides comprehensive barcode generation and recognition capabilities. It supports multiple barcode formats, including Aztec, QR, and Data Matrix.

Benefits of Using GdPicture.NET

  • High Accuracy: Reliable barcode recognition and generation.
  • Customization: Allows control over barcode size, error correction, colors, and quiet zones.
  • Seamless .NET Integration: Works smoothly with C#, VB.NET, and other .NET languages.
  • Extensive Documentation: Easy-to-follow guides and API references.

3. How to Create an Aztec Barcode with GdPicture.NET

Step 1: Setting Up GdPicture.NET

Before generating an Aztec barcode, ensure you have GdPicture.NET installed in your .NET application. You can download and install it via the official website.

Step 2: Generating an Aztec Barcode

To create an Aztec barcode, use the GdPictureImaging class. Below is a sample C# implementation:

using GdPicture14;

LicenseManager licenseManager = new LicenseManager();
licenseManager.RegisterKEY("");

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Set the version of the barcode
BarcodeAztecCodeVersion version = BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto;
// Compute the size of the barcode
gdpictureImaging.BarcodeAztecGetSize("SampleData", ref version, 23, 4, 8, out int width, out int height);
// Create an empty GdPicture image
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, gdpictureImaging.ARGB(255, 255, 255));
// Write the barcode to the empty image
gdpictureImaging.BarcodeAztecWrite(imageID, "SampleData", ref version, 23, 4, 8, 0, 0, 0, gdpictureImaging.ARGB(0, 0, 0), gdpictureImaging.ARGB(255, 255, 255));
// Save the image as a PNG file
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\aztec_code.png");
// Release resources
gdpictureImaging.ReleaseGdPictureImage(imageID);

Explanation of Key Parameters:

  • Version: Automatically selects the appropriate barcode size.
  • Error Correction Level: Set to 23% for better resilience against damage.
  • Quiet Zone: Defines spacing around the barcode.
  • Module Size: Determines the pixel size of each barcode module.
Aztec barcode generated using GdPicture.NET, displaying encoded sample data in a square matrix pattern with high contrast for easy scanning.

4. How to Read an Aztec Barcode Using GdPicture.NET

Step 1: Loading an Aztec Barcode Image

To read an Aztec barcode, first, load the image containing the barcode.

Example of an Aztec barcode

Step 2: Decoding the Aztec Code

Use GdPicture.NET’s built-in recognition methods to extract data from the barcode:

using GdPicture14;

LicenseManager licenseManager = new LicenseManager();
licenseManager.RegisterKEY("");

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Select the image to process.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\aztec.png");
// Scan the barcodes.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID);
// Determine the number of scanned barcodes.
int barcodeCount = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
string content = "";
if (barcodeCount > 0)
{
    content = "Number of barcodes scanned: " + barcodeCount.ToString();
    // Save the value of each barcode.
    for (int i = 1; i <= barcodeCount; i++)
    {
        content += $"\nBarcode Number: {i} Value: {gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i)}";
    }
}
// Write the values to the console.
Console.WriteLine(content);
// Release unnecessary resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
Screenshot of a terminal displaying the decoded Aztec barcode data after scanning, showing the number of detected barcodes and their extracted values.

Key Features:

  • High Accuracy: Detects and extracts data efficiently.
  • Fast Processing: Optimized for .NET applications.
  • Versatile Format Support: Reads Aztec barcodes from various file formats (PNG, JPEG, BMP, etc.).

5. Customizing Your Aztec Barcode in GdPicture.NET

GdPicture.NET provides extensive customization options to fit specific application needs. You can control:

1. Barcode Size & Version

  • The BarcodeAztecCodeVersion enumeration allows you to select different barcode versions.
  • Using BarcodeAztecCodeVersionAuto lets the engine determine the minimum version required to encode all data efficiently.

2. Error Correction Level

  • The default recommended value is 23%, but it can be adjusted between 5% and 95%.
  • Higher values increase redundancy and make the barcode more resilient to damage.

3. Colors & Appearance

  • Modify the foreground (fill color) and background colors to match your application’s needs.

Example Code for Customization:

using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    string data = "123456";
    BarcodeAztecCodeVersion version = BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto;
    int moduleSize = 8;
    int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
    int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
    int dstLeft = 10;
    int dstTop = 10;

    gdpictureImaging.BarcodeAztecGetSize(data, ref version, 23, 0, moduleSize, out int width, out int height);

    int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + width, 20 + height, 32, Color.White);
    gdpictureImaging.BarcodeAztecWrite(imageID, data, ref version, 23, 0, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
    gdpictureImaging.SaveAsPNG(imageID, "output.png");

    gdpictureImaging.ReleaseGdPictureImage(imageID);
}

This example demonstrates how to create an Aztec barcode with customized size, version, error correction level, and colors. It also shows how to save the resulting image as a PNG file.


6. Conclusion

GdPicture.NET offers a powerful and flexible solution for generating and reading Aztec barcodes in .NET applications. Its high accuracy, customization options, and seamless integration make it an ideal choice for developers needing barcode functionality.

Key Takeaways:

  • Aztec Codes are space-efficient and widely used for secure data encoding.
  • GdPicture.NET provides easy-to-use methods for barcode creation and recognition.
  • Customization options allow fine-tuning barcode appearance and performance.

Next Steps:

By leveraging GdPicture.NET, you can efficiently create and manage Aztec barcodes with minimal effort while ensuring high performance and reliability in your applications.

FAQ

1. What is a 2D Data Matrix barcode?

A Data Matrix barcode is a two-dimensional code that can store large amounts of data in a compact space. It is widely used in industries like manufacturing, healthcare, retail, and logistics for product identification and traceability.

2. Why should I use GdPicture .NET SDK for Data Matrix barcode scanning?

GdPicture .NET SDK provides high-speed, accurate, and reliable barcode scanning. It supports multiple barcode types, advanced image processing algorithms, and batch scanning, making it a powerful choice for .NET applications.

3. What barcode formats does GdPicture .NET SDK support?

GdPicture supports 2D Data Matrix, QR Code, PDF417, Aztec Code, MaxiCode, and various 1D barcode types.

4. What are the system requirements for using GdPicture .NET SDK?

You need:

  • Visual Studio (Community, Professional, or Enterprise)
  • .NET Framework (6.0 or later recommended)
  • GdPicture.NET SDK, which can be installed via NuGet or from the official website.

5. How can I install GdPicture .NET SDK in my project?

  1. Install Visual Studio and select the .NET desktop development workload.
  2. Download GdPicture.NET SDK from the official website.
  3. Create a new C# Console App (.NET) project.
  4. Add GdPicture.NET via NuGet Package Manager.

6. Do I need a license to use GdPicture .NET SDK?

No license is needed for evaluation purposes. Simply register the SDK in evaluation mode using:

LicenseManager licenseManager = new LicenseManager();
licenseManager.RegisterKEY("");


Tags: