Skip to content

Commit

Permalink
Merge pull request #426 from TheLevelUp/zxing-ports
Browse files Browse the repository at this point in the history
Continued with zxing-ports
  • Loading branch information
benjohnde authored Sep 25, 2018
2 parents 9a5c425 + 26ba0b7 commit 896a5cf
Show file tree
Hide file tree
Showing 40 changed files with 267 additions and 2,294 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The following barcodes are currently supported for both encoding and decoding:
* Aztec ('beta' quality)
* PDF 417 ('beta' quality)

ZXingObjC currently has feature parity with ZXing version 3.3.2.
ZXingObjC currently has feature parity with ZXing version 3.3.3.

## Requirements

Expand Down
18 changes: 11 additions & 7 deletions ZXingObjC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,8 @@
4B42B8A521590C920010C328 /* ZXITFWriterTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B42B8A321590C920010C328 /* ZXITFWriterTestCase.m */; };
4B42B8A7215917A40010C328 /* ZXCode39ExtendedModeTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B42B8A6215917A40010C328 /* ZXCode39ExtendedModeTestCase.m */; };
4B42B8A8215917A40010C328 /* ZXCode39ExtendedModeTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B42B8A6215917A40010C328 /* ZXCode39ExtendedModeTestCase.m */; };
4B501858215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B501857215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m */; };
4B501859215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B501857215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m */; };
4B674F132157E84200F97DEE /* ZXMaxicodeBlackBox1TestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B674F0F2157E7FD00F97DEE /* ZXMaxicodeBlackBox1TestCase.m */; };
4B674F142157E84200F97DEE /* ZXMaxicodeBlackBox1TestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B674F0F2157E7FD00F97DEE /* ZXMaxicodeBlackBox1TestCase.m */; };
4B7ACDA52153D8AA001EB8A5 /* ZXCode93Writer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7ACDA42153D8AA001EB8A5 /* ZXCode93Writer.m */; };
Expand All @@ -1687,8 +1689,6 @@
4B7ACDAB2153D8B8001EB8A5 /* ZXCode93Writer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7ACDA92153D8B8001EB8A5 /* ZXCode93Writer.h */; };
4B7ACDAC2153D8B8001EB8A5 /* ZXCode93Writer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7ACDA92153D8B8001EB8A5 /* ZXCode93Writer.h */; };
4B7ACDAD2153D8B8001EB8A5 /* ZXCode93Writer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7ACDA92153D8B8001EB8A5 /* ZXCode93Writer.h */; };
4B942BB61BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B942BB51BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.m */; };
4B942BB71BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B942BB51BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.m */; };
4B9DB4472158C1D800A10495 /* ZXPDF417WriterTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9DB4462158C1D800A10495 /* ZXPDF417WriterTestCase.m */; };
4B9DB4482158C1D800A10495 /* ZXPDF417WriterTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9DB4462158C1D800A10495 /* ZXPDF417WriterTestCase.m */; };
4B9DB44B2158CCF400A10495 /* ZXMultiTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9DB44A2158CCF400A10495 /* ZXMultiTestCase.m */; };
Expand Down Expand Up @@ -2921,12 +2921,12 @@
4B42B8A321590C920010C328 /* ZXITFWriterTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXITFWriterTestCase.m; sourceTree = "<group>"; };
4B42B8A6215917A40010C328 /* ZXCode39ExtendedModeTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXCode39ExtendedModeTestCase.m; sourceTree = "<group>"; };
4B42B8A9215917AD0010C328 /* ZXCode39ExtendedModeTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXCode39ExtendedModeTestCase.h; sourceTree = "<group>"; };
4B501856215A2EA900ACD238 /* ZXPDF417DecoderTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXPDF417DecoderTestCase.h; sourceTree = "<group>"; };
4B501857215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXPDF417DecoderTestCase.m; sourceTree = "<group>"; };
4B674F0F2157E7FD00F97DEE /* ZXMaxicodeBlackBox1TestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXMaxicodeBlackBox1TestCase.m; sourceTree = "<group>"; };
4B674F112157E82A00F97DEE /* ZXMaxicodeBlackBox1TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXMaxicodeBlackBox1TestCase.h; sourceTree = "<group>"; };
4B7ACDA42153D8AA001EB8A5 /* ZXCode93Writer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXCode93Writer.m; sourceTree = "<group>"; };
4B7ACDA92153D8B8001EB8A5 /* ZXCode93Writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXCode93Writer.h; sourceTree = "<group>"; };
4B942BB41BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXEAN8BlackBox2TestCase.h; sourceTree = "<group>"; };
4B942BB51BD80E2000A2C08F /* ZXEAN8BlackBox2TestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXEAN8BlackBox2TestCase.m; sourceTree = "<group>"; };
4B9DB4462158C1D800A10495 /* ZXPDF417WriterTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXPDF417WriterTestCase.m; sourceTree = "<group>"; };
4B9DB4492158C1E300A10495 /* ZXPDF417WriterTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXPDF417WriterTestCase.h; sourceTree = "<group>"; };
4B9DB44A2158CCF400A10495 /* ZXMultiTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXMultiTestCase.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4162,6 +4162,8 @@
isa = PBXGroup;
children = (
254040A7166AA0F100E13304 /* ec */,
4B501856215A2EA900ACD238 /* ZXPDF417DecoderTestCase.h */,
4B501857215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m */,
);
path = decoder;
sourceTree = "<group>";
Expand Down Expand Up @@ -5817,6 +5819,7 @@
25404118166AA0F100E13304 /* ZXBitArrayBuilderTest.m in Sources */,
25404119166AA0F100E13304 /* ZXRSSExpandedInformationDecoderTest.m in Sources */,
25404126166AA0F100E13304 /* ZXCodaBarWriterTestCase.m in Sources */,
4B501858215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m in Sources */,
255E986C18DF258C000A2681 /* ZXCode128WriterTestCase.m in Sources */,
25404128166AA0F100E13304 /* ZXEAN13WriterTestCase.m in Sources */,
25404129166AA0F100E13304 /* ZXEAN8WriterTestCase.m in Sources */,
Expand Down Expand Up @@ -6187,6 +6190,7 @@
2540435A166AB8B800E13304 /* ZXBinaryUtil.m in Sources */,
2540435B166AB8B800E13304 /* ZXBinaryUtilTest.m in Sources */,
2540435C166AB8B800E13304 /* ZXBitArrayBuilderTest.m in Sources */,
4B501859215A2EB800ACD238 /* ZXPDF417DecoderTestCase.m in Sources */,
255E986D18DF258C000A2681 /* ZXCode128WriterTestCase.m in Sources */,
2540435D166AB8B800E13304 /* ZXRSSExpandedInformationDecoderTest.m in Sources */,
2540436A166AB8B800E13304 /* ZXCodaBarWriterTestCase.m in Sources */,
Expand Down Expand Up @@ -6723,7 +6727,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = 3.1.0;
FRAMEWORK_VERSION = 3.3.4;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down Expand Up @@ -6855,7 +6859,7 @@
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_VERSION = 3.1.0;
FRAMEWORK_VERSION = 3.3.4;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -6906,7 +6910,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = 3.1.0;
FRAMEWORK_VERSION = 3.3.4;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down
43 changes: 27 additions & 16 deletions ZXingObjC/datamatrix/ZXDataMatrixWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ - (ZXBitMatrix *)encode:(NSString *)contents format:(ZXBarcodeFormat)format widt
}

if (width < 0 || height < 0) {
[NSException raise:NSInvalidArgumentException
format:@"Requested dimensions are too small: %dx%d", width, height];
[NSException raise:NSInvalidArgumentException format:@"Requested dimensions cannot be negative: %dx%d", width, height];
}

// Try to get force shape & min / max size
Expand Down Expand Up @@ -141,24 +140,36 @@ - (ZXBitMatrix *)encodeLowLevel:(ZXDataMatrixDefaultPlacement *)placement symbol
/**
* Convert the ZXByteMatrix to ZXBitMatrix.
*
* @param reqHeight The requested height of the image (in pixels) with the Datamatrix code
* @param reqWidth The requested width of the image (in pixels) with the Datamatrix code
* @param input The input matrix.
* @return The output matrix.
*/
- (ZXBitMatrix *)convertByteMatrixToBitMatrix:(ZXByteMatrix *)input width:(int)width height:(int)height {
int inputWidth = input.width;
int inputHeight = input.height;
int outputWidth = MAX(width, inputWidth);
int outputHeight = MAX(height, inputHeight);

int multiple = MIN(outputWidth / inputWidth, outputHeight / inputHeight);
int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

ZXBitMatrix *output = [[ZXBitMatrix alloc] initWithWidth:outputWidth height:outputHeight];
- (ZXBitMatrix *)convertByteMatrixToBitMatrix:(ZXByteMatrix *)matrix width:(int)width height:(int)height {
int matrixWidth = matrix.width;
int matrixHeight = matrix.height;
int outputWidth = MAX(width, matrixWidth);
int outputHeight = MAX(height, matrixHeight);

int multiple = MIN(outputWidth / matrixWidth, outputHeight / matrixHeight);

int leftPadding = (outputWidth - (matrixWidth * multiple)) / 2;
int topPadding = (outputHeight - (matrixHeight * multiple)) / 2;

ZXBitMatrix *output;

// remove padding if requested width and height are too small
if (height < matrixHeight || width < matrixWidth) {
leftPadding = 0;
topPadding = 0;
output = [[ZXBitMatrix alloc] initWithWidth:matrixWidth height:matrixHeight];
} else {
output = [[ZXBitMatrix alloc] initWithWidth:width height:height];
}

for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
if ([input getX:inputX y:inputY] == 1) {
for (int inputY = 0, outputY = topPadding; inputY < matrixHeight; inputY++, outputY += multiple) {
for (int inputX = 0, outputX = leftPadding; inputX < matrixWidth; inputX++, outputX += multiple) {
if ([matrix getX:inputX y:inputY] == 1) {
[output setRegionAtLeft:outputX top:outputY width:multiple height:multiple];
}
}
Expand Down
5 changes: 5 additions & 0 deletions ZXingObjC/datamatrix/encoder/ZXDataMatrixEdifactEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ - (void)handleEOD:(ZXDataMatrixEncoderContext *)context buffer:(NSMutableString
[context updateSymbolInfo];
int available = context.symbolInfo.dataCapacity - context.codewordCount;
int remaining = [context remainingCharacters];
// The following two lines are a hack inspired by the 'fix' from https://sourceforge.net/p/barcode4j/svn/221/
if (remaining > available) {
[context updateSymbolInfoWithLength:context.codewordCount + 1];
available = context.symbolInfo.dataCapacity - context.codewordCount;
}
if (remaining <= available && available <= 2) {
return; //No unlatch
}
Expand Down
10 changes: 6 additions & 4 deletions ZXingObjC/oned/ZXUPCAReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ - (int)decodeMiddle:(ZXBitArray *)row startRange:(NSRange)startRange result:(NSM
- (ZXResult *)maybeReturnResult:(ZXResult *)result {
NSString *text = result.text;
if ([text characterAtIndex:0] == '0') {
return [ZXResult resultWithText:[text substringFromIndex:1]
rawBytes:nil
resultPoints:result.resultPoints
format:kBarcodeFormatUPCA];
ZXResult *upcaResult = [ZXResult resultWithText:[text substringFromIndex:1]
rawBytes:nil
resultPoints:result.resultPoints
format:kBarcodeFormatUPCA];
[upcaResult putAllMetadata:[result resultMetadata]];
return upcaResult;
} else {
return nil;
}
Expand Down
9 changes: 8 additions & 1 deletion ZXingObjC/pdf417/ZXPDF417ResultMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@

@property (nonatomic, assign) int segmentIndex;
@property (nonatomic, copy) NSString *fileId;
@property (nonatomic, strong) NSArray *optionalData;
@property (nonatomic, assign) BOOL lastSegment;
@property (nonatomic, assign) int segmentCount;
@property (nonatomic, copy) NSString *sender;
@property (nonatomic, copy) NSString *addressee;
@property (nonatomic, copy) NSString *fileName;
@property (nonatomic, assign) long fileSize;
@property (nonatomic, assign) long timestamp;
@property (nonatomic, assign) int checksum;
@property (nonatomic, strong) NSArray *optionalData;

@end
10 changes: 10 additions & 0 deletions ZXingObjC/pdf417/ZXPDF417ResultMetadata.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@

@implementation ZXPDF417ResultMetadata

- (id)init {
if (self = [super init]) {
_segmentCount = -1;
_fileSize = -1;
_timestamp = -1;
_checksum = -1;
}
return self;
}

@end
3 changes: 3 additions & 0 deletions ZXingObjC/pdf417/decoder/ZXPDF417DecodedBitStreamParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#import "ZXPDF417ResultMetadata.h"

@class ZXDecoderResult, ZXIntArray;

/**
Expand All @@ -22,5 +24,6 @@
@interface ZXPDF417DecodedBitStreamParser : NSObject

+ (ZXDecoderResult *)decode:(ZXIntArray *)codewords ecLevel:(NSString *)ecLevel error:(NSError **)error;
+ (int)decodeMacroBlock:(ZXIntArray *)codewords codeIndex:(int)codeIndex resultMetadata:(ZXPDF417ResultMetadata *)resultMetadata;

@end
113 changes: 89 additions & 24 deletions ZXingObjC/pdf417/decoder/ZXPDF417DecodedBitStreamParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
* limitations under the License.
*/

#import "ZXPDF417DecodedBitStreamParser.h"
#import "ZXCharacterSetECI.h"
#import "ZXDecoderResult.h"
#import "ZXErrors.h"
#import "ZXIntArray.h"
#import "ZXPDF417DecodedBitStreamParser.h"
#import "ZXPDF417ResultMetadata.h"

typedef enum {
ZXPDF417ModeAlpha = 0,
Expand All @@ -43,6 +42,14 @@
const int ZX_PDF417_MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913;
const int ZX_PDF417_MAX_NUMERIC_CODEWORDS = 15;

const int ZX_MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5;
const int ZX_MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6;

const int ZX_PDF417_PL = 25;
const int ZX_PDF417_LL = 27;
const int ZX_PDF417_AS = 27;
Expand Down Expand Up @@ -113,8 +120,7 @@ + (ZXDecoderResult *)decode:(ZXIntArray *)codewords ecLevel:(NSString *)ecLevel
}
break;
case ZX_PDF417_ECI_CHARSET: {
ZXCharacterSetECI *charsetECI =
[ZXCharacterSetECI characterSetECIByValue:codewords.array[codeIndex++]];
ZXCharacterSetECI *charsetECI = [ZXCharacterSetECI characterSetECIByValue:codewords.array[codeIndex++]];
encoding = charsetECI.encoding;
break;
}
Expand All @@ -124,7 +130,7 @@ + (ZXDecoderResult *)decode:(ZXIntArray *)codewords ecLevel:(NSString *)ecLevel
break;
case ZX_PDF417_ECI_USER_DEFINED:
// Can't do anything with user ECI; skip its 1 character
codeIndex ++;
codeIndex++;
break;
case ZX_PDF417_BEGIN_MACRO_PDF417_CONTROL_BLOCK:
codeIndex = [self decodeMacroBlock:codewords codeIndex:codeIndex resultMetadata:resultMetadata];
Expand Down Expand Up @@ -177,32 +183,91 @@ + (int)decodeMacroBlock:(ZXIntArray *)codewords codeIndex:(int)codeIndex resultM
codeIndex = [self textCompaction:codewords codeIndex:codeIndex result:fileId];
resultMetadata.fileId = [NSString stringWithString:fileId];

int optionalFieldsStart = -1;
if (codewords.array[codeIndex] == ZX_PDF417_BEGIN_MACRO_PDF417_OPTIONAL_FIELD) {
codeIndex++;
NSMutableArray *additionalOptionCodeWords = [NSMutableArray array];
optionalFieldsStart = codeIndex + 1;
}

BOOL end = NO;
while ((codeIndex < codewords.array[0]) && !end) {
int code = codewords.array[codeIndex++];
if (code < ZX_PDF417_TEXT_COMPACTION_MODE_LATCH) {
[additionalOptionCodeWords addObject:@(code)];
} else {
switch (code) {
case ZX_PDF417_MACRO_PDF417_TERMINATOR:
resultMetadata.lastSegment = YES;
codeIndex++;
end = YES;
while (codeIndex < codewords.array[0]) {
switch (codewords.array[codeIndex]) {
case ZX_PDF417_BEGIN_MACRO_PDF417_OPTIONAL_FIELD:
codeIndex++;
switch (codewords.array[codeIndex]) {
case ZX_MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:
{
NSMutableString *fileName = [NSMutableString new];
codeIndex = [self textCompaction:codewords codeIndex:codeIndex + 1 result:fileName];
resultMetadata.fileName = fileName;
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_SENDER:
{
NSMutableString *sender = [NSMutableString new];
codeIndex = [self textCompaction:codewords codeIndex:codeIndex + 1 result:sender];
resultMetadata.sender = sender;
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:
{
NSMutableString *addressee = [NSMutableString new];
codeIndex = [self textCompaction:codewords codeIndex:codeIndex + 1 result:addressee];
resultMetadata.addressee = addressee;
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:
{
NSMutableString *segmentCount = [NSMutableString new];
codeIndex = [self numericCompaction:codewords codeIndex:codeIndex + 1 result:segmentCount];
resultMetadata.segmentCount = [segmentCount intValue];
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:
{
NSMutableString *timestamp = [NSMutableString new];
codeIndex = [self numericCompaction:codewords codeIndex:codeIndex + 1 result:timestamp];
resultMetadata.timestamp = [timestamp longLongValue];
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:
{
NSMutableString *checksum = [NSMutableString new];
codeIndex = [self numericCompaction:codewords codeIndex:codeIndex + 1 result:checksum];
resultMetadata.checksum = [checksum intValue];
break;
}
case ZX_MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:
{
NSMutableString *fileSize = [NSMutableString new];
codeIndex = [self numericCompaction:codewords codeIndex:codeIndex + 1 result:fileSize];
resultMetadata.fileSize = [fileSize longLongValue];
break;
}
default:
return -1;
[NSException raise:NSInvalidArgumentException format:@"MacroPDF417 invalid format"];
}
}
break;
case ZX_PDF417_MACRO_PDF417_TERMINATOR:
codeIndex++;
resultMetadata.lastSegment = YES;
break;
default:
[NSException raise:NSInvalidArgumentException format:@"MacroPDF417 invalid format"];
}

resultMetadata.optionalData = additionalOptionCodeWords;
} else if (codewords.array[codeIndex] == ZX_PDF417_MACRO_PDF417_TERMINATOR) {
resultMetadata.lastSegment = YES;
codeIndex++;
// copy optional fields to additional options
if (optionalFieldsStart != -1) {
int optionalFieldsLength = codeIndex - optionalFieldsStart;
if (resultMetadata.lastSegment) {
// do not include terminator
optionalFieldsLength--;
}
NSMutableArray *additionalOptionCodeWords = [NSMutableArray array];
for (int i = optionalFieldsStart; i < (optionalFieldsStart + optionalFieldsLength); i++) {
int code = codewords.array[i];
[additionalOptionCodeWords addObject:@(code)];
}
resultMetadata.optionalData = additionalOptionCodeWords;
}
}

return codeIndex;
Expand Down
Binary file added ZXingObjCTests/Resources/blackbox/pdf417-3/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 896a5cf

Please sign in to comment.