您的位置:首页 > 文旅 > 旅游 > 利用Aspose.BarCode 在 C# 中创建微型二维码

利用Aspose.BarCode 在 C# 中创建微型二维码

2025/4/19 16:38:34 来源:https://blog.csdn.net/m0_67129275/article/details/141423372  浏览:    关键词:利用Aspose.BarCode 在 C# 中创建微型二维码

Aspose.BarCode提供多种编程语言的 API,例如Java、Python、C++等。它提供了强大的解决方案,可以通过编程创建和处理条形码和二维码,我们将实现如何使用Aspose.BarCode for .NET在 C# 中创建微型二维码。接下来,我们还将演示如何以编程方式创建/读取其他类型的二维码。

Aspose.BarCode for .NET 是一个功能强大的API,可以从任意角度生成和识别多种图像类型的一维和二维条形码。开发人员可以轻松添加条形码生成和识别功能,以及在.NET应用程序中将生成的条形码导出为高质量的图像格式。

Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

Aspose.BarCode 最新下载

QR Code SDK 集成

如果遇到任何意外情况, 请转到安装指南。不过,您可以在NuGet 包管理器中运行以下命令或下载 此 C# 库的DLL文件:

PM> Install-Package Aspose.BarCode
在 C# 中创建微型二维码 - 代码片段

您可以简单地按照以下步骤操作:

  • 创建BarcodeGenerator类的实例,并使用要编码的 QRcode 符号类型和文本对其进行初始化。
  • 以像素为单位设置二维码的大小。
  • 将二维码图像保存(默认自动)为 PNG 格式的特定文件。
  • 设置MicroQR M4版本并调用Save方法保存输出文件。

以下代码示例展示了如何使用C# 开发微型二维码生成器:

namespace CSharp.MicroQRVersionM4
{
class MicroQRVersionM4
{
static void Main(string[] args)
{
// Define the path to the documents directory.
string path = "/Desktop/";
System.Console.WriteLine("MicroQRVersion:");
// Create an instance of the BarcodeGenerator class and initialize it with the QRcode symbology type and text to be encoded.
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.MicroQR, "EARTH"))
{
// Set the size of QR code in Pixels.
gen.Parameters.Barcode.XDimension.Pixels = 4;
// Save(auto by default) the QR Code image to a specific file in PNG format.
gen.Save($"{path}MicroQRVersionAuto.png", BarCodeImageFormat.Png);
// Set MicroQR M4 version and invoke the Save method to save the output file.
gen.Parameters.Barcode.QR.MicroQRVersion = MicroQRVersion.M4;
gen.Save($"{path}MicroQRVersionM4.png", BarCodeImageFormat.Png);
}
}
}
}

输出:

微型二维码生成器

同样,您可以使用以下代码片段生成矩形微型二维码:

namespace CSharp.RectMicroQRVersionR11x77
{
class RectMicroQRVersionR11x77
{
static void Main(string[] args)
{
// Define the path to the documents directory.
string path = "/Desktop/";
System.Console.WriteLine("MicroQRVersion:");using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.RectMicroQR, "EARTH"))
{
gen.Parameters.Barcode.XDimension.Pixels = 4;//auto (by default)
gen.Save($"{path}RectMicroQRVersionAuto.png", BarCodeImageFormat.Png);//set RectMicroQR R11x77 version
gen.Parameters.Barcode.QR.RectMicroQrVersion = Aspose.BarCode.Generation.RectMicroQRVersion.R11x77;
gen.Save($"{path}RectMicroQRVersionR11x77.png", BarCodeImageFormat.Png);
}
}
}
}

您可以在下图中看到生成的矩形微型二维码:

矩形微型二维码

免费微型二维码生成器 - 在线工具

有一个由Aspose.BarCode提供支持的在线微型二维码扫描器和生成器。此外,它是免费的,您可以在几乎所有常用的 Web 浏览器中打开它。

免费微型二维码生成器

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com