gpt4 book ai didi

java - ZXing Result.getRawBytes(),到底是什么?

转载 作者:搜寻专家 更新时间:2023-11-01 07:35:54 26 4
gpt4 key购买 nike

我正在使用 zxing QR 码 API,我正在尝试从 Android 设备上的 QR 码中提取二进制数据。但是,在 Android 上,Result.getResultMetadata() 没有通过 Intent 传递给我,因此我尝试使用 Result.getRawBytes() 来检索我的字节数组。然而,getRawBytes() 似乎并没有返回同样的东西。

Result.getRawBytes() 究竟是什么?有谁知道如何正确地从 zxing QR 码中提取字节数组?

谢谢

最佳答案

所以我认为您想要的是字节数组中的原始解码数据。 zxing 为您提供的 Intent 源缺少元数据,但它仍在发送到 Intent 过滤器。

在 IntentIntegrator.java 的 parseActivityResult 中,可以添加:

byte[] dataBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTE_SEGMENTS_0");
return new IntentResult(contents,
formatName,
rawBytes,
orientation,
errorCorrectionLevel,
dataBytes);

我修改了 IntentResult 类以能够获取这个额外的部分:

private final byte[] dataBytes;

IntentResult() {
this(null, null, null, null, null, null);
}

IntentResult(String contents,
String formatName,
byte[] rawBytes,
Integer orientation,
String errorCorrectionLevel,
byte[] dataBytes) {
this.contents = contents;
this.formatName = formatName;
this.rawBytes = rawBytes;
this.orientation = orientation;
this.errorCorrectionLevel = errorCorrectionLevel;
this.dataBytes = dataBytes;
}


/**
* @return raw content of barcode in bytes
*/

public byte [] getDataBytes() {
return dataBytes;
}

此字节数组存储元数据的第一个数组,也就是以字节为单位的数据的原始内容。

关于java - ZXing Result.getRawBytes(),到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11368684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com