提交 7c613ddf 编写于 作者: DCloud_iOS_WZT's avatar DCloud_iOS_WZT

update unimpsdk

上级 e4cb3b27
/*
* Copyright 2012 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 "ZXReader.h"
@class ZXDecodeHints;
/**
* ZXMultiFormatReader is a convenience class and the main entry point into the library for most uses.
* By default it attempts to decode all barcode formats that the library supports. Optionally, you
* can provide a hints object to request different behavior, for example only decoding QR codes.
*/
@interface ZXMultiFormatReader : NSObject <ZXReader>
@property (nonatomic, strong) ZXDecodeHints *hints;
+ (id)reader;
/**
* Decode an image using the state set up by calling setHints() previously. Continuous scan
* clients will get a <b>large</b> speed increase by using this instead of decode().
*
* @param image The pixel data to decode
* @return The contents of the image or nil if any errors occurred
*/
- (ZXResult *)decodeWithState:(ZXBinaryBitmap *)image error:(NSError **)error;
@end
/*
* Copyright 2012 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 is a factory class which finds the appropriate Writer subclass for the BarcodeFormat
* requested and encodes the barcode with the supplied contents.
*/
@interface ZXMultiFormatWriter : NSObject <ZXWriter>
+ (id)writer;
@end
/*
* Copyright 2012 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 <Foundation/Foundation.h>
#ifndef _ZXINGOBJC_
#define _ZXINGOBJC_
#import "ZXingObjCCore.h"
#if defined(ZXINGOBJC_AZTEC) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCAztec.h"
#endif
#if defined(ZXINGOBJC_DATAMATRIX) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCDataMatrix.h"
#endif
#if defined(ZXINGOBJC_MAXICODE) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCMaxiCode.h"
#endif
#if defined(ZXINGOBJC_ONED) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCOneD.h"
#endif
#if defined(ZXINGOBJC_PDF417) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCPDF417.h"
#endif
#if defined(ZXINGOBJC_QRCODE) || !defined(ZXINGOBJC_USE_SUBSPECS)
#import "ZXingObjCQRCode.h"
#endif
#import "ZXMultiFormatReader.h"
#import "ZXMultiFormatWriter.h"
#endif
/*
* Copyright 2012 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 "ZXBitMatrix.h"
#import "ZXDetectorResult.h"
@interface ZXAztecDetectorResult : ZXDetectorResult
@property (nonatomic, assign, readonly, getter = isCompact) BOOL compact;
@property (nonatomic, assign, readonly) int nbDatablocks;
@property (nonatomic, assign, readonly) int nbLayers;
- (id)initWithBits:(ZXBitMatrix *)bits
points:(NSArray *)points
compact:(BOOL)compact
nbDatablocks:(int)nbDatablocks
nbLayers:(int)nbLayers;
@end
/*
* Copyright 2012 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 "ZXReader.h"
@class ZXBinaryBitmap, ZXDecodeHints, ZXResult;
/**
* This implementation can detect and decode Aztec codes in an image.
*/
@interface ZXAztecReader : NSObject <ZXReader>
@end
/*
* 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"
@interface ZXAztecWriter : NSObject <ZXWriter>
@end
/*
* Copyright 2014 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 "ZXingObjCCore.h"
#ifndef _ZXINGOBJC_AZTEC_
#define _ZXINGOBJC_AZTEC_
#import "ZXAztecCode.h"
#import "ZXAztecDecoder.h"
#import "ZXAztecDetector.h"
#import "ZXAztecDetectorResult.h"
#import "ZXAztecEncoder.h"
#import "ZXAztecHighLevelEncoder.h"
#import "ZXAztecReader.h"
#import "ZXAztecWriter.h"
#endif
/*
* Copyright 2012 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.
*/
@class ZXAztecDetectorResult, ZXBoolArray, ZXDecoderResult;
/**
* The main class which implements Aztec Code decoding -- as opposed to locating and extracting
* the Aztec Code from an image.
*/
@interface ZXAztecDecoder : NSObject
- (ZXDecoderResult *)decode:(ZXAztecDetectorResult *)detectorResult error:(NSError **)error;
// This method is used for testing the high-level encoder
+ (NSString *)highLevelDecode:(ZXBoolArray *)correctedBits;
@end
/*
* Copyright 2012 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.
*/
@interface ZXAztecPoint : NSObject
@property (nonatomic, assign, readonly) int x;
@property (nonatomic, assign, readonly) int y;
- (id)initWithX:(int)x y:(int)y;
@end
@class ZXAztecDetectorResult, ZXBitMatrix;
/**
* Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code
* is rotated or skewed, or partially obscured.
*/
@interface ZXAztecDetector : NSObject
- (id)initWithImage:(ZXBitMatrix *)image;
- (ZXAztecDetectorResult *)detectWithError:(NSError **)error;
/**
* 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
*/
- (ZXAztecDetectorResult *)detectWithMirror:(BOOL)isMirror error:(NSError **)error;
@end
/*
* Copyright 2014 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 "ZXAztecToken.h"
@interface ZXAztecBinaryShiftToken : ZXAztecToken
- (id)initWithPrevious:(ZXAztecToken *)previous binaryShiftStart:(int)binaryShiftStart binaryShiftByteCount:(int)binaryShiftByteCount;
@end
/*
* 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.
*/
@class ZXBitMatrix;
/**
* Aztec 2D code representation
*/
@interface ZXAztecCode : NSObject
/**
* Number of data codewords
*/
@property (nonatomic, assign) int codeWords;
/**
* Compact or full symbol indicator
*/
@property (nonatomic, assign, getter = isCompact) BOOL compact;
/**
* Number of levels
*/
@property (nonatomic, assign) int layers;
/**
* The symbol image
*/
@property (nonatomic, strong) ZXBitMatrix *matrix;
/**
* Size in pixels (width and height)
*/
@property (nonatomic, assign) int size;
@end
/*
* 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.
*/
extern const int ZX_AZTEC_DEFAULT_EC_PERCENT;
extern const int ZX_AZTEC_DEFAULT_LAYERS;
@class ZXAztecCode, ZXBitArray, ZXByteArray, ZXGenericGF;
/**
* Generates Aztec 2D barcodes.
*/
@interface ZXAztecEncoder : NSObject
/**
* Encodes the given binary content as an Aztec symbol
*
* @param data input data string
* @return Aztec symbol matrix with metadata
*/
+ (ZXAztecCode *)encode:(ZXByteArray *)data;
/**
* Encodes the given binary content as an Aztec symbol
*
* @param data input data string
* @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,
* a minimum of 23% + 3 words is recommended)
* @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers
* @return Aztec symbol matrix with metadata
*/
+ (ZXAztecCode *)encode:(ZXByteArray *)data
minECCPercent:(int)minECCPercent
userSpecifiedLayers:(int)userSpecifiedLayers;
@end
/*
* Copyright 2014 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.
*/
extern NSArray *ZX_AZTEC_MODE_NAMES;
extern const int ZX_AZTEC_MODE_UPPER;
extern const int ZX_AZTEC_MODE_LOWER;
extern const int ZX_AZTEC_MODE_DIGIT;
extern const int ZX_AZTEC_MODE_MIXED;
extern const int ZX_AZTEC_MODE_PUNCT;
extern const int ZX_AZTEC_LATCH_TABLE[][5];
#define ZX_AZTEC_SHIFT_TABLE_SIZE 6
extern int ZX_AZTEC_SHIFT_TABLE[ZX_AZTEC_SHIFT_TABLE_SIZE][ZX_AZTEC_SHIFT_TABLE_SIZE];
@class ZXBitArray, ZXByteArray;
/**
* This produces nearly optimal encodings of text into the first-level of
* encoding used by Aztec code.
*
* It uses a dynamic algorithm. For each prefix of the string, it determines
* a set of encodings that could lead to this prefix. We repeatedly add a
* character and generate a new set of optimal encodings until we have read
* through the entire input.
*/
@interface ZXAztecHighLevelEncoder : NSObject
- (id)initWithText:(ZXByteArray *)text;
/**
* Convert the text represented by this High Level Encoder into a BitArray.
*/
- (ZXBitArray *)encode;
@end
/*
* Copyright 2014 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 "ZXAztecToken.h"
@interface ZXAztecSimpleToken : ZXAztecToken
- (id)initWithPrevious:(ZXAztecToken *)previous value:(int)value bitCount:(int)bitCount;
@end
/*
* Copyright 2014 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.
*/
@class ZXAztecToken, ZXBitArray, ZXByteArray;
/**
* State represents all information about a sequence necessary to generate the current output.
* Note that a state is immutable.
*/
@interface ZXAztecState : NSObject
// The current mode of the encoding (or the mode to which we'll return if
// we're in Binary Shift mode.
@property (nonatomic, assign, readonly) int mode;
// The list of tokens that we output. If we are in Binary Shift mode, this
// token list does *not* yet included the token for those bytes
@property (nonatomic, strong, readonly) ZXAztecToken *token;
// If non-zero, the number of most recent bytes that should be output
// in Binary Shift mode.
@property (nonatomic, assign, readonly) int binaryShiftByteCount;
// The total number of bits generated (including Binary Shift).
@property (nonatomic, assign, readonly) int bitCount;
- (id)initWithToken:(ZXAztecToken *)token mode:(int)mode binaryBytes:(int)binaryBytes bitCount:(int)bitCount;
+ (ZXAztecState *)initialState;
- (ZXAztecState *)latchAndAppend:(int)mode value:(int)value;
- (ZXAztecState *)shiftAndAppend:(int)mode value:(int)value;
- (ZXAztecState *)addBinaryShiftChar:(int)index;
- (ZXAztecState *)endBinaryShift:(int)index;
- (BOOL)isBetterThanOrEqualTo:(ZXAztecState *)other;
- (ZXBitArray *)toBitArray:(ZXByteArray *)text;
@end
/*
* Copyright 2014 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.
*/
@class ZXBitArray, ZXByteArray;
@interface ZXAztecToken : NSObject
@property (nonatomic, strong, readonly) ZXAztecToken *previous;
- (id)initWithPrevious:(ZXAztecToken *)previous;
+ (ZXAztecToken *)empty;
- (ZXAztecToken *)add:(int)value bitCount:(int)bitCount;
- (ZXAztecToken *)addBinaryShift:(int)start byteCount:(int)byteCount;
- (void)appendTo:(ZXBitArray *)bitArray text:(ZXByteArray *)text;
@end
/*
* Copyright 2012 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 <CoreVideo/CoreVideo.h>
#import "ZXLuminanceSource.h"
@class ZXImage;
@interface ZXCGImageLuminanceSource : ZXLuminanceSource
+ (CGImageRef)createImageFromBuffer:(CVImageBufferRef)buffer CF_RETURNS_RETAINED;
+ (CGImageRef)createImageFromBuffer:(CVImageBufferRef)buffer
left:(size_t)left
top:(size_t)top
width:(size_t)width
height:(size_t)height CF_RETURNS_RETAINED;
- (id)initWithZXImage:(ZXImage *)image
left:(size_t)left
top:(size_t)top
width:(size_t)width
height:(size_t)height;
- (id)initWithZXImage:(ZXImage *)image;
- (id)initWithCGImage:(CGImageRef)image
left:(size_t)left
top:(size_t)top
width:(size_t)width
height:(size_t)height;
- (id)initWithCGImage:(CGImageRef)image;
- (id)initWithBuffer:(CVPixelBufferRef)buffer
left:(size_t)left
top:(size_t)top
width:(size_t)width
height:(size_t)height;
- (id)initWithBuffer:(CVPixelBufferRef)buffer;
- (CGImageRef)image;
@end
/*
* Copyright 2012 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 <AVFoundation/AVFoundation.h>
@protocol ZXCaptureDelegate, ZXReader;
@class ZXDecodeHints;
@interface ZXCapture : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate, CAAction>
@property (nonatomic, assign) int camera;
@property (nonatomic, strong) AVCaptureDevice *captureDevice;
@property (nonatomic, copy) NSString *captureToFilename;
@property (nonatomic, weak) id<ZXCaptureDelegate> delegate;
@property (nonatomic, assign) AVCaptureFocusMode focusMode;
@property (nonatomic, strong) ZXDecodeHints *hints;
@property (nonatomic, assign) CGImageRef lastScannedImage;
@property (nonatomic, assign) BOOL invert;
@property (nonatomic, strong, readonly) CALayer *layer;
@property (nonatomic, assign) BOOL mirror;
@property (nonatomic, strong, readonly) AVCaptureVideoDataOutput *output;
@property (nonatomic, strong) id<ZXReader> reader;
@property (nonatomic, assign) CGFloat rotation;
@property (nonatomic, assign, readonly) BOOL running;
@property (nonatomic, assign) CGRect scanRect;
@property (nonatomic, copy) NSString *sessionPreset;
@property (nonatomic, assign) BOOL torch;
@property (nonatomic, assign) CGAffineTransform transform;
@property (nonatomic, assign) BOOL hardStop;
@property (nonatomic, assign) BOOL autoDecodeCharset;
- (int)back;
- (int)front;
- (BOOL)hasBack;
- (BOOL)hasFront;
- (BOOL)hasTorch;
- (CALayer *)binary;
- (void)setBinary:(BOOL)on_off;
- (CALayer *)luminance;
- (void)setLuminance:(BOOL)on_off;
- (void)hard_stop;
- (void)order_skip;
- (void)start;
- (void)stop;
@end
/*
* Copyright 2012 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.
*/
@class ZXCapture;
@class ZXResult;
@protocol ZXCaptureDelegate <NSObject>
- (void)captureResult:(ZXCapture *)capture result:(ZXResult *)result;
@optional
- (void)captureSize:(ZXCapture *)capture
width:(NSNumber *)width
height:(NSNumber *)height;
- (void)captureCameraIsReady:(ZXCapture *)capture;
@end
/*
* Copyright 2012 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 <QuartzCore/QuartzCore.h>
@class ZXBitMatrix;
@interface ZXImage : NSObject
@property (nonatomic, assign, readonly) CGImageRef cgimage;
- (ZXImage *)initWithCGImageRef:(CGImageRef)image;
- (ZXImage *)initWithURL:(NSURL const *)url;
- (size_t)width;
- (size_t)height;
+ (ZXImage *)imageWithMatrix:(ZXBitMatrix *)matrix;
+ (ZXImage *)imageWithMatrix:(ZXBitMatrix *)matrix onColor:(CGColorRef)onColor offColor:(CGColorRef)offColor;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* See DoCoMo's documentation http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/about/s2.html
* about the result types represented by subclasses of this class.
*/
@interface ZXAbstractDoCoMoResultParser : ZXResultParser
+ (NSArray *)matchDoCoMoPrefixedField:(NSString *)prefix rawText:(NSString *)rawText trim:(BOOL)trim;
+ (NSString *)matchSingleDoCoMoPrefixedField:(NSString *)prefix rawText:(NSString *)rawText trim:(BOOL)trim;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Implements KDDI AU's address book format. See http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html.
* (Thanks to Yuzo for translating!)
*/
@interface ZXAddressBookAUResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXAbstractDoCoMoResultParser.h"
#import "ZXResult.h"
/**
* Implements the "MECARD" address book entry format.
*
* Supported keys: N, SOUND, TEL, EMAIL, NOTE, ADR, BDAY, URL, plus ORG
* Unsupported keys: TEL-AV, NICKNAME
*
* Except for TEL, multiple values for keys are also not supported;
* the first one found takes precedence.
*
* Our understanding of the MECARD format is based on this document:
*
* http://www.mobicode.org.tw/files/OMIA%20Mobile%20Bar%20Code%20Standard%20v3.2.1.doc
*/
@interface ZXAddressBookDoCoMoResultParser : ZXAbstractDoCoMoResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXAddressBookParsedResult : ZXParsedResult
@property (nonatomic, readonly, strong) NSArray *names;
@property (nonatomic, readonly, strong) NSArray *nicknames;
/**
* In Japanese, the name is written in kanji, which can have multiple readings. Therefore a hint
* is often provided, called furigana, which spells the name phonetically.
*
* @return The pronunciation of the names property, often in hiragana or katakana.
*/
@property (nonatomic, readonly, copy) NSString *pronunciation;
@property (nonatomic, readonly, strong) NSArray *phoneNumbers;
/**
* @return optional descriptions of the type of each phone number. It could be like "HOME", but,
* there is no guaranteed or standard format.
*/
@property (nonatomic, readonly, strong) NSArray *phoneTypes;
@property (nonatomic, readonly, strong) NSArray *emails;
/**
* @return optional descriptions of the type of each e-mail. It could be like "WORK", but,
* there is no guaranteed or standard format.
*/
@property (nonatomic, readonly, strong) NSArray *emailTypes;
@property (nonatomic, readonly, copy) NSString *instantMessenger;
@property (nonatomic, readonly, copy) NSString *note;
@property (nonatomic, readonly, strong) NSArray *addresses;
/**
* @return optional descriptions of the type of each e-mail. It could be like "WORK", but,
* there is no guaranteed or standard format.
*/
@property (nonatomic, readonly, strong) NSArray *addressTypes;
@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *org;
@property (nonatomic, readonly, strong) NSArray *urls;
/**
* @return birthday formatted as yyyyMMdd (e.g. 19780917)
*/
@property (nonatomic, readonly, copy) NSString *birthday;
/**
* @return a location as a latitude/longitude pair
*/
@property (nonatomic, readonly, strong) NSArray *geo;
- (id)initWithNames:(NSArray *)names phoneNumbers:(NSArray *)phoneNumbers
phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes;
- (id)initWithNames:(NSArray *)names nicknames:(NSArray *)nicknames pronunciation:(NSString *)pronunciation
phoneNumbers:(NSArray *)phoneNumbers phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails
emailTypes:(NSArray *)emailTypes instantMessenger:(NSString *)instantMessenger note:(NSString *)note
addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes org:(NSString *)org
birthday:(NSString *)birthday title:(NSString *)title urls:(NSArray *)urls geo:(NSArray *)geo;
+ (id)addressBookParsedResultWithNames:(NSArray *)names phoneNumbers:(NSArray *)phoneNumbers
phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
addresses:(NSArray *)addresses addressTypes:(NSArray *)addressTypes;
+ (id)addressBookParsedResultWithNames:(NSArray *)names nicknames:(NSArray *)nicknames
pronunciation:(NSString *)pronunciation phoneNumbers:(NSArray *)phoneNumbers
phoneTypes:(NSArray *)phoneTypes emails:(NSArray *)emails emailTypes:(NSArray *)emailTypes
instantMessenger:(NSString *)instantMessenger note:(NSString *)note addresses:(NSArray *)addresses
addressTypes:(NSArray *)addressTypes org:(NSString *)org birthday:(NSString *)birthday
title:(NSString *)title urls:(NSArray *)urls geo:(NSArray *)geo;
@end
/*
* Copyright 2012 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 "ZXAbstractDoCoMoResultParser.h"
/**
* Implements the "BIZCARD" address book entry format, though this has been
* largely reverse-engineered from examples observed in the wild -- still
* looking for a definitive reference.
*/
@interface ZXBizcardResultParser : ZXAbstractDoCoMoResultParser
@end
/*
* Copyright 2012 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 "ZXAbstractDoCoMoResultParser.h"
@interface ZXBookmarkDoCoMoResultParser : ZXAbstractDoCoMoResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXCalendarParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *summary;
@property (nonatomic, strong, readonly) NSDate *start;
@property (nonatomic, assign, readonly) BOOL startAllDay;
@property (nonatomic, strong, readonly) NSDate *end;
@property (nonatomic, assign, readonly) BOOL endAllDay;
@property (nonatomic, copy, readonly) NSString *location;
@property (nonatomic, copy, readonly) NSString *organizer;
@property (nonatomic, strong, readonly) NSArray *attendees;
@property (nonatomic, copy, readonly) NSString *resultDescription;
@property (nonatomic, assign, readonly) double latitude;
@property (nonatomic, assign, readonly) double longitude;
- (id)initWithSummary:(NSString *)summary startString:(NSString *)startString endString:(NSString *)endString
durationString:(NSString *)durationString location:(NSString *)location organizer:(NSString *)organizer
attendees:(NSArray *)attendees description:(NSString *)description latitude:(double)latitude
longitude:(double)longitude;
+ (id)calendarParsedResultWithSummary:(NSString *)summary startString:(NSString *)startString
endString:(NSString *)endString durationString:(NSString *)durationString
location:(NSString *)location organizer:(NSString *)organizer
attendees:(NSArray *)attendees description:(NSString *)description latitude:(double)latitude
longitude:(double)longitude;
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXEmailAddressParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSArray *tos;
@property (nonatomic, copy, readonly) NSArray *ccs;
@property (nonatomic, copy, readonly) NSArray *bccs;
@property (nonatomic, copy, readonly) NSString *subject;
@property (nonatomic, copy, readonly) NSString *body;
/**
* @return first elements of tos or nil if none
* @deprecated use tos
*/
@property (nonatomic, copy, readonly) NSString *emailAddress DEPRECATED_ATTRIBUTE;
/**
* @return "mailto:"
* @deprecated without replacement
*/
@property (nonatomic, copy, readonly) NSString *mailtoURI DEPRECATED_ATTRIBUTE;
- (id)initWithTo:(NSString *)to;
- (id)initWithTos:(NSArray *)tos
ccs:(NSArray *)ccs
bccs:(NSArray *)bccs
subject:(NSString *)subject
body:(NSString *)body;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Represents a result that encodes an e-mail address, either as a plain address
* like "joe@example.org" or a mailto: URL like "mailto:joe@example.org".
*/
@interface ZXEmailAddressResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXAbstractDoCoMoResultParser.h"
/**
* Implements the "MATMSG" email message entry format.
*
* Supported keys: TO, SUB, BODY
*/
@interface ZXEmailDoCoMoResultParser : ZXAbstractDoCoMoResultParser
/**
* This implements only the most basic checking for an email address's validity -- that it contains
* an '@' and contains no characters disallowed by RFC 2822. This is an overly lenient definition of
* validity. We want to generally be lenient here since this class is only intended to encapsulate what's
* in a barcode, not "judge" it.
*/
+ (BOOL)isBasicallyValidEmailAddress:(NSString *)email;
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
extern NSString * const ZX_KILOGRAM;
extern NSString * const ZX_POUND;
@interface ZXExpandedProductParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *rawText;
@property (nonatomic, copy, readonly) NSString *productID;
@property (nonatomic, copy, readonly) NSString *sscc;
@property (nonatomic, copy, readonly) NSString *lotNumber;
@property (nonatomic, copy, readonly) NSString *productionDate;
@property (nonatomic, copy, readonly) NSString *packagingDate;
@property (nonatomic, copy, readonly) NSString *bestBeforeDate;
@property (nonatomic, copy, readonly) NSString *expirationDate;
@property (nonatomic, copy, readonly) NSString *weight;
@property (nonatomic, copy, readonly) NSString *weightType;
@property (nonatomic, copy, readonly) NSString *weightIncrement;
@property (nonatomic, copy, readonly) NSString *price;
@property (nonatomic, copy, readonly) NSString *priceIncrement;
@property (nonatomic, copy, readonly) NSString *priceCurrency;
@property (nonatomic, strong, readonly) NSMutableDictionary *uncommonAIs;
- (id)initWithRawText:(NSString *)rawText productID:(NSString *)productID sscc:(NSString *)sscc
lotNumber:(NSString *)lotNumber productionDate:(NSString *)productionDate
packagingDate:(NSString *)packagingDate bestBeforeDate:(NSString *)bestBeforeDate
expirationDate:(NSString *)expirationDate weight:(NSString *)weight weightType:(NSString *)weightType
weightIncrement:(NSString *)weightIncrement price:(NSString *)price priceIncrement:(NSString *)priceIncrement
priceCurrency:(NSString *)priceCurrency uncommonAIs:(NSMutableDictionary *)uncommonAIs;
+ (id)expandedProductParsedResultWithRawText:(NSString *)rawText productID:(NSString *)productID sscc:(NSString *)sscc
lotNumber:(NSString *)lotNumber productionDate:(NSString *)productionDate
packagingDate:(NSString *)packagingDate bestBeforeDate:(NSString *)bestBeforeDate
expirationDate:(NSString *)expirationDate weight:(NSString *)weight
weightType:(NSString *)weightType weightIncrement:(NSString *)weightIncrement
price:(NSString *)price priceIncrement:(NSString *)priceIncrement
priceCurrency:(NSString *)priceCurrency uncommonAIs:(NSMutableDictionary *)uncommonAIs;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses strings of digits that represent a RSS Extended code.
*/
@interface ZXExpandedProductResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXGeoParsedResult : ZXParsedResult
/**
* @return latitude in degrees
*/
@property (nonatomic, assign, readonly) double latitude;
/**
* @return longitude in degrees
*/
@property (nonatomic, assign, readonly) double longitude;
/**
* @return altitude in meters. If not specified, in the geo URI, returns 0.0
*/
@property (nonatomic, assign, readonly) double altitude;
/**
* @return query string associated with geo URI or null if none exists
*/
@property (nonatomic, copy, readonly) NSString *query;
- (id)initWithLatitude:(double)latitude longitude:(double)longitude altitude:(double)altitude query:(NSString *)query;
+ (id)geoParsedResultWithLatitude:(double)latitude longitude:(double)longitude altitude:(double)altitude query:(NSString *)query;
- (NSString *)geoURI;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses a "geo:" URI result, which specifies a location on the surface of
* the Earth as well as an optional altitude above the surface. See
* http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00.
*/
@interface ZXGeoResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXISBNParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *isbn;
- (id)initWithIsbn:(NSString *)isbn;
+ (id)isbnParsedResultWithIsbn:(NSString *)isbn;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses strings of digits that represent a ISBN.
*/
@interface ZXISBNResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResultType.h"
#import "ZXResult.h"
/**
* Abstract class representing the result of decoding a barcode, as more than
* a String -- as some type of structured data. This might be a subclass which represents
* a URL, or an e-mail address. parseResult() will turn a raw
* decoded string into the most appropriate type of structured representation.
*
* Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
* on exception-based mechanisms during parsing.
*/
@interface ZXParsedResult : NSObject
@property (nonatomic, assign, readonly) ZXParsedResultType type;
- (id)initWithType:(ZXParsedResultType)type;
+ (id)parsedResultWithType:(ZXParsedResultType)type;
- (NSString *)displayResult;
+ (void)maybeAppend:(NSString *)value result:(NSMutableString *)result;
+ (void)maybeAppendArray:(NSArray *)value result:(NSMutableString *)result;
@end
/*
* Copyright 2012 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.
*/
/**
* Represents the type of data encoded by a barcode -- from plain text, to a
* URI, to an e-mail address, etc.
*/
typedef enum {
kParsedResultTypeAddressBook,
kParsedResultTypeEmailAddress,
kParsedResultTypeProduct,
kParsedResultTypeURI,
kParsedResultTypeText,
kParsedResultTypeAndroidIntent,
kParsedResultTypeGeo,
kParsedResultTypeTel,
kParsedResultTypeSMS,
kParsedResultTypeCalendar,
kParsedResultTypeWifi,
kParsedResultTypeNDEFSMartPoster,
kParsedResultTypeMobiletagRichWeb,
kParsedResultTypeISBN,
kParsedResultTypeVIN
} ZXParsedResultType;
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXProductParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *normalizedProductID;
@property (nonatomic, copy, readonly) NSString *productID;
- (id)initWithProductID:(NSString *)productID;
- (id)initWithProductID:(NSString *)productID normalizedProductID:(NSString *)normalizedProductID;
+ (id)productParsedResultWithProductID:(NSString *)productID;
+ (id)productParsedResultWithProductID:(NSString *)productID normalizedProductID:(NSString *)normalizedProductID;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses strings of digits that represent a UPC code.
*/
@interface ZXProductResultParser : ZXResultParser
@end
/*
* Copyright 2012 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.
*/
@class ZXParsedResult, ZXResult;
/**
* Abstract class representing the result of decoding a barcode, as more than
* a String -- as some type of structured data. This might be a subclass which represents
* a URL, or an e-mail address. parseResult() will turn a raw
* decoded string into the most appropriate type of structured representation.
*
* Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
* on exception-based mechanisms during parsing.
*/
@interface ZXResultParser : NSObject
/**
* Attempts to parse the raw ZXResult's contents as a particular type
* of information (email, URL, etc.) and return a ZXParsedResult encapsulating
* the result of parsing.
*/
- (ZXParsedResult *)parse:(ZXResult *)result;
+ (NSString *)massagedText:(ZXResult *)result;
+ (ZXParsedResult *)parseResult:(ZXResult *)theResult;
- (void)maybeAppend:(NSString *)value result:(NSMutableString *)result;
- (void)maybeAppendArray:(NSArray *)value result:(NSMutableString *)result;
- (NSArray *)maybeWrap:(NSString *)value;
+ (BOOL)isStringOfDigits:(NSString *)value length:(unsigned int)length;
+ (BOOL)isSubstringOfDigits:(NSString *)value offset:(int)offset length:(int)length;
+ (int)parseHexDigit:(unichar)c;
- (NSMutableDictionary *)parseNameValuePairs:(NSString *)uri;
+ (NSString *)urlDecode:(NSString *)encoded;
+ (NSArray *)matchPrefixedField:(NSString *)prefix rawText:(NSString *)rawText endChar:(unichar)endChar trim:(BOOL)trim;
+ (NSString *)matchSinglePrefixedField:(NSString *)prefix rawText:(NSString *)rawText endChar:(unichar)endChar trim:(BOOL)trim;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses an "sms:" URI result, which specifies a number to SMS.
* See http://tools.ietf.org/html/rfc5724 on this.
*
* This class supports "via" syntax for numbers, which is not part of the spec.
* For example "+12125551212;via=+12124440101" may appear as a number.
* It also supports a "subject" query parameter, which is not mentioned in the spec.
* These are included since they were mentioned in earlier IETF drafts and might be
* used.
*
* This actually also parses URIs starting with "mms:" and treats them all the same way,
* and effectively converts them to an "sms:" URI for purposes of forwarding to the platform.
*/
@interface ZXSMSMMSResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXSMSParsedResult : ZXParsedResult
@property (nonatomic, strong, readonly) NSArray *numbers;
@property (nonatomic, strong, readonly) NSArray *vias;
@property (nonatomic, copy, readonly) NSString *subject;
@property (nonatomic, copy, readonly) NSString *body;
- (id)initWithNumber:(NSString *)number via:(NSString *)via subject:(NSString *)subject body:(NSString *)body;
- (id)initWithNumbers:(NSArray *)numbers vias:(NSArray *)vias subject:(NSString *)subject body:(NSString *)body;
+ (id)smsParsedResultWithNumber:(NSString *)number via:(NSString *)via subject:(NSString *)subject body:(NSString *)body;
+ (id)smsParsedResultWithNumbers:(NSArray *)numbers vias:(NSArray *)vias subject:(NSString *)subject body:(NSString *)body;
- (NSString *)sMSURI;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses an "smsto:" URI result, whose format is not standardized but appears to be like:
* smsto:number(:body).
*
* This actually also parses URIs starting with "smsto:", "mmsto:", "SMSTO:", and
* "MMSTO:", and treats them all the same way, and effectively converts them to an "sms:" URI
* for purposes of forwarding to the platform.
*/
@interface ZXSMSTOMMSTOResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses an "smtp:" URI result, whose format is not standardized but appears to be like:
* smtp[:subject[:body]].
*/
@interface ZXSMTPResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXTelParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *number;
@property (nonatomic, copy, readonly) NSString *telURI;
@property (nonatomic, copy, readonly) NSString *title;
- (id)initWithNumber:(NSString *)number telURI:(NSString *)telURI title:(NSString *)title;
+ (id)telParsedResultWithNumber:(NSString *)number telURI:(NSString *)telURI title:(NSString *)title;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses a "tel:" URI result, which specifies a phone number.
*/
@interface ZXTelResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
/**
* A simple result type encapsulating a string that has no further
* interpretation.
*/
@interface ZXTextParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *text;
@property (nonatomic, copy, readonly) NSString *language;
- (id)initWithText:(NSString *)text language:(NSString *)language;
+ (id)textParsedResultWithText:(NSString *)text language:(NSString *)language;
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXURIParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *uri;
@property (nonatomic, copy, readonly) NSString *title;
- (id)initWithUri:(NSString *)uri title:(NSString *)title;
+ (id)uriParsedResultWithUri:(NSString *)uri title:(NSString *)title;
/**
* @return true if the URI contains suspicious patterns that may suggest it intends to
* mislead the user about its true nature. At the moment this looks for the presence
* of user/password syntax in the host/authority portion of a URI which may be used
* in attempts to make the URI's host appear to be other than it is. Example:
* http://yourbank.com@phisher.com This URI connects to phisher.com but may appear
* to connect to yourbank.com at first glance.
*/
- (BOOL)possiblyMaliciousURI;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Tries to parse results that are a URI of some kind.
*/
@interface ZXURIResultParser : ZXResultParser
+ (BOOL)isBasicallyValidURI:(NSString *)uri;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]".
* This seems to be used sometimes, but I am not able to find documentation
* on its origin or official format?
*/
@interface ZXURLTOResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses contact information formatted according to the VCard (2.1) format. This is not a complete
* implementation but should parse information as commonly encoded in 2D barcodes.
*/
@interface ZXVCardResultParser : ZXResultParser
+ (NSArray *)matchSingleVCardPrefixedField:(NSString *)prefix rawText:(NSString *)rawText trim:(BOOL)trim parseFieldDivider:(BOOL)parseFieldDivider;
+ (NSMutableArray *)matchVCardPrefixedField:(NSString *)prefix rawText:(NSString *)rawText trim:(BOOL)trim parseFieldDivider:(BOOL)parseFieldDivider;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Partially implements the iCalendar format's "VEVENT" format for specifying a
* calendar event. See RFC 2445. This supports SUMMARY, LOCATION, GEO, DTSTART and DTEND fields.
*/
@interface ZXVEventResultParser : ZXResultParser
@end
/*
* Copyright 2014 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 "ZXParsedResult.h"
@interface ZXVINParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *vin;
@property (nonatomic, copy, readonly) NSString *worldManufacturerID;
@property (nonatomic, copy, readonly) NSString *vehicleDescriptorSection;
@property (nonatomic, copy, readonly) NSString *vehicleIdentifierSection;
@property (nonatomic, copy, readonly) NSString *countryCode;
@property (nonatomic, copy, readonly) NSString *vehicleAttributes;
@property (nonatomic, assign, readonly) int modelYear;
@property (nonatomic, assign, readonly) unichar plantCode;
@property (nonatomic, copy, readonly) NSString *sequentialNumber;
- (id)initWithVIN:(NSString *)vin worldManufacturerID:(NSString *)worldManufacturerID
vehicleDescriptorSection:(NSString *)vehicleDescriptorSection vehicleIdentifierSection:(NSString *)vehicleIdentifierSection
countryCode:(NSString *)countryCode vehicleAttributes:(NSString *)vehicleAttributes modelYear:(int)modelYear
plantCode:(unichar)plantCode sequentialNumber:(NSString *)sequentialNumber;
@end
/*
* Copyright 2014 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 "ZXResultParser.h"
/**
* Detects a result that is likely a vehicle identification number.
*/
@interface ZXVINResultParser : ZXResultParser
@end
/*
* Copyright 2012 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 "ZXParsedResult.h"
@interface ZXWifiParsedResult : ZXParsedResult
@property (nonatomic, copy, readonly) NSString *ssid;
@property (nonatomic, copy, readonly) NSString *networkEncryption;
@property (nonatomic, copy, readonly) NSString *password;
@property (nonatomic, assign, readonly) BOOL hidden;
- (id)initWithNetworkEncryption:(NSString *)networkEncryption ssid:(NSString *)ssid password:(NSString *)password;
- (id)initWithNetworkEncryption:(NSString *)networkEncryption ssid:(NSString *)ssid password:(NSString *)password hidden:(BOOL)hidden;
+ (id)wifiParsedResultWithNetworkEncryption:(NSString *)networkEncryption ssid:(NSString *)ssid password:(NSString *)password;
+ (id)wifiParsedResultWithNetworkEncryption:(NSString *)networkEncryption ssid:(NSString *)ssid password:(NSString *)password hidden:(BOOL)hidden;
@end
/*
* Copyright 2012 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 "ZXResultParser.h"
/**
* Parses a WIFI configuration string. Strings will be of the form:
*
* WIFI:T:[network type];S:[SSID];P:[network password];H:[hidden?];;
*
* The fields can appear in any order. Only "S:" is required.
*/
@interface ZXWifiResultParser : ZXResultParser
@end
/*
* Copyright 2012 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.
*/
@class ZXByteArray, ZXIntArray;
/**
* A simple, fast array of bits, represented compactly by an array of ints internally.
*/
@interface ZXBitArray : NSObject <NSCopying>
/**
* @return underlying array of ints. The first element holds the first 32 bits, and the least
* significant bit is bit 0.
*/
@property (nonatomic, assign, readonly) int32_t *bits;
@property (nonatomic, assign, readonly) int size;
- (id)initWithSize:(int)size;
- (int)sizeInBytes;
/**
* @param i bit to get
* @return true iff bit i is set
*/
- (BOOL)get:(int)i;
/**
* Sets bit i.
*
* @param i bit to set
*/
- (void)set:(int)i;
/**
* Flips bit i.
*
* @param i bit to set
*/
- (void)flip:(int)i;
/**
* @param from first bit to check
* @return index of first bit that is set, starting from the given index, or size if none are set
* at or beyond this given index
*/
- (int)nextSet:(int)from;
- (int)nextUnset:(int)from;
/**
* Sets a block of 32 bits, starting at bit i.
*
* @param i first bit to set
* @param newBits the new value of the next 32 bits. Note again that the least-significant bit
* corresponds to bit i, the next-least-significant to i+1, and so on.
*/
- (void)setBulk:(int)i newBits:(int32_t)newBits;
/**
* Sets a range of bits.
*
* @param start start of range, inclusive.
* @param end end of range, exclusive
*/
- (void)setRange:(int)start end:(int)end;
/**
* Clears all bits (sets to false).
*/
- (void)clear;
/**
* Efficient method to check if a range of bits is set, or not set.
*
* @param start start of range, inclusive.
* @param end end of range, exclusive
* @param value if true, checks that bits in range are set, otherwise checks that they are not set
* @return true iff all bits are set or not set in range, according to value argument
* @throws NSInvalidArgumentException if end is less than or equal to start
*/
- (BOOL)isRange:(int)start end:(int)end value:(BOOL)value;
- (void)appendBit:(BOOL)bit;
/**
* Appends the least-significant bits, from value, in order from most-significant to
* least-significant. For example, appending 6 bits from 0x000001E will append the bits
* 0, 1, 1, 1, 1, 0 in that order.
*/
- (void)appendBits:(int32_t)value numBits:(int)numBits;
- (void)appendBitArray:(ZXBitArray *)other;
- (void)xor:(ZXBitArray *)other;
/**
*
* @param bitOffset first bit to start writing
* @param array array to write into. Bytes are written most-significant byte first. This is the opposite
* of the internal representation, which is exposed by {@link #getBitArray()}
* @param offset position in array to start writing
* @param numBytes how many bytes to write
*/
- (void)toBytes:(int)bitOffset array:(ZXByteArray *)array offset:(int)offset numBytes:(int)numBytes;
/**
* @return underlying array of ints. The first element holds the first 32 bits, and the least
* significant bit is bit 0.
*/
- (ZXIntArray *)bitArray;
/**
* Reverses all bits in the array.
*/
- (void)reverse;
@end
/*
* Copyright 2012 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.
*/
@class ZXBitArray, ZXIntArray;
/**
* Represents a 2D matrix of bits. In function arguments below, and throughout the common
* module, x is the column position, and y is the row position. The ordering is always x, y.
* The origin is at the top-left.
*
* Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins
* with a new NSInteger. This is done intentionally so that we can copy out a row into a BitArray very
* efficiently.
*
* The ordering of bits is row-major. Within each NSInteger, the least significant bits are used first,
* meaning they represent lower x values. This is compatible with BitArray's implementation.
*/
@interface ZXBitMatrix : NSObject <NSCopying>
/**
* @return The width of the matrix
*/
@property (nonatomic, assign, readonly) int width;
/**
* @return The height of the matrix
*/
@property (nonatomic, assign, readonly) int height;
@property (nonatomic, assign, readonly) int32_t *bits;
/**
* @return The row size of the matrix
*/
@property (nonatomic, assign, readonly) int rowSize;
// A helper to construct a square matrix.
- (id)initWithDimension:(int)dimension;
- (id)initWithWidth:(int)width height:(int)height;
+ (ZXBitMatrix *)parse:(NSString *)stringRepresentation
setString:(NSString *)setString
unsetString:(NSString *)unsetString;
/**
* Gets the requested bit, where true means black.
*
* @param x The horizontal component (i.e. which column)
* @param y The vertical component (i.e. which row)
* @return value of given bit in matrix
*/
- (BOOL)getX:(int)x y:(int)y;
/**
* Sets the given bit to true.
*
* @param x The horizontal component (i.e. which column)
* @param y The vertical component (i.e. which row)
*/
- (void)setX:(int)x y:(int)y;
- (void)unsetX:(int)x y:(int)y;
/**
* Flips the given bit.
*
* @param x The horizontal component (i.e. which column)
* @param y The vertical component (i.e. which row)
*/
- (void)flipX:(int)x y:(int)y;
/**
* Exclusive-or (XOR): Flip the bit in this ZXBitMatrix if the corresponding
* mask bit is set.
*
* @param mask XOR mask
*/
- (void)xor:(ZXBitMatrix *)mask;
/**
* Clears all bits (sets to false).
*/
- (void)clear;
/**
* Sets a square region of the bit matrix to true.
*
* @param left The horizontal position to begin at (inclusive)
* @param top The vertical position to begin at (inclusive)
* @param width The width of the region
* @param height The height of the region
*/
- (void)setRegionAtLeft:(int)left top:(int)top width:(int)width height:(int)height;
/**
* A fast method to retrieve one row of data from the matrix as a ZXBitArray.
*
* @param y The row to retrieve
* @param row An optional caller-allocated BitArray, will be allocated if null or too small
* @return The resulting BitArray - this reference should always be used even when passing
* your own row
*/
- (ZXBitArray *)rowAtY:(int)y row:(ZXBitArray *)row;
/**
* @param y row to set
* @param row ZXBitArray to copy from
*/
- (void)setRowAtY:(int)y row:(ZXBitArray *)row;
/**
* Modifies this ZXBitMatrix to represent the same but rotated 180 degrees
*/
- (void)rotate180;
/**
* This is useful in detecting the enclosing rectangle of a 'pure' barcode.
*
* @return {left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white
*/
- (ZXIntArray *)enclosingRectangle;
/**
* This is useful in detecting a corner of a 'pure' barcode.
*
* @return {x,y} coordinate of top-left-most 1 bit, or null if it is all white
*/
- (ZXIntArray *)topLeftOnBit;
- (ZXIntArray *)bottomRightOnBit;
- (NSString *)descriptionWithSetString:(NSString *)setString unsetString:(NSString *)unsetString;
/**
* @deprecated call descriptionWithSetString:unsetString: only, which uses \n line separator always
*/
- (NSString *)descriptionWithSetString:(NSString *)setString unsetString:(NSString *)unsetString
lineSeparator:(NSString *)lineSeparator DEPRECATED_ATTRIBUTE;
@end
/*
* Copyright 2012 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.
*/
@class ZXByteArray;
/**
* This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
* number of bits read is not often a multiple of 8.
*
* This class is thread-safe but not reentrant -- unless the caller modifies the bytes array
* it passed in, in which case all bets are off.
*/
@interface ZXBitSource : NSObject
/**
* @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}.
*/
@property (nonatomic, assign, readonly) int bitOffset;
/**
* @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}.
*/
@property (nonatomic, assign, readonly) int byteOffset;
/**
* @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
* Bits are read within a byte from most-significant to least-significant bit.
*/
- (id)initWithBytes:(ZXByteArray *)bytes;
/**
* @param numBits number of bits to read
* @return int representing the bits read. The bits will appear as the least-significant
* bits of the int
* @throws NSInvalidArgumentException if numBits isn't in [1,32] or more than is available
*/
- (int)readBits:(int)numBits;
/**
* @return number of bits that can be read successfully
*/
- (int)available;
@end
/*
* Copyright 2014 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.
*/
@interface ZXBoolArray : NSObject
@property (nonatomic, assign, readonly) BOOL *array;
@property (nonatomic, assign, readonly) unsigned int length;
- (id)initWithLength:(unsigned int)length;
@end
/*
* Copyright 2014 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.
*/
@interface ZXByteArray : NSObject
@property (nonatomic, assign, readonly) int8_t *array;
@property (nonatomic, assign, readonly) unsigned int length;
- (id)initWithLength:(unsigned int)length;
- (id)initWithBytes:(int8_t)byte1, ...;
@end
/*
* Copyright 2012 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.
*/
/**
* Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1
* of ISO 18004.
*/
@interface ZXCharacterSetECI : NSObject
@property (nonatomic, assign, readonly) NSStringEncoding encoding;
@property (nonatomic, assign, readonly) int value;
/**
* @param value character set ECI value
* @return CharacterSetECI representing ECI of given value, or nil if it is legal but
* unsupported
*/
+ (ZXCharacterSetECI *)characterSetECIByValue:(int)value;
/**
* @param encoding character set ECI encoding name
* @return CharacterSetECI representing ECI for character encoding, or nil if it is legal
* but unsupported
*/
+ (ZXCharacterSetECI *)characterSetECIByEncoding:(NSStringEncoding)encoding;
@end
/*
* Copyright 2012 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.
*/
@class ZXByteArray;
/**
* Encapsulates the result of decoding a matrix of bits. This typically
* applies to 2D barcode formats. For now it contains the raw bytes obtained,
* as well as a String interpretation of those bytes, if applicable.
*/
@interface ZXDecoderResult : NSObject
@property (nonatomic, strong, readonly) ZXByteArray *rawBytes;
@property (nonatomic, copy, readonly) NSString *text;
@property (nonatomic, strong, readonly) NSMutableArray *byteSegments;
@property (nonatomic, copy, readonly) NSString *ecLevel;
@property (nonatomic, copy) NSNumber *errorsCorrected;
@property (nonatomic, copy) NSNumber *erasures;
@property (nonatomic, strong) id other;
@property (nonatomic, assign, readonly) int structuredAppendParity;
@property (nonatomic, assign, readonly) int structuredAppendSequenceNumber;
- (id)initWithRawBytes:(ZXByteArray *)rawBytes text:(NSString *)text
byteSegments:(NSMutableArray *)byteSegments ecLevel:(NSString *)ecLevel;
- (id)initWithRawBytes:(ZXByteArray *)rawBytes text:(NSString *)text
byteSegments:(NSMutableArray *)byteSegments ecLevel:(NSString *)ecLevel
saSequence:(int)saSequence saParity:(int)saParity;
- (BOOL)hasStructuredAppend;
@end
/*
* Copyright 2012 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 "ZXGridSampler.h"
@class ZXBitMatrix, ZXPerspectiveTransform;
@interface ZXDefaultGridSampler : ZXGridSampler
@end
/*
* Copyright 2012 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.
*/
@class ZXBitMatrix;
/**
* Encapsulates the result of detecting a barcode in an image. This includes the raw
* matrix of black/white pixels corresponding to the barcode, and possibly points of interest
* in the image, like the location of finder patterns or corners of the barcode in the image.
*/
@interface ZXDetectorResult : NSObject
@property (nonatomic, strong, readonly) ZXBitMatrix *bits;
@property (nonatomic, strong, readonly) NSArray *points;
- (id)initWithBits:(ZXBitMatrix *)bits points:(NSArray *)points;
@end
/*
* Copyright 2012 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 "ZXBinarizer.h"
@class ZXBitArray, ZXBitMatrix, ZXLuminanceSource;
/**
* This Binarizer implementation uses the old ZXing global histogram approach. It is suitable
* for low-end mobile devices which don't have enough CPU or memory to use a local thresholding
* algorithm. However, because it picks a global black point, it cannot handle difficult shadows
* and gradients.
*
* Faster mobile devices and all desktop applications should probably use ZXHybridBinarizer instead.
*/
@interface ZXGlobalHistogramBinarizer : ZXBinarizer
// Applies simple sharpening to the row data to improve performance of the 1D Readers.
- (ZXBitArray *)blackRow:(int)y row:(ZXBitArray *)row error:(NSError **)error;
// Does not sharpen the data, as this call is intended to only be used by 2D Readers.
- (ZXBinarizer *)createBinarizer:(ZXLuminanceSource *)source;
@end
/*
* Copyright 2012 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.
*/
@class ZXBitMatrix, ZXPerspectiveTransform;
/**
* Implementations of this class can, given locations of finder patterns for a QR code in an
* image, sample the right points in the image to reconstruct the QR code, accounting for
* perspective distortion. It is abstracted since it is relatively expensive and should be allowed
* to take advantage of platform-specific optimized implementations, like Sun's Java Advanced
* Imaging library, but which may not be available in other environments such as J2ME, and vice
* versa.
*
* The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)}
* with an instance of a class which implements this interface.
*/
@interface ZXGridSampler : NSObject
/**
* Sets the implementation of GridSampler used by the library. One global
* instance is stored, which may sound problematic. But, the implementation provided
* ought to be appropriate for the entire platform, and all uses of this library
* in the whole lifetime of the JVM. For instance, an Android activity can swap in
* an implementation that takes advantage of native platform libraries.
*
* @param newGridSampler The platform-specific object to install.
*/
+ (void)setGridSampler:(ZXGridSampler *)newGridSampler;
/**
* @return the current implementation of GridSampler
*/
+ (ZXGridSampler *)instance;
/**
* Samples an image for a rectangular matrix of bits of the given dimension.
* @param image image to sample
* @param dimensionX width of ZXBitMatrix to sample from image
* @param dimensionY height of ZXBitMatrix to sample from image
* @return ZXBitMatrix representing a grid of points sampled from the image within a region
* defined by the "from" parameters or nil if image can't be sampled, for example, if the transformation defined
* by the given points is invalid or results in sampling outside the image boundaries
*/
- (ZXBitMatrix *)sampleGrid:(ZXBitMatrix *)image
dimensionX:(int)dimensionX
dimensionY:(int)dimensionY
p1ToX:(float)p1ToX p1ToY:(float)p1ToY
p2ToX:(float)p2ToX p2ToY:(float)p2ToY
p3ToX:(float)p3ToX p3ToY:(float)p3ToY
p4ToX:(float)p4ToX p4ToY:(float)p4ToY
p1FromX:(float)p1FromX p1FromY:(float)p1FromY
p2FromX:(float)p2FromX p2FromY:(float)p2FromY
p3FromX:(float)p3FromX p3FromY:(float)p3FromY
p4FromX:(float)p4FromX p4FromY:(float)p4FromY
error:(NSError **)error;
- (ZXBitMatrix *)sampleGrid:(ZXBitMatrix *)image
dimensionX:(int)dimensionX
dimensionY:(int)dimensionY
transform:(ZXPerspectiveTransform *)transform
error:(NSError **)error;
/**
* <p>Checks a set of points that have been transformed to sample points on an image against
* the image's dimensions to see if the point are even within the image.</p>
*
* <p>This method will actually "nudge" the endpoints back onto the image if they are found to be
* barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder
* patterns in an image where the QR Code runs all the way to the image border.</p>
*
* <p>For efficiency, the method will check points from either end of the line until one is found
* to be within the image. Because the set of points are assumed to be linear, this is valid.</p>
*
* @param image image into which the points should map
* @param points actual points in x1,y1,...,xn,yn form
* @returns NO if an endpoint is lies outside the image boundaries
*/
+ (BOOL)checkAndNudgePoints:(ZXBitMatrix *)image points:(float *)points pointsLen:(int)pointsLen error:(NSError **)error;
@end
/*
* Copyright 2012 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 "ZXGlobalHistogramBinarizer.h"
@class ZXBinarizer, ZXBitMatrix, ZXLuminanceSource;
/**
* This class implements a local thresholding algorithm, which while slower than the
* ZXGlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for
* high frequency images of barcodes with black data on white backgrounds. For this application,
* it does a much better job than a global blackpoint with severe shadows and gradients.
* However it tends to produce artifacts on lower frequency images and is therefore not
* a good general purpose binarizer for uses outside ZXing.
*
* This class extends ZXGlobalHistogramBinarizer, using the older histogram approach for 1D readers,
* and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already
* inherently local, and only fails for horizontal gradients. We can revisit that problem later,
* but for now it was not a win to use local blocks for 1D.
*
* This Binarizer is the default for the unit tests and the recommended class for library users.
*/
@interface ZXHybridBinarizer : ZXGlobalHistogramBinarizer
@end
/*
* Copyright 2014 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.
*/
@interface ZXIntArray : NSObject <NSCopying>
@property (nonatomic, assign, readonly) int32_t *array;
@property (nonatomic, assign, readonly) unsigned int length;
- (id)initWithLength:(unsigned int)length;
- (id)initWithInts:(int32_t)int1, ...;
- (void)clear;
- (int)sum;
@end
/*
* Copyright 2012 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.
*/
/**
* This class implements a perspective transform in two dimensions. Given four source and four
* destination points, it will compute the transformation implied between them. The code is based
* directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.
*/
@interface ZXPerspectiveTransform : NSObject
+ (ZXPerspectiveTransform *)quadrilateralToQuadrilateral:(float)x0 y0:(float)y0 x1:(float)x1 y1:(float)y1 x2:(float)x2 y2:(float)y2 x3:(float)x3 y3:(float)y3 x0p:(float)x0p y0p:(float)y0p x1p:(float)x1p y1p:(float)y1p x2p:(float)x2p y2p:(float)y2p x3p:(float)x3p y3p:(float)y3p;
- (void)transformPoints:(float *)points pointsLen:(int)pointsLen;
- (void)transformPoints:(float *)xValues yValues:(float *)yValues pointsLen:(int)pointsLen;
+ (ZXPerspectiveTransform *)squareToQuadrilateral:(float)x0 y0:(float)y0 x1:(float)x1 y1:(float)y1 x2:(float)x2 y2:(float)y2 x3:(float)x3 y3:(float)y3;
+ (ZXPerspectiveTransform *)quadrilateralToSquare:(float)x0 y0:(float)y0 x1:(float)x1 y1:(float)y1 x2:(float)x2 y2:(float)y2 x3:(float)x3 y3:(float)y3;
- (ZXPerspectiveTransform *)buildAdjoint;
- (ZXPerspectiveTransform *)times:(ZXPerspectiveTransform *)other;
@end
/*
* Copyright 2012 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.
*/
@class ZXByteArray, ZXDecodeHints;
/**
* Common string-related functions.
*/
@interface ZXStringUtils : NSObject
/**
* @param bytes bytes encoding a string, whose encoding should be guessed
* @param hints decode hints if applicable
* @return name of guessed encoding; at the moment will only guess one of:
* NSShiftJISStringEncoding, NSUTF8StringEncoding, NSISOLatin1StringEncoding, or the platform
* default encoding if none of these can possibly be correct
*/
+ (NSStringEncoding)guessEncoding:(ZXByteArray *)bytes hints:(ZXDecodeHints *)hints;
+ (NSStringEncoding)uchardetGuessEncoding:(ZXByteArray *)bytes hints:(ZXDecodeHints *)hints autoDecodeCharset:(BOOL)autoDecodeCharset charset:(NSString*)charset;
@end
/*
* Copyright 2012 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.
*/
@interface ZXMathUtils : NSObject
+ (int)round:(float)d;
+ (float)distance:(float)aX aY:(float)aY bX:(float)bX bY:(float)bY;
+ (float)distanceInt:(int)aX aY:(int)aY bX:(int)bX bY:(int)bY;
@end
/*
* Copyright 2012 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.
*/
@class ZXBitMatrix;
/**
* A somewhat generic detector that looks for a barcode-like rectangular region within an image.
* It looks within a mostly white region of an image for a region of black and white, but mostly
* black. It returns the four corners of the region, as best it can determine.
*/
@interface ZXMonochromeRectangleDetector : NSObject
- (id)initWithImage:(ZXBitMatrix *)image;
/**
* Detects a rectangular region of black and white -- mostly black -- with a region of mostly
* white, in an image.
*
* @return ZXResultPoint array describing the corners of the rectangular region. The first and
* last points are opposed on the diagonal, as are the second and third. The first point will be
* the topmost point and the last, the bottommost. The second point will be leftmost and the
* third, the rightmost
* @return nil if no Data Matrix Code can be found
*/
- (NSArray *)detectWithError:(NSError **)error;
@end
/*
* Copyright 2012 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 "ZXResultPoint.h"
#import "ZXBitMatrix.h"
/**
* Detects a candidate barcode-like rectangular region within an image. It
* starts around the center of the image, increases the size of the candidate
* region until it finds a white rectangular region. By keeping track of the
* last black points it encountered, it determines the corners of the barcode.
*/
@interface ZXWhiteRectangleDetector : NSObject
- (id)initWithImage:(ZXBitMatrix *)image error:(NSError **)error;
- (id)initWithImage:(ZXBitMatrix *)image initSize:(int)initSize x:(int)x y:(int)y error:(NSError **)error;
/**
* Detects a candidate barcode-like rectangular region within an image. It
* starts around the center of the image, increases the size of the candidate
* region until it finds a white rectangular region.
*
* @return {@link ResultPoint}[] describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost
* @return nil if no Data Matrix Code can be found
*/
- (NSArray *)detectWithError:(NSError **)error;
@end
/*
* Copyright 2012 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.
*/
@class ZXGenericGFPoly;
/**
* This class contains utility methods for performing mathematical operations over
* the Galois Fields. Operations use a given primitive polynomial in calculations.
*
* Throughout this package, elements of the GF are represented as an int
* for convenience and speed (but at the cost of memory).
*/
@interface ZXGenericGF : NSObject
@property (nonatomic, strong, readonly) ZXGenericGFPoly *zero;
@property (nonatomic, strong, readonly) ZXGenericGFPoly *one;
@property (nonatomic, assign, readonly) int32_t size;
@property (nonatomic, assign, readonly) int32_t generatorBase;
+ (ZXGenericGF *)AztecData12;
+ (ZXGenericGF *)AztecData10;
+ (ZXGenericGF *)AztecData6;
+ (ZXGenericGF *)AztecParam;
+ (ZXGenericGF *)QrCodeField256;
+ (ZXGenericGF *)DataMatrixField256;
+ (ZXGenericGF *)AztecData8;
+ (ZXGenericGF *)MaxiCodeField64;
/**
* Create a representation of GF(size) using the given primitive polynomial.
*
* @param primitive irreducible polynomial whose coefficients are represented by
* the bits of an int, where the least-significant bit represents the constant
* coefficient
* @param size the size of the field
* @param b the factor b in the generator polynomial can be 0- or 1-based
* (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))).
* In most cases it should be 1, but for QR code it is 0.
*/
- (id)initWithPrimitive:(int)primitive size:(int)size b:(int)b;
/**
* @return the monomial representing coefficient * x^degree
*/
- (ZXGenericGFPoly *)buildMonomial:(int)degree coefficient:(int)coefficient;
/**
* Implements both addition and subtraction -- they are the same in GF(size).
*
* @return sum/difference of a and b
*/
+ (int32_t)addOrSubtract:(int32_t)a b:(int32_t)b;
/**
* @return 2 to the power of a in GF(size)
*/
- (int32_t)exp:(int)a;
/**
* @return base 2 log of a in GF(size)
*/
- (int32_t)log:(int)a;
/**
* @return multiplicative inverse of a
*/
- (int32_t)inverse:(int)a;
/**
* @return product of a and b in GF(size)
*/
- (int32_t)multiply:(int)a b:(int)b;
@end
/*
* Copyright 2012 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.
*/
@class ZXGenericGF, ZXIntArray;
/**
* Represents a polynomial whose coefficients are elements of a GF.
* Instances of this class are immutable.
*
* Much credit is due to William Rucklidge since portions of this code are an indirect
* port of his C++ Reed-Solomon implementation.
*/
@interface ZXGenericGFPoly : NSObject
@property (nonatomic, strong, readonly) ZXIntArray *coefficients;
/**
* @param field the {@link GenericGF} instance representing the field to use
* to perform computations
* @param coefficients coefficients as ints representing elements of GF(size), arranged
* from most significant (highest-power term) coefficient to least significant
*/
- (id)initWithField:(ZXGenericGF *)field coefficients:(ZXIntArray *)coefficients;
/**
* @return degree of this polynomial
*/
- (int)degree;
/**
* @return true iff this polynomial is the monomial "0"
*/
- (BOOL)zero;
/**
* @return coefficient of x^degree term in this polynomial
*/
- (int)coefficient:(int)degree;
/**
* @return evaluation of this polynomial at a given point
*/
- (int)evaluateAt:(int)a;
- (ZXGenericGFPoly *)addOrSubtract:(ZXGenericGFPoly *)other;
- (ZXGenericGFPoly *)multiply:(ZXGenericGFPoly *)other;
- (ZXGenericGFPoly *)multiplyScalar:(int)scalar;
- (ZXGenericGFPoly *)multiplyByMonomial:(int)degree coefficient:(int)coefficient;
- (NSArray *)divide:(ZXGenericGFPoly *)other;
@end
/*
* Copyright 2012 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.
*/
@class ZXGenericGF, ZXIntArray;
/**
* Implements Reed-Solomon decoding, as the name implies.
*
* The algorithm will not be explained here, but the following references were helpful
* in creating this implementation:
*
* Bruce Maggs.
* http://www.cs.cmu.edu/afs/cs.cmu.edu/project/pscico-guyb/realworld/www/rs_decode.ps
* "Decoding Reed-Solomon Codes" (see discussion of Forney's Formula)
*
* J.I. Hall. www.mth.msu.edu/~jhall/classes/codenotes/GRS.pdf
* "Chapter 5. Generalized Reed-Solomon Codes"
* (see discussion of Euclidean algorithm)
*
* Much credit is due to William Rucklidge since portions of this code are an indirect
* port of his C++ Reed-Solomon implementation.
*/
@interface ZXReedSolomonDecoder : NSObject
- (id)initWithField:(ZXGenericGF *)field;
/**
* Decodes given set of received codewords, which include both data and error-correction
* codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
* in the input.
*
* @param received data and error-correction codewords
* @param twoS number of error-correction codewords available
* @return NO if decoding fails for any reason
*/
- (BOOL)decode:(ZXIntArray *)received twoS:(int)twoS error:(NSError **)error;
@end
/*
* Copyright 2012 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.
*/
@class ZXGenericGF, ZXIntArray;
/**
* Implements Reed-Solomon enbcoding, as the name implies.
*/
@interface ZXReedSolomonEncoder : NSObject
- (id)initWithField:(ZXGenericGF *)field;
- (void)encode:(ZXIntArray *)toEncode ecBytes:(int)ecBytes;
@end
/*
* Copyright 2012 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.
*/
/**
* Enumerates barcode formats known to this package. Please keep alphabetized.
*/
typedef enum {
/** Aztec 2D barcode format. */
kBarcodeFormatAztec,
/** CODABAR 1D format. */
kBarcodeFormatCodabar,
/** Code 39 1D format. */
kBarcodeFormatCode39,
/** Code 93 1D format. */
kBarcodeFormatCode93,
/** Code 128 1D format. */
kBarcodeFormatCode128,
/** Data Matrix 2D barcode format. */
kBarcodeFormatDataMatrix,
/** EAN-8 1D format. */
kBarcodeFormatEan8,
/** EAN-13 1D format. */
kBarcodeFormatEan13,
/** ITF (Interleaved Two of Five) 1D format. */
kBarcodeFormatITF,
/** MaxiCode 2D barcode format. */
kBarcodeFormatMaxiCode,
/** PDF417 format. */
kBarcodeFormatPDF417,
/** QR Code 2D barcode format. */
kBarcodeFormatQRCode,
/** RSS 14 */
kBarcodeFormatRSS14,
/** RSS EXPANDED */
kBarcodeFormatRSSExpanded,
/** UPC-A 1D format. */
kBarcodeFormatUPCA,
/** UPC-E 1D format. */
kBarcodeFormatUPCE,
/** UPC/EAN extension format. Not a stand-alone format. */
kBarcodeFormatUPCEANExtension
} ZXBarcodeFormat;
/*
* Copyright 2012 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 <CoreGraphics/CoreGraphics.h>
#import "ZXBitArray.h"
#import "ZXBitMatrix.h"
#import "ZXLuminanceSource.h"
/**
* This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
* It allows the algorithm to vary polymorphically, for example allowing a very expensive
* thresholding technique for servers and a fast one for mobile. It also permits the implementation
* to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
*/
@interface ZXBinarizer : NSObject
@property (nonatomic, strong, readonly) ZXLuminanceSource *luminanceSource;
@property (nonatomic, assign, readonly) int width;
@property (nonatomic, assign, readonly) int height;
- (id)initWithSource:(ZXLuminanceSource *)source;
+ (id)binarizerWithSource:(ZXLuminanceSource *)source;
/**
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
* For callers which only examine one row of pixels at a time, the same BitArray should be reused
* and passed in with each call for performance. However it is legal to keep more than one row
* at a time if needed.
*
* @param y The row to fetch, 0 <= y < bitmap height.
* @param row An optional preallocated array. If null or too small, it will be ignored.
* If used, the Binarizer will call ZXBitArray clear. Always use the returned object.
* @return The array of bits for this row (true means black).
*/
- (ZXBitArray *)blackRow:(int)y row:(ZXBitArray *)row error:(NSError **)error;
/**
* Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
* fetched using getBlackRow(), so don't mix and match between them.
*
* @return The 2D array of bits for the image (true means black).
*/
- (ZXBitMatrix *)blackMatrixWithError:(NSError **)error;
/**
* Creates a new object with the same type as this Binarizer implementation, but with pristine
* state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
* of 1 bit data. See Effective Java for why we can't use Java's clone() method.
*
* @param source The LuminanceSource this Binarizer will operate on.
* @return A new concrete Binarizer implementation object.
*/
- (ZXBinarizer *)createBinarizer:(ZXLuminanceSource *)source;
- (CGImageRef)createImage CF_RETURNS_RETAINED;
@end
/*
* Copyright 2012 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.
*/
@class ZXBinarizer, ZXBitArray, ZXBitMatrix;
/**
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
* accept a BinaryBitmap and attempt to decode it.
*/
@interface ZXBinaryBitmap : NSObject
/**
* @return The width of the bitmap.
*/
@property (nonatomic, readonly) int width;
/**
* @return The height of the bitmap.
*/
@property (nonatomic, readonly) int height;
/**
* @return Whether this bitmap can be cropped.
*/
@property (nonatomic, readonly) BOOL cropSupported;
/**
* @return Whether this bitmap supports counter-clockwise rotation.
*/
@property (nonatomic, readonly) BOOL rotateSupported;
- (id)initWithBinarizer:(ZXBinarizer *)binarizer;
+ (id)binaryBitmapWithBinarizer:(ZXBinarizer *)binarizer;
/**
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
*
* @param y The row to fetch, 0 <= y < bitmap height.
* @param row An optional preallocated array. If null or too small, it will be ignored.
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
* @return The array of bits for this row (true means black).
*/
- (ZXBitArray *)blackRow:(int)y row:(ZXBitArray *)row error:(NSError **)error;
/**
* Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
* fetched using getBlackRow(), so don't mix and match between them.
*
* @return The 2D array of bits for the image (true means black).
*/
- (ZXBitMatrix *)blackMatrixWithError:(NSError **)error;
/**
* Returns a new object with cropped image data. Implementations may keep a reference to the
* original data rather than a copy. Only callable if isCropSupported() is true.
*
* @param left The left coordinate, 0 <= left < getWidth().
* @param top The top coordinate, 0 <= top <= getHeight().
* @param width The width of the rectangle to crop.
* @param height The height of the rectangle to crop.
* @return A cropped version of this object.
*/
- (ZXBinaryBitmap *)crop:(int)left top:(int)top width:(int)width height:(int)height;
/**
* Returns a new object with rotated image data by 90 degrees counterclockwise.
* Only callable if {@link #isRotateSupported()} is true.
*
* @return A rotated version of this object.
*/
- (ZXBinaryBitmap *)rotateCounterClockwise;
/**
* Returns a new object with rotated image data by 45 degrees counterclockwise.
* Only callable if {@link #isRotateSupported()} is true.
*
* @return A rotated version of this object.
*/
- (ZXBinaryBitmap *)rotateCounterClockwise45;
@end
/*
* Copyright 2012 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.
*/
@interface ZXByteMatrix : NSObject
@property (nonatomic, assign, readonly) int8_t **array;
@property (nonatomic, assign, readonly) int height;
@property (nonatomic, assign, readonly) int width;
- (id)initWithWidth:(int)width height:(int)height;
- (int8_t)getX:(int)x y:(int)y;
- (void)setX:(int)x y:(int)y byteValue:(int8_t)value;
- (void)setX:(int)x y:(int)y intValue:(int32_t)value;
- (void)setX:(int)x y:(int)y boolValue:(BOOL)value;
- (void)clear:(int8_t)value;
@end
/*
* Copyright 2012 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 "ZXBarcodeFormat.h"
@protocol ZXResultPointCallback;
@class ZXIntArray;
/**
* Encapsulates hints that a caller may pass to a barcode reader to help it
* more quickly or accurately decode it. It is up to implementations to decide what,
* if anything, to do with the information that is supplied.
*/
@interface ZXDecodeHints : NSObject <NSCopying>
+ (id)hints;
/**
* Assume Code 39 codes employ a check digit.
*/
@property (nonatomic, assign) BOOL assumeCode39CheckDigit;
/**
* Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed.
* For example this affects FNC1 handling for Code 128 (aka GS1-128).
*/
@property (nonatomic, assign) BOOL assumeGS1;
/**
* Allowed lengths of encoded data -- reject anything else.
*/
@property (nonatomic, strong) NSArray *allowedLengths;
/**
* Specifies what character encoding to use when decoding, where applicable (type String)
*/
@property (nonatomic, assign) NSStringEncoding encoding;
/**
* Unspecified, application-specific hint.
*/
@property (nonatomic, strong) id other;
/**
* Image is a pure monochrome image of a barcode.
*/
@property (nonatomic, assign) BOOL pureBarcode;
/**
* If true, return the start and end digits in a Codabar barcode instead of stripping them. They
* are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them
* to not be.
*/
@property (nonatomic, assign) BOOL returnCodaBarStartEnd;
/**
* The caller needs to be notified via callback when a possible ZXResultPoint
* is found.
*/
@property (nonatomic, strong) id <ZXResultPointCallback> resultPointCallback;
/**
* Spend more time to try to find a barcode; optimize for accuracy, not speed.
*/
@property (nonatomic, assign) BOOL tryHarder;
/**
* Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this.
* Maps to an ZXIntArray of the allowed extension lengths, for example [2], [5], or [2, 5].
* If it is optional to have an extension, do not set this hint. If this is set,
* and a UPC or EAN barcode is found but an extension is not, then no result will be returned
* at all.
*/
@property (nonatomic, strong) ZXIntArray *allowedEANExtensions;
/**
* Image is known to be of one of a few possible formats.
*/
- (void)addPossibleFormat:(ZXBarcodeFormat)format;
- (BOOL)containsFormat:(ZXBarcodeFormat)format;
- (int)numberOfPossibleFormats;
- (void)removePossibleFormat:(ZXBarcodeFormat)format;
@end
\ No newline at end of file
/*
* 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
/*
* Copyright 2012 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.
*/
/**
* Enumeration for DataMatrix symbol shape hint. It can be used to force square or rectangular
* symbols.
*/
typedef enum {
ZXDataMatrixSymbolShapeHintForceNone,
ZXDataMatrixSymbolShapeHintForceSquare,
ZXDataMatrixSymbolShapeHintForceRectangle
} ZXDataMatrixSymbolShapeHint;
typedef enum {
ZXPDF417CompactionAuto,
ZXPDF417CompactionText,
ZXPDF417CompactionByte,
ZXPDF417CompactionNumeric
} ZXPDF417Compaction;
@class ZXDimension, ZXPDF417Dimensions, ZXQRCodeErrorCorrectionLevel;
/**
* These are a set of hints that you may pass to Writers to specify their behavior.
*/
@interface ZXEncodeHints : NSObject
+ (id)hints;
/**
* Specifies what character encoding to use where applicable.
*/
@property (nonatomic, assign) NSStringEncoding encoding;
/**
* Specifies the matrix shape for Data Matrix.
*/
@property (nonatomic, assign) ZXDataMatrixSymbolShapeHint dataMatrixShape;
/**
* Specifies a minimum barcode size. Only applicable to Data Matrix now.
*
* @deprecated use width/height params in
* ZXDataMatrixWriter encode:format:width:height:error:
*/
@property (nonatomic, strong) ZXDimension *minSize DEPRECATED_ATTRIBUTE;
/**
* Specifies a maximum barcode size. Only applicable to Data Matrix now.
*
* @deprecated without replacement
*/
@property (nonatomic, strong) ZXDimension *maxSize DEPRECATED_ATTRIBUTE;
/**
* Specifies what degree of error correction to use, for example in QR Codes.
* For Aztec it represents the minimal percentage of error correction words.
* Note: an Aztec symbol should have a minimum of 25% EC words.
*/
@property (nonatomic, strong) ZXQRCodeErrorCorrectionLevel *errorCorrectionLevel;
/**
* Specifies what percent of error correction to use.
* For Aztec it represents the minimal percentage of error correction words.
* Note: an Aztec symbol should have a minimum of 25% EC words.
*/
@property (nonatomic, strong) NSNumber *errorCorrectionPercent;
/**
* Specifies margin, in pixels, to use when generating the barcode. The meaning can vary
* by format; for example it controls margin before and after the barcode horizontally for
* most 1D formats.
*/
@property (nonatomic, strong) NSNumber *margin;
/**
* Specifies whether to use compact mode for PDF417.
*/
@property (nonatomic, assign) BOOL pdf417Compact;
/**
* Specifies what compaction mode to use for PDF417.
*/
@property (nonatomic, assign) ZXPDF417Compaction pdf417Compaction;
/**
* Specifies the minimum and maximum number of rows and columns for PDF417.
*/
@property (nonatomic, strong) ZXPDF417Dimensions *pdf417Dimensions;
/**
* Specifies the required number of layers for an Aztec code:
* a negative number (-1, -2, -3, -4) specifies a compact Aztec code
* 0 indicates to use the minimum number of layers (the default)
* a positive number (1, 2, .. 32) specifies a normaol (non-compact) Aztec code
*/
@property (nonatomic, strong) NSNumber *aztecLayers;
@end
/*
* Copyright 2012 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.
*/
#define ZXErrorDomain @"ZXErrorDomain"
enum {
/**
* Thrown when a barcode was successfully detected and decoded, but
* was not returned because its checksum feature failed.
*/
ZXChecksumError = 1000,
/**
* Thrown when a barcode was successfully detected, but some aspect of
* the content did not conform to the barcode's format rules. This could have
* been due to a mis-detection.
*/
ZXFormatError = 1001,
/**
* Thrown when a barcode was not found in the image. It might have been
* partially detected but could not be confirmed.
*/
ZXNotFoundError = 1002,
/**
* Thrown when an exception occurs during Reed-Solomon decoding, such as when
* there are too many errors to correct.
*/
ZXReedSolomonError = 1003,
/**
* This general error is thrown when something goes wrong during decoding of a barcode.
* This includes, but is not limited to, failing checksums / error correction algorithms, being
* unable to locate finder timing patterns, and so on.
*/
ZXReaderError = 1004,
/**
* Covers the range of error which may occur when encoding a barcode using the Writer framework.
*/
ZXWriterError = 1005
};
// Helper methods for error instances
NSError *ZXChecksumErrorInstance(void);
NSError *ZXFormatErrorInstance(void);
NSError *ZXNotFoundErrorInstance(void);
/*
* 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 "ZXLuminanceSource.h"
/**
* A wrapper implementation of ZXLuminanceSource which inverts the luminances it returns -- black becomes
* white and vice versa, and each value becomes (255-value).
*/
@interface ZXInvertedLuminanceSource : ZXLuminanceSource
- (id)initWithDelegate:(ZXLuminanceSource *)delegate;
@end
/*
* Copyright 2012 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.
*/
@class ZXByteArray;
/**
* The purpose of this class hierarchy is to abstract different bitmap implementations across
* platforms into a standard interface for requesting greyscale luminance values. The interface
* only provides immutable methods; therefore crop and rotation create copies. This is to ensure
* that one Reader does not modify the original luminance source and leave it in an unknown state
* for other Readers in the chain.
*/
@interface ZXLuminanceSource : NSObject
/**
* @return The width of the bitmap.
*/
@property (nonatomic, assign, readonly) int width;
/**
* @return The height of the bitmap.
*/
@property (nonatomic, assign, readonly) int height;
/**
* @return Whether this subclass supports cropping.
*/
@property (nonatomic, assign, readonly) BOOL cropSupported;
/**
* @return Whether this subclass supports counter-clockwise rotation.
*/
@property (nonatomic, assign, readonly) BOOL rotateSupported;
- (id)initWithWidth:(int)width height:(int)height;
/**
* Fetches one row of luminance data from the underlying platform's bitmap. Values range from
* 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
* to bitwise and with 0xff for each value. It is preferable for implementations of this method
* to only fetch this row rather than the whole image, since no 2D Readers may be installed and
* getMatrix() may never be called.
*
* @param y The row to fetch, 0 <= y < getHeight().
* @param row An optional preallocated array. If null or too small, it will be ignored.
* Always use the returned object, and ignore the .length of the array.
* @return An array containing the luminance data.
*/
- (ZXByteArray *)rowAtY:(int)y row:(ZXByteArray *)row;
/**
* Fetches luminance data for the underlying bitmap. Values should be fetched using:
* int luminance = array[y * width + x] & 0xff;
*
* @return A row-major 2D array of luminance values. Do not use result.length as it may be
* larger than width * height bytes on some platforms. Do not modify the contents
* of the result.
*/
- (ZXByteArray *)matrix;
/**
* Returns a new object with cropped image data. Implementations may keep a reference to the
* original data rather than a copy. Only callable if isCropSupported() is true.
*
* @param left The left coordinate, 0 <= left < getWidth().
* @param top The top coordinate, 0 <= top <= getHeight().
* @param width The width of the rectangle to crop.
* @param height The height of the rectangle to crop.
* @return A cropped version of this object.
*/
- (ZXLuminanceSource *)crop:(int)left top:(int)top width:(int)width height:(int)height;
/**
* @return a wrapper of this ZXLuminanceSource which inverts the luminances it returns -- black becomes
* white and vice versa, and each value becomes (255-value).
*/
- (ZXLuminanceSource *)invert;
/**
* Returns a new object with rotated image data by 90 degrees counterclockwise.
* Only callable if isRotateSupported is true.
*
* @return A rotated version of this object.
*/
- (ZXLuminanceSource *)rotateCounterClockwise;
/**
* Returns a new object with rotated image data by 45 degrees counterclockwise.
* Only callable if isRotateSupported is true.
*
* @return A rotated version of this object.
*/
- (ZXLuminanceSource *)rotateCounterClockwise45;
@end
/*
* Copyright 2012 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 "ZXLuminanceSource.h"
/**
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
* with the option to crop to a rectangle within the full data. This can be used to exclude
* superfluous pixels around the perimeter and speed up decoding.
*
* It works for any pixel format where the Y channel is planar and appears first, including
* YCbCr_420_SP and YCbCr_422_SP.
*/
@interface ZXPlanarYUVLuminanceSource : ZXLuminanceSource
/**
* @return width of image from renderThumbnail
*/
@property (nonatomic, assign, readonly) int thumbnailWidth;
/**
* @return height of image from renderThumbnail
*/
@property (nonatomic, assign, readonly) int thumbnailHeight;
- (id)initWithYuvData:(int8_t *)yuvData yuvDataLen:(int)yuvDataLen dataWidth:(int)dataWidth
dataHeight:(int)dataHeight left:(int)left top:(int)top width:(int)width height:(int)height
reverseHorizontal:(BOOL)reverseHorizontal;
- (int32_t *)renderThumbnail;
@end
/*
* Copyright 2012 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 "ZXLuminanceSource.h"
/**
* This class is used to help decode images from files which arrive as RGB data from
* an ARGB pixel array. It does not support rotation.
*/
@interface ZXRGBLuminanceSource : ZXLuminanceSource
- (id)initWithWidth:(int)width height:(int)height pixels:(int32_t *)pixels pixelsLen:(int)pixelsLen;
@end
/*
* Copyright 2012 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.
*/
@class ZXBinaryBitmap, ZXDecodeHints, ZXResult;
/**
* Implementations of this interface can decode an image of a barcode in some format into
* the String it encodes. For example, ZXQRCodeReader can
* decode a QR code. The decoder may optionally receive hints from the caller which may help
* it decode more quickly or accurately.
*
* See ZXMultiFormatReader, which attempts to determine what barcode
* format is present within the image as well, and then decodes it accordingly.
*/
@protocol ZXReader <NSObject>
/**
* Locates and decodes a barcode in some format within an image.
*
* @param image image of barcode to decode
* @return String which the barcode encodes or nil if
* the barcode cannot be located or decoded for any reason
*/
- (ZXResult *)decode:(ZXBinaryBitmap *)image error:(NSError **)error;
/**
* Locates and decodes a barcode in some format within an image. This method also accepts
* hints, each possibly associated to some data, which may help the implementation decode.
*
* @param image image of barcode to decode
* @param hints passed as a {@link java.util.Map} from {@link com.google.zxing.DecodeHintType}
* to arbitrary data. The
* meaning of the data depends upon the hint type. The implementation may or may not do
* anything with these hints.
* @return String which the barcode encodes or nil if
* the barcode cannot be located or decoded for any reason
*/
- (ZXResult *)decode:(ZXBinaryBitmap *)image hints:(ZXDecodeHints *)hints error:(NSError **)error autoDecodeCharset:(BOOL)autoDecodeCharset;
/**
* Resets any internal state the implementation has after a decode, to prepare it
* for reuse.
*/
- (void)reset;
@end
/*
* Copyright 2012 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 "ZXBarcodeFormat.h"
#import "ZXResultMetadataType.h"
@class ZXByteArray;
/**
* Encapsulates the result of decoding a barcode within an image.
*/
@interface ZXResult : NSObject
/**
* @return raw text encoded by the barcode
*/
@property (nonatomic, copy, readonly) NSString *text;
/**
* @return raw bytes encoded by the barcode, if applicable, otherwise nil
*/
@property (nonatomic, strong, readonly) ZXByteArray *rawBytes;
/**
* @return points related to the barcode in the image. These are typically points
* identifying finder patterns or the corners of the barcode. The exact meaning is
* specific to the type of barcode that was decoded.
*/
@property (nonatomic, strong, readonly) NSMutableArray *resultPoints;
/**
* @return ZXBarcodeFormat representing the format of the barcode that was decoded
*/
@property (nonatomic, assign, readonly) ZXBarcodeFormat barcodeFormat;
/**
* @return NSDictionary mapping ZXResultMetadataType keys to values. May be
* nil. This contains optional metadata about what was detected about the barcode,
* like orientation.
*/
@property (nonatomic, strong, readonly) NSMutableDictionary *resultMetadata;
@property (nonatomic, assign, readonly) long timestamp;
- (id)initWithText:(NSString *)text rawBytes:(ZXByteArray *)rawBytes resultPoints:(NSArray *)resultPoints format:(ZXBarcodeFormat)format;
- (id)initWithText:(NSString *)text rawBytes:(ZXByteArray *)rawBytes resultPoints:(NSArray *)resultPoints format:(ZXBarcodeFormat)format timestamp:(long)timestamp;
+ (id)resultWithText:(NSString *)text rawBytes:(ZXByteArray *)rawBytes resultPoints:(NSArray *)resultPoints format:(ZXBarcodeFormat)format;
+ (id)resultWithText:(NSString *)text rawBytes:(ZXByteArray *)rawBytes resultPoints:(NSArray *)resultPoints format:(ZXBarcodeFormat)format timestamp:(long)timestamp;
- (void)putMetadata:(ZXResultMetadataType)type value:(id)value;
- (void)putAllMetadata:(NSMutableDictionary *)metadata;
- (void)addResultPoints:(NSArray *)newPoints;
@end
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册