利用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 浏览器中打开它。

免费微型二维码生成器

  • 23
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值