modernize iphone & objective c for 1d

git-svn-id: https://zxing.googlecode.com/svn/trunk@2609 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2013-04-01 06:00:53 +00:00
parent af53906502
commit 98e5f33f93
19 changed files with 245 additions and 132 deletions

View file

@ -19,6 +19,7 @@
#include <zxing/BarcodeFormat.h>
const char* zxing::BarcodeFormat::barcodeFormatNames[] = {
0,
"AZTEC",
"CODABAR",
"CODE_39",
@ -35,5 +36,5 @@ const char* zxing::BarcodeFormat::barcodeFormatNames[] = {
"RSS_EXPANDED",
"UPC_A",
"UPC_E",
"UPC_EAN_EXTENSION",
"UPC_EAN_EXTENSION"
};

View file

@ -28,6 +28,7 @@ namespace zxing {
class zxing::BarcodeFormat {
public:
enum Value {
NONE,
AZTEC,
CODABAR,
CODE_39,

View file

@ -23,12 +23,14 @@
#include <zxing/Exception.h>
namespace zxing {
class IllegalArgumentException : public zxing::Exception {
class IllegalArgumentException;
}
class zxing::IllegalArgumentException : public zxing::Exception {
public:
IllegalArgumentException();
IllegalArgumentException(const char *msg);
~IllegalArgumentException() throw();
};
}
#endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__

View file

@ -37,7 +37,7 @@ public:
explicit String(const std::string &text);
char charAt(int) const;
Ref<String> substring(int) const;
const std::string &getText() const;
const std::string& getText() const;
int size() const;
int length() const;
friend std::ostream& zxing::operator << (std::ostream& out, String const& s);

View file

@ -7,6 +7,12 @@
objects = {
/* Begin PBXBuildFile section */
3B5A492F17091807004E112F /* ChecksumException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A492D17091807004E112F /* ChecksumException.cpp */; };
3B5A493017091807004E112F /* ChecksumException.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5A492E17091807004E112F /* ChecksumException.h */; };
3B5A493517091826004E112F /* CodaBarReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A493117091826004E112F /* CodaBarReader.cpp */; };
3B5A493617091826004E112F /* CodaBarReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5A493217091826004E112F /* CodaBarReader.h */; };
3B5A493717091826004E112F /* Code93Reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A493317091826004E112F /* Code93Reader.cpp */; };
3B5A493817091826004E112F /* Code93Reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5A493417091826004E112F /* Code93Reader.h */; };
3B83E992158E66C600A3B31F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B83E991158E66C600A3B31F /* Foundation.framework */; };
3B83EA63158E679000A3B31F /* AztecDetectorResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83E9A4158E679000A3B31F /* AztecDetectorResult.cpp */; };
3B83EA64158E679000A3B31F /* AztecDetectorResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83E9A5158E679000A3B31F /* AztecDetectorResult.h */; };
@ -113,7 +119,6 @@
3B83EAC9158E679000A3B31F /* QRCodeMultiReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA15158E679000A3B31F /* QRCodeMultiReader.h */; };
3B83EACA158E679000A3B31F /* MultiFormatReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA16158E679000A3B31F /* MultiFormatReader.cpp */; };
3B83EACB158E679000A3B31F /* MultiFormatReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA17158E679000A3B31F /* MultiFormatReader.h */; };
3B83EACC158E679000A3B31F /* NotFoundException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA18158E679000A3B31F /* NotFoundException.cpp */; };
3B83EACD158E679000A3B31F /* NotFoundException.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA19158E679000A3B31F /* NotFoundException.h */; };
3B83EACE158E679000A3B31F /* Code128Reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA1B158E679000A3B31F /* Code128Reader.cpp */; };
3B83EACF158E679000A3B31F /* Code128Reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA1C158E679000A3B31F /* Code128Reader.h */; };
@ -175,7 +180,6 @@
3B83EB07158E679000A3B31F /* Version.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA58158E679000A3B31F /* Version.h */; };
3B83EB08158E679000A3B31F /* Reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA59158E679000A3B31F /* Reader.cpp */; };
3B83EB09158E679000A3B31F /* Reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA5A158E679000A3B31F /* Reader.h */; };
3B83EB0A158E679000A3B31F /* ReaderException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA5B158E679000A3B31F /* ReaderException.cpp */; };
3B83EB0B158E679000A3B31F /* ReaderException.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA5C158E679000A3B31F /* ReaderException.h */; };
3B83EB0C158E679000A3B31F /* Result.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B83EA5D158E679000A3B31F /* Result.cpp */; };
3B83EB0D158E679000A3B31F /* Result.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B83EA5E158E679000A3B31F /* Result.h */; };
@ -186,6 +190,12 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3B5A492D17091807004E112F /* ChecksumException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChecksumException.cpp; sourceTree = "<group>"; };
3B5A492E17091807004E112F /* ChecksumException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChecksumException.h; sourceTree = "<group>"; };
3B5A493117091826004E112F /* CodaBarReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodaBarReader.cpp; sourceTree = "<group>"; };
3B5A493217091826004E112F /* CodaBarReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodaBarReader.h; sourceTree = "<group>"; };
3B5A493317091826004E112F /* Code93Reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Code93Reader.cpp; sourceTree = "<group>"; };
3B5A493417091826004E112F /* Code93Reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Code93Reader.h; sourceTree = "<group>"; };
3B83E98E158E66C600A3B31F /* libzxing-cpp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libzxing-cpp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
3B83E991158E66C600A3B31F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3B83E9A4158E679000A3B31F /* AztecDetectorResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AztecDetectorResult.cpp; sourceTree = "<group>"; };
@ -293,7 +303,6 @@
3B83EA15158E679000A3B31F /* QRCodeMultiReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QRCodeMultiReader.h; sourceTree = "<group>"; };
3B83EA16158E679000A3B31F /* MultiFormatReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiFormatReader.cpp; sourceTree = "<group>"; };
3B83EA17158E679000A3B31F /* MultiFormatReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MultiFormatReader.h; sourceTree = "<group>"; };
3B83EA18158E679000A3B31F /* NotFoundException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotFoundException.cpp; sourceTree = "<group>"; };
3B83EA19158E679000A3B31F /* NotFoundException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotFoundException.h; sourceTree = "<group>"; };
3B83EA1B158E679000A3B31F /* Code128Reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Code128Reader.cpp; sourceTree = "<group>"; };
3B83EA1C158E679000A3B31F /* Code128Reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Code128Reader.h; sourceTree = "<group>"; };
@ -356,7 +365,6 @@
3B83EA58158E679000A3B31F /* Version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Version.h; sourceTree = "<group>"; };
3B83EA59158E679000A3B31F /* Reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Reader.cpp; sourceTree = "<group>"; };
3B83EA5A158E679000A3B31F /* Reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reader.h; sourceTree = "<group>"; };
3B83EA5B158E679000A3B31F /* ReaderException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReaderException.cpp; sourceTree = "<group>"; };
3B83EA5C158E679000A3B31F /* ReaderException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReaderException.h; sourceTree = "<group>"; };
3B83EA5D158E679000A3B31F /* Result.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Result.cpp; sourceTree = "<group>"; };
3B83EA5E158E679000A3B31F /* Result.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Result.h; sourceTree = "<group>"; };
@ -411,6 +419,8 @@
3B83E9A2158E679000A3B31F /* zxing */ = {
isa = PBXGroup;
children = (
3B5A492D17091807004E112F /* ChecksumException.cpp */,
3B5A492E17091807004E112F /* ChecksumException.h */,
3B83E9A3158E679000A3B31F /* aztec */,
3B83E9AE158E679000A3B31F /* BarcodeFormat.cpp */,
3B83E9AF158E679000A3B31F /* BarcodeFormat.h */,
@ -431,13 +441,11 @@
3B83EA07158E679000A3B31F /* multi */,
3B83EA16158E679000A3B31F /* MultiFormatReader.cpp */,
3B83EA17158E679000A3B31F /* MultiFormatReader.h */,
3B83EA18158E679000A3B31F /* NotFoundException.cpp */,
3B83EA19158E679000A3B31F /* NotFoundException.h */,
3B83EA1A158E679000A3B31F /* oned */,
3B83EA33158E679000A3B31F /* qrcode */,
3B83EA59158E679000A3B31F /* Reader.cpp */,
3B83EA5A158E679000A3B31F /* Reader.h */,
3B83EA5B158E679000A3B31F /* ReaderException.cpp */,
3B83EA5C158E679000A3B31F /* ReaderException.h */,
3B83EA5D158E679000A3B31F /* Result.cpp */,
3B83EA5E158E679000A3B31F /* Result.h */,
@ -634,6 +642,10 @@
3B83EA1A158E679000A3B31F /* oned */ = {
isa = PBXGroup;
children = (
3B5A493117091826004E112F /* CodaBarReader.cpp */,
3B5A493217091826004E112F /* CodaBarReader.h */,
3B5A493317091826004E112F /* Code93Reader.cpp */,
3B5A493417091826004E112F /* Code93Reader.h */,
3B83EA1B158E679000A3B31F /* Code128Reader.cpp */,
3B83EA1C158E679000A3B31F /* Code128Reader.h */,
3B83EA1D158E679000A3B31F /* Code39Reader.cpp */,
@ -824,6 +836,9 @@
3B83EB0D158E679000A3B31F /* Result.h in Headers */,
3B83EB0F158E679000A3B31F /* ResultPoint.h in Headers */,
3B83EB11158E679000A3B31F /* ResultPointCallback.h in Headers */,
3B5A493017091807004E112F /* ChecksumException.h in Headers */,
3B5A493617091826004E112F /* CodaBarReader.h in Headers */,
3B5A493817091826004E112F /* Code93Reader.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -853,7 +868,7 @@
3B83E985158E66C600A3B31F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
LastUpgradeCheck = 0460;
};
buildConfigurationList = 3B83E988158E66C600A3B31F /* Build configuration list for PBXProject "zxing-cpp" */;
compatibilityVersion = "Xcode 3.2";
@ -929,7 +944,6 @@
3B83EAC6158E679000A3B31F /* MultiFinderPatternFinder.cpp in Sources */,
3B83EAC8158E679000A3B31F /* QRCodeMultiReader.cpp in Sources */,
3B83EACA158E679000A3B31F /* MultiFormatReader.cpp in Sources */,
3B83EACC158E679000A3B31F /* NotFoundException.cpp in Sources */,
3B83EACE158E679000A3B31F /* Code128Reader.cpp in Sources */,
3B83EAD0158E679000A3B31F /* Code39Reader.cpp in Sources */,
3B83EAD2158E679000A3B31F /* EAN13Reader.cpp in Sources */,
@ -960,10 +974,12 @@
3B83EB04158E679000A3B31F /* QRCodeReader.cpp in Sources */,
3B83EB06158E679000A3B31F /* Version.cpp in Sources */,
3B83EB08158E679000A3B31F /* Reader.cpp in Sources */,
3B83EB0A158E679000A3B31F /* ReaderException.cpp in Sources */,
3B83EB0C158E679000A3B31F /* Result.cpp in Sources */,
3B83EB0E158E679000A3B31F /* ResultPoint.cpp in Sources */,
3B83EB10158E679000A3B31F /* ResultPointCallback.cpp in Sources */,
3B5A492F17091807004E112F /* ChecksumException.cpp in Sources */,
3B5A493517091826004E112F /* CodaBarReader.cpp in Sources */,
3B5A493717091826004E112F /* Code93Reader.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -980,6 +996,10 @@
armv7s,
armv7,
);
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@ -1017,6 +1037,10 @@
armv7s,
armv7,
);
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_THUMB_SUPPORT = NO;

View file

@ -26,13 +26,20 @@
#endif
#ifndef ZXAZ
#define ZXAZ 0
#define ZXAZ 1
#endif
#if ZXAZ
#import "AztecReader.h"
#endif
#ifndef ZX1D
#define ZX1D 1
#endif
#if ZX1D
#import "MultiFormatOneDReader.h"
#endif
@interface RootViewController()
@ -53,7 +60,8 @@
- (IBAction)scanPressed:(id)sender {
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
ZXingWidgetController *widController =
[[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
NSMutableSet *readers = [[NSMutableSet alloc ] init];
@ -69,6 +77,14 @@
[aztecReader release];
#endif
#if ZX1D
{
MultiFormatOneDReader* reader = [[MultiFormatOneDReader alloc] init];
[readers addObject:reader];
[reader release];
}
#endif
widController.readers = readers;
[readers release];

View file

@ -24,17 +24,24 @@
// This must remain parallel to zxing::BarcodeFormat.
typedef enum BarcodeFormat {
BarcodeFormat_None = 0,
BarcodeFormat_QR_CODE,
BarcodeFormat_DATA_MATRIX,
BarcodeFormat_UPC_E,
BarcodeFormat_UPC_A,
BarcodeFormat_EAN_8,
BarcodeFormat_EAN_13,
BarcodeFormat_CODE_128,
BarcodeFormat_CODE_39,
BarcodeFormat_ITF,
BarcodeFormat_AZTEC
BarcodeFormat_NONE,
BarcodeFormat_AZTEC,
BarcodeFormat_CODABAR,
BarcodeFormat_CODE_39,
BarcodeFormat_CODE_93,
BarcodeFormat_CODE_128,
BarcodeFormat_DATA_MATRIX,
BarcodeFormat_EAN_8,
BarcodeFormat_EAN_13,
BarcodeFormat_ITF,
BarcodeFormat_MAXICODE,
BarcodeFormat_PDF_417,
BarcodeFormat_QR_CODE,
BarcodeFormat_RSS_14,
BarcodeFormat_RSS_EXPANDED,
BarcodeFormat_UPC_A,
BarcodeFormat_UPC_E,
BarcodeFormat_UPC_EAN_EXTENSION
} BarcodeFormat;
#endif // __CBARCODE_FORMAT_H__

View file

@ -24,29 +24,42 @@ BarcodeFormat CBarcodeFormatConvert(zxing::BarcodeFormat value);
// zxing::BarcodeFormat.
BarcodeFormat CBarcodeFormatConvert(zxing::BarcodeFormat value) {
switch (value) {
case zxing::BarcodeFormat_None:
return BarcodeFormat_None;
case zxing::BarcodeFormat_QR_CODE:
return BarcodeFormat_QR_CODE;
case zxing::BarcodeFormat_DATA_MATRIX:
return BarcodeFormat_DATA_MATRIX;
case zxing::BarcodeFormat_UPC_E:
return BarcodeFormat_UPC_E;
case zxing::BarcodeFormat_UPC_A:
return BarcodeFormat_UPC_A;
case zxing::BarcodeFormat_EAN_8:
return BarcodeFormat_EAN_8;
case zxing::BarcodeFormat_EAN_13:
return BarcodeFormat_EAN_13;
case zxing::BarcodeFormat_CODE_128:
return BarcodeFormat_CODE_128;
case zxing::BarcodeFormat_CODE_39:
return BarcodeFormat_CODE_39;
case zxing::BarcodeFormat_ITF:
return BarcodeFormat_ITF;
case zxing::BarcodeFormat_AZTEC:
case zxing::BarcodeFormat::NONE:
return BarcodeFormat_NONE;
case zxing::BarcodeFormat::AZTEC:
return BarcodeFormat_AZTEC;
case zxing::BarcodeFormat::CODABAR:
return BarcodeFormat_CODABAR;
case zxing::BarcodeFormat::CODE_39:
return BarcodeFormat_CODE_39;
case zxing::BarcodeFormat::CODE_93:
return BarcodeFormat_CODE_93;
case zxing::BarcodeFormat::CODE_128:
return BarcodeFormat_CODE_128;
case zxing::BarcodeFormat::DATA_MATRIX:
return BarcodeFormat_DATA_MATRIX;
case zxing::BarcodeFormat::EAN_8:
return BarcodeFormat_EAN_8;
case zxing::BarcodeFormat::EAN_13:
return BarcodeFormat_EAN_13;
case zxing::BarcodeFormat::ITF:
return BarcodeFormat_ITF;
case zxing::BarcodeFormat::MAXICODE:
return BarcodeFormat_MAXICODE;
case zxing::BarcodeFormat::PDF_417:
return BarcodeFormat_PDF_417;
case zxing::BarcodeFormat::QR_CODE:
return BarcodeFormat_QR_CODE;
case zxing::BarcodeFormat::RSS_14:
return BarcodeFormat_RSS_14;
case zxing::BarcodeFormat::RSS_EXPANDED:
return BarcodeFormat_RSS_EXPANDED;
case zxing::BarcodeFormat::UPC_A:
return BarcodeFormat_UPC_A;
case zxing::BarcodeFormat::UPC_E:
return BarcodeFormat_UPC_E;
case zxing::BarcodeFormat::UPC_EAN_EXTENSION:
return BarcodeFormat_UPC_EAN_EXTENSION;
}
return BarcodeFormat_None;
return BarcodeFormat_NONE;
}

View file

@ -28,7 +28,6 @@
UIImage *image;
CGRect cropRect;
UIImage *subsetImage;
unsigned char *subsetData;
size_t subsetWidth;
size_t subsetHeight;
size_t subsetBytesPerRow;
@ -37,12 +36,14 @@
@property(nonatomic, retain) UIImage *image;
@property(nonatomic, retain) NSSet *readers;
#if 0
@property(nonatomic, assign) CGRect cropRect;
@property(nonatomic, retain) UIImage *subsetImage;
@property(nonatomic, assign) unsigned char *subsetData;
@property(nonatomic, assign) char *subsetData;
@property(assign) size_t subsetWidth;
@property(assign) size_t subsetHeight;
@property(assign) size_t subsetBytesPerRow;
#endif
@property(nonatomic, assign) id<DecoderDelegate> delegate;
- (BOOL) decodeImage:(UIImage *)image;

View file

@ -40,15 +40,21 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
}
};
@interface Decoder ()
@property(nonatomic, retain) UIImage *subsetImage;
@end
@implementation Decoder
@synthesize image;
@synthesize cropRect;
@synthesize subsetImage;
#if 0
@synthesize cropRect;
@synthesize subsetData;
@synthesize subsetWidth;
@synthesize subsetHeight;
@synthesize subsetBytesPerRow;
#endif
@synthesize delegate;
@synthesize readers;
@ -80,7 +86,7 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
}
#define SUBSET_SIZE 360
- (void) prepareSubset {
- (ArrayRef<char>) prepareSubset {
CGSize size = [image size];
#ifdef DEBUG
NSLog(@"decoding: image is (%.1f x %.1f), cropRect is (%.1f,%.1f)x(%.1f,%.1f)", size.width, size.height,
@ -100,7 +106,7 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
NSLog(@"decoding: image to decode is (%d x %d) (%d bytes/row)", subsetWidth, subsetHeight, subsetBytesPerRow);
#endif
subsetData = (unsigned char *)malloc(subsetBytesPerRow * subsetHeight);
ArrayRef<char> subsetData (subsetBytesPerRow * subsetHeight);
#ifdef DEBUG
NSLog(@"allocated %d bytes of memory", subsetBytesPerRow * subsetHeight);
#endif
@ -108,7 +114,7 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
CGColorSpaceRef grayColorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef ctx =
CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight,
CGBitmapContextCreate(&subsetData->values()[0], subsetWidth, subsetHeight,
8, subsetBytesPerRow, grayColorSpace,
kCGImageAlphaNone);
CGColorSpaceRelease(grayColorSpace);
@ -150,9 +156,10 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
#ifdef DEBUG
NSLog(@"released context");
#endif
return subsetData;
}
- (BOOL)decode {
- (BOOL)decode:(ArrayRef<char>)subsetData {
NSAutoreleasePool* mainpool = [[NSAutoreleasePool alloc] init];
TwoDDecoderResult *decoderResult = nil;
BOOL returnCode = NO;
@ -160,17 +167,13 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
//NSSet *formatReaders = [FormatReader formatReaders];
NSSet *formatReaders = self.readers;
Ref<LuminanceSource> source
(new GreyscaleLuminanceSource(subsetData, subsetBytesPerRow, subsetHeight, 0, 0, subsetWidth, subsetHeight));
(new GreyscaleLuminanceSource(ArrayRef<char>(subsetData), subsetBytesPerRow, subsetHeight, 0, 0, subsetWidth, subsetHeight));
subsetData = 0;
Ref<Binarizer> binarizer (new HybridBinarizer(source));
source = 0;
Ref<BinaryBitmap> grayImage (new BinaryBitmap(binarizer));
binarizer = 0;
#ifdef DEBUG
NSLog(@"created GreyscaleLuminanceSource(%p,%d,%d,%d,%d,%d,%d)",
subsetData, subsetBytesPerRow, subsetHeight, 0, 0, subsetWidth, subsetHeight);
NSLog(@"grayImage count = %d", grayImage->count());
#endif
#ifdef TRY_ROTATIONS
for (int i = 0; !decoderResult && i < 4; i++) {
@ -192,10 +195,10 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
Ref<String> resultText(result->getText());
const char *cString = resultText->getText().c_str();
const std::vector<Ref<ResultPoint> > &resultPoints = result->getResultPoints();
const ArrayRef<Ref<ResultPoint> > &resultPoints = result->getResultPoints();
points = [[NSMutableArray alloc ] initWithCapacity:resultPoints.size()];
for (size_t i = 0; i < resultPoints.size(); i++) {
for (int i = 0; i < resultPoints.size(); i++) {
const Ref<ResultPoint> &rp = resultPoints[i];
CGPoint p = CGPointMake(rp->getX(), rp->getY());
[points addObject:[NSValue valueWithCGPoint:p]];
@ -235,14 +238,6 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
}
#endif
free(subsetData);
self.subsetData = NULL;
// DONT COMMIT
// [decoderResult release];
// decoderResult = nil;
if (decoderResult) {
[self performSelectorOnMainThread:@selector(didDecodeImage:)
withObject:[decoderResult copy]
@ -271,17 +266,16 @@ ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {}
- (BOOL) decodeImage:(UIImage *)i cropRect:(CGRect)cr {
self.image = i;
self.cropRect = cr;
[self prepareSubset];
cropRect = cr;
ArrayRef<char> subsetData = [self prepareSubset];
[self willDecodeImage];
return [self decode];
return [self decode:subsetData];
}
- (void) dealloc {
delegate = nil;
[image release];
[subsetImage release];
free(subsetData);
[readers release];
[super dealloc];
}

View file

@ -1,3 +1,4 @@
// -*- Mode: ObjC; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
//
// ProductResultParser.m
// ZXing
@ -24,43 +25,47 @@
#import "CBarcodeFormat.h"
#include "../../../../cpp/core/src/zxing/oned/UPCEReader.h"
using std::string;
using zxing::String;
using zxing::Ref;
@implementation ProductResultParser
+ (void)load {
[ResultParser registerResultParserClass:self];
[ResultParser registerResultParserClass:self];
}
+ (ParsedResult *)parsedResultForString:(NSString *)s format:(BarcodeFormat)format {
// Treat all UPC and EAN variants as UPCs, in the sense that they are all
// product barcodes.
if (format != BarcodeFormat_UPC_E &&
format != BarcodeFormat_UPC_A &&
format != BarcodeFormat_EAN_8 &&
format != BarcodeFormat_EAN_13) {
return nil;
}
// Treat all UPC and EAN variants as UPCs, in the sense that they are all
// product barcodes.
if (format != BarcodeFormat_UPC_E &&
format != BarcodeFormat_UPC_A &&
format != BarcodeFormat_EAN_8 &&
format != BarcodeFormat_EAN_13) {
return nil;
}
// Barcode must be all digits.
for (unsigned int i = 0; i < [s length]; i++) {
unichar c = [s characterAtIndex:i];
if (c < '0' || c > '9') {
return nil;
}
// Barcode must be all digits.
for (unsigned int i = 0; i < [s length]; i++) {
unichar c = [s characterAtIndex:i];
if (c < '0' || c > '9') {
return nil;
}
}
NSString *normalizedProductID;
// Expand UPC-E for purposes of searching
if (format == BarcodeFormat_UPC_E) {
std::string textStr = std::string([s UTF8String]);
std::string normal = zxing::oned::UPCEReader::convertUPCEtoUPCA(textStr);
normalizedProductID = [NSString stringWithUTF8String:normal.c_str()];
} else {
normalizedProductID = s;
}
NSString *normalizedProductID;
// Expand UPC-E for purposes of searching
if (format == BarcodeFormat_UPC_E) {
Ref<String> textStr (new String([s UTF8String]));
string normal = zxing::oned::UPCEReader::convertUPCEtoUPCA(textStr)->getText();
normalizedProductID = [NSString stringWithUTF8String:normal.c_str()];
} else {
normalizedProductID = s;
}
return [[[ProductParsedResult alloc] initWithProductID:s
normalizedProductID:normalizedProductID]
autorelease];
return [[[ProductParsedResult alloc] initWithProductID:s
normalizedProductID:normalizedProductID]
autorelease];
}
@end

View file

@ -76,7 +76,7 @@ static NSMutableSet *sResultParsers = nil;
}
+ (ParsedResult *)parsedResultForString:(NSString *)s {
return [ResultParser parsedResultForString:s format:BarcodeFormat_None];
return [ResultParser parsedResultForString:s format:BarcodeFormat_NONE];
}
+ (NSDictionary*)dictionaryForQueryString:(NSString *)queryString {

View file

@ -88,7 +88,7 @@ static NSMutableArray *sTheResultParsers = nil;
}
+ (ParsedResult *)parsedResultForString:(NSString *)theString {
return [self parsedResultForString:theString format:BarcodeFormat_None];
return [self parsedResultForString:theString format:BarcodeFormat_NONE];
}
@end

View file

@ -121,7 +121,6 @@
1FB431A012901C76002D63E8 /* UniversalResultParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4319E12901C76002D63E8 /* UniversalResultParser.m */; };
3B117EF1145B220A0035037B /* MonochromeRectangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EEF145B220A0035037B /* MonochromeRectangleDetector.cpp */; };
3B117EF2145B220A0035037B /* WhiteRectangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EF0145B220A0035037B /* WhiteRectangleDetector.cpp */; };
3B117EF5145B221D0035037B /* NotFoundException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EF4145B221D0035037B /* NotFoundException.cpp */; };
3B248F7D14EF3A660065F0DA /* GenericGF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F7914EF3A660065F0DA /* GenericGF.cpp */; };
3B248F7E14EF3A660065F0DA /* GenericGF.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F7A14EF3A660065F0DA /* GenericGF.h */; };
3B248F7F14EF3A660065F0DA /* GenericGFPoly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F7B14EF3A660065F0DA /* GenericGFPoly.cpp */; };
@ -142,6 +141,12 @@
3B27C5E2144735E6005157C4 /* CharacterSetECI.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5DC144735E6005157C4 /* CharacterSetECI.h */; };
3B27C5E5144735E6005157C4 /* StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B27C5DF144735E6005157C4 /* StringUtils.cpp */; };
3B27C5E6144735E6005157C4 /* StringUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5E0144735E6005157C4 /* StringUtils.h */; };
3B6C805717090ED300D22AB2 /* CodaBarReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B6C805317090ED300D22AB2 /* CodaBarReader.cpp */; };
3B6C805817090ED300D22AB2 /* CodaBarReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6C805417090ED300D22AB2 /* CodaBarReader.h */; };
3B6C805917090ED300D22AB2 /* Code93Reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B6C805517090ED300D22AB2 /* Code93Reader.cpp */; };
3B6C805A17090ED300D22AB2 /* Code93Reader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6C805617090ED300D22AB2 /* Code93Reader.h */; };
3B6C805D17090EFC00D22AB2 /* ChecksumException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B6C805B17090EFC00D22AB2 /* ChecksumException.cpp */; };
3B6C805E17090EFC00D22AB2 /* ChecksumException.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B6C805C17090EFC00D22AB2 /* ChecksumException.h */; };
3B72D96F12130EF6007CEF32 /* ResultPointCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B72D96D12130EF6007CEF32 /* ResultPointCallback.cpp */; };
3B72D97012130EF6007CEF32 /* ResultPointCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B72D96E12130EF6007CEF32 /* ResultPointCallback.h */; };
3B81AAC5120F07E40022E5D4 /* DecodeHints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B81AAC3120F07E40022E5D4 /* DecodeHints.cpp */; };
@ -275,7 +280,6 @@
E53459BF11987396000CB77F /* Version.h in Headers */ = {isa = PBXBuildFile; fileRef = E534593A11987396000CB77F /* Version.h */; };
E53459C011987396000CB77F /* Reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E534593B11987396000CB77F /* Reader.cpp */; };
E53459C111987396000CB77F /* Reader.h in Headers */ = {isa = PBXBuildFile; fileRef = E534593C11987396000CB77F /* Reader.h */; };
E53459C211987396000CB77F /* ReaderException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E534593D11987396000CB77F /* ReaderException.cpp */; };
E53459C311987396000CB77F /* ReaderException.h in Headers */ = {isa = PBXBuildFile; fileRef = E534593E11987396000CB77F /* ReaderException.h */; };
E53459C411987396000CB77F /* Result.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E534593F11987396000CB77F /* Result.cpp */; };
E53459C511987396000CB77F /* Result.h in Headers */ = {isa = PBXBuildFile; fileRef = E534594011987396000CB77F /* Result.h */; };
@ -411,7 +415,6 @@
1FB4319E12901C76002D63E8 /* UniversalResultParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UniversalResultParser.m; path = Classes/resultParsers/UniversalResultParser.m; sourceTree = "<group>"; };
3B117EEF145B220A0035037B /* MonochromeRectangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MonochromeRectangleDetector.cpp; path = detector/MonochromeRectangleDetector.cpp; sourceTree = "<group>"; };
3B117EF0145B220A0035037B /* WhiteRectangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WhiteRectangleDetector.cpp; path = detector/WhiteRectangleDetector.cpp; sourceTree = "<group>"; };
3B117EF4145B221D0035037B /* NotFoundException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotFoundException.cpp; sourceTree = "<group>"; };
3B248F7914EF3A660065F0DA /* GenericGF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGF.cpp; sourceTree = "<group>"; };
3B248F7A14EF3A660065F0DA /* GenericGF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericGF.h; sourceTree = "<group>"; };
3B248F7B14EF3A660065F0DA /* GenericGFPoly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGFPoly.cpp; sourceTree = "<group>"; };
@ -432,6 +435,12 @@
3B27C5DC144735E6005157C4 /* CharacterSetECI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterSetECI.h; sourceTree = "<group>"; };
3B27C5DF144735E6005157C4 /* StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringUtils.cpp; sourceTree = "<group>"; };
3B27C5E0144735E6005157C4 /* StringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringUtils.h; sourceTree = "<group>"; };
3B6C805317090ED300D22AB2 /* CodaBarReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodaBarReader.cpp; sourceTree = "<group>"; };
3B6C805417090ED300D22AB2 /* CodaBarReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodaBarReader.h; sourceTree = "<group>"; };
3B6C805517090ED300D22AB2 /* Code93Reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Code93Reader.cpp; sourceTree = "<group>"; };
3B6C805617090ED300D22AB2 /* Code93Reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Code93Reader.h; sourceTree = "<group>"; };
3B6C805B17090EFC00D22AB2 /* ChecksumException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChecksumException.cpp; sourceTree = "<group>"; };
3B6C805C17090EFC00D22AB2 /* ChecksumException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChecksumException.h; sourceTree = "<group>"; };
3B72D96D12130EF6007CEF32 /* ResultPointCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResultPointCallback.cpp; sourceTree = "<group>"; };
3B72D96E12130EF6007CEF32 /* ResultPointCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultPointCallback.h; sourceTree = "<group>"; };
3B81AAC3120F07E40022E5D4 /* DecodeHints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecodeHints.cpp; sourceTree = "<group>"; };
@ -566,7 +575,6 @@
E534593A11987396000CB77F /* Version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Version.h; sourceTree = "<group>"; };
E534593B11987396000CB77F /* Reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Reader.cpp; sourceTree = "<group>"; };
E534593C11987396000CB77F /* Reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reader.h; sourceTree = "<group>"; };
E534593D11987396000CB77F /* ReaderException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReaderException.cpp; sourceTree = "<group>"; };
E534593E11987396000CB77F /* ReaderException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReaderException.h; sourceTree = "<group>"; };
E534593F11987396000CB77F /* Result.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Result.cpp; sourceTree = "<group>"; };
E534594011987396000CB77F /* Result.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Result.h; sourceTree = "<group>"; };
@ -746,8 +754,9 @@
E53458B411987396000CB77F /* zxing */ = {
isa = PBXGroup;
children = (
3B6C805B17090EFC00D22AB2 /* ChecksumException.cpp */,
3B6C805C17090EFC00D22AB2 /* ChecksumException.h */,
3B248F8314EF3A980065F0DA /* aztec */,
3B117EF4145B221D0035037B /* NotFoundException.cpp */,
3B27C5D6144735CE005157C4 /* FormatException.cpp */,
3B27C5D7144735CE005157C4 /* FormatException.h */,
3B72D96D12130EF6007CEF32 /* ResultPointCallback.cpp */,
@ -772,7 +781,6 @@
E534591611987396000CB77F /* qrcode */,
E534593B11987396000CB77F /* Reader.cpp */,
E534593C11987396000CB77F /* Reader.h */,
E534593D11987396000CB77F /* ReaderException.cpp */,
E534593E11987396000CB77F /* ReaderException.h */,
E534593F11987396000CB77F /* Result.cpp */,
E534594011987396000CB77F /* Result.h */,
@ -888,6 +896,10 @@
E53458FD11987396000CB77F /* oned */ = {
isa = PBXGroup;
children = (
3B6C805317090ED300D22AB2 /* CodaBarReader.cpp */,
3B6C805417090ED300D22AB2 /* CodaBarReader.h */,
3B6C805517090ED300D22AB2 /* Code93Reader.cpp */,
3B6C805617090ED300D22AB2 /* Code93Reader.h */,
E53458FE11987396000CB77F /* Code128Reader.cpp */,
E53458FF11987396000CB77F /* Code128Reader.h */,
E534590011987396000CB77F /* Code39Reader.cpp */,
@ -1211,6 +1223,9 @@
3B248F9314EF3A980065F0DA /* Decoder.h in Headers */,
3B248F9514EF3A980065F0DA /* Detector.h in Headers */,
3B248F9814EF3AF80065F0DA /* AztecReader.h in Headers */,
3B6C805817090ED300D22AB2 /* CodaBarReader.h in Headers */,
3B6C805A17090ED300D22AB2 /* Code93Reader.h in Headers */,
3B6C805E17090EFC00D22AB2 /* ChecksumException.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1388,7 +1403,6 @@
E53459BC11987396000CB77F /* QRCodeReader.cpp in Sources */,
E53459BE11987396000CB77F /* Version.cpp in Sources */,
E53459C011987396000CB77F /* Reader.cpp in Sources */,
E53459C211987396000CB77F /* ReaderException.cpp in Sources */,
E53459C411987396000CB77F /* Result.cpp in Sources */,
E53459C611987396000CB77F /* ResultPoint.cpp in Sources */,
1F027FAC11A7BEAF006B06DE /* Decoder.mm in Sources */,
@ -1450,7 +1464,6 @@
3B27C5E5144735E6005157C4 /* StringUtils.cpp in Sources */,
3B117EF1145B220A0035037B /* MonochromeRectangleDetector.cpp in Sources */,
3B117EF2145B220A0035037B /* WhiteRectangleDetector.cpp in Sources */,
3B117EF5145B221D0035037B /* NotFoundException.cpp in Sources */,
3B248F7D14EF3A660065F0DA /* GenericGF.cpp in Sources */,
3B248F7F14EF3A660065F0DA /* GenericGFPoly.cpp in Sources */,
3B248F8E14EF3A980065F0DA /* AztecDetectorResult.cpp in Sources */,
@ -1458,6 +1471,9 @@
3B248F9214EF3A980065F0DA /* Decoder.cpp in Sources */,
3B248F9414EF3A980065F0DA /* Detector.cpp in Sources */,
3B248F9914EF3AF80065F0DA /* AztecReader.mm in Sources */,
3B6C805717090ED300D22AB2 /* CodaBarReader.cpp in Sources */,
3B6C805917090ED300D22AB2 /* Code93Reader.cpp in Sources */,
3B6C805D17090EFC00D22AB2 /* ChecksumException.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -188,7 +188,7 @@
3BA99649159122210056A230 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0460;
};
buildConfigurationList = 3BA9964C159122210056A230 /* Build configuration list for PBXProject "bare" */;
compatibilityVersion = "Xcode 3.2";
@ -301,6 +301,10 @@
armv7,
armv7s,
);
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
@ -333,6 +337,10 @@
armv7,
armv7s,
);
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;

View file

@ -175,7 +175,7 @@
3B5D0F0B1590F12B00C33931 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
LastUpgradeCheck = 0460;
};
buildConfigurationList = 3B5D0F0E1590F12B00C33931 /* Build configuration list for PBXProject "bare" */;
compatibilityVersion = "Xcode 3.2";
@ -253,6 +253,10 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@ -279,6 +283,10 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
@ -297,6 +305,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "bare/bare-Prefix.pch";
HEADER_SEARCH_PATHS = (
@ -314,6 +323,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "bare/bare-Prefix.pch";
HEADER_SEARCH_PATHS = (

View file

@ -16,9 +16,15 @@
*/
#import <ZXing/ZXCGImageLuminanceSource.h>
#include <sstream>
#include <zxing/common/IllegalArgumentException.h>
namespace zxing {
using std::string;
using std::ostringstream;
using zxing::CGImageLuminanceSource;
using zxing::ArrayRef;
using zxing::Ref;
using zxing::LuminanceSource;
CGImageRef CGImageLuminanceSource::createImageFromBuffer
(CVPixelBufferRef buffer, int left, int top, int width, int height)
@ -190,33 +196,38 @@ CGImageLuminanceSource::~CGImageLuminanceSource() {
}
}
unsigned char* CGImageLuminanceSource::getRow(int y, unsigned char* row) {
ArrayRef<char> CGImageLuminanceSource::getRow(int y, ArrayRef<char> row) {
if (y < 0 || y >= this->getHeight()) {
throw IllegalArgumentException("Requested row is outside the image: " + y);
ostringstream msg;
msg << "Requested row is outside the image: " << y;
throw IllegalArgumentException(msg.str().c_str());
}
int width = getWidth();
// TODO(flyashi): determine if row has enough size.
if (row == NULL) {
row = new unsigned char[width_];
if (!row) {
row = ArrayRef<char>(width_);
}
int offset = (y + top_) * dataWidth_ + left_;
CFDataGetBytes(data_, CFRangeMake(offset, width), row);
char* v = &row->values()[0];
CFDataGetBytes(data_, CFRangeMake(offset, width), (unsigned char*)v);
return row;
}
unsigned char* CGImageLuminanceSource::getMatrix() {
ArrayRef<char> CGImageLuminanceSource::getMatrix() {
int size = width_ * height_;
unsigned char* result = new unsigned char[size];
ArrayRef<char> result (size);
if (left_ == 0 &&
top_ == 0 &&
dataWidth_ == width_ &&
dataHeight_ == height_) {
CFDataGetBytes(data_, CFRangeMake(0, size), result);
char* v = &result->values()[0];
CFDataGetBytes(data_, CFRangeMake(0, size), (unsigned char*)v);
} else {
for (int row = 0; row < height_; row++) {
char* v = &result->values()[0];
CFDataGetBytes(data_,
CFRangeMake((top_ + row) * dataWidth_ + left_, width_),
result + row * width_);
(unsigned char*)v + row * width_);
}
}
return result;
@ -225,5 +236,3 @@ unsigned char* CGImageLuminanceSource::getMatrix() {
Ref<LuminanceSource> CGImageLuminanceSource::rotateCounterClockwise() {
return Ref<LuminanceSource>(0);
}
}

View file

@ -60,8 +60,8 @@ class CGImageLuminanceSource : public LuminanceSource {
CGImageRef image() { return image_; }
CGImageRef image(size_t width, size_t height);
unsigned char* getRow(int y, unsigned char* row);
unsigned char* getMatrix();
ArrayRef<char> getRow(int y, ArrayRef<char> row);
ArrayRef<char> getMatrix();
bool isRotateSupported() const {
return true;

View file

@ -366,7 +366,7 @@
3B83EB1C158E6C5100A3B31F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
LastUpgradeCheck = 0460;
};
buildConfigurationList = 3B83EB1F158E6C5100A3B31F /* Build configuration list for PBXProject "zxing-objc" */;
compatibilityVersion = "Xcode 3.2";
@ -510,7 +510,10 @@
armv7,
x86_64,
);
COMBINE_HIDPI_IMAGES = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
@ -551,7 +554,10 @@
armv7,
x86_64,
);
COMBINE_HIDPI_IMAGES = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;