在 iPhone 和 Android 上生成 2D 条形码(例如 QR 码、Data Matrix、PDF417)

发布于 2024-10-05 18:57:09 字数 222 浏览 1 评论 0原文

我需要一个库来在 iPhone 和 Android(最好是 WM7,也可能是 j2me)上生成 2D 条形码 - 这个想法是将信息传输到具有相应扫描仪(解码器)的另一台设备。有哪些好的选择?

ZXing 是一个选项,特别是对于读取/解码方面,但我想要在这些设备上生成它们。

I need a library to generate a 2D bar code on iPhone and Android (and preferably WM7 and possibly j2me too) - the idea is to transfer information to another device with a corresponding scanner (decoder). What are the good options?

ZXing is an option, in particular for the reading/decoding aspect, but I want to generate them on these devices.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

暮凉 2024-10-12 18:57:09

最佳选择应该是 ZXing 的 库。我不确定 Windows Phone 7 是否支持。

Best option should be ZXing's library. I'm not sure about the Windows Phone 7 support tho.

不交电费瞎发啥光 2024-10-12 18:57:09

我尝试了上述所有解决方案但没有成功,但后来发现了这个库:
akopanev-iOS-QR-Code-Encoder

开源,实现简单,有示例 xcode 项目,伟大的

作者 - Andrew Kopanev

I tried all solutions described above with no success, but then found this library:
akopanev-iOS-QR-Code-Encoder

Open-source, simple to implement, has sample xcode project, works great

author - Andrew Kopanev

盛装女皇 2024-10-12 18:57:09

zxing 适用于 Android。 Java 编码器尚未移植到 C++(请随意参与并做出贡献......应该不会那么难。)在此之前,我一直在使用 psytec 编码器(http://groups.google.com/group/zxing/msg/27e421daeb510d0f)。评论是日文的,不过很简单。

我对 WM7 没有什么要补充的。那是C#吗? zxing 有一个 C# 端口,但我不知道有人积极维护它,也不知道它是否包含编码器。

zxing will work for Android. The Java encoder hasn't been ported to C++ (feel free to jump in and contribute ... shouldn't be that hard.) Until that happens, I've been using the psytec encoder (http://groups.google.com/group/zxing/msg/27e421daeb510d0f). The comments are in Japanese, but it's pretty straightforward.

I don't have anything to add on WM7. Is that C#? There is a C# port of zxing but I don't know of anyone actively maintaining it and don't know if it includes an encoder.

哀由 2024-10-12 18:57:09

我一直在使用ZXING成功编码QR条形码。然而,至少在当前版本中,它似乎对其他符号编码(例如:PDF-417)的支持有限。

我使用以下代码片段:

    // Encode the bitmap and display it on the screen
    try {
        // This will produce a 150x150 QR Barcode and display it on the screen.
        Bitmap bm = encodeAsBitmap(barcodeContentString, BarcodeFormat.QR_CODE, 150, 150);

        if(bm != null) {
            barcodeImage.setImageBitmap(bm);
        }
}
    catch (WriterException e) { ... }

在此示例中,“barcodeContentString”是正在编码的数据。 “barcodeImage”是一个标准的ImageView。

我没有在这里显示它,但我在显示条形码的整个时间段内都打开屏幕。因此,我能够使用兼容 QR 的条码扫描仪成功扫描条码。

I have been using ZXING to encode QR barcodes successfully. However, at least with the current version, it appears to have limited support for encoding other symbologies (ex: PDF-417).

I use the following code snippet:

    // Encode the bitmap and display it on the screen
    try {
        // This will produce a 150x150 QR Barcode and display it on the screen.
        Bitmap bm = encodeAsBitmap(barcodeContentString, BarcodeFormat.QR_CODE, 150, 150);

        if(bm != null) {
            barcodeImage.setImageBitmap(bm);
        }
}
    catch (WriterException e) { ... }

In this example, the "barcodeContentString" is the data that is being encoded. The "barcodeImage" is a standard ImageView.

I don't show it here, but I turn the screen on for the entire length of time that the barcode is displayed. As such, I am able to successfully scan the barcode with a QR compatible barcode scanner.

凡间太子 2024-10-12 18:57:09

如果您要在线传输到另一台设备,那么您可能需要使用第 3 方二维码 API 来获取图像。调用 REST API 是跨平台移动应用程序的最佳选择。

此 API 对 URI 执行此操作: http://www.tag.cx/qr-codes/

您还可以托管自己的私有二维码生成器 API。

If you are going to transfer to another device online, then you might want to use a 3rd party QR code API to get the image. Making a call to an REST API is the best option of cross-platform mobile apps.

This API does it for URI's: http://www.tag.cx/qr-codes/

You could also host your own private QR code generator API.

南渊 2024-10-12 18:57:09

这是另一个 Java 版本:
http://qrcode.sourceforge.jp/

摘要--“该项目开发和分发 QR 码解码/编码GPL v2 下的库。该项目的目标是利用 QR 码嵌入全世界的可编程设备。QR 码是工业标准、JIS-X-0510 和 ISO/IEC18004。”

Here is another Java version:
http://qrcode.sourceforge.jp/

Summary--"This project develops and distributes QR Code decode/encode library under GPL v2. The project goal is Utilize QR Code embedded information for programmable devices all over the world. QR Code is the industrial standard, JIS-X-0510 and ISO/IEC18004."

轻许诺言 2024-10-12 18:57:09

另请查看(我无法发布这些内容,因为 stackoverflow 阻止了多个 url):
以及 .net 版本(如上面网站所列):
http://www.codeproject.com/KB/cs/qrcode.aspx

Also check out (I couldn't post these because stackoverflow prevented more than one url):
And a .net version (as listed on the site above):
http://www.codeproject.com/KB/cs/qrcode.aspx

温柔一刀 2024-10-12 18:57:09

另请查看(我无法发布这些内容,因为 stackoverflow 阻止了多个 url):
python 版本(如上面网站所列):
http://pyqrcode.sourceforge.net/

Also check out (I couldn't post these because stackoverflow prevented more than one url):
A python version (as listed on the site above):
http://pyqrcode.sourceforge.net/

别念他 2024-10-12 18:57:09

我可能来不及以任何方式帮助你,但我已经找到了一个很好的数据矩阵代码 SDK。更多说明位于其网站此处,但在此处提供代码为好吧,你会做这样的事情:

OBLinear *pLinear = [OBLinear new];
[pLinear setNBarcodeType: OB_CODE128A];
[pLinear setPDataMsg: [[NSString alloc] initWithString:@"AB"]];
//[pLinear setPSupData: [[NSString alloc] initWithString:@"14562"]];
[pLinear setFX: USER_DEF_BAR_WIDTH];
[pLinear setFY: USER_DEF_BAR_HEIGHT];

[pLinear setFLeftMargin:USER_DEF_LEFT_MARGIN];
[pLinear setFRightMargin:USER_DEF_RIGHT_MARGIN];
[pLinear setFTopMargin:USER_DEF_TOP_MARGIN];
[pLinear setFBottomMargin:USER_DEF_BOTTOM_MARGIN];

[pLinear setNRotate:OB_Rotate0];

UIFont *pTextFont = [UIFont fontWithName: @"Arial" size: 8.0f];
[pLinear setPTextFont: pTextFont];

[pLinear drawWithView:self.view];

I might be too late to help you in any way, but I have found a good SDK for Data Matrix codes. More instructions are on their website HERE, but to provide the code here as well, you'd do something like this:

OBLinear *pLinear = [OBLinear new];
[pLinear setNBarcodeType: OB_CODE128A];
[pLinear setPDataMsg: [[NSString alloc] initWithString:@"AB"]];
//[pLinear setPSupData: [[NSString alloc] initWithString:@"14562"]];
[pLinear setFX: USER_DEF_BAR_WIDTH];
[pLinear setFY: USER_DEF_BAR_HEIGHT];

[pLinear setFLeftMargin:USER_DEF_LEFT_MARGIN];
[pLinear setFRightMargin:USER_DEF_RIGHT_MARGIN];
[pLinear setFTopMargin:USER_DEF_TOP_MARGIN];
[pLinear setFBottomMargin:USER_DEF_BOTTOM_MARGIN];

[pLinear setNRotate:OB_Rotate0];

UIFont *pTextFont = [UIFont fontWithName: @"Arial" size: 8.0f];
[pLinear setPTextFont: pTextFont];

[pLinear drawWithView:self.view];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文