Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
update ZXingObjC
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikunj committed May 1, 2019
1 parent 34a9f94 commit 395c875
Show file tree
Hide file tree
Showing 230 changed files with 6,014 additions and 1,392 deletions.
33 changes: 18 additions & 15 deletions Checkouts/ZXingObjC/README.md
Expand Up @@ -7,25 +7,22 @@ The following barcodes are currently supported for both encoding and decoding:
* UPC-A and UPC-E
* EAN-8 and EAN-13
* Code 39
* Code 93 (not implemented yet)
* Code 93
* Code 128
* ITF
* Codabar
* RSS-14 (all variants)
* QR Code
* Data Matrix
* Maxicode
* Aztec ('beta' quality)
* PDF 417 ('alpha' quality)
* PDF 417 ('beta' quality)

ZXingObjC currently has feature parity with ZXing version 3.0.

## Roadmap

Sorry, this project had some sort of winter sleep for a long time. There were also some ideas to rewrite this project in Swift. Instead of rewriting the project in Swift as a whole, we planned to keep up feature parity with zxing-core at first, then rewrite the capture module as well as the examples in Swift. From this new starting point, we are going to replace classes step-by-step with new Swift implementations. We do not want to create a new barcode scanner but to keep the code as similar as possible to zxing-core.
ZXingObjC currently has feature parity with ZXing version 3.3.3.

## Requirements

ZXingObjC requires Xcode 8.3.3, targeting either iOS 8.0 and above, or Mac OS X 10.8 Mountain Lion and above.
ZXingObjC requires Xcode 8.3.3 and above, targeting either iOS 8.0 and above, or Mac OS X 10.8 Mountain Lion and above.

## Usage

Expand All @@ -40,9 +37,11 @@ ZXBitMatrix* result = [writer encode:@"A string to encode"
height:500
error:&error];
if (result) {
CGImageRef image = [[ZXImage imageWithMatrix:result] cgimage];
CGImageRef image = CGImageRetain([[ZXImage imageWithMatrix:result] cgimage]);

// This CGImageRef image can be placed in a UIImage, NSImage, or written to a file.

CGImageRelease(image);
} else {
NSString *errorMessage = [error localizedDescription];
}
Expand Down Expand Up @@ -85,28 +84,32 @@ We highly recommend Carthage as module manager.

#### Carthage

