使用 VintaSoft Barcode .NET SDK 识别和生成阿兹特克条形码

博客分类:条形码   .NET

2025/07/16

VintaSoft Barcode .NET SDK 是一款专业的跨平台 SDK,支持 Windows、Linux 和 macOS,可用于在 .NET、WPF、Web 和 MAUI 中识别和生成阿兹特克条形码。VintaSoft Barcode .NET SDK 只需几行代码即可嵌入阿兹特克条形码识别和生成功能。


什么是阿兹特克条形码?

阿兹特克码条形码是最紧凑的二维矩阵条形码。由于没有自由区和紧凑的搜索模式,它比其他矩阵条形码占用空间更小。阿兹特克条形码的一个显著特征是位于条形码中心的独特方形搜索图案"靶心":


阿兹特克条形码的特征

阿兹特克条形码由2008年ISO/IEC 24778标准定义。阿兹特克条形码可以以三种编码模式存储不同类型的混合数据:

阿兹特克条形码使用里德-所罗门纠错算法,使其能够识别损坏的条形码。创建条形码时,用户可以指定纠错码字所占用的数据区域百分比。

支持 GS1 标准允许您以 GS1 格式对数据进行编码(BarcodeSymbologySubsets.GS1Aztec)。

阿兹特克条形码可以编码以下特殊字符:


什么是"Aztec Rune"条形码?

阿兹特克条形码有一个特殊版本--阿兹特克符文条形码,它只能编码0到255范围内的一个数字(一个字节)。


阿兹特克符文条形码尺寸紧凑,为 11x11 模块,可用作生产中的标签,例如,用于控制包装方向或检查货物完整性。此标签还可用于在图像上创建定向参考点,为此,VintaSoft Barcode .NET SDK 提供已识别条形码搜索模式中心的精确坐标:AztecInfo.BulleyeCenter

此功能也可用于 OMR 表单,以实现 OMR 表单的快速自动识别。有关使用阿兹特克符文条形码进行自动图像对齐的更多信息,请参阅文章在.NET/C#中使用二维条形码对齐图像


阿兹特克条形码矩阵的结构。

阿兹特克条形码矩阵有两个版本--全尺寸和紧凑型。紧凑型版本最多可包含 4 个数据层(全尺寸版本最多可包含 32 个数据层),其特点是搜索模式简化且缺少时序模式:
     


什么是"GS1 Aztec"条形码?

"GS1 Aztec"条形码是一种以 GS1 系统数据格式存储值的阿兹特克条形码。VintaSoft Barcode .NET SDK 可以生成和识别"GS1 Aztec"条形码。
以下是"GS1 Aztec"条形码的图像:


什么是"XFA Compressed Aztec"条形码?

"XFA Compressed Aztec"条形码是一种根据 Adobe XFA 规范压缩存储数据的阿兹特克条形码。 VintaSoft Barcode .NET SDK 可以生成和识别"XFA Compressed Aztec"条形码。
以下是"XFA Compressed Aztec"条形码的图片:


什么是"HIBC LIC Aztec"条形码?

"HIBC LIC Aztec"条形码是 Aztec 条形码的一个子集,用于医疗保健产品的标签识别。VintaSoft Barcode .NET SDK 可以生成和识别"HIBC LIC Aztec"条形码。
以下是"HIBC LIC Aztec"条形码的图像:


由于特殊的"结构附加"符号,阿兹特克码条形码可以不仅仅是一个正方形

阿兹特克码条形码支持特殊的"结构附加"符号,该符号允许将数据分割成多个阿兹特克码条形码。"结构附加"符号编码在条形码中,用于唯一确定条形码部分的数量及其顺序。

由于阿兹特克条形码没有自由区,因此可以创建矩形阿兹特克条形码来标记细长区域:


VintaSoft Barcode .NET SDK 包含一个算法,用于从一组使用"结构附加"符号分离的 Aztec Code 条形码部分中恢复数据。


VintaSoft 条形码可以创建哪些阿兹特克条形码。VintaSoft Barcode .NET SDK 可以识别哪些条形码?

VintaSoft Barcode .NET SDK 可识别所有类型的阿兹特克条码和阿兹特克符文条码。它采用独特的识别算法,能够快速识别存在各种问题的条码:



以下 C# 代码演示了如何识别相机拍摄图像中的阿兹特克条形码:
/// <summary>
/// Reads Aztec Code barcodes from a <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="bitmap">A bitmap with barcodes.</param>
public static void ReadAztecCodeBarcodesFromBitmap(System.Drawing.Bitmap bitmap)
{
    // create barcode reader
    using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
    {
        // specify that reader must search for Aztec barcodes
        reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.Aztec;

        // read barcodes from image
        Vintasoft.Barcode.IBarcodeInfo[] infos = Vintasoft.Barcode.GdiExtensions.ReadBarcodes(reader, bitmap);

        // if barcodes are not detected
        if (infos.Length == 0)
        {
            System.Console.WriteLine("No barcodes found.");
        }
        // if barcodes are detected
        else
        {
            // get information about extracted barcodes

            System.Console.WriteLine(string.Format("{0} barcodes found:", infos.Length));
            System.Console.WriteLine();
            for (int i = 0; i < infos.Length; i++)
            {
                Vintasoft.Barcode.IBarcodeInfo info = infos[i];
                System.Console.WriteLine(string.Format("[{0}:{1}]", i + 1, info.BarcodeType));
                System.Console.WriteLine(string.Format("Value:      {0}", info.Value));
                System.Console.WriteLine(string.Format("Region:     {0}", info.Region));
                System.Console.WriteLine();
            }
        }
    }
}


VintaSoft Barcode .NET SDK 可以生成哪些阿兹特克条形码?

VintaSoft Barcode .NET SDK 可生成所有类型的阿兹特克代码和阿兹特克符文条形码。

以下 C# 代码演示了如何生成阿兹特克代码条形码的栅格图像:
/// <summary>
/// Returns the Aztec Code barcode as <see cref="System.Drawing.Bitmap"/>.
/// </summary>
/// <param name="value">The barcode value.</param>
/// <returns>A <see cref="System.Drawing.Bitmap"/> object.</returns>
public static System.Drawing.Bitmap GetAztecCodeBarcodeAsBitmap(string value)
{
    // create the barcode writer
    using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
    {
        // set barcode writer settings
        barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.Aztec;
        barcodeWriter.Settings.Value = value;

        // get a barcode image as System.Drawing.Bitmap
        return Vintasoft.Barcode.GdiExtensions.GetBarcodeAsBitmap(barcodeWriter);
    }
}


以下 C# 代码演示了如何生成阿兹特克代码条形码的矢量 (SVG) 图像:
/// <summary>
/// Returns the Aztec Code barcode in vector form as a SVG string.
/// </summary>
/// <param name="barcodeValue">Barcode value.</param>
public static void GetAztecCodeBarcodeAsSvgString(string barcodeValue)
{
    // create the barcode writer
    using (Vintasoft.Barcode.BarcodeWriter barcodeWriter = new Vintasoft.Barcode.BarcodeWriter())
    {
        // set barcode writer settings
        barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.Aztec;
        barcodeWriter.Settings.Value = barcodeValue;

        // generate Aztec Code barcode as a SVG string
        return barcodeWriter.GetBarcodeAsSvgFile();
    }
}