mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
[iphone] torch patch from iss746. Also added ability to change text in OverlayView
git-svn-id: https://zxing.googlecode.com/svn/trunk@1725 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
27445b32cd
commit
10262e8bf1
|
@ -6,6 +6,8 @@
|
|||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array/>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
|
@ -20,13 +22,37 @@
|
|||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>CFBundleURLIconFile</key>
|
||||
<string>icon@2x</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.rpechayr.zxing</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>zxing</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainWindow</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>still-camera</string>
|
||||
<string>video-camera</string>
|
||||
</array>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array/>
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -575,6 +575,41 @@
|
|||
};
|
||||
name = Release;
|
||||
};
|
||||
1F81B3E012F1E42200659778 /* Distribution */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Romain Pechayre";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = 4.2;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
../../cpp/core/src,
|
||||
"../ZXingWidget/Classes/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.1;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
PREBINDING = NO;
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "27669F64-E861-4AE5-B39E-E93E68BFC37D";
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Distribution;
|
||||
};
|
||||
1F81B3E112F1E42200659778 /* Distribution */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = Barcodes_Prefix.pch;
|
||||
GCC_VERSION = 4.2;
|
||||
INFOPLIST_FILE = "Barcodes-Info.plist";
|
||||
PRODUCT_NAME = Barcodes;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Distribution;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
|
@ -582,7 +617,7 @@
|
|||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Romain Pechayre (2CQ4EGKG4S)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_VERSION = 4.2;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
|
@ -591,8 +626,8 @@
|
|||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.1;
|
||||
PREBINDING = NO;
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "A74F7EF8-F2D5-4961-891C-BB2D09877990";
|
||||
SDKROOT = iphoneos4.2;
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "613CA1B9-372B-44AF-BDD8-9F204D0C27C9";
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -602,6 +637,7 @@
|
|||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = 4.2;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
|
@ -623,6 +659,7 @@
|
|||
buildConfigurations = (
|
||||
1D6058940D05DD3E006BFB54 /* Debug */,
|
||||
1D6058950D05DD3E006BFB54 /* Release */,
|
||||
1F81B3E112F1E42200659778 /* Distribution */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
|
@ -632,6 +669,7 @@
|
|||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
1F81B3E012F1E42200659778 /* Distribution */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
|
|
7
iphone/Barcodes/Barcodes.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
iphone/Barcodes/Barcodes.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:Barcodes.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -26,12 +26,14 @@
|
|||
id<CancelDelegate> delegate;
|
||||
BOOL oneDMode;
|
||||
CGRect cropRect;
|
||||
NSString *displayedMessage;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSMutableArray* points;
|
||||
@property (nonatomic, assign) id<CancelDelegate> delegate;
|
||||
@property (nonatomic, assign) BOOL oneDMode;
|
||||
@property (nonatomic, assign) CGRect cropRect;
|
||||
@property (nonatomic, copy) NSString *displayedMessage;
|
||||
|
||||
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ static const CGFloat kPadding = 10;
|
|||
@synthesize cancelButton;
|
||||
@synthesize cropRect;
|
||||
@synthesize instructionsLabel;
|
||||
@synthesize displayedMessage;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (id) initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled {
|
||||
|
@ -63,7 +64,6 @@ static const CGFloat kPadding = 10;
|
|||
[self addSubview:cancelButton];
|
||||
[self addSubview:imageView];
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ static const CGFloat kPadding = 10;
|
|||
[imageView release];
|
||||
[_points release];
|
||||
[instructionsLabel release];
|
||||
[displayedMessage release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -124,9 +125,14 @@ static const CGFloat kPadding = 10;
|
|||
return point;
|
||||
}
|
||||
|
||||
#define kTextMargin 10
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
[super drawRect:rect];
|
||||
if (displayedMessage == nil) {
|
||||
self.displayedMessage = @"Place a barcode inside the viewfinder rectangle to scan it.";
|
||||
}
|
||||
CGContextRef c = UIGraphicsGetCurrentContext();
|
||||
|
||||
if (nil != _points) {
|
||||
|
@ -149,13 +155,11 @@ static const CGFloat kPadding = 10;
|
|||
CGContextShowTextAtPoint(c, 74.0, 285.0, text, 49);
|
||||
}
|
||||
else {
|
||||
char *text = "Place a barcode inside the";
|
||||
char *text2 = "viewfinder rectangle to scan it.";
|
||||
CGContextSelectFont(c, "Helvetica", 18, kCGEncodingMacRoman);
|
||||
CGContextScaleCTM(c, -1.0, 1.0);
|
||||
CGContextRotateCTM(c, M_PI);
|
||||
CGContextShowTextAtPoint(c, 48.0, -45.0, text, 26);
|
||||
CGContextShowTextAtPoint(c, 33.0, -70.0, text2, 32);
|
||||
UIFont *font = [UIFont systemFontOfSize:18];
|
||||
CGSize constraint = CGSizeMake(rect.size.width - 2 * kTextMargin, cropRect.origin.y);
|
||||
CGSize displaySize = [displayedMessage sizeWithFont:font constrainedToSize:constraint];
|
||||
CGRect displayRect = CGRectMake((rect.size.width - displaySize.width) / 2 , cropRect.origin.y - displaySize.height, displaySize.width, displaySize.height);
|
||||
[self.displayedMessage drawInRect:displayRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
|
||||
}
|
||||
CGContextRestoreGState(c);
|
||||
int offset = rect.size.width / 2;
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
- (id)initWithDelegate:(id<ZXingDelegate>)delegate showCancel:(BOOL)shouldShowCancel OneDMode:(BOOL)shouldUseoOneDMode;
|
||||
|
||||
- (BOOL)fixedFocus;
|
||||
- (void)setTorch:(BOOL)status;
|
||||
- (BOOL)torchIsOn;
|
||||
|
||||
@end
|
||||
|
||||
@protocol ZXingDelegate
|
||||
|
|
|
@ -284,6 +284,9 @@
|
|||
}
|
||||
*/
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark AVFoundation
|
||||
|
||||
- (void)initCapture {
|
||||
#if HAS_AVFF
|
||||
AVCaptureDeviceInput *captureInput =
|
||||
|
@ -470,4 +473,39 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
|||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - Torch
|
||||
|
||||
- (void)setTorch:(BOOL)status {
|
||||
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
|
||||
if (captureDeviceClass != nil) {
|
||||
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
|
||||
[device lockForConfiguration:nil];
|
||||
if ( [device hasTorch] ) {
|
||||
if ( status ) {
|
||||
[device setTorchMode:AVCaptureTorchModeOn];
|
||||
} else {
|
||||
[device setTorchMode:AVCaptureTorchModeOn];
|
||||
}
|
||||
}
|
||||
[device unlockForConfiguration];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)torchIsOn {
|
||||
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
|
||||
if (captureDeviceClass != nil) {
|
||||
|
||||
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
|
||||
if ( [device hasTorch] ) {
|
||||
return [device torchMode] == AVCaptureTorchModeOn;
|
||||
}
|
||||
[device unlockForConfiguration];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
- (NSString *)stringForDisplay {
|
||||
NSMutableString *result = [NSMutableString stringWithString:self.name];
|
||||
if (self.jobTitle) [result appendFormat:@"\n%@",self.jobTitle];
|
||||
if (self.organization) [result appendFormat:@"\n%@",self.organization];
|
||||
if (self.phoneNumbers) {
|
||||
for (NSString *number in self.phoneNumbers) {
|
||||
|
|
|
@ -1181,6 +1181,7 @@
|
|||
);
|
||||
PRESERVE_DEAD_CODE_INITS_AND_TERMS = NO;
|
||||
PRODUCT_NAME = ZXingWidget;
|
||||
SDKROOT = iphoneos;
|
||||
SEPARATE_STRIP = NO;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
|
@ -1198,6 +1199,7 @@
|
|||
HEADER_SEARCH_PATHS = ../../cpp/core/src;
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
PRODUCT_NAME = ZXingWidget;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
7
iphone/ZXingWidget/ZXingWidget.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
iphone/ZXingWidget/ZXingWidget.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:ZXingWidget.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
Loading…
Reference in a new issue