如何使用Zxing条码扫描库解码EAN128条码 [英] How to decode EAN128 barcode with zxing barcode scanning library

查看:280
本文介绍了如何使用Zxing条码扫描库解码EAN128条码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用zxing条码扫描库读取EAN128条码.而且我正在Xamarin共享项目中使用它……

I am trying to read an EAN128 barcode using zxing barcode scanning library. And I am using it in the Xamarin shared project like this…

private async void OnButtonForBarcodeReadPressed(object sender, EventArgs e)
{
    ZXingScannerPage scannerPage = new ZXingScannerPage();
    scannerPage.OnScanResult += (result) =>
    {
        scannerPage.IsScanning = false;
        var rawBytes = result.RawBytes;
        var barcodeType = result.BarcodeFormat.ToString();
        var barcodeText = result.Text;
    };
}

问题是结果 Text 属性不包含特殊字符.

The problem is that the Text property of the result does not contain the special character.

我注意到 result 的属性 RawBytes (这是一个字节数组)对于每个特殊字符在正确的位置都有一个字节102,但是我似乎看不到了解其余字节是如何计算的.

I noticed that the property RawBytes of the result (which is a byte array) has a byte 102 in correct place for every special character but I can't seem to understand how the rest of the bytes have been calculated.

这里是一个例子.我生成了EAN128条码(21)500600(11)201201 .我是使用在线条形码生成器完成的,因此我确定在正确的位置有一个特殊字符!当我用zxing扫描它时,结果结果 Text 属性为"2150060011201201",长度恰好为16个字符,因此不包含特殊字符.而这是 RawBytes 中字节数组的图像 >属性.如您所见,每个应用程序标识符之前都有一个字节102.但是其余的似乎有点不足.而且,当您在条形码中添加字母时,会更加令人困惑.

Here is an example. I generate this EAN128 barcode (21)500600(11)201201. I did it with an online barcode generator so I am sure that there is a special character in the right place! When I scan it with zxing the Text property of the result is "2150060011201201" and the length is exactly 16 chars so there is no special character included. And this is an image of the byte array in the RawBytes property. As you can see before every application identifier there is a byte 102. But the rest seem a bit of. And when you add a letter in the barcode then it is more confusing.

是否可以通过属性 RawBytes 获取带有特殊字符的正确条形码文本,还是可以配置zxing以便 Text 属性包含特殊字符的方式? ?

Is there a way to get the correct barcode text with the special character from the property RawBytes or a way to configure the zxing so the Text property contains the special character?

推荐答案

您需要设置ScanningOptions的 BarcodeFormat .

You need to set the BarcodeFormat of the ScanningOptions .

var options = new ZXing.Mobile.MobileBarcodeScanningOptions
{
    PossibleFormats = new List<ZXing.BarcodeFormat>() {
          ZXing.BarcodeFormat.CODE_128
    },

    ryHarder = true,
    AssumeGS1 = true,
    AutoRotate = true,

};

这篇关于如何使用Zxing条码扫描库解码EAN128条码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