【发布时间】:2016-01-04 12:42:23
【问题描述】:
我正在开发一个 iOS 应用程序,该应用程序应该解码某种类型的 Aztec 条形码(example,PDF)。我需要扫描仪返回低级别的数据,因为它是 zlib 压缩的,之后我需要对其进行解压缩。使用AVCapture 的内置条形码扫描仪适用于常规字符串数据,但fails in my case。
我已经转向Zxing,或者更确切地说是它的Objective C 端口ZXingObjC,希望能够在解码的条形码数据变成字符串之前访问它。我成功了一半。返回的ZXResult 确实包含一个名为rawBytes 的ZXByteArray,但仅 用于二维码(对于阿兹特克代码,它是nil)!我查看了ZXAztecDecoder.m 内部,果然,字节数组从未填充,甚至在Java 中的原始Zxing 代码中也没有。
有人试图通过这样做来为原始库(Pull Request,第 80 行)修复它
byte[] rawBytes = convertBoolArrayToByteArray(correctedBits);
我想为ZXingObjC 添加相同的功能,但我无法将ZXBoolArray 转换为ZXByteArray。这是我设想的解码功能:
- (ZXDecoderResult *)decode:(ZXAztecDetectorResult *)detectorResult error:(NSError **)error {
self.ddata = detectorResult;
ZXBitMatrix *matrix = [detectorResult bits];
ZXBoolArray *rawbits = [self extractBits:matrix];
if (!rawbits) {
if (error) *error = ZXFormatErrorInstance();
return nil;
}
ZXBoolArray *correctedBits = [self correctBits:rawbits error:error];
if (!correctedBits) {
return nil;
}
ZXByteArray *rawBytes = /* somehow turn correctedBits into ZXByteArray */;
NSString *result = [[self class] encodedData:correctedBits];
return [[ZXDecoderResult alloc] initWithRawBytes:rawBytes text:result byteSegments:nil ecLevel:nil];
}
如果有人知道如何执行此操作或知道如何执行此操作,我将不胜感激。如果成功,我想将代码贡献给ZXingObjC,这样以后就不会打扰人们了。提前致谢!
【问题讨论】:
-
您找到解决方案了吗?
标签: java ios objective-c zxing