Alternatively, ZXingObjC can be installed using [Carthage](https://github.com/Carthage/Carthage). After installing Carthage just add ZXingObjC to your Cartfile:
ZXingObjC can be installed using [Carthage](https://github.com/Carthage/Carthage). After installing Carthage just add ZXingObjC to your Cartfile:

```ogdl
github "TheLevelUp/ZXingObjC" ~> 3.2.1
github "TheLevelUp/ZXingObjC" ~> 3.6
```

#### CocoaPods

[CocoaPods](http://cocoapods.org) is a dependency manager for Swift and Objective-C Cocoa projects. After installing CocoaPods add ZXingObjC to your Podfile:

```ruby
platform :ios, '7.0'
pod 'ZXingObjC', '~> 3.2.1'
platform :ios, '8.0'
pod 'ZXingObjC', '~> 3.6.4'
```

## Examples

ZXingObjC includes several example applications found in "examples" folder:

* BarcodeScanner - An iOS application that captures video from the camera, scans for barcodes and displays results on screen.
* BarcodeScannerOSX - An OS X application that captures video from the camera, scans for barcodes and displays results on screen.
* QrCodeTest - A basic QR code generator that accepts input, encodes it as a QR code, and displays it on screen.
* BarcodeScannerSwift - An iOS application that captures video from the camera, scans for barcodes and displays results on screen, completely rewritten in Swift.

## Kudos

- [cwalcott](https://github.com/cwalcott) initial creator of this project
- [neacao](https://github.com/neacao) for his unparalleled support lately

## License

Expand Down
4 changes: 2 additions & 2 deletions Checkouts/ZXingObjC/ZXingObjC.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ZXingObjC'
s.version = '3.2.1'
s.version = '3.6.4'
s.summary = 'An Objective-C Port of the ZXing barcode framework.'
s.homepage = 'https://github.com/TheLevelUp/ZXingObjC'
s.author = 'ZXingObjC team'
Expand All @@ -23,7 +23,7 @@ Pod::Spec.new do |s|

s.subspec 'Core' do |ss|
ss.source_files = 'ZXingObjC/*.{h,m}', 'ZXingObjC/client/*.{h,m}', 'ZXingObjC/common/**/*.{h,m}', 'ZXingObjC/core/**/*.{h,m}', 'ZXingObjC/multi/**/*.{h,m}'
ss.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "ZXINGOBJC_USE_SUBSPECS" }
ss.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "ZXINGOBJC_USE_SUBSPECS" }
end

s.subspec 'Aztec' do |ss|
Expand Down
217 changes: 209 additions & 8 deletions Checkouts/ZXingObjC/ZXingObjC.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand All @@ -47,7 +46,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -70,7 +69,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
5 changes: 5 additions & 0 deletions Checkouts/ZXingObjC/ZXingObjC/ZXMultiFormatWriter.m
Expand Up @@ -24,6 +24,7 @@
#if defined(ZXINGOBJC_ONED) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXCodaBarWriter.h"
#import "ZXCode39Writer.h"
#import "ZXCode93Writer.h"
#import "ZXCode128Writer.h"
#import "ZXEAN8Writer.h"
#import "ZXEAN13Writer.h"
Expand Down Expand Up @@ -75,6 +76,10 @@ - (ZXBitMatrix *)encode:(NSString *)contents format:(ZXBarcodeFormat)format widt
writer = [[ZXCode39Writer alloc] init];
break;

case kBarcodeFormatCode93:
writer = [[ZXCode93Writer alloc] init];
break;

case kBarcodeFormatCode128:
writer = [[ZXCode128Writer alloc] init];
break;
Expand Down
2 changes: 1 addition & 1 deletion Checkouts/ZXingObjC/ZXingObjC/aztec/ZXAztecReader.m
Expand Up @@ -68,7 +68,7 @@ - (ZXResult *)decode:(ZXBinaryBitmap *)image hints:(ZXDecodeHints *)hints error:
}
}

ZXResult *result = [ZXResult resultWithText:decoderResult.text rawBytes:decoderResult.rawBytes resultPoints:points format:kBarcodeFormatAztec];
ZXResult *result = [ZXResult resultWithText:decoderResult.text rawBytes:decoderResult.rawBytes numBits:decoderResult.numBits resultPoints:points format:kBarcodeFormatAztec];

NSMutableArray *byteSegments = decoderResult.byteSegments;
if (byteSegments != nil) {
Expand Down
3 changes: 3 additions & 0 deletions Checkouts/ZXingObjC/ZXingObjC/aztec/decoder/ZXAztecDecoder.h
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#import "ZXByteArray.h"

@class ZXAztecDetectorResult, ZXBoolArray, ZXDecoderResult;

/**
Expand All @@ -26,5 +28,6 @@

// This method is used for testing the high-level encoder
+ (NSString *)highLevelDecode:(ZXBoolArray *)correctedBits;
+ (ZXByteArray *)convertBoolArrayToByteArray:(ZXBoolArray *) boolArr;

@end
41 changes: 24 additions & 17 deletions Checkouts/ZXingObjC/ZXingObjC/aztec/decoder/ZXAztecDecoder.m
Expand Up @@ -80,16 +80,19 @@ - (ZXDecoderResult *)decode:(ZXAztecDetectorResult *)detectorResult error:(NSErr
if (!correctedBits) {
return nil;
}
NSMutableArray *rawBytes = [ZXAztecDecoder convertBoolArrayToByteArray: correctedBits];
NSString *result = [[self class] encodedData:correctedBits];

NSUInteger rawBytesSize = [rawBytes count];
ZXByteArray *rawBytesReturned = [[ZXByteArray alloc] initWithLength:(unsigned int)rawBytesSize];
for (int i = 0; i < rawBytesSize; i++) {
rawBytesReturned.array[i] = (int8_t)[rawBytes[i] intValue];
}

return [[ZXDecoderResult alloc] initWithRawBytes:rawBytesReturned text:result byteSegments:nil ecLevel:nil];
ZXByteArray *rawBytes = [ZXAztecDecoder convertBoolArrayToByteArray:correctedBits];
NSString *result = [[self class] encodedData:correctedBits];

NSUInteger rawBytesSize = rawBytes.length;
ZXByteArray *rawBytesReturned = [[ZXByteArray alloc] initWithLength:(unsigned int)rawBytesSize];
for (int i = 0; i < rawBytesSize; i++) {
rawBytesReturned.array[i] = (int8_t)rawBytes.array[i];
}

ZXDecoderResult *decoderResult = [[ZXDecoderResult alloc] initWithRawBytes:rawBytesReturned text:result byteSegments:nil ecLevel:nil];
decoderResult.numBits = correctedBits.length;

return decoderResult;
}

+ (NSString *)highLevelDecode:(ZXBoolArray *)correctedBits {
Expand Down Expand Up @@ -144,6 +147,10 @@ + (NSString *)encodedData:(ZXBoolArray *)correctedBits {
NSString *str = [self character:shiftTable code:code];
if ([str hasPrefix:@"CTRL_"]) {
// Table changes
// ISO/IEC 24778:2008 prescibes ending a shift sequence in the mode from which it was invoked.
// That's including when that mode is a shift.
// Our test case dlusbs.png for issue #642 exercises that.
latchTable = shiftTable; // Latch the current mode, so as to return to Upper after U/S B/S
shiftTable = [self table:[str characterAtIndex:5]];
if ([str characterAtIndex:6] == 'L') {
latchTable = shiftTable;
Expand Down Expand Up @@ -355,23 +362,23 @@ + (int)readCode:(ZXBoolArray *)rawbits startIndex:(int)startIndex length:(int)le
/**
* Reads a code of length 8 in an array of bits, padding with zeros
*/
+ (int) readByte:(ZXBoolArray *) rawbits startIndex:(int) startIndex {
+ (int8_t) readByte:(ZXBoolArray *) rawbits startIndex:(int) startIndex {
int n = rawbits.length - startIndex;
if (n >= 8) {
return (int) [self readCode:rawbits startIndex:startIndex length:8];
return (int8_t) [self readCode:rawbits startIndex:startIndex length:8];
}
return (int) ([self readCode:rawbits startIndex:startIndex length:n] << (8 - n));
return (int8_t) ([self readCode:rawbits startIndex:startIndex length:n] << (8 - n));
}

/**
* Packs a bit array into bytes, most significant bit first
*/
+ (NSMutableArray *) convertBoolArrayToByteArray:(ZXBoolArray *) boolArr {
NSMutableArray *byteArr = [[NSMutableArray alloc] init];
+ (ZXByteArray *)convertBoolArrayToByteArray:(ZXBoolArray *) boolArr {
int byteArrLength = (boolArr.length + 7) / 8;
ZXByteArray *byteArr = [[ZXByteArray alloc] initWithLength:byteArrLength];
for (int i = 0; i < byteArrLength; i++) {
int code = [self readByte:boolArr startIndex:8 * i];
[byteArr addObject:@(code)];
int8_t code = [self readByte:boolArr startIndex:8 * i];
byteArr.array[i] = code;
}
return byteArr;
}
Expand Down
Expand Up @@ -38,7 +38,9 @@
/**
* Detects an Aztec Code in an image.
*
* @return ZXAztecDetectorResult encapsulating results of detecting an Aztec Code, or nil if no Aztec Code can be found
* @param isMirror if true, image is a mirror-image of original
* @return ZXAztecDetectorResult encapsulating results of detecting an Aztec Code, or nil if no
* Aztec Code can be found
*/
- (ZXAztecDetectorResult *)detectWithMirror:(BOOL)isMirror error:(NSError **)error;

Expand Down
10 changes: 5 additions & 5 deletions Checkouts/ZXingObjC/ZXingObjC/aztec/encoder/ZXAztecCode.h
Expand Up @@ -22,27 +22,27 @@
@interface ZXAztecCode : NSObject

/**
* Number of data codewords
* @return number of data codewords
*/
@property (nonatomic, assign) int codeWords;

/**
* Compact or full symbol indicator
* @return YES if compact instead of full mode
*/
@property (nonatomic, assign, getter = isCompact) BOOL compact;

/**
* Number of levels
* @return number of levels
*/
@property (nonatomic, assign) int layers;

/**
* The symbol image
* @return the symbol image
*/
@property (nonatomic, strong) ZXBitMatrix *matrix;

/**
* Size in pixels (width and height)
* @return size in pixels (width and height)
*/
@property (nonatomic, assign) int size;

Expand Down
Expand Up @@ -43,7 +43,7 @@ extern int ZX_AZTEC_SHIFT_TABLE[ZX_AZTEC_SHIFT_TABLE_SIZE][ZX_AZTEC_SHIFT_TABLE_
- (id)initWithText:(ZXByteArray *)text;

/**
* Convert the text represented by this High Level Encoder into a BitArray.
* @return text represented by this encoder encoded as a ZXBitArray
*/
- (ZXBitArray *)encode;

Expand Down

0 comments on commit 395c875

Please sign in to comment.