Skip to content

Commit

Permalink
Ported r2569 from ZXing
Browse files Browse the repository at this point in the history
Original commit message: "Issue 572 port of Data Matrix encoder from
barcode4j, adapted for Android, ported by Guillaume Le Biller and
stoty47 and adapted a bit more by me"
  • Loading branch information
cwalcott committed Mar 18, 2013
1 parent d4be48a commit f481291
Show file tree
Hide file tree
Showing 49 changed files with 3,827 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ evansepdx
Erik Barbara
Fred Lin (Anobiit)
gcstang
Guillaume Le Biller
Hannes Erven
hosigumayuugi
hypest (Barcorama project)
Expand Down Expand Up @@ -90,6 +91,7 @@ Shiyuan Guo / 郭世元
ShumovichY
Simon Flannery (Ericsson)
Steven Parkes
stoty74
Suraj Supekar
Sven Klinkhamer
techinstantdx
Expand Down
302 changes: 302 additions & 0 deletions ZXingObjC.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions ZXingObjC/ZXDimension.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Simply encapsulates a width and height.
*/

@interface ZXDimension : NSObject

@property (nonatomic, assign, readonly) int height;
@property (nonatomic, assign, readonly) int width;

- (id)initWithWidth:(int)width height:(int)height;

@end
61 changes: 61 additions & 0 deletions ZXingObjC/ZXDimension.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "ZXDimension.h"

@interface ZXDimension ()

@property (nonatomic, assign) int height;
@property (nonatomic, assign) int width;

@end

@implementation ZXDimension

@synthesize width = _width;
@synthesize height = _height;

- (id)initWithWidth:(int)width height:(int)height {
if (width < 0 || height < 0) {
[NSException raise:NSInvalidArgumentException
format:@"Width and height must not be negative"];
}

if (self = [super init]) {
_width = width;
_height = height;
}

return self;
}

- (BOOL)isEqual:(id)other {
if ([other isKindOfClass:[ZXDimension class]]) {
ZXDimension *d = (ZXDimension *)other;
return self.width == d.width && self.height == d.height;
}
return NO;
}

- (NSUInteger)hash {
return self.width * 32713 + self.height;
}

- (NSString *)description {
return [NSString stringWithFormat:@"%dx%d", self.width, self.height];
}

@end
18 changes: 18 additions & 0 deletions ZXingObjC/ZXEncodeHints.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
#import "ZXCompaction.h"
#import "ZXDimensions.h"
#import "ZXErrorCorrectionLevel.h"
#import "ZXSymbolShapeHint.h"

/**
* These are a set of hints that you may pass to Writers to specify their behavior.
*/

@class ZXDimension, ZXSymbolShapeHint;

@interface ZXEncodeHints : NSObject

+ (id)hints;
Expand All @@ -31,6 +34,21 @@
*/
@property (nonatomic, assign) NSStringEncoding encoding;

/**
* Specifies the matrix shape for Data Matrix .
*/
@property (nonatomic, retain) ZXSymbolShapeHint *dataMatrixShape;

/**
* Specifies a minimum barcode size. Only applicable to Data Matrix now.
*/
@property (nonatomic, retain) ZXDimension *minSize;

/**
* Specifies a maximum barcode size. Only applicable to Data Matrix now.
*/
@property (nonatomic, retain) ZXDimension *maxSize;

/**
* Specifies what degree of error correction to use, for example in QR Codes.
*/
Expand Down
6 changes: 6 additions & 0 deletions ZXingObjC/ZXEncodeHints.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
@implementation ZXEncodeHints

@synthesize encoding;
@synthesize dataMatrixShape;
@synthesize minSize;
@synthesize maxSize;
@synthesize errorCorrectionLevel;
@synthesize margin;
@synthesize pdf417Compact;
Expand All @@ -30,6 +33,9 @@ + (id)hints {
}

- (void)dealloc {
[dataMatrixShape release];
[minSize release];
[maxSize release];
[errorCorrectionLevel release];
[margin release];
[pdf417Dimensions release];
Expand Down
5 changes: 5 additions & 0 deletions ZXingObjC/ZXMultiFormatWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "ZXCodaBarWriter.h"
#import "ZXCode39Writer.h"
#import "ZXCode128Writer.h"
#import "ZXDataMatrixWriter.h"
#import "ZXEAN8Writer.h"
#import "ZXEAN13Writer.h"
#import "ZXITFWriter.h"
Expand Down Expand Up @@ -75,6 +76,10 @@ - (ZXBitMatrix *)encode:(NSString *)contents format:(ZXBarcodeFormat)format widt
writer = [[[ZXCodaBarWriter alloc] init] autorelease];
break;

case kBarcodeFormatDataMatrix:
writer = [[[ZXDataMatrixWriter alloc] init] autorelease];
break;

default:
[NSException raise:NSInvalidArgumentException
format:@"No encoder available for format"];
Expand Down
19 changes: 18 additions & 1 deletion ZXingObjC/ZXingObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,25 @@
// ZXingObjC/datamatrix/detector
#import "ZXDataMatrixDetector.h"

// ZXingObjC/datamatrix/encoder
#import "ZXASCIIEncoder.h"
#import "ZXBase256Encoder.h"
#import "ZXC40Encoder.h"
#import "ZXDataMatrixEncoder.h"
#import "ZXDataMatrixErrorCorrection.h"
#import "ZXDataMatrixSymbolInfo144.h"
#import "ZXDefaultPlacement.h"
#import "ZXEdifactEncoder.h"
#import "ZXEncoderContext.h"
#import "ZXHighLevelEncoder.h"
#import "ZXSymbolInfo.h"
#import "ZXSymbolShapeHint.h"
#import "ZXTextEncoder.h"
#import "ZXX12Encoder.h"

// ZXingObjC/datamatrix
#import "ZXDataMatrixReader.h"
#import "ZXDataMatrixWriter.h"

// ZXingObjC/maxicode/decoder
#import "ZXMaxiCodeBitMatrixParser.h"
Expand Down Expand Up @@ -255,6 +272,7 @@
#import "ZXBinarizer.h"
#import "ZXBinaryBitmap.h"
#import "ZXDecodeHints.h"
#import "ZXDimension.h"
#import "ZXEncodeHints.h"
#import "ZXErrors.h"
#import "ZXLuminanceSource.h"
Expand All @@ -268,4 +286,3 @@
#import "ZXResultPointCallback.h"
#import "ZXRGBLuminanceSource.h"
#import "ZXWriter.h"
#import "ZXingObjC.h"
25 changes: 25 additions & 0 deletions ZXingObjC/datamatrix/ZXDataMatrixWriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2013 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "ZXWriter.h"

/**
* This object renders a Data Matrix code as a BitMatrix 2D array of greyscale values.
*/

@interface ZXDataMatrixWriter : NSObject <ZXWriter>

@end
Loading

0 comments on commit f481291

Please sign in to comment.