├── JB_ZBarSDK_Demo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── jaybin.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── jaybin.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── JB_ZBarSDK_Demo.xcscheme │ └── xcschememanagement.plist ├── JB_ZBarSDK_Demo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── CreateScanQRCode │ ├── CreateRQCodeViewController.h │ ├── CreateRQCodeViewController.m │ └── CreateRQCodeViewController.xib ├── CustomScanQRCode │ ├── QRView.h │ ├── QRView.m │ ├── ScanQRCodeViewController.h │ ├── ScanQRCodeViewController.m │ └── ScanQRCodeViewController.xib ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── QRCodeScanLine.imageset │ │ ├── Contents.json │ │ └── QRCodeScanLine@2x.png │ ├── album.imageset │ │ ├── Contents.json │ │ └── iOS-O2O-icon_hand-album.pdf │ └── bulb.imageset │ │ ├── Contents.json │ │ └── iOS-O2O-icon_icon-bulb .pdf ├── Info.plist ├── PrefixHeader.pch ├── Util │ ├── UIColor+HEX.h │ └── UIColor+HEX.m ├── Vendor │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ ├── ZBarSDK │ │ ├── Headers │ │ │ └── ZBarSDK │ │ │ │ ├── ZBarCameraSimulator.h │ │ │ │ ├── ZBarCaptureReader.h │ │ │ │ ├── ZBarHelpController.h │ │ │ │ ├── ZBarImage.h │ │ │ │ ├── ZBarImageScanner.h │ │ │ │ ├── ZBarReaderController.h │ │ │ │ ├── ZBarReaderView.h │ │ │ │ ├── ZBarReaderViewController.h │ │ │ │ ├── ZBarSDK.h │ │ │ │ ├── ZBarSymbol.h │ │ │ │ ├── zbar.h │ │ │ │ └── zbar │ │ │ │ ├── Decoder.h │ │ │ │ ├── Exception.h │ │ │ │ ├── Image.h │ │ │ │ ├── ImageScanner.h │ │ │ │ ├── Processor.h │ │ │ │ ├── Scanner.h │ │ │ │ ├── Symbol.h │ │ │ │ ├── Video.h │ │ │ │ └── Window.h │ │ ├── Resources │ │ │ ├── zbar-back.png │ │ │ ├── zbar-help.html │ │ │ ├── zbar-helpicons.png │ │ │ └── zbar-samples.png │ │ └── libzbar.a │ └── libqrencode │ │ ├── QRCodeGenerator.h │ │ ├── QRCodeGenerator.m │ │ ├── bitstream.c │ │ ├── bitstream.h │ │ ├── mask.c │ │ ├── mask.h │ │ ├── qrencode.c │ │ ├── qrencode.h │ │ ├── qrinput.c │ │ ├── qrinput.h │ │ ├── qrspec.c │ │ ├── qrspec.h │ │ ├── rscode.c │ │ ├── rscode.h │ │ ├── split.c │ │ └── split.h ├── ViewController.h ├── ViewController.m ├── main.m └── screenshots │ ├── create.gif │ ├── customScan.gif │ └── normalScan.gif ├── JB_ZBarSDK_DemoTests ├── Info.plist └── JB_ZBarSDK_DemoTests.m └── README.md /JB_ZBarSDK_Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo.xcodeproj/project.xcworkspace/xcuserdata/jaybin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo.xcodeproj/project.xcworkspace/xcuserdata/jaybin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo.xcodeproj/xcuserdata/jaybin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo.xcodeproj/xcuserdata/jaybin.xcuserdatad/xcschemes/JB_ZBarSDK_Demo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo.xcodeproj/xcuserdata/jaybin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | JB_ZBarSDK_Demo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 73F704F21BA6E41400226EFC 16 | 17 | primary 18 | 19 | 20 | 73F7050B1BA6E41400226EFC 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/9/14. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/9/14. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | ViewController *VC = [[ViewController alloc] init]; 22 | UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:VC]; 23 | _window.rootViewController = naviVC; 24 | _window.backgroundColor = [UIColor whiteColor]; 25 | [_window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application { 30 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 31 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 32 | } 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application { 35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | - (void)applicationWillEnterForeground:(UIApplication *)application { 40 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 41 | } 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CreateScanQRCode/CreateRQCodeViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CreateRQCodeViewController.h 3 | // DiDi 4 | // 5 | // Created by jaybin on 15/8/4. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CreateRQCodeViewController : UIViewController{ 12 | IBOutlet UIImageView *testImageView;//二维码图片 13 | IBOutlet UITextField *testTextField; 14 | 15 | } 16 | 17 | - (IBAction)buttonClicked:(id)sender; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CreateScanQRCode/CreateRQCodeViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CreateRQCodeViewController.m 3 | // DiDi 4 | // 5 | // Created by jaybin on 15/8/4. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import "CreateRQCodeViewController.h" 10 | #import "QRCodeGenerator.h" 11 | #import "Masonry.h" 12 | 13 | #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] 14 | 15 | 16 | @interface CreateRQCodeViewController () 17 | 18 | @end 19 | 20 | @implementation CreateRQCodeViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view from its nib. 25 | 26 | if(IOS_VERSION>=7.0){ 27 | self.edgesForExtendedLayout = UIRectEdgeNone; 28 | } 29 | } 30 | 31 | #pragma mark - UITextFieldDelegate 32 | -(BOOL)textFieldShouldReturn:(UITextField *)textField 33 | { 34 | [textField resignFirstResponder]; 35 | return YES; 36 | } 37 | 38 | -(void)buttonClicked:(id)sender{ 39 | UIButton *btn = (UIButton *)sender; 40 | switch (btn.tag) { 41 | case 100://生成二维码 42 | { 43 | /*字符转二维码 44 | */ 45 | testImageView.image = [QRCodeGenerator qrImageForString:testTextField.text imageSize:testImageView.bounds.size.width]; 46 | } 47 | break; 48 | case 101://保存二维码到相册 49 | { 50 | [self saveImageToAlbum]; 51 | } 52 | break; 53 | default: 54 | break; 55 | } 56 | 57 | } 58 | 59 | //保存二维码图片到相册 60 | -(void)saveImageToAlbum 61 | { 62 | UIImageWriteToSavedPhotosAlbum(testImageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL); 63 | } 64 | 65 | //保存图片回调方法 66 | - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *) error contextInfo:(void *)contextInfo 67 | { 68 | if(error != NULL) 69 | { 70 | UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"请打开应用的相册权限" message:nil preferredStyle:UIAlertControllerStyleAlert]; 71 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 72 | }]; 73 | [alertVC addAction:action]; 74 | [self presentViewController:alertVC animated:YES completion:^{ 75 | }]; 76 | } 77 | else 78 | { 79 | UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"已保存到相册" message:nil preferredStyle:UIAlertControllerStyleAlert]; 80 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 81 | }]; 82 | [alertVC addAction:action]; 83 | [self presentViewController:alertVC animated:YES completion:^{ 84 | }]; 85 | } 86 | 87 | } 88 | 89 | - (void)didReceiveMemoryWarning { 90 | [super didReceiveMemoryWarning]; 91 | // Dispose of any resources that can be recreated. 92 | } 93 | 94 | /* 95 | #pragma mark - Navigation 96 | 97 | // In a storyboard-based application, you will often want to do a little preparation before navigation 98 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 99 | // Get the new view controller using [segue destinationViewController]. 100 | // Pass the selected object to the new view controller. 101 | } 102 | */ 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CreateScanQRCode/CreateRQCodeViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 57 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CustomScanQRCode/QRView.h: -------------------------------------------------------------------------------- 1 | // 自定义扫描视图 2 | // QRView.h 3 | // QRWeiXinDemo 4 | // 5 | // Created by lovelydd on 15/4/25. 6 | // Copyright (c) 2015年 lovelydd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface QRView : UIView 12 | 13 | /** 14 | * 透明的区域 15 | */ 16 | @property (nonatomic, assign) CGSize transparentArea; 17 | 18 | - (void)startScan; 19 | - (void)stopScan; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CustomScanQRCode/QRView.m: -------------------------------------------------------------------------------- 1 | // 2 | // QRView.m 3 | // QRWeiXinDemo 4 | // 5 | // Created by lovelydd on 15/4/25. 6 | // Copyright (c) 2015年 lovelydd. All rights reserved. 7 | // 8 | 9 | #import "QRView.h" 10 | #import "Masonry.h" 11 | 12 | @implementation QRView { 13 | 14 | UIImageView *_line; 15 | BOOL isStop; 16 | } 17 | 18 | - (instancetype)init{ 19 | if(self=[super init]){ 20 | [self initLine]; 21 | } 22 | 23 | return self; 24 | } 25 | 26 | - (void)initLine { 27 | if(!_line){ 28 | _line = [[UIImageView alloc] init]; 29 | _line.image = [UIImage imageNamed:@"QRCodeScanLine"]; 30 | [_line setBackgroundColor:[UIColor clearColor]]; 31 | _line.contentMode = UIViewContentModeScaleAspectFill; 32 | [self addSubview:_line]; 33 | } 34 | } 35 | 36 | - (void)layoutLine{ 37 | __weak __typeof(self) weakSelf = self; 38 | [_line mas_makeConstraints:^(MASConstraintMaker *make) { 39 | make.centerX.equalTo(weakSelf); 40 | make.centerY.equalTo(weakSelf).with.offset(-40-110+6); 41 | make.size.mas_equalTo(CGSizeMake(self.transparentArea.width, 12)); 42 | }]; 43 | } 44 | 45 | - (void)startAnimation{ 46 | if(!_line || isStop){ 47 | return; 48 | } 49 | 50 | [self layoutLine]; 51 | 52 | [UIView animateWithDuration:2.3 animations:^{ 53 | _line.transform = CGAffineTransformMakeTranslation(0, self.transparentArea.height-12); 54 | } completion:^(BOOL finished) { 55 | _line.transform = CGAffineTransformIdentity; 56 | [self startAnimation]; 57 | }]; 58 | 59 | } 60 | 61 | - (void)startScan{ 62 | if(_line){ 63 | isStop = NO; 64 | if(nil == _line.superview){ 65 | [self addSubview:_line]; 66 | } 67 | [self startAnimation]; 68 | } 69 | } 70 | 71 | - (void)stopScan{ 72 | isStop = YES; 73 | [_line removeFromSuperview]; 74 | } 75 | 76 | - (void)drawRect:(CGRect)rect { 77 | 78 | //整个二维码扫描界面的颜色 79 | CGSize viewSize =self.bounds.size; 80 | CGRect screenDrawRect =CGRectMake(0, 0, viewSize.width,viewSize.height); 81 | 82 | //中间清空的矩形框 83 | CGRect clearDrawRect = CGRectMake(screenDrawRect.size.width / 2 - self.transparentArea.width / 2, 84 | screenDrawRect.size.height / 2 - self.transparentArea.height / 2 -40, 85 | self.transparentArea.width,self.transparentArea.height); 86 | 87 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 88 | [self addScreenFillRect:ctx rect:screenDrawRect]; 89 | 90 | [self addCenterClearRect:ctx rect:clearDrawRect]; 91 | 92 | [self addWhiteRect:ctx rect:clearDrawRect]; 93 | 94 | [self addCornerLineWithContext:ctx rect:clearDrawRect]; 95 | 96 | 97 | } 98 | 99 | - (void)addScreenFillRect:(CGContextRef)ctx rect:(CGRect)rect { 100 | 101 | CGContextSetRGBFillColor(ctx, 60 / 255.0,40 / 255.0,40 / 255.0,0.5); 102 | CGContextFillRect(ctx, rect); //draw the transparent layer 103 | } 104 | 105 | - (void)addCenterClearRect :(CGContextRef)ctx rect:(CGRect)rect { 106 | 107 | CGContextClearRect(ctx, rect); //clear the center rect of the layer 108 | } 109 | 110 | - (void)addWhiteRect:(CGContextRef)ctx rect:(CGRect)rect { 111 | 112 | CGContextStrokeRect(ctx, rect); 113 | CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1); 114 | CGContextSetLineWidth(ctx, 0.8); 115 | CGContextAddRect(ctx, rect); 116 | CGContextStrokePath(ctx); 117 | } 118 | 119 | - (void)addCornerLineWithContext:(CGContextRef)ctx rect:(CGRect)rect{ 120 | 121 | //画四个边角 122 | CGContextSetLineWidth(ctx, 2); 123 | CGContextSetRGBStrokeColor(ctx, 52 /255.0, 152/255.0, 219/255.0, 1);//蓝色 124 | 125 | //左上角 126 | CGPoint poinsTopLeftA[] = { 127 | CGPointMake(rect.origin.x+0.7, rect.origin.y), 128 | CGPointMake(rect.origin.x+0.7 , rect.origin.y + 15) 129 | }; 130 | 131 | CGPoint poinsTopLeftB[] = {CGPointMake(rect.origin.x, rect.origin.y +0.7),CGPointMake(rect.origin.x + 15, rect.origin.y+0.7)}; 132 | [self addLine:poinsTopLeftA pointB:poinsTopLeftB ctx:ctx]; 133 | 134 | //左下角 135 | CGPoint poinsBottomLeftA[] = {CGPointMake(rect.origin.x+ 0.7, rect.origin.y + rect.size.height - 15),CGPointMake(rect.origin.x +0.7,rect.origin.y + rect.size.height)}; 136 | CGPoint poinsBottomLeftB[] = {CGPointMake(rect.origin.x , rect.origin.y + rect.size.height - 0.7) ,CGPointMake(rect.origin.x+0.7 +15, rect.origin.y + rect.size.height - 0.7)}; 137 | [self addLine:poinsBottomLeftA pointB:poinsBottomLeftB ctx:ctx]; 138 | 139 | //右上角 140 | CGPoint poinsTopRightA[] = {CGPointMake(rect.origin.x+ rect.size.width - 15, rect.origin.y+0.7),CGPointMake(rect.origin.x + rect.size.width,rect.origin.y +0.7 )}; 141 | CGPoint poinsTopRightB[] = {CGPointMake(rect.origin.x+ rect.size.width-0.7, rect.origin.y),CGPointMake(rect.origin.x + rect.size.width-0.7,rect.origin.y + 15 +0.7 )}; 142 | [self addLine:poinsTopRightA pointB:poinsTopRightB ctx:ctx]; 143 | 144 | CGPoint poinsBottomRightA[] = {CGPointMake(rect.origin.x+ rect.size.width -0.7 , rect.origin.y+rect.size.height+ -15),CGPointMake(rect.origin.x-0.7 + rect.size.width,rect.origin.y +rect.size.height )}; 145 | CGPoint poinsBottomRightB[] = {CGPointMake(rect.origin.x+ rect.size.width - 15 , rect.origin.y + rect.size.height-0.7),CGPointMake(rect.origin.x + rect.size.width,rect.origin.y + rect.size.height - 0.7 )}; 146 | [self addLine:poinsBottomRightA pointB:poinsBottomRightB ctx:ctx]; 147 | CGContextStrokePath(ctx); 148 | } 149 | 150 | - (void)addLine:(CGPoint[])pointA pointB:(CGPoint[])pointB ctx:(CGContextRef)ctx { 151 | CGContextAddLines(ctx, pointA, 2); 152 | CGContextAddLines(ctx, pointB, 2); 153 | } 154 | 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CustomScanQRCode/ScanQRCodeViewController.h: -------------------------------------------------------------------------------- 1 | // 自定义扫描二维码模块 2 | // ScanQRCodeViewController.h 3 | // DiDi 4 | // 5 | // Created by jaybin on 15/7/28. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZBarSDK.h" 11 | 12 | @interface ScanQRCodeViewController : UIViewController 13 | 14 | //打开二维码扫描视图 15 | - (void)setZBarReaderViewStart; 16 | //关闭二维码扫描视图 17 | - (void)setZBarReaderViewStop; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/CustomScanQRCode/ScanQRCodeViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/QRCodeScanLine.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "QRCodeScanLine@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/QRCodeScanLine.imageset/QRCodeScanLine@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Images.xcassets/QRCodeScanLine.imageset/QRCodeScanLine@2x.png -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/album.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "iOS-O2O-icon_hand-album.pdf" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/album.imageset/iOS-O2O-icon_hand-album.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Images.xcassets/album.imageset/iOS-O2O-icon_hand-album.pdf -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/bulb.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "iOS-O2O-icon_icon-bulb .pdf" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Images.xcassets/bulb.imageset/iOS-O2O-icon_icon-bulb .pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Images.xcassets/bulb.imageset/iOS-O2O-icon_icon-bulb .pdf -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.jaybin.com.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleLocalizations 14 | 15 | zh_CN 16 | en 17 | 18 | CFBundleName 19 | $(PRODUCT_NAME) 20 | CFBundlePackageType 21 | APPL 22 | CFBundleShortVersionString 23 | 1.0 24 | CFBundleSignature 25 | ???? 26 | CFBundleVersion 27 | 1 28 | LSRequiresIPhoneOS 29 | 30 | NSAppTransportSecurity 31 | 32 | NSAllowsArbitraryLoads 33 | 34 | 35 | UILaunchStoryboardName 36 | LaunchScreen 37 | UIMainStoryboardFile 38 | Main 39 | UIRequiredDeviceCapabilities 40 | 41 | armv7 42 | 43 | UISupportedInterfaceOrientations 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | UISupportedInterfaceOrientations~ipad 50 | 51 | UIInterfaceOrientationPortrait 52 | UIInterfaceOrientationPortraitUpsideDown 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/9/14. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #ifndef __IPHONE_4_0 12 | #warning "This project uses features only available in iOS SDK 4.0 and later." 13 | #endif 14 | 15 | #ifdef __OBJC__ 16 | #import 17 | #import 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Util/UIColor+HEX.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HEX.h 3 | // iOS-Categories (https://github.com/shaojiankui/iOS-Categories) 4 | // 5 | // Created by Jakey on 14/12/15. 6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HEX) 12 | + (UIColor *)colorWithHex:(UInt32)hex; 13 | + (UIColor *)colorWithHex:(UInt32)hex andAlpha:(CGFloat)alpha; 14 | + (UIColor *)colorWithHexString:(NSString *)hexString; 15 | - (NSString *)HEXString; 16 | 17 | + (UIColor *)colorWithWholeRed:(CGFloat)red 18 | green:(CGFloat)green 19 | blue:(CGFloat)blue 20 | alpha:(CGFloat)alpha; 21 | 22 | + (UIColor *)colorWithWholeRed:(CGFloat)red 23 | green:(CGFloat)green 24 | blue:(CGFloat)blue; 25 | @end 26 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Util/UIColor+HEX.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HEX.m 3 | // iOS-Categories (https://github.com/shaojiankui/iOS-Categories) 4 | // 5 | // Created by Jakey on 14/12/15. 6 | // Copyright (c) 2014年 www.skyfox.org. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HEX.h" 10 | CGFloat colorComponentFrom(NSString *string, NSUInteger start, NSUInteger length) { 11 | NSString *substring = [string substringWithRange:NSMakeRange(start, length)]; 12 | NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; 13 | 14 | unsigned hexComponent; 15 | [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; 16 | return hexComponent / 255.0; 17 | } 18 | 19 | @implementation UIColor (HEX) 20 | + (UIColor *)colorWithHex:(UInt32)hex{ 21 | return [UIColor colorWithHex:hex andAlpha:1]; 22 | } 23 | + (UIColor *)colorWithHex:(UInt32)hex andAlpha:(CGFloat)alpha{ 24 | return [UIColor colorWithRed:((hex >> 16) & 0xFF)/255.0 25 | green:((hex >> 8) & 0xFF)/255.0 26 | blue:(hex & 0xFF)/255.0 27 | alpha:alpha]; 28 | } 29 | 30 | + (UIColor *)colorWithHexString:(NSString *)hexString { 31 | CGFloat alpha, red, blue, green; 32 | 33 | NSString *colorString = hexString; 34 | 35 | if ([hexString hasPrefix:@"#"]) { 36 | colorString = [[hexString stringByReplacingOccurrencesOfString:@"#" withString:@""] uppercaseString];; 37 | } 38 | 39 | if ([hexString hasPrefix:@"0x"]){ 40 | colorString = [hexString substringFromIndex:2]; 41 | } 42 | 43 | switch ([colorString length]) { 44 | case 3: // #RGB 45 | alpha = 1.0f; 46 | red = colorComponentFrom(colorString, 0, 1); 47 | green = colorComponentFrom(colorString, 1, 1); 48 | blue = colorComponentFrom(colorString, 2, 1); 49 | break; 50 | 51 | case 4: // #ARGB 52 | alpha = colorComponentFrom(colorString, 0, 1); 53 | red = colorComponentFrom(colorString, 1, 1); 54 | green = colorComponentFrom(colorString, 2, 1); 55 | blue = colorComponentFrom(colorString, 3, 1); 56 | break; 57 | 58 | case 6: // #RRGGBB 59 | alpha = 1.0f; 60 | red = colorComponentFrom(colorString, 0, 2); 61 | green = colorComponentFrom(colorString, 2, 2); 62 | blue = colorComponentFrom(colorString, 4, 2); 63 | break; 64 | 65 | case 8: // #AARRGGBB 66 | alpha = colorComponentFrom(colorString, 0, 2); 67 | red = colorComponentFrom(colorString, 2, 2); 68 | green = colorComponentFrom(colorString, 4, 2); 69 | blue = colorComponentFrom(colorString, 6, 2); 70 | break; 71 | 72 | default: 73 | return nil; 74 | } 75 | return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 76 | } 77 | 78 | - (NSString *)HEXString{ 79 | UIColor* color = self; 80 | if (CGColorGetNumberOfComponents(color.CGColor) < 4) { 81 | const CGFloat *components = CGColorGetComponents(color.CGColor); 82 | color = [UIColor colorWithRed:components[0] 83 | green:components[0] 84 | blue:components[0] 85 | alpha:components[1]]; 86 | } 87 | if (CGColorSpaceGetModel(CGColorGetColorSpace(color.CGColor)) != kCGColorSpaceModelRGB) { 88 | return [NSString stringWithFormat:@"#FFFFFF"]; 89 | } 90 | return [NSString stringWithFormat:@"#%02X%02X%02X", (int)((CGColorGetComponents(color.CGColor))[0]*255.0), 91 | (int)((CGColorGetComponents(color.CGColor))[1]*255.0), 92 | (int)((CGColorGetComponents(color.CGColor))[2]*255.0)]; 93 | } 94 | 95 | + (UIColor *)colorWithWholeRed:(CGFloat)red 96 | green:(CGFloat)green 97 | blue:(CGFloat)blue 98 | alpha:(CGFloat)alpha 99 | { 100 | return [UIColor colorWithRed:red/255.f 101 | green:green/255.f 102 | blue:blue/255.f 103 | alpha:alpha]; 104 | } 105 | 106 | + (UIColor *)colorWithWholeRed:(CGFloat)red 107 | green:(CGFloat)green 108 | blue:(CGFloat)blue 109 | { 110 | return [self colorWithWholeRed:red 111 | green:green 112 | blue:blue 113 | alpha:1.0]; 114 | } 115 | @end 116 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MAS_VIEW_CONTROLLER UIViewController 16 | #define MASEdgeInsets UIEdgeInsets 17 | 18 | typedef UILayoutPriority MASLayoutPriority; 19 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 23 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 24 | 25 | #elif TARGET_OS_MAC 26 | 27 | #import 28 | #define MAS_VIEW NSView 29 | #define MASEdgeInsets NSEdgeInsets 30 | 31 | typedef NSLayoutPriority MASLayoutPriority; 32 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 33 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 34 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 36 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 37 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 38 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 39 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 40 | 41 | #endif 42 | 43 | /** 44 | * Allows you to attach keys to objects matching the variable names passed. 45 | * 46 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 47 | * 48 | * is equivalent to: 49 | * 50 | * MASAttachKeys(view1, view2); 51 | */ 52 | #define MASAttachKeys(...) \ 53 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 54 | for (id key in keyPairs.allKeys) { \ 55 | id obj = keyPairs[key]; \ 56 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 57 | @"Cannot attach mas_key to %@", obj); \ 58 | [obj setMas_key:key]; \ 59 | } 60 | 61 | /** 62 | * Used to create object hashes 63 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 64 | */ 65 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 66 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 67 | 68 | /** 69 | * Given a scalar or struct value, wraps it in NSValue 70 | * Based on EXPObjectify: https://github.com/specta/expecta 71 | */ 72 | static inline id _MASBoxValue(const char *type, ...) { 73 | va_list v; 74 | va_start(v, type); 75 | id obj = nil; 76 | if (strcmp(type, @encode(id)) == 0) { 77 | id actual = va_arg(v, id); 78 | obj = actual; 79 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 80 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 81 | obj = [NSValue value:&actual withObjCType:type]; 82 | } else if (strcmp(type, @encode(CGSize)) == 0) { 83 | CGSize actual = (CGSize)va_arg(v, CGSize); 84 | obj = [NSValue value:&actual withObjCType:type]; 85 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 86 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 87 | obj = [NSValue value:&actual withObjCType:type]; 88 | } else if (strcmp(type, @encode(double)) == 0) { 89 | double actual = (double)va_arg(v, double); 90 | obj = [NSNumber numberWithDouble:actual]; 91 | } else if (strcmp(type, @encode(float)) == 0) { 92 | float actual = (float)va_arg(v, double); 93 | obj = [NSNumber numberWithFloat:actual]; 94 | } else if (strcmp(type, @encode(int)) == 0) { 95 | int actual = (int)va_arg(v, int); 96 | obj = [NSNumber numberWithInt:actual]; 97 | } else if (strcmp(type, @encode(long)) == 0) { 98 | long actual = (long)va_arg(v, long); 99 | obj = [NSNumber numberWithLong:actual]; 100 | } else if (strcmp(type, @encode(long long)) == 0) { 101 | long long actual = (long long)va_arg(v, long long); 102 | obj = [NSNumber numberWithLongLong:actual]; 103 | } else if (strcmp(type, @encode(short)) == 0) { 104 | short actual = (short)va_arg(v, int); 105 | obj = [NSNumber numberWithShort:actual]; 106 | } else if (strcmp(type, @encode(char)) == 0) { 107 | char actual = (char)va_arg(v, int); 108 | obj = [NSNumber numberWithChar:actual]; 109 | } else if (strcmp(type, @encode(bool)) == 0) { 110 | bool actual = (bool)va_arg(v, int); 111 | obj = [NSNumber numberWithBool:actual]; 112 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 113 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 114 | obj = [NSNumber numberWithUnsignedChar:actual]; 115 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 116 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 117 | obj = [NSNumber numberWithUnsignedInt:actual]; 118 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 119 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 120 | obj = [NSNumber numberWithUnsignedLong:actual]; 121 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 122 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 123 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 124 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 125 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 126 | obj = [NSNumber numberWithUnsignedShort:actual]; 127 | } 128 | va_end(v); 129 | return obj; 130 | } 131 | 132 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 133 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | @interface NSArray (MASAdditions) 14 | 15 | /** 16 | * Creates a MASConstraintMaker with each view in the callee. 17 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 18 | * 19 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 20 | * 21 | * @return Array of created MASConstraints 22 | */ 23 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 24 | 25 | /** 26 | * Creates a MASConstraintMaker with each view in the callee. 27 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 28 | * If an existing constraint exists then it will be updated instead. 29 | * 30 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 31 | * 32 | * @return Array of created/updated MASConstraints 33 | */ 34 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | /** 37 | * Creates a MASConstraintMaker with each view in the callee. 38 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 39 | * All constraints previously installed for the views will be removed. 40 | * 41 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 42 | * 43 | * @return Array of created/updated MASConstraints 44 | */ 45 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if TARGET_OS_IPHONE 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILa 8youtGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | 19 | - (MASViewAttribute *)mas_bottomLayoutGuide { 20 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 21 | } 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarCameraSimulator.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2010-2011 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | @class ZBarReaderView; 25 | 26 | // hack around missing simulator support for AVCapture interfaces 27 | 28 | @interface ZBarCameraSimulator 29 | : NSObject 30 | < UINavigationControllerDelegate, 31 | UIImagePickerControllerDelegate, 32 | UIPopoverControllerDelegate > 33 | { 34 | UIViewController *viewController; 35 | ZBarReaderView *readerView; 36 | UIImagePickerController *picker; 37 | UIPopoverController *pickerPopover; 38 | } 39 | 40 | - (id) initWithViewController: (UIViewController*) viewController; 41 | - (void) takePicture; 42 | 43 | @property (nonatomic, assign) ZBarReaderView *readerView; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarCaptureReader.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "ZBarImageScanner.h" 26 | 27 | @class AVCaptureVideoDataOutput, AVCaptureOutput; 28 | @class ZBarCaptureReader, ZBarCVImage; 29 | 30 | @protocol ZBarCaptureDelegate 31 | 32 | // called when a new barcode is detected. the image refers to the 33 | // video buffer and must not be retained for long 34 | - (void) captureReader: (ZBarCaptureReader*) captureReader 35 | didReadNewSymbolsFromImage: (ZBarImage*) image; 36 | 37 | @optional 38 | // called when a potential/uncertain barcode is detected. will also 39 | // be called *after* captureReader:didReadNewSymbolsFromImage: 40 | // when good barcodes are detected 41 | - (void) captureReader: (ZBarCaptureReader*) captureReader 42 | didTrackSymbols: (ZBarSymbolSet*) symbols; 43 | 44 | @end 45 | 46 | @interface ZBarCaptureReader 47 | : NSObject 48 | { 49 | #if !TARGET_IPHONE_SIMULATOR 50 | AVCaptureVideoDataOutput *captureOutput; 51 | id captureDelegate; 52 | ZBarImageScanner *scanner; 53 | CGRect scanCrop; 54 | CGSize size; 55 | CGFloat framesPerSecond; 56 | BOOL enableCache; 57 | 58 | dispatch_queue_t queue; 59 | ZBarImage *image; 60 | ZBarCVImage *result; 61 | volatile uint32_t state; 62 | int framecnt; 63 | unsigned width, height; 64 | uint64_t t_frame, t_fps, t_scan; 65 | CGFloat dt_frame; 66 | #endif 67 | } 68 | 69 | // supply a pre-configured image scanner 70 | - (id) initWithImageScanner: (ZBarImageScanner*) imageScanner; 71 | 72 | // this must be called before the session is started 73 | - (void) willStartRunning; 74 | 75 | // this must be called *before* the session is stopped 76 | - (void) willStopRunning; 77 | 78 | // clear the internal result cache 79 | - (void) flushCache; 80 | 81 | // capture the next frame after processing. the captured image will 82 | // follow the same delegate path as an image with decoded symbols. 83 | - (void) captureFrame; 84 | 85 | // the capture output. add this to an instance of AVCaptureSession 86 | @property (nonatomic, readonly) AVCaptureOutput *captureOutput; 87 | 88 | // delegate is notified of decode results and symbol tracking. 89 | @property (nonatomic, assign) id captureDelegate; 90 | 91 | // access to image scanner for configuration. 92 | @property (nonatomic, readonly) ZBarImageScanner *scanner; 93 | 94 | // region of image to scan in normalized coordinates. 95 | // NB horizontal crop currently ignored... 96 | @property (nonatomic, assign) CGRect scanCrop; 97 | 98 | // size of video frames. 99 | @property (nonatomic, readonly) CGSize size; 100 | 101 | // (quickly) gate the reader function without interrupting the video 102 | // stream. also flushes the cache when enabled. defaults to *NO* 103 | @property (nonatomic) BOOL enableReader; 104 | 105 | // current frame rate (for debug/optimization). 106 | // only valid when running 107 | @property (nonatomic, readonly) CGFloat framesPerSecond; 108 | 109 | @property (nonatomic) BOOL enableCache; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarHelpController.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2009-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | 26 | @class ZBarHelpController; 27 | 28 | @protocol ZBarHelpDelegate 29 | @optional 30 | 31 | - (void) helpControllerDidFinish: (ZBarHelpController*) help; 32 | 33 | @end 34 | 35 | 36 | // failure dialog w/a few useful tips 37 | 38 | @interface ZBarHelpController : UIViewController 39 | < UIWebViewDelegate, 40 | UIAlertViewDelegate > 41 | { 42 | NSString *reason; 43 | id delegate; 44 | UIWebView *webView; 45 | UIToolbar *toolbar; 46 | UIBarButtonItem *doneBtn, *backBtn, *space; 47 | NSURL *linkURL; 48 | NSUInteger orientations; 49 | } 50 | 51 | @property (nonatomic, assign) id delegate; 52 | 53 | // designated initializer 54 | - (id) initWithReason: (NSString*) reason; 55 | 56 | - (BOOL) isInterfaceOrientationSupported: (UIInterfaceOrientation) orientation; 57 | - (void) setInterfaceOrientation: (UIInterfaceOrientation) orientation 58 | supported: (BOOL) supported; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarImage.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "zbar.h" 26 | #import "ZBarSymbol.h" 27 | 28 | #ifdef __cplusplus 29 | using namespace zbar; 30 | #endif 31 | 32 | // Obj-C wrapper for ZBar image 33 | 34 | @interface ZBarImage : NSObject 35 | { 36 | zbar_image_t *zimg; 37 | double t_convert; 38 | } 39 | 40 | @property (nonatomic) unsigned long format; 41 | @property (nonatomic) unsigned sequence; 42 | @property (nonatomic) CGSize size; 43 | @property (nonatomic) CGRect crop; 44 | @property (readonly, nonatomic) const void *data; 45 | @property (readonly, nonatomic) unsigned long dataLength; 46 | @property (copy, nonatomic) ZBarSymbolSet *symbols; 47 | @property (readonly, nonatomic) zbar_image_t *zbarImage; 48 | @property (readonly, nonatomic) UIImage *UIImage; 49 | 50 | - (id) initWithImage: (zbar_image_t*) image; 51 | - (id) initWithCGImage: (CGImageRef) image; 52 | - (id) initWithCGImage: (CGImageRef) image 53 | size: (CGSize) size; 54 | - (id) initWithCGImage: (CGImageRef) image 55 | crop: (CGRect) crop 56 | size: (CGSize) size; 57 | 58 | - (void) setData: (const void*) data 59 | withLength: (unsigned long) length; 60 | - (UIImage*) UIImageWithOrientation: (UIImageOrientation) imageOrientation; 61 | - (void) cleanup; 62 | 63 | + (unsigned long) fourcc: (NSString*) format; 64 | 65 | #if 0 66 | - convertToFormat: (unsigned long) format; 67 | #endif 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarImageScanner.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "zbar.h" 26 | #import "ZBarImage.h" 27 | 28 | #ifdef __cplusplus 29 | using namespace zbar; 30 | #endif 31 | 32 | // Obj-C wrapper for ZBar image scanner 33 | 34 | @interface ZBarImageScanner : NSObject 35 | { 36 | zbar_image_scanner_t *scanner; 37 | } 38 | 39 | @property (nonatomic) BOOL enableCache; 40 | @property (readonly, nonatomic) ZBarSymbolSet *results; 41 | 42 | // decoder configuration 43 | - (void) parseConfig: (NSString*) configStr; 44 | - (void) setSymbology: (zbar_symbol_type_t) symbology 45 | config: (zbar_config_t) config 46 | to: (int) value; 47 | 48 | // image scanning interface 49 | - (NSInteger) scanImage: (ZBarImage*) image; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarReaderController.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2009-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "ZBarImageScanner.h" 26 | 27 | #ifdef __cplusplus 28 | using namespace zbar; 29 | #endif 30 | 31 | typedef enum { 32 | // default interface provided by UIImagePickerController - user manually 33 | // captures an image by pressing a button 34 | ZBarReaderControllerCameraModeDefault = 0, 35 | 36 | // automatically scan by taking screenshots with UIGetScreenImage(). 37 | // resolution is limited by the screen, so this is inappropriate for 38 | // longer codes 39 | ZBarReaderControllerCameraModeSampling, 40 | 41 | // automatically scan by rapidly taking pictures with takePicture. 42 | // tradeoff resolution with frame rate by adjusting the crop, and size 43 | // properties of the reader along with the density configs of the image 44 | // scanner 45 | ZBarReaderControllerCameraModeSequence, 46 | 47 | } ZBarReaderControllerCameraMode; 48 | 49 | 50 | @class ZBarReaderController, ZBarHelpController; 51 | 52 | @protocol ZBarReaderDelegate 53 | @optional 54 | 55 | // called when no barcode is found in an image selected by the user. 56 | // if retry is NO, the delegate *must* dismiss the controller 57 | - (void) readerControllerDidFailToRead: (ZBarReaderController*) reader 58 | withRetry: (BOOL) retry; 59 | 60 | @end 61 | 62 | 63 | @interface ZBarReaderController 64 | : UIImagePickerController 65 | < UINavigationControllerDelegate, 66 | UIImagePickerControllerDelegate > 67 | { 68 | ZBarImageScanner *scanner; 69 | ZBarHelpController *help; 70 | UIView *overlay, *boxView; 71 | CALayer *boxLayer; 72 | 73 | UIToolbar *toolbar; 74 | UIBarButtonItem *cancelBtn, *scanBtn, *space[3]; 75 | UIButton *infoBtn; 76 | 77 | id readerDelegate; 78 | BOOL showsZBarControls, showsHelpOnFail, takesPicture, enableCache; 79 | ZBarReaderControllerCameraMode cameraMode; 80 | CGRect scanCrop; 81 | NSInteger maxScanDimension; 82 | 83 | BOOL hasOverlay, sampling; 84 | uint64_t t_frame; 85 | double dt_frame; 86 | 87 | ZBarSymbol *symbol; 88 | } 89 | 90 | // access to configure image scanner 91 | @property (readonly, nonatomic) ZBarImageScanner *scanner; 92 | 93 | // barcode result recipient (NB don't use delegate) 94 | @property (nonatomic, assign) id readerDelegate; 95 | 96 | // whether to use alternate control set 97 | @property (nonatomic) BOOL showsZBarControls; 98 | 99 | // whether to display helpful information when decoding fails 100 | @property (nonatomic) BOOL showsHelpOnFail; 101 | 102 | // how to use the camera (when sourceType == Camera) 103 | @property (nonatomic) ZBarReaderControllerCameraMode cameraMode; 104 | 105 | // whether to outline symbols with the green tracking box. 106 | @property (nonatomic) BOOL tracksSymbols; 107 | 108 | // whether to automatically take a full picture when a barcode is detected 109 | // (when cameraMode == Sampling) 110 | @property (nonatomic) BOOL takesPicture; 111 | 112 | // whether to use the "cache" for realtime modes (default YES). this can be 113 | // used to safely disable the inter-frame consistency and duplicate checks, 114 | // speeding up recognition, iff: 115 | // 1. the controller is dismissed when a barcode is read and 116 | // 2. unreliable symbologies are disabled (all EAN/UPC variants and I2/5) 117 | @property (nonatomic) BOOL enableCache; 118 | 119 | // crop images for scanning. the original image will be cropped to this 120 | // rectangle before scanning. the rectangle is normalized to the image size 121 | // and aspect ratio; useful values will place the rectangle between 0 and 1 122 | // on each axis, where the x-axis corresponds to the image major axis. 123 | // defaults to the full image (0, 0, 1, 1). 124 | @property (nonatomic) CGRect scanCrop; 125 | 126 | // scale image to scan. after cropping, the image will be scaled if 127 | // necessary, such that neither of its dimensions exceed this value. 128 | // defaults to 640. 129 | @property (nonatomic) NSInteger maxScanDimension; 130 | 131 | // display the built-in help browser. for use with custom overlays if 132 | // you don't also want to create your own help view. only send this 133 | // message when the reader is displayed. the argument will be passed 134 | // to the onZBarHelp() javascript function. 135 | - (void) showHelpWithReason: (NSString*) reason; 136 | 137 | // direct scanner interface - scan UIImage and return something enumerable 138 | - (id ) scanImage: (CGImageRef) image; 139 | 140 | @end 141 | 142 | extern NSString* const ZBarReaderControllerResults; 143 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarReaderView.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "ZBarImageScanner.h" 26 | 27 | @class AVCaptureSession, AVCaptureDevice; 28 | @class CALayer; 29 | @class ZBarImageScanner, ZBarCaptureReader, ZBarReaderView; 30 | 31 | // delegate is notified of decode results. 32 | 33 | @protocol ZBarReaderViewDelegate < NSObject > 34 | 35 | - (void) readerView: (ZBarReaderView*) readerView 36 | didReadSymbols: (ZBarSymbolSet*) symbols 37 | fromImage: (UIImage*) image; 38 | 39 | @end 40 | 41 | // read barcodes from the displayed video preview. the view maintains 42 | // a complete video capture session feeding a ZBarCaptureReader and 43 | // presents the associated preview with symbol tracking annotations. 44 | 45 | @interface ZBarReaderView 46 | : UIView 47 | { 48 | id readerDelegate; 49 | ZBarCaptureReader *captureReader; 50 | CGRect scanCrop, effectiveCrop; 51 | CGAffineTransform previewTransform; 52 | CGFloat zoom, zoom0, maxZoom; 53 | UIColor *trackingColor; 54 | BOOL tracksSymbols, showsFPS; 55 | NSInteger torchMode; 56 | UIInterfaceOrientation interfaceOrientation; 57 | NSTimeInterval animationDuration; 58 | 59 | CALayer *preview, *overlay, *tracking, *cropLayer; 60 | UIView *fpsView; 61 | UILabel *fpsLabel; 62 | UIPinchGestureRecognizer *pinch; 63 | CGFloat imageScale; 64 | CGSize imageSize; 65 | BOOL started, running; 66 | } 67 | 68 | // supply a pre-configured image scanner. 69 | - (id) initWithImageScanner: (ZBarImageScanner*) imageScanner; 70 | 71 | // start the video stream and barcode reader. 72 | - (void) start; 73 | 74 | // stop the video stream and barcode reader. 75 | - (void) stop; 76 | 77 | // clear the internal result cache 78 | - (void) flushCache; 79 | 80 | // compensate for device/camera/interface orientation 81 | - (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) orient 82 | duration: (NSTimeInterval) duration; 83 | 84 | // delegate is notified of decode results. 85 | @property (nonatomic, assign) id readerDelegate; 86 | 87 | // access to image scanner for configuration. 88 | @property (nonatomic, readonly) ZBarImageScanner *scanner; 89 | 90 | // whether to display the tracking annotation for uncertain barcodes 91 | // (default YES). 92 | @property (nonatomic) BOOL tracksSymbols; 93 | 94 | // color of the tracking box (default green) 95 | @property (nonatomic, retain) UIColor *trackingColor; 96 | 97 | // enable pinch gesture recognition for zooming the preview/decode 98 | // (default YES). 99 | @property (nonatomic) BOOL allowsPinchZoom; 100 | 101 | // torch mode to set automatically (default Auto). 102 | @property (nonatomic) NSInteger torchMode; 103 | 104 | // whether to display the frame rate for debug/configuration 105 | // (default NO). 106 | @property (nonatomic) BOOL showsFPS; 107 | 108 | // zoom scale factor applied to video preview *and* scanCrop. 109 | // also updated by pinch-zoom gesture. clipped to range [1,maxZoom], 110 | // defaults to 1.25 111 | @property (nonatomic) CGFloat zoom; 112 | - (void) setZoom: (CGFloat) zoom 113 | animated: (BOOL) animated; 114 | 115 | // maximum settable zoom factor. 116 | @property (nonatomic) CGFloat maxZoom; 117 | 118 | // the region of the image that will be scanned. normalized coordinates. 119 | @property (nonatomic) CGRect scanCrop; 120 | 121 | // additional transform applied to video preview. 122 | // (NB *not* applied to scan crop) 123 | @property (nonatomic) CGAffineTransform previewTransform; 124 | 125 | // specify an alternate capture device. 126 | @property (nonatomic, retain) AVCaptureDevice *device; 127 | 128 | // direct access to the capture session. warranty void if opened... 129 | @property (nonatomic, readonly) AVCaptureSession *session; 130 | @property (nonatomic, readonly) ZBarCaptureReader *captureReader; 131 | 132 | // this flag still works, but its use is deprecated 133 | @property (nonatomic) BOOL enableCache; 134 | 135 | @end 136 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarReaderViewController.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import "ZBarReaderController.h" 26 | 27 | // orientation set support 28 | #define ZBarOrientationMask(orient) (1 << orient) 29 | #define ZBarOrientationMaskAll \ 30 | (ZBarOrientationMask(UIInterfaceOrientationPortrait) | \ 31 | ZBarOrientationMask(UIInterfaceOrientationPortraitUpsideDown) | \ 32 | ZBarOrientationMask(UIInterfaceOrientationLandscapeLeft) | \ 33 | ZBarOrientationMask(UIInterfaceOrientationLandscapeRight)) 34 | 35 | @class ZBarReaderView, ZBarCameraSimulator; 36 | 37 | // drop in video scanning replacement for ZBarReaderController. 38 | // this is a thin controller around a ZBarReaderView that adds the UI 39 | // controls and select functionality offered by ZBarReaderController. 40 | // Automatically falls back to a ZBarReaderController if video APIs 41 | // are unavailable (eg for OS < 4.0) 42 | 43 | @interface ZBarReaderViewController 44 | : UIViewController 45 | { 46 | ZBarImageScanner *scanner; 47 | id readerDelegate; 48 | ZBarReaderView *readerView; 49 | UIView *cameraOverlayView; 50 | CGAffineTransform cameraViewTransform; 51 | CGRect scanCrop; 52 | NSUInteger supportedOrientationsMask; 53 | UIImagePickerControllerCameraDevice cameraDevice; 54 | UIImagePickerControllerCameraFlashMode cameraFlashMode; 55 | UIImagePickerControllerQualityType videoQuality; 56 | BOOL showsZBarControls, tracksSymbols, enableCache; 57 | 58 | ZBarHelpController *helpController; 59 | UIView *controls; 60 | BOOL didHideStatusBar, rotating; 61 | ZBarCameraSimulator *cameraSim; 62 | } 63 | 64 | // access to configure image scanner 65 | @property (nonatomic, readonly) ZBarImageScanner *scanner; 66 | 67 | // barcode result recipient 68 | @property (nonatomic, assign) id readerDelegate; 69 | 70 | // whether to use alternate control set 71 | @property (nonatomic) BOOL showsZBarControls; 72 | 73 | // whether to show the green tracking box. note that, even when 74 | // enabled, the box will only be visible when scanning EAN and I2/5. 75 | @property (nonatomic) BOOL tracksSymbols; 76 | 77 | // interface orientation support. bit-mask of accepted orientations. 78 | // see eg ZBarOrientationMask() and ZBarOrientationMaskAll 79 | @property (nonatomic) NSUInteger supportedOrientationsMask; 80 | 81 | // crop images for scanning. the image will be cropped to this 82 | // rectangle before scanning. the rectangle is normalized to the 83 | // image size and aspect ratio; useful values will place the rectangle 84 | // between 0 and 1 on each axis, where the x-axis corresponds to the 85 | // image major axis. defaults to the full image (0, 0, 1, 1). 86 | @property (nonatomic) CGRect scanCrop; 87 | 88 | // provide a custom overlay. note that this can be used with 89 | // showsZBarControls enabled (but not if you want backward compatibility) 90 | @property (nonatomic, retain) UIView *cameraOverlayView; 91 | 92 | // transform applied to the preview image. 93 | @property (nonatomic) CGAffineTransform cameraViewTransform; 94 | 95 | // display the built-in help browser. the argument will be passed to 96 | // the onZBarHelp() javascript function. 97 | - (void) showHelpWithReason: (NSString*) reason; 98 | 99 | // capture the next frame and send it over the usual delegate path. 100 | - (void) takePicture; 101 | 102 | // these attempt to emulate UIImagePickerController 103 | + (BOOL) isCameraDeviceAvailable: (UIImagePickerControllerCameraDevice) cameraDevice; 104 | + (BOOL) isFlashAvailableForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice; 105 | + (NSArray*) availableCaptureModesForCameraDevice: (UIImagePickerControllerCameraDevice) cameraDevice; 106 | @property(nonatomic) UIImagePickerControllerCameraDevice cameraDevice; 107 | @property(nonatomic) UIImagePickerControllerCameraFlashMode cameraFlashMode; 108 | @property(nonatomic) UIImagePickerControllerCameraCaptureMode cameraCaptureMode; 109 | @property(nonatomic) UIImagePickerControllerQualityType videoQuality; 110 | 111 | // direct access to the ZBarReaderView 112 | @property (nonatomic, readonly) ZBarReaderView *readerView; 113 | 114 | // this flag still works, but its use is deprecated 115 | @property (nonatomic) BOOL enableCache; 116 | 117 | // these are present only for backward compatibility. 118 | // they will error if inappropriate/unsupported values are set 119 | @property (nonatomic) UIImagePickerControllerSourceType sourceType; // Camera 120 | @property (nonatomic) BOOL allowsEditing; // NO 121 | @property (nonatomic) BOOL allowsImageEditing; // NO 122 | @property (nonatomic) BOOL showsCameraControls; // NO 123 | @property (nonatomic) BOOL showsHelpOnFail; // ignored 124 | @property (nonatomic) ZBarReaderControllerCameraMode cameraMode; // Sampling 125 | @property (nonatomic) BOOL takesPicture; // NO 126 | @property (nonatomic) NSInteger maxScanDimension; // ignored 127 | 128 | + (BOOL) isSourceTypeAvailable: (UIImagePickerControllerSourceType) sourceType; 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarSDK.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------ 2 | * Copyright 2010 (c) Jeff Brown 3 | * 4 | * This file is part of the ZBar Bar Code Reader. 5 | * 6 | * The ZBar Bar Code Reader is free software; you can redistribute it 7 | * and/or modify it under the terms of the GNU Lesser Public License as 8 | * published by the Free Software Foundation; either version 2.1 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * The ZBar Bar Code Reader is distributed in the hope that it will be 12 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser Public License 17 | * along with the ZBar Bar Code Reader; if not, write to the Free 18 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | * Boston, MA 02110-1301 USA 20 | * 21 | * http://sourceforge.net/projects/zbar 22 | *------------------------------------------------------------------------*/ 23 | 24 | #import "zbar.h" 25 | 26 | #import "ZBarSymbol.h" 27 | #import "ZBarImage.h" 28 | #import "ZBarImageScanner.h" 29 | #import "ZBarReaderView.h" 30 | #import "ZBarReaderViewController.h" 31 | #import "ZBarReaderController.h" 32 | #import "ZBarCaptureReader.h" 33 | #import "ZBarHelpController.h" 34 | #import "ZBarCameraSimulator.h" 35 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/ZBarSymbol.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2009-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | 24 | #import 25 | #import 26 | #import "zbar.h" 27 | 28 | #ifdef __cplusplus 29 | using namespace zbar; 30 | #endif 31 | 32 | // Obj-C wrapper for ZBar result types 33 | 34 | @interface ZBarSymbolSet 35 | : NSObject 36 | { 37 | const zbar_symbol_set_t *set; 38 | BOOL filterSymbols; 39 | } 40 | 41 | @property (readonly, nonatomic) int count; 42 | @property (readonly, nonatomic) const zbar_symbol_set_t *zbarSymbolSet; 43 | @property (nonatomic) BOOL filterSymbols; 44 | 45 | - (id) initWithSymbolSet: (const zbar_symbol_set_t*) set; 46 | 47 | @end 48 | 49 | 50 | @interface ZBarSymbol : NSObject 51 | { 52 | const zbar_symbol_t *symbol; 53 | } 54 | 55 | @property (readonly, nonatomic) zbar_symbol_type_t type; 56 | @property (readonly, nonatomic) NSString *typeName; 57 | @property (readonly, nonatomic) NSUInteger configMask; 58 | @property (readonly, nonatomic) NSUInteger modifierMask; 59 | @property (readonly, nonatomic) NSString *data; 60 | @property (readonly, nonatomic) int quality; 61 | @property (readonly, nonatomic) int count; 62 | @property (readonly, nonatomic) zbar_orientation_t orientation; 63 | @property (readonly, nonatomic) ZBarSymbolSet *components; 64 | @property (readonly, nonatomic) const zbar_symbol_t *zbarSymbol; 65 | @property (readonly, nonatomic) CGRect bounds; 66 | 67 | - (id) initWithSymbol: (const zbar_symbol_t*) symbol; 68 | 69 | + (NSString*) nameForType: (zbar_symbol_type_t) type; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Decoder.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_DECODER_H_ 24 | #define _ZBAR_DECODER_H_ 25 | 26 | /// @file 27 | /// Decoder C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Decoder.h" 31 | #endif 32 | 33 | #include 34 | 35 | namespace zbar { 36 | 37 | /// low-level bar width stream decoder interface. 38 | /// identifies symbols and extracts encoded data 39 | 40 | class Decoder { 41 | public: 42 | 43 | /// Decoder result handler. 44 | /// applications should subtype this and pass an instance to 45 | /// set_handler() to implement result processing 46 | class Handler { 47 | public: 48 | virtual ~Handler() { } 49 | 50 | /// invoked by the Decoder as decode results become available. 51 | virtual void decode_callback(Decoder &decoder) = 0; 52 | }; 53 | 54 | /// constructor. 55 | Decoder () 56 | : _handler(NULL) 57 | { 58 | _decoder = zbar_decoder_create(); 59 | } 60 | 61 | ~Decoder () 62 | { 63 | zbar_decoder_destroy(_decoder); 64 | } 65 | 66 | /// clear all decoder state. 67 | /// see zbar_decoder_reset() 68 | void reset () 69 | { 70 | zbar_decoder_reset(_decoder); 71 | } 72 | 73 | /// mark start of a new scan pass. 74 | /// see zbar_decoder_new_scan() 75 | void new_scan () 76 | { 77 | zbar_decoder_new_scan(_decoder); 78 | } 79 | 80 | /// process next bar/space width from input stream. 81 | /// see zbar_decode_width() 82 | zbar_symbol_type_t decode_width (unsigned width) 83 | { 84 | return(zbar_decode_width(_decoder, width)); 85 | } 86 | 87 | /// process next bar/space width from input stream. 88 | /// see zbar_decode_width() 89 | Decoder& operator<< (unsigned width) 90 | { 91 | zbar_decode_width(_decoder, width); 92 | return(*this); 93 | } 94 | 95 | /// retrieve color of @em next element passed to Decoder. 96 | /// see zbar_decoder_get_color() 97 | zbar_color_t get_color () const 98 | { 99 | return(zbar_decoder_get_color(_decoder)); 100 | } 101 | 102 | /// retrieve last decoded symbol type. 103 | /// see zbar_decoder_get_type() 104 | zbar_symbol_type_t get_type () const 105 | { 106 | return(zbar_decoder_get_type(_decoder)); 107 | } 108 | 109 | /// retrieve string name of last decoded symbol type. 110 | /// see zbar_get_symbol_name() 111 | const char *get_symbol_name () const 112 | { 113 | return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder))); 114 | } 115 | 116 | /// retrieve string name for last decode addon. 117 | /// see zbar_get_addon_name() 118 | /// @deprecated in 0.11 119 | const char *get_addon_name () const 120 | { 121 | return(zbar_get_addon_name(zbar_decoder_get_type(_decoder))); 122 | } 123 | 124 | /// retrieve last decoded data in ASCII format as a char array. 125 | /// see zbar_decoder_get_data() 126 | const char *get_data_chars() const 127 | { 128 | return(zbar_decoder_get_data(_decoder)); 129 | } 130 | 131 | /// retrieve last decoded data as a std::string. 132 | /// see zbar_decoder_get_data() 133 | const std::string get_data_string() const 134 | { 135 | return(std::string(zbar_decoder_get_data(_decoder), 136 | zbar_decoder_get_data_length(_decoder))); 137 | } 138 | 139 | /// retrieve last decoded data as a std::string. 140 | /// see zbar_decoder_get_data() 141 | const std::string get_data() const 142 | { 143 | return(get_data_string()); 144 | } 145 | 146 | /// retrieve length of decoded binary data. 147 | /// see zbar_decoder_get_data_length() 148 | int get_data_length() const 149 | { 150 | return(zbar_decoder_get_data_length(_decoder)); 151 | } 152 | 153 | /// retrieve last decode direction. 154 | /// see zbar_decoder_get_direction() 155 | /// @since 0.11 156 | int get_direction() const 157 | { 158 | return(zbar_decoder_get_direction(_decoder)); 159 | } 160 | 161 | /// setup callback to handle result data. 162 | void set_handler (Handler &handler) 163 | { 164 | _handler = &handler; 165 | zbar_decoder_set_handler(_decoder, _cb); 166 | zbar_decoder_set_userdata(_decoder, this); 167 | } 168 | 169 | /// set config for indicated symbology (0 for all) to specified value. 170 | /// @see zbar_decoder_set_config() 171 | /// @since 0.4 172 | int set_config (zbar_symbol_type_t symbology, 173 | zbar_config_t config, 174 | int value) 175 | { 176 | return(zbar_decoder_set_config(_decoder, symbology, config, value)); 177 | } 178 | 179 | /// set config parsed from configuration string. 180 | /// @see zbar_decoder_parse_config() 181 | /// @since 0.4 182 | int set_config (std::string cfgstr) 183 | { 184 | return(zbar_decoder_parse_config(_decoder, cfgstr.c_str())); 185 | } 186 | 187 | private: 188 | friend class Scanner; 189 | zbar_decoder_t *_decoder; 190 | Handler *_handler; 191 | 192 | static void _cb (zbar_decoder_t *cdcode) 193 | { 194 | Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode); 195 | if(dcode && dcode->_handler) 196 | dcode->_handler->decode_callback(*dcode); 197 | } 198 | }; 199 | 200 | } 201 | 202 | #endif 203 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Exception.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_EXCEPTION_H_ 24 | #define _ZBAR_EXCEPTION_H_ 25 | 26 | /// @file 27 | /// C++ Exception definitions 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Exception.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | namespace zbar { 37 | 38 | /// base class for exceptions defined by this API. 39 | class Exception : public std::exception { 40 | 41 | public: 42 | /// create exception from C library error 43 | Exception (const void *obj = NULL) 44 | : std::exception(), 45 | _obj(obj) 46 | { } 47 | 48 | ~Exception () throw() { } 49 | 50 | /// retrieve error message 51 | virtual const char* what () const throw() 52 | { 53 | if(!_obj) 54 | return("zbar library unspecified generic error"); 55 | return(_zbar_error_string(_obj, 0)); 56 | } 57 | 58 | private: 59 | const void *_obj; 60 | }; 61 | 62 | /// internal library error. 63 | class InternalError : public Exception { 64 | public: 65 | /// create exception from C library error 66 | InternalError (const void *obj) 67 | : Exception(obj) 68 | { } 69 | }; 70 | 71 | /// unsupported request. 72 | class UnsupportedError : public Exception { 73 | public: 74 | /// create exception from C library error 75 | UnsupportedError (const void *obj) 76 | : Exception(obj) 77 | { } 78 | }; 79 | 80 | /// invalid request. 81 | class InvalidError : public Exception { 82 | public: 83 | /// create exception from C library error 84 | InvalidError (const void *obj) 85 | : Exception(obj) 86 | { } 87 | }; 88 | 89 | /// failed system call. 90 | class SystemError : public Exception { 91 | public: 92 | /// create exception from C library error 93 | SystemError (const void *obj) 94 | : Exception(obj) 95 | { } 96 | }; 97 | 98 | /// locking error. 99 | class LockingError : public Exception { 100 | public: 101 | /// create exception from C library error 102 | LockingError (const void *obj) 103 | : Exception(obj) 104 | { } 105 | }; 106 | 107 | /// all resources busy. 108 | class BusyError : public Exception { 109 | public: 110 | /// create exception from C library error 111 | BusyError (const void *obj) 112 | : Exception(obj) 113 | { } 114 | }; 115 | 116 | /// X11 display error. 117 | class XDisplayError : public Exception { 118 | public: 119 | /// create exception from C library error 120 | XDisplayError (const void *obj) 121 | : Exception(obj) 122 | { } 123 | }; 124 | 125 | /// X11 protocol error. 126 | class XProtoError : public Exception { 127 | public: 128 | /// create exception from C library error 129 | XProtoError (const void *obj) 130 | : Exception(obj) 131 | { } 132 | }; 133 | 134 | /// output window is closed. 135 | class ClosedError : public Exception { 136 | public: 137 | /// create exception from C library error 138 | ClosedError (const void *obj) 139 | : Exception(obj) 140 | { } 141 | }; 142 | 143 | /// image format error 144 | class FormatError : public Exception { 145 | // FIXME needs c equivalent 146 | 147 | virtual const char* what () const throw() 148 | { 149 | // FIXME what format? 150 | return("unsupported format"); 151 | } 152 | }; 153 | 154 | /// @internal 155 | 156 | /// extract error information and create exception. 157 | static inline std::exception throw_exception (const void *obj) 158 | { 159 | switch(_zbar_get_error_code(obj)) { 160 | case ZBAR_ERR_NOMEM: 161 | throw std::bad_alloc(); 162 | case ZBAR_ERR_INTERNAL: 163 | throw InternalError(obj); 164 | case ZBAR_ERR_UNSUPPORTED: 165 | throw UnsupportedError(obj); 166 | case ZBAR_ERR_INVALID: 167 | throw InvalidError(obj); 168 | case ZBAR_ERR_SYSTEM: 169 | throw SystemError(obj); 170 | case ZBAR_ERR_LOCKING: 171 | throw LockingError(obj); 172 | case ZBAR_ERR_BUSY: 173 | throw BusyError(obj); 174 | case ZBAR_ERR_XDISPLAY: 175 | throw XDisplayError(obj); 176 | case ZBAR_ERR_XPROTO: 177 | throw XProtoError(obj); 178 | case ZBAR_ERR_CLOSED: 179 | throw ClosedError(obj); 180 | default: 181 | throw Exception(obj); 182 | } 183 | } 184 | 185 | } 186 | 187 | #endif 188 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/ImageScanner.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_IMAGE_SCANNER_H_ 24 | #define _ZBAR_IMAGE_SCANNER_H_ 25 | 26 | /// @file 27 | /// Image Scanner C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/ImageScanner.h" 31 | #endif 32 | 33 | #include "Image.h" 34 | 35 | namespace zbar { 36 | 37 | /// mid-level image scanner interface. 38 | /// reads barcodes from a 2-D Image 39 | 40 | class ImageScanner { 41 | public: 42 | /// constructor. 43 | ImageScanner (zbar_image_scanner_t *scanner = NULL) 44 | { 45 | if(scanner) 46 | _scanner = scanner; 47 | else 48 | _scanner = zbar_image_scanner_create(); 49 | } 50 | 51 | ~ImageScanner () 52 | { 53 | zbar_image_scanner_destroy(_scanner); 54 | } 55 | 56 | /// cast to C image_scanner object 57 | operator zbar_image_scanner_t* () const 58 | { 59 | return(_scanner); 60 | } 61 | 62 | /// setup result handler callback. 63 | void set_handler (Image::Handler &handler) 64 | { 65 | zbar_image_scanner_set_data_handler(_scanner, handler, &handler); 66 | } 67 | 68 | /// set config for indicated symbology (0 for all) to specified value. 69 | /// @see zbar_image_scanner_set_config() 70 | /// @since 0.4 71 | int set_config (zbar_symbol_type_t symbology, 72 | zbar_config_t config, 73 | int value) 74 | { 75 | return(zbar_image_scanner_set_config(_scanner, symbology, 76 | config, value)); 77 | } 78 | 79 | /// set config parsed from configuration string. 80 | /// @see zbar_image_scanner_parse_config() 81 | /// @since 0.4 82 | int set_config (std::string cfgstr) 83 | { 84 | return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str())); 85 | } 86 | 87 | /// enable or disable the inter-image result cache. 88 | /// see zbar_image_scanner_enable_cache() 89 | void enable_cache (bool enable = true) 90 | { 91 | zbar_image_scanner_enable_cache(_scanner, enable); 92 | } 93 | 94 | /// remove previous results from scanner and image. 95 | /// @see zbar_image_scanner_recycle_image() 96 | /// @since 0.10 97 | void recycle_image (Image &image) 98 | { 99 | zbar_image_scanner_recycle_image(_scanner, image); 100 | } 101 | 102 | /// retrieve decode results for last scanned image. 103 | /// @see zbar_image_scanner_get_results() 104 | /// @since 0.10 105 | const SymbolSet get_results () const { 106 | return(SymbolSet(zbar_image_scanner_get_results(_scanner))); 107 | } 108 | 109 | /// scan for symbols in provided image. 110 | /// see zbar_scan_image() 111 | int scan (Image& image) 112 | { 113 | return(zbar_scan_image(_scanner, image)); 114 | } 115 | 116 | /// scan for symbols in provided image. 117 | /// see zbar_scan_image() 118 | ImageScanner& operator<< (Image& image) 119 | { 120 | scan(image); 121 | return(*this); 122 | } 123 | 124 | private: 125 | zbar_image_scanner_t *_scanner; 126 | }; 127 | 128 | } 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Processor.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_PROCESSOR_H_ 24 | #define _ZBAR_PROCESSOR_H_ 25 | 26 | /// @file 27 | /// Processor C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Processor.h" 31 | #endif 32 | 33 | #include "Exception.h" 34 | #include "Image.h" 35 | 36 | namespace zbar { 37 | 38 | /// high-level self-contained image processor. 39 | /// processes video and images for barcodes, optionally displaying 40 | /// images to a library owned output window 41 | 42 | class Processor { 43 | public: 44 | /// value to pass for no timeout. 45 | static const int FOREVER = -1; 46 | 47 | /// constructor. 48 | Processor (bool threaded = true, 49 | const char *video_device = "", 50 | bool enable_display = true) 51 | { 52 | _processor = zbar_processor_create(threaded); 53 | if(!_processor) 54 | throw std::bad_alloc(); 55 | init(video_device, enable_display); 56 | } 57 | 58 | ~Processor () 59 | { 60 | zbar_processor_destroy(_processor); 61 | } 62 | 63 | /// cast to C processor object. 64 | operator zbar_processor_t* () 65 | { 66 | return(_processor); 67 | } 68 | 69 | /// opens a video input device and/or prepares to display output. 70 | /// see zbar_processor_init() 71 | void init (const char *video_device = "", 72 | bool enable_display = true) 73 | { 74 | if(zbar_processor_init(_processor, video_device, enable_display)) 75 | throw_exception(_processor); 76 | } 77 | 78 | /// setup result handler callback. 79 | /// see zbar_processor_set_data_handler() 80 | void set_handler (Image::Handler& handler) 81 | { 82 | zbar_processor_set_data_handler(_processor, handler, &handler); 83 | } 84 | 85 | /// set config for indicated symbology (0 for all) to specified value. 86 | /// @see zbar_processor_set_config() 87 | /// @since 0.4 88 | int set_config (zbar_symbol_type_t symbology, 89 | zbar_config_t config, 90 | int value) 91 | { 92 | return(zbar_processor_set_config(_processor, symbology, 93 | config, value)); 94 | } 95 | 96 | /// set config parsed from configuration string. 97 | /// @see zbar_processor_parse_config() 98 | /// @since 0.4 99 | int set_config (std::string cfgstr) 100 | { 101 | return(zbar_processor_parse_config(_processor, cfgstr.c_str())); 102 | } 103 | 104 | /// retrieve the current state of the ouput window. 105 | /// see zbar_processor_is_visible() 106 | bool is_visible () 107 | { 108 | int rc = zbar_processor_is_visible(_processor); 109 | if(rc < 0) 110 | throw_exception(_processor); 111 | return(rc != 0); 112 | } 113 | 114 | /// show or hide the display window owned by the library. 115 | /// see zbar_processor_set_visible() 116 | void set_visible (bool visible = true) 117 | { 118 | if(zbar_processor_set_visible(_processor, visible) < 0) 119 | throw_exception(_processor); 120 | } 121 | 122 | /// control the processor in free running video mode. 123 | /// see zbar_processor_set_active() 124 | void set_active (bool active = true) 125 | { 126 | if(zbar_processor_set_active(_processor, active) < 0) 127 | throw_exception(_processor); 128 | } 129 | 130 | /// retrieve decode results for last scanned image. 131 | /// @see zbar_processor_get_results() 132 | /// @since 0.10 133 | const SymbolSet get_results () const { 134 | return(SymbolSet(zbar_processor_get_results(_processor))); 135 | } 136 | 137 | /// wait for input to the display window from the user. 138 | /// see zbar_processor_user_wait() 139 | int user_wait (int timeout = FOREVER) 140 | { 141 | int rc = zbar_processor_user_wait(_processor, timeout); 142 | if(rc < 0) 143 | throw_exception(_processor); 144 | return(rc); 145 | } 146 | 147 | /// process from the video stream until a result is available. 148 | /// see zbar_process_one() 149 | void process_one (int timeout = FOREVER) 150 | { 151 | if(zbar_process_one(_processor, timeout) < 0) 152 | throw_exception(_processor); 153 | } 154 | 155 | /// process the provided image for barcodes. 156 | /// see zbar_process_image() 157 | void process_image (Image& image) 158 | { 159 | if(zbar_process_image(_processor, image) < 0) 160 | throw_exception(_processor); 161 | } 162 | 163 | /// process the provided image for barcodes. 164 | /// see zbar_process_image() 165 | Processor& operator<< (Image& image) 166 | { 167 | process_image(image); 168 | return(*this); 169 | } 170 | 171 | /// force specific input and output formats for debug/testing. 172 | /// see zbar_processor_force_format() 173 | void force_format (unsigned long input_format, 174 | unsigned long output_format) 175 | { 176 | if(zbar_processor_force_format(_processor, input_format, 177 | output_format)) 178 | throw_exception(_processor); 179 | } 180 | 181 | /// force specific input and output formats for debug/testing. 182 | /// see zbar_processor_force_format() 183 | void force_format (std::string& input_format, 184 | std::string& output_format) 185 | { 186 | unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str()); 187 | unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str()); 188 | if(zbar_processor_force_format(_processor, ifourcc, ofourcc)) 189 | throw_exception(_processor); 190 | } 191 | 192 | /// request a preferred size for the video image from the device. 193 | /// see zbar_processor_request_size() 194 | /// @since 0.6 195 | void request_size (int width, int height) 196 | { 197 | zbar_processor_request_size(_processor, width, height); 198 | } 199 | 200 | /// request a preferred driver interface version for debug/testing. 201 | /// see zbar_processor_request_interface() 202 | /// @since 0.6 203 | void request_interface (int version) 204 | { 205 | zbar_processor_request_interface(_processor, version); 206 | } 207 | 208 | /// request a preferred I/O mode for debug/testing. 209 | /// see zbar_processor_request_iomode() 210 | /// @since 0.7 211 | void request_iomode (int iomode) 212 | { 213 | if(zbar_processor_request_iomode(_processor, iomode)) 214 | throw_exception(_processor); 215 | } 216 | 217 | private: 218 | zbar_processor_t *_processor; 219 | }; 220 | 221 | } 222 | 223 | #endif 224 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Scanner.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_SCANNER_H_ 24 | #define _ZBAR_SCANNER_H_ 25 | 26 | /// @file 27 | /// Scanner C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Scanner.h" 31 | #endif 32 | 33 | #include 34 | 35 | namespace zbar { 36 | 37 | /// low-level linear intensity sample stream scanner interface. 38 | /// identifies "bar" edges and measures width between them. 39 | /// optionally passes to bar width Decoder 40 | 41 | class Scanner { 42 | public: 43 | 44 | /// constructor. 45 | /// @param decoder reference to a Decoder instance which will 46 | /// be passed scan results automatically 47 | Scanner (Decoder& decoder) 48 | { 49 | _scanner = zbar_scanner_create(decoder._decoder); 50 | } 51 | 52 | /// constructor. 53 | /// @param decoder pointer to a Decoder instance which will 54 | /// be passed scan results automatically 55 | Scanner (Decoder* decoder = NULL) 56 | { 57 | zbar_decoder_t *zdcode = NULL; 58 | if(decoder) 59 | zdcode = decoder->_decoder; 60 | _scanner = zbar_scanner_create(zdcode); 61 | } 62 | 63 | ~Scanner () 64 | { 65 | zbar_scanner_destroy(_scanner); 66 | } 67 | 68 | /// clear all scanner state. 69 | /// see zbar_scanner_reset() 70 | void reset () 71 | { 72 | zbar_scanner_reset(_scanner); 73 | } 74 | 75 | /// mark start of a new scan pass. 76 | /// see zbar_scanner_new_scan() 77 | zbar_symbol_type_t new_scan () 78 | { 79 | _type = zbar_scanner_new_scan(_scanner); 80 | return(_type); 81 | } 82 | 83 | /// flush scanner pipeline. 84 | /// see zbar_scanner_flush() 85 | zbar_symbol_type_t flush () 86 | { 87 | _type = zbar_scanner_flush(_scanner); 88 | return(_type); 89 | } 90 | 91 | /// process next sample intensity value. 92 | /// see zbar_scan_y() 93 | zbar_symbol_type_t scan_y (int y) 94 | { 95 | _type = zbar_scan_y(_scanner, y); 96 | return(_type); 97 | } 98 | 99 | /// process next sample intensity value. 100 | /// see zbar_scan_y() 101 | Scanner& operator<< (int y) 102 | { 103 | _type = zbar_scan_y(_scanner, y); 104 | return(*this); 105 | } 106 | 107 | /// process next sample from RGB (or BGR) triple. 108 | /// see zbar_scan_rgb24() 109 | zbar_symbol_type_t scan_rgb24 (unsigned char *rgb) 110 | { 111 | _type = zbar_scan_rgb24(_scanner, rgb); 112 | return(_type); 113 | } 114 | 115 | /// process next sample from RGB (or BGR) triple. 116 | /// see zbar_scan_rgb24() 117 | Scanner& operator<< (unsigned char *rgb) 118 | { 119 | _type = zbar_scan_rgb24(_scanner, rgb); 120 | return(*this); 121 | } 122 | 123 | /// retrieve last scanned width. 124 | /// see zbar_scanner_get_width() 125 | unsigned get_width () const 126 | { 127 | return(zbar_scanner_get_width(_scanner)); 128 | } 129 | 130 | /// retrieve last scanned color. 131 | /// see zbar_scanner_get_color() 132 | zbar_color_t get_color () const 133 | { 134 | return(zbar_scanner_get_color(_scanner)); 135 | } 136 | 137 | /// retrieve last scan result. 138 | zbar_symbol_type_t get_type () const 139 | { 140 | return(_type); 141 | } 142 | 143 | /// cast to C scanner 144 | operator zbar_scanner_t* () const 145 | { 146 | return(_scanner); 147 | } 148 | 149 | /// retrieve C scanner 150 | const zbar_scanner_t *get_c_scanner () const 151 | { 152 | return(_scanner); 153 | } 154 | 155 | private: 156 | zbar_scanner_t *_scanner; 157 | zbar_symbol_type_t _type; 158 | }; 159 | 160 | } 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Video.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2010 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_VIDEO_H_ 24 | #define _ZBAR_VIDEO_H_ 25 | 26 | /// @file 27 | /// Video Input C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Video.h" 31 | #endif 32 | 33 | #include "Image.h" 34 | 35 | namespace zbar { 36 | 37 | /// mid-level video source abstraction. 38 | /// captures images from a video device 39 | 40 | class Video { 41 | public: 42 | /// constructor. 43 | Video (zbar_video_t *video = NULL) 44 | { 45 | if(video) 46 | _video = video; 47 | else 48 | _video = zbar_video_create(); 49 | } 50 | 51 | /// constructor. 52 | Video (std::string& device) 53 | { 54 | _video = zbar_video_create(); 55 | open(device); 56 | } 57 | 58 | ~Video () 59 | { 60 | zbar_video_destroy(_video); 61 | } 62 | 63 | /// cast to C video object. 64 | operator zbar_video_t* () const 65 | { 66 | return(_video); 67 | } 68 | 69 | /// open and probe a video device. 70 | void open (std::string& device) 71 | { 72 | if(zbar_video_open(_video, device.c_str())) 73 | throw_exception(_video); 74 | } 75 | 76 | /// close video device if open. 77 | void close () 78 | { 79 | if(zbar_video_open(_video, NULL)) 80 | throw_exception(_video); 81 | } 82 | 83 | /// initialize video using a specific format for debug. 84 | /// see zbar_video_init() 85 | void init (unsigned long fourcc) 86 | { 87 | if(zbar_video_init(_video, fourcc)) 88 | throw_exception(_video); 89 | } 90 | 91 | /// initialize video using a specific format for debug. 92 | /// see zbar_video_init() 93 | void init (std::string& format) 94 | { 95 | unsigned int fourcc = zbar_fourcc_parse(format.c_str()); 96 | if(zbar_video_init(_video, fourcc)) 97 | throw_exception(_video); 98 | } 99 | 100 | /// retrieve file descriptor associated with open *nix video device. 101 | /// see zbar_video_get_fd() 102 | int get_fd () 103 | { 104 | return(zbar_video_get_fd(_video)); 105 | } 106 | 107 | /// retrieve current output image width. 108 | /// see zbar_video_get_width() 109 | int get_width () 110 | { 111 | return(zbar_video_get_width(_video)); 112 | } 113 | 114 | /// retrieve current output image height. 115 | /// see zbar_video_get_height() 116 | int get_height () 117 | { 118 | return(zbar_video_get_height(_video)); 119 | } 120 | 121 | /// start/stop video capture. 122 | /// see zbar_video_enable() 123 | void enable (bool enable = true) 124 | { 125 | if(zbar_video_enable(_video, enable)) 126 | throw_exception(_video); 127 | } 128 | 129 | /// retrieve next captured image. 130 | /// see zbar_video_next_image() 131 | Image next_image () 132 | { 133 | zbar_image_t *img = zbar_video_next_image(_video); 134 | if(!img) 135 | throw_exception(_video); 136 | return(Image(img)); 137 | } 138 | 139 | /// request a preferred size for the video image from the device. 140 | /// see zbar_video_request_size() 141 | /// @since 0.6 142 | void request_size (int width, int height) 143 | { 144 | zbar_video_request_size(_video, width, height); 145 | } 146 | 147 | /// request a preferred driver interface version for debug/testing. 148 | /// see zbar_video_request_interface() 149 | /// @since 0.6 150 | void request_interface (int version) 151 | { 152 | zbar_video_request_interface(_video, version); 153 | } 154 | 155 | /// request a preferred I/O mode for debug/testing. 156 | /// see zbar_video_request_iomode() 157 | /// @since 0.7 158 | void request_iomode (int iomode) 159 | { 160 | if(zbar_video_request_iomode(_video, iomode)) 161 | throw_exception(_video); 162 | } 163 | 164 | private: 165 | zbar_video_t *_video; 166 | }; 167 | 168 | } 169 | 170 | #endif 171 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Headers/ZBarSDK/zbar/Window.h: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------ 2 | // Copyright 2007-2009 (c) Jeff Brown 3 | // 4 | // This file is part of the ZBar Bar Code Reader. 5 | // 6 | // The ZBar Bar Code Reader is free software; you can redistribute it 7 | // and/or modify it under the terms of the GNU Lesser Public License as 8 | // published by the Free Software Foundation; either version 2.1 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The ZBar Bar Code Reader is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Lesser Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Lesser Public License 17 | // along with the ZBar Bar Code Reader; if not, write to the Free 18 | // Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | // Boston, MA 02110-1301 USA 20 | // 21 | // http://sourceforge.net/projects/zbar 22 | //------------------------------------------------------------------------ 23 | #ifndef _ZBAR_WINDOW_H_ 24 | #define _ZBAR_WINDOW_H_ 25 | 26 | /// @file 27 | /// Output Window C++ wrapper 28 | 29 | #ifndef _ZBAR_H_ 30 | # error "include zbar.h in your application, **not** zbar/Window.h" 31 | #endif 32 | 33 | #include "Image.h" 34 | 35 | namespace zbar { 36 | 37 | /// mid-level output window abstraction. 38 | /// displays images to user-specified platform specific output window 39 | 40 | class Window { 41 | public: 42 | /// constructor. 43 | Window (zbar_window_t *window = NULL) 44 | { 45 | if(window) 46 | _window = window; 47 | else 48 | _window = zbar_window_create(); 49 | } 50 | 51 | /// constructor. 52 | Window (void *x11_display_w32_hwnd, 53 | unsigned long x11_drawable) 54 | { 55 | _window = zbar_window_create(); 56 | attach(x11_display_w32_hwnd, x11_drawable); 57 | } 58 | 59 | ~Window () 60 | { 61 | zbar_window_destroy(_window); 62 | } 63 | 64 | /// cast to C window object. 65 | operator zbar_window_t* () const 66 | { 67 | return(_window); 68 | } 69 | 70 | /// associate reader with an existing platform window. 71 | /// see zbar_window_attach() 72 | void attach (void *x11_display_w32_hwnd, 73 | unsigned long x11_drawable = 0) 74 | { 75 | if(zbar_window_attach(_window, 76 | x11_display_w32_hwnd, x11_drawable) < 0) 77 | throw_exception(_window); 78 | } 79 | 80 | /// control content level of the reader overlay. 81 | /// see zbar_window_set_overlay() 82 | void set_overlay (int level) 83 | { 84 | zbar_window_set_overlay(_window, level); 85 | } 86 | 87 | /// retrieve current content level of reader overlay. 88 | /// see zbar_window_get_overlay() 89 | 90 | /// draw a new image into the output window. 91 | /// see zbar_window_draw() 92 | void draw (Image& image) 93 | { 94 | if(zbar_window_draw(_window, image) < 0) 95 | throw_exception(_window); 96 | } 97 | 98 | /// clear the image from the output window. 99 | /// see zbar_window_draw() 100 | void clear () 101 | { 102 | if(zbar_window_draw(_window, NULL) < 0) 103 | throw_exception(_window); 104 | } 105 | 106 | /// redraw the last image. 107 | /// zbar_window_redraw() 108 | void redraw () 109 | { 110 | if(zbar_window_redraw(_window) < 0) 111 | throw_exception(_window); 112 | } 113 | 114 | /// resize the image window. 115 | /// zbar_window_resize() 116 | void resize (unsigned width, unsigned height) 117 | { 118 | if(zbar_window_resize(_window, width, height) < 0) 119 | throw_exception(_window); 120 | } 121 | 122 | private: 123 | zbar_window_t *_window; 124 | }; 125 | 126 | /// select a compatible format between video input and output window. 127 | /// see zbar_negotiate_format() 128 | static inline void negotiate_format (Video& video, Window& window) 129 | { 130 | if(zbar_negotiate_format(video, window) < 0) 131 | throw_exception(video); 132 | } 133 | 134 | } 135 | 136 | #endif 137 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-back.png -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-help.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | Barcode Reader Help 11 | 31 | 32 | 33 |

Barcode Reader Help

34 |
35 |

Recognized barcodes should look like

36 |
37 | 38 |

EAN/UPC
Product Codes

39 |
40 |
41 | 42 |

QR Codes

43 |
44 |

Also recognized, but not shown: 45 | Code 128, 46 | DataBar (RSS), 47 | Code 93, 48 | Code 39 and 49 | Interleaved 2 of 5

50 |
51 |

Hints for successful scanning

52 |
53 |
54 |

Ensure there is plenty of

55 |

Light

56 |
57 |
58 |
4"
59 |

Distance

60 |

should be about 3 to 5 inches

61 |
62 |
63 |
64 |

Shake

65 |

to force the camera to focus

66 |
67 |
68 |
69 |

Wait

70 |

for the autofocus to finish

71 |
72 |
73 |
74 |

Hold Still

75 |

while the barcode is scanned

76 |
77 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-helpicons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-helpicons.png -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-samples.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Vendor/ZBarSDK/Resources/zbar-samples.png -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/ZBarSDK/libzbar.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/Vendor/ZBarSDK/libzbar.a -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/QRCodeGenerator.h: -------------------------------------------------------------------------------- 1 | // 2 | // QR Code Generator - generates UIImage from NSString 3 | // 4 | // Copyright (C) 2012 http://moqod.com Andrew Kopanev 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | #import 25 | 26 | @interface QRCodeGenerator : NSObject 27 | 28 | + (UIImage *)qrImageForString:(NSString *)string imageSize:(CGFloat)size; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/QRCodeGenerator.m: -------------------------------------------------------------------------------- 1 | // 2 | // QR Code Generator - generates UIImage from NSString 3 | // 4 | // Copyright (C) 2012 http://moqod.com Andrew Kopanev 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | // of the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 18 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 19 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | // DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | #import "QRCodeGenerator.h" 25 | #import "qrencode.h" 26 | 27 | enum { 28 | qr_margin = 3 29 | }; 30 | 31 | @implementation QRCodeGenerator 32 | 33 | + (void)drawQRCode:(QRcode *)code context:(CGContextRef)ctx size:(CGFloat)size { 34 | unsigned char *data = 0; 35 | int width; 36 | data = code->data; 37 | width = code->width; 38 | float zoom = (double)size / (code->width + 2.0 * qr_margin); 39 | CGRect rectDraw = CGRectMake(0, 0, zoom, zoom); 40 | 41 | // draw 42 | CGContextSetFillColor(ctx, CGColorGetComponents([UIColor blackColor].CGColor)); 43 | for(int i = 0; i < width; ++i) { 44 | for(int j = 0; j < width; ++j) { 45 | if(*data & 1) { 46 | rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom); 47 | CGContextAddRect(ctx, rectDraw); 48 | } 49 | ++data; 50 | } 51 | } 52 | CGContextFillPath(ctx); 53 | } 54 | 55 | + (UIImage *)qrImageForString:(NSString *)string imageSize:(CGFloat)size { 56 | if (![string length]) { 57 | return nil; 58 | } 59 | 60 | QRcode *code = QRcode_encodeString([string UTF8String], 0, QR_ECLEVEL_L, QR_MODE_8, 1); 61 | if (!code) { 62 | return nil; 63 | } 64 | 65 | // create context 66 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 67 | CGContextRef ctx = CGBitmapContextCreate(0, size, size, 8, size * 4, colorSpace, kCGImageAlphaPremultipliedLast); 68 | 69 | CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(0, -size); 70 | CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1, -1); 71 | CGContextConcatCTM(ctx, CGAffineTransformConcat(translateTransform, scaleTransform)); 72 | 73 | // draw QR on this context 74 | [QRCodeGenerator drawQRCode:code context:ctx size:size]; 75 | 76 | // get image 77 | CGImageRef qrCGImage = CGBitmapContextCreateImage(ctx); 78 | UIImage * qrImage = [UIImage imageWithCGImage:qrCGImage]; 79 | 80 | // some releases 81 | CGContextRelease(ctx); 82 | CGImageRelease(qrCGImage); 83 | CGColorSpaceRelease(colorSpace); 84 | QRcode_free(code); 85 | 86 | return qrImage; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/bitstream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "bitstream.h" 27 | 28 | BitStream *BitStream_new(void) 29 | { 30 | BitStream *bstream; 31 | 32 | bstream = (BitStream *)malloc(sizeof(BitStream)); 33 | if(bstream == NULL) return NULL; 34 | 35 | bstream->length = 0; 36 | bstream->data = NULL; 37 | 38 | return bstream; 39 | } 40 | 41 | static int BitStream_allocate(BitStream *bstream, int length) 42 | { 43 | unsigned char *data; 44 | 45 | if(bstream == NULL) { 46 | return -1; 47 | } 48 | 49 | data = (unsigned char *)malloc(length); 50 | if(data == NULL) { 51 | return -1; 52 | } 53 | 54 | if(bstream->data) { 55 | free(bstream->data); 56 | } 57 | bstream->length = length; 58 | bstream->data = data; 59 | 60 | return 0; 61 | } 62 | 63 | static BitStream *BitStream_newFromNum(int bits, unsigned int num) 64 | { 65 | unsigned int mask; 66 | int i; 67 | unsigned char *p; 68 | BitStream *bstream; 69 | 70 | bstream = BitStream_new(); 71 | if(bstream == NULL) return NULL; 72 | 73 | if(BitStream_allocate(bstream, bits)) { 74 | BitStream_free(bstream); 75 | return NULL; 76 | } 77 | 78 | p = bstream->data; 79 | mask = 1 << (bits - 1); 80 | for(i=0; i> 1; 88 | } 89 | 90 | return bstream; 91 | } 92 | 93 | static BitStream *BitStream_newFromBytes(int size, unsigned char *data) 94 | { 95 | unsigned char mask; 96 | int i, j; 97 | unsigned char *p; 98 | BitStream *bstream; 99 | 100 | bstream = BitStream_new(); 101 | if(bstream == NULL) return NULL; 102 | 103 | if(BitStream_allocate(bstream, size * 8)) { 104 | BitStream_free(bstream); 105 | return NULL; 106 | } 107 | 108 | p = bstream->data; 109 | for(i=0; i> 1; 119 | } 120 | } 121 | 122 | return bstream; 123 | } 124 | 125 | int BitStream_append(BitStream *bstream, BitStream *arg) 126 | { 127 | unsigned char *data; 128 | 129 | if(arg == NULL) { 130 | return -1; 131 | } 132 | if(arg->length == 0) { 133 | return 0; 134 | } 135 | if(bstream->length == 0) { 136 | if(BitStream_allocate(bstream, arg->length)) { 137 | return -1; 138 | } 139 | memcpy(bstream->data, arg->data, arg->length); 140 | return 0; 141 | } 142 | 143 | data = (unsigned char *)malloc(bstream->length + arg->length); 144 | if(data == NULL) { 145 | return -1; 146 | } 147 | memcpy(data, bstream->data, bstream->length); 148 | memcpy(data + bstream->length, arg->data, arg->length); 149 | 150 | free(bstream->data); 151 | bstream->length += arg->length; 152 | bstream->data = data; 153 | 154 | return 0; 155 | } 156 | 157 | int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) 158 | { 159 | BitStream *b; 160 | int ret; 161 | 162 | if(bits == 0) return 0; 163 | 164 | b = BitStream_newFromNum(bits, num); 165 | if(b == NULL) return -1; 166 | 167 | ret = BitStream_append(bstream, b); 168 | BitStream_free(b); 169 | 170 | return ret; 171 | } 172 | 173 | int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) 174 | { 175 | BitStream *b; 176 | int ret; 177 | 178 | if(size == 0) return 0; 179 | 180 | b = BitStream_newFromBytes(size, data); 181 | if(b == NULL) return -1; 182 | 183 | ret = BitStream_append(bstream, b); 184 | BitStream_free(b); 185 | 186 | return ret; 187 | } 188 | 189 | unsigned char *BitStream_toByte(BitStream *bstream) 190 | { 191 | int i, j, size, bytes; 192 | unsigned char *data, v; 193 | unsigned char *p; 194 | 195 | size = BitStream_size(bstream); 196 | if(size == 0) { 197 | return NULL; 198 | } 199 | data = (unsigned char *)malloc((size + 7) / 8); 200 | if(data == NULL) { 201 | return NULL; 202 | } 203 | 204 | bytes = size / 8; 205 | 206 | p = bstream->data; 207 | for(i=0; idata); 233 | free(bstream); 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __BITSTREAM_H__ 23 | #define __BITSTREAM_H__ 24 | 25 | typedef struct { 26 | int length; 27 | unsigned char *data; 28 | } BitStream; 29 | 30 | extern BitStream *BitStream_new(void); 31 | extern int BitStream_append(BitStream *bstream, BitStream *arg); 32 | extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); 33 | extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); 34 | #define BitStream_size(__bstream__) (__bstream__->length) 35 | extern unsigned char *BitStream_toByte(BitStream *bstream); 36 | extern void BitStream_free(BitStream *bstream); 37 | 38 | #endif /* __BITSTREAM_H__ */ 39 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/mask.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | //#include "config.h" 26 | #include "qrencode.h" 27 | #include "qrspec.h" 28 | #include "mask.h" 29 | 30 | //__STATIC 31 | static int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level) 32 | { 33 | unsigned int format; 34 | unsigned char v; 35 | int i; 36 | int blacks = 0; 37 | 38 | format = QRspec_getFormatInfo(mask, level); 39 | 40 | for(i=0; i<8; i++) { 41 | if(format & 1) { 42 | blacks += 2; 43 | v = 0x85; 44 | } else { 45 | v = 0x84; 46 | } 47 | frame[width * 8 + width - 1 - i] = v; 48 | if(i < 6) { 49 | frame[width * i + 8] = v; 50 | } else { 51 | frame[width * (i + 1) + 8] = v; 52 | } 53 | format= format >> 1; 54 | } 55 | for(i=0; i<7; i++) { 56 | if(format & 1) { 57 | blacks += 2; 58 | v = 0x85; 59 | } else { 60 | v = 0x84; 61 | } 62 | frame[width * (width - 7 + i) + 8] = v; 63 | if(i == 0) { 64 | frame[width * 8 + 7] = v; 65 | } else { 66 | frame[width * 8 + 6 - i] = v; 67 | } 68 | format= format >> 1; 69 | } 70 | 71 | return blacks; 72 | } 73 | 74 | /** 75 | * Demerit coefficients. 76 | * See Section 8.8.2, pp.45, JIS X0510:2004. 77 | */ 78 | #define N1 (3) 79 | #define N2 (3) 80 | #define N3 (40) 81 | #define N4 (10) 82 | 83 | #define MASKMAKER(__exp__) \ 84 | int x, y;\ 85 | int b = 0;\ 86 | \ 87 | for(y=0; y= 5) { 174 | demerit += N1 + (runLength[i] - 5); 175 | //n1 += N1 + (runLength[i] - 5); 176 | } 177 | if((i & 1)) { 178 | if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) { 179 | fact = runLength[i] / 3; 180 | if(runLength[i-2] == fact && 181 | runLength[i-1] == fact && 182 | runLength[i+1] == fact && 183 | runLength[i+2] == fact) { 184 | if(runLength[i-3] < 0 || runLength[i-3] >= 4 * fact) { 185 | demerit += N3; 186 | //n3 += N3; 187 | } else if(i+3 >= length || runLength[i+3] >= 4 * fact) { 188 | demerit += N3; 189 | //n3 += N3; 190 | } 191 | } 192 | } 193 | } 194 | } 195 | 196 | return demerit; 197 | } 198 | 199 | //__STATIC 200 | static int Mask_evaluateSymbol(int width, unsigned char *frame) 201 | { 202 | int x, y; 203 | unsigned char *p; 204 | unsigned char b22, w22; 205 | int head; 206 | int demerit = 0; 207 | 208 | p = frame; 209 | for(y=0; y 0 && y > 0) { 214 | b22 = p[0] & p[-1] & p[-width] & p [-width-1]; 215 | w22 = p[0] | p[-1] | p[-width] | p [-width-1]; 216 | if((b22 | (w22 ^ 1))&1) { 217 | demerit += N2; 218 | } 219 | } 220 | if(x == 0 && (p[0] & 1)) { 221 | runLength[0] = -1; 222 | head = 1; 223 | runLength[head] = 1; 224 | } else if(x > 0) { 225 | if((p[0] ^ p[-1]) & 1) { 226 | head++; 227 | runLength[head] = 1; 228 | } else { 229 | runLength[head]++; 230 | } 231 | } 232 | p++; 233 | } 234 | demerit += Mask_calcN1N3(head+1, runLength); 235 | } 236 | 237 | for(x=0; x 0) { 247 | if((p[0] ^ p[-width]) & 1) { 248 | head++; 249 | runLength[head] = 1; 250 | } else { 251 | runLength[head]++; 252 | } 253 | } 254 | p+=width; 255 | } 256 | demerit += Mask_calcN1N3(head+1, runLength); 257 | } 258 | 259 | return demerit; 260 | } 261 | 262 | unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level) 263 | { 264 | int i; 265 | unsigned char *mask, *bestMask; 266 | int minDemerit = INT_MAX; 267 | int bestMaskNum = 0; 268 | int blacks; 269 | int demerit; 270 | 271 | mask = (unsigned char *)malloc(width * width); 272 | if(mask == NULL) return NULL; 273 | bestMask = NULL; 274 | 275 | for(i=0; i<8; i++) { 276 | // n1 = n2 = n3 = n4 = 0; 277 | demerit = 0; 278 | blacks = maskMakers[i](width, frame, mask); 279 | blacks += Mask_writeFormatInformation(width, mask, i, level); 280 | blacks = 100 * blacks / (width * width); 281 | demerit = (abs(blacks - 50) / 5) * N4; 282 | // n4 = demerit; 283 | demerit += Mask_evaluateSymbol(width, mask); 284 | // printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit); 285 | if(demerit < minDemerit) { 286 | minDemerit = demerit; 287 | bestMaskNum = i; 288 | if(bestMask != NULL) { 289 | free(bestMask); 290 | } 291 | bestMask = (unsigned char *)malloc(width * width); 292 | if(bestMask == NULL) break; 293 | memcpy(bestMask, mask, width * width); 294 | } 295 | } 296 | free(mask); 297 | return bestMask; 298 | } 299 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MASK_H__ 23 | #define __MASK_H__ 24 | 25 | #include "qrinput.h" 26 | 27 | extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); 28 | extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); 29 | 30 | #endif /* __MASK_H__ */ 31 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/qrinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data chunk class 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __QRINPUT_H__ 23 | #define __QRINPUT_H__ 24 | 25 | #include "qrencode.h" 26 | #include "bitstream.h" 27 | 28 | /****************************************************************************** 29 | * Entry of input data 30 | *****************************************************************************/ 31 | typedef struct _QRinput_List QRinput_List; 32 | 33 | struct _QRinput_List { 34 | QRencodeMode mode; 35 | int size; ///< Size of data chunk (byte). 36 | unsigned char *data; ///< Data chunk. 37 | BitStream *bstream; 38 | QRinput_List *next; 39 | }; 40 | 41 | /****************************************************************************** 42 | * Input Data 43 | *****************************************************************************/ 44 | struct _QRinput { 45 | int version; 46 | QRecLevel level; 47 | QRinput_List *head; 48 | QRinput_List *tail; 49 | }; 50 | 51 | /****************************************************************************** 52 | * Structured append input data 53 | *****************************************************************************/ 54 | typedef struct _QRinput_InputList QRinput_InputList; 55 | 56 | struct _QRinput_InputList { 57 | QRinput *input; 58 | QRinput_InputList *next; 59 | }; 60 | 61 | struct _QRinput_Struct { 62 | int size; ///< number of structured symbols 63 | int parity; 64 | QRinput_InputList *head; 65 | QRinput_InputList *tail; 66 | }; 67 | 68 | /** 69 | * Pack all bit streams padding bits into a byte array. 70 | * @param input input data. 71 | * @return padded merged byte stream 72 | */ 73 | extern unsigned char *QRinput_getByteStream(QRinput *input); 74 | 75 | 76 | extern int QRinput_estimateBitsModeNum(int size); 77 | extern int QRinput_estimateBitsModeAn(int size); 78 | extern int QRinput_estimateBitsMode8(int size); 79 | extern int QRinput_estimateBitsModeKanji(int size); 80 | 81 | extern QRinput *QRinput_dup(QRinput *input); 82 | 83 | extern const signed char QRinput_anTable[128]; 84 | 85 | /** 86 | * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). 87 | * @param __c__ character 88 | * @return value 89 | */ 90 | #define QRinput_lookAnTable(__c__) \ 91 | ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__]) 92 | 93 | /** 94 | * Length of a segment of structured-append header. 95 | */ 96 | #define STRUCTURE_HEADER_BITS 20 97 | 98 | /** 99 | * Maximum number of symbols in a set of structured-appended symbols. 100 | */ 101 | #define MAX_STRUCTURED_SYMBOLS 16 102 | 103 | #endif /* __QRINPUT_H__ */ 104 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/qrspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * QR Code specification in convenient format. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __QRSPEC_H__ 23 | #define __QRSPEC_H__ 24 | 25 | #include "qrencode.h" 26 | 27 | /****************************************************************************** 28 | * Version and capacity 29 | *****************************************************************************/ 30 | 31 | /** 32 | * Maximum version (size) of QR-code symbol. 33 | */ 34 | #define QRSPEC_VERSION_MAX 40 35 | 36 | /** 37 | * Maximum width of a symbol 38 | */ 39 | #define QRSPEC_WIDTH_MAX 177 40 | 41 | /** 42 | * Return maximum data code length (bytes) for the version. 43 | * @param version 44 | * @param level 45 | * @return maximum size (bytes) 46 | */ 47 | extern int QRspec_getDataLength(int version, QRecLevel level); 48 | 49 | /** 50 | * Return maximum error correction code length (bytes) for the version. 51 | * @param version 52 | * @param level 53 | * @return ECC size (bytes) 54 | */ 55 | extern int QRspec_getECCLength(int version, QRecLevel level); 56 | 57 | /** 58 | * Return a version number that satisfies the input code length. 59 | * @param size input code length (byte) 60 | * @param level 61 | * @return version number 62 | */ 63 | extern int QRspec_getMinimumVersion(int size, QRecLevel level); 64 | 65 | /** 66 | * Return the width of the symbol for the version. 67 | * @param version 68 | * @return width 69 | */ 70 | extern int QRspec_getWidth(int version); 71 | 72 | /** 73 | * Return the numer of remainder bits. 74 | * @param version 75 | * @return number of remainder bits 76 | */ 77 | extern int QRspec_getRemainder(int version); 78 | 79 | /****************************************************************************** 80 | * Length indicator 81 | *****************************************************************************/ 82 | 83 | /** 84 | * Return the size of lenght indicator for the mode and version. 85 | * @param mode 86 | * @param version 87 | * @return the size of the appropriate length indicator (bits). 88 | */ 89 | extern int QRspec_lengthIndicator(QRencodeMode mode, int version); 90 | 91 | /** 92 | * Return the maximum length for the mode and version. 93 | * @param mode 94 | * @param version 95 | * @return the maximum length (bytes) 96 | */ 97 | extern int QRspec_maximumWords(QRencodeMode mode, int version); 98 | 99 | /****************************************************************************** 100 | * Error correction code 101 | *****************************************************************************/ 102 | 103 | /** 104 | * Return an array of ECC specification. 105 | * @param version 106 | * @param level 107 | * @param spec an array of ECC specification contains as following: 108 | * {# of type1 blocks, # of data code, # of ecc code, 109 | * # of type2 blocks, # of data code} 110 | */ 111 | void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]); 112 | 113 | #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) 114 | #define QRspec_rsBlockNum1(__spec__) (__spec__[0]) 115 | #define QRspec_rsDataCodes1(__spec__) (__spec__[1]) 116 | #define QRspec_rsEccCodes1(__spec__) (__spec__[2]) 117 | #define QRspec_rsBlockNum2(__spec__) (__spec__[3]) 118 | #define QRspec_rsDataCodes2(__spec__) (__spec__[4]) 119 | #define QRspec_rsEccCodes2(__spec__) (__spec__[2]) 120 | 121 | #define QRspec_rsDataLength(__spec__) \ 122 | ((QRspec_rsBlockNum1(__spec__) * QRspec_rsDataCodes1(__spec__)) + \ 123 | (QRspec_rsBlockNum2(__spec__) * QRspec_rsDataCodes2(__spec__))) 124 | #define QRspec_rsEccLength(__spec__) \ 125 | (QRspec_rsBlockNum(__spec__) * QRspec_rsEccCodes1(__spec__)) 126 | 127 | /****************************************************************************** 128 | * Version information pattern 129 | *****************************************************************************/ 130 | 131 | /** 132 | * Return BCH encoded version information pattern that is used for the symbol 133 | * of version 7 or greater. Use lower 18 bits. 134 | * @param version 135 | * @return BCH encoded version information pattern 136 | */ 137 | extern unsigned int QRspec_getVersionPattern(int version); 138 | 139 | /****************************************************************************** 140 | * Format information 141 | *****************************************************************************/ 142 | 143 | /** 144 | * Return BCH encoded format information pattern. 145 | * @param mask 146 | * @param level 147 | * @return BCH encoded format information pattern 148 | */ 149 | extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); 150 | 151 | /****************************************************************************** 152 | * Frame 153 | *****************************************************************************/ 154 | 155 | /** 156 | * Return a copy of initialized frame. 157 | * When the same version is requested twice or more, a copy of cached frame 158 | * is returned. 159 | * WARNING: Thread unsafe!!! 160 | * @param version 161 | * @return Array of unsigned char. You can free it by free(). 162 | */ 163 | extern unsigned char *QRspec_newFrame(int version); 164 | 165 | /** 166 | * Clear the frame cache. Typically for debug. 167 | * WARNING: Thread unsafe!!! 168 | */ 169 | extern void QRspec_clearCache(void); 170 | 171 | #endif /* __QRSPEC_H__ */ 172 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/rscode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon encoder. This code is taken from Phil Karn's libfec then 5 | * editted and packed into a pair of .c and .h files. 6 | * 7 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 8 | * (libfec is released under the GNU Lesser General Public License.) 9 | * 10 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #ifndef __RSCODE_H__ 28 | #define __RSCODE_H__ 29 | 30 | /* 31 | * General purpose RS codec, 8-bit symbols. 32 | */ 33 | 34 | typedef struct _RS RS; 35 | 36 | /* WARNING: Thread unsafe!!! */ 37 | extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); 38 | extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); 39 | extern void free_rs_char(RS *rs); 40 | extern void free_rs_cache(void); 41 | 42 | #endif /* __RSCODE_H__ */ 43 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/Vendor/libqrencode/split.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data splitter. 5 | * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi 6 | * 7 | * The following data / specifications are taken from 8 | * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) 9 | * or 10 | * "Automatic identification and data capture techniques -- 11 | * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) 12 | * 13 | * This library is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or any later version. 17 | * 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public 24 | * License along with this library; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | */ 27 | 28 | #ifndef __SPLIT_H__ 29 | #define __SPLIT_H__ 30 | 31 | #include "qrencode.h" 32 | 33 | /** 34 | * Split the input string (null terminated) into QRinput. 35 | * @param string input string 36 | * @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8. 37 | * @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS. 38 | * @retval 0 success. 39 | * @retval -1 an error occurred. errno is set to indicate the error. See 40 | * Exceptions for the details. 41 | * @throw EINVAL invalid input object. 42 | * @throw ENOMEM unable to allocate memory for input objects. 43 | */ 44 | extern int Split_splitStringToQRinput(const char *string, QRinput *input, 45 | QRencodeMode hint, int casesensitive); 46 | 47 | #endif /* __SPLIT_H__ */ 48 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/8/26. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZBarSDK.h" 11 | 12 | @interface ViewController : UIViewController 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/8/26. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "Masonry.h" 11 | #import "ScanQRCodeViewController.h" 12 | #import "UIColor+HEX.h" 13 | #import "CreateRQCodeViewController.h" 14 | 15 | @interface ViewController () 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | [self.view setBackgroundColor:[UIColor whiteColor]]; 25 | 26 | UIButton *normalScanBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 27 | [normalScanBtn setTitle:@"常规扫描二维码" forState:UIControlStateNormal]; 28 | [normalScanBtn setBackgroundColor:[UIColor colorWithHexString:@"#3498db"]]; 29 | [normalScanBtn addTarget:self action:@selector(normalScanQRCodeView) forControlEvents:UIControlEventTouchUpInside]; 30 | [self.view addSubview:normalScanBtn]; 31 | __weak __typeof(self) weakSelf = self; 32 | [normalScanBtn mas_makeConstraints:^(MASConstraintMaker *make) { 33 | make.centerX.equalTo(weakSelf.view); 34 | make.top.equalTo(weakSelf.view).with.offset(100); 35 | make.size.mas_equalTo(CGSizeMake(150, 40)); 36 | }]; 37 | 38 | UIButton *customScanBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 39 | [customScanBtn setTitle:@"自定义扫描二维码" forState:UIControlStateNormal]; 40 | [customScanBtn setBackgroundColor:[UIColor colorWithHexString:@"#3498db"]]; 41 | [customScanBtn addTarget:self action:@selector(customScanQRCodeView) forControlEvents:UIControlEventTouchUpInside]; 42 | [self.view addSubview:customScanBtn]; 43 | [customScanBtn mas_makeConstraints:^(MASConstraintMaker *make) { 44 | make.centerX.equalTo(weakSelf.view); 45 | make.top.equalTo(weakSelf.view).with.offset(200); 46 | make.size.mas_equalTo(CGSizeMake(150, 40)); 47 | }]; 48 | 49 | UIButton *createBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 50 | [createBtn setTitle:@"生成二维码" forState:UIControlStateNormal]; 51 | [createBtn setBackgroundColor:[UIColor colorWithHexString:@"#3498db"]]; 52 | [createBtn addTarget:self action:@selector(createQRCodeView) forControlEvents:UIControlEventTouchUpInside]; 53 | [self.view addSubview:createBtn]; 54 | [createBtn mas_makeConstraints:^(MASConstraintMaker *make) { 55 | make.centerX.equalTo(weakSelf.view); 56 | make.top.equalTo(weakSelf.view).with.offset(300); 57 | make.size.mas_equalTo(CGSizeMake(150, 40)); 58 | }]; 59 | } 60 | 61 | - (void)customScanQRCodeView{ 62 | ScanQRCodeViewController *scanQRCodeVC = [[ScanQRCodeViewController alloc] initWithNibName:@"ScanQRCodeViewController" bundle:nil]; 63 | [self.navigationController pushViewController:scanQRCodeVC animated:YES]; 64 | } 65 | 66 | - (void)createQRCodeView{ 67 | CreateRQCodeViewController *createQRCodeVC = [[CreateRQCodeViewController alloc] initWithNibName:@"CreateRQCodeViewController" bundle:nil]; 68 | [self.navigationController pushViewController:createQRCodeVC animated:YES]; 69 | } 70 | 71 | - (void)normalScanQRCodeView{ 72 | //初始化相机控制器 73 | ZBarReaderViewController *reader = [ZBarReaderViewController new]; 74 | //设置代理 75 | reader.readerDelegate = self; 76 | //基本适配 77 | reader.supportedOrientationsMask = ZBarOrientationMaskAll; 78 | //二维码/条形码识别设置 79 | ZBarImageScanner *scanner = reader.scanner; 80 | [scanner setSymbology: ZBAR_I25 81 | config: ZBAR_CFG_ENABLE 82 | to: 0]; 83 | //弹出系统照相机,全屏拍摄 84 | [self presentViewController:reader animated:YES completion:^{ 85 | 86 | }]; 87 | } 88 | 89 | #pragma mark - 90 | #pragma mark ZBarReaderDelegate 91 | //扫描二维码的时候,识别成功会进入此方法,读取二维码内容 92 | -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 93 | { 94 | id results = [info objectForKey:ZBarReaderControllerResults]; 95 | ZBarSymbol * symbol; 96 | for(symbol in results) 97 | break; 98 | 99 | [picker dismissViewControllerAnimated:YES completion:nil]; 100 | 101 | NSString *result = symbol.data; 102 | 103 | NSLog(@"%@",result); 104 | 105 | //二维码扫描成功,弹窗提示 106 | UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"扫描成功" message:[NSString stringWithFormat:@"二维码内容:\n%@",result] preferredStyle:UIAlertControllerStyleAlert]; 107 | UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 108 | }]; 109 | [alertVC addAction:action]; 110 | [self presentViewController:alertVC animated:YES completion:^{ 111 | }]; 112 | } 113 | 114 | - (void) readerControllerDidFailToRead: (ZBarReaderController*) reader 115 | withRetry: (BOOL) retry{ 116 | 117 | } 118 | 119 | - (void)didReceiveMemoryWarning { 120 | [super didReceiveMemoryWarning]; 121 | // Dispose of any resources that can be recreated. 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JB_ZBarSDK_Demo 4 | // 5 | // Created by jaybin on 15/9/14. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/screenshots/create.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/screenshots/create.gif -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/screenshots/customScan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/screenshots/customScan.gif -------------------------------------------------------------------------------- /JB_ZBarSDK_Demo/screenshots/normalScan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaybinhe/JB_ZBarSDK_Demo/952e76a5a04fdd6dc09e92278aa792898a1cd012/JB_ZBarSDK_Demo/screenshots/normalScan.gif -------------------------------------------------------------------------------- /JB_ZBarSDK_DemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.jaybin.com.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /JB_ZBarSDK_DemoTests/JB_ZBarSDK_DemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JB_ZBarSDK_DemoTests.m 3 | // JB_ZBarSDK_DemoTests 4 | // 5 | // Created by jaybin on 15/9/14. 6 | // Copyright (c) 2015年 jaybin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface JB_ZBarSDK_DemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation JB_ZBarSDK_DemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JB_ZBarSDK_Demo 2 | =================================== 3 | 4 | Overview 5 | ---------------------------------- 6 | 通过ZBar SDK,实现IOS扫描二维码的功能。Demo介绍了ZBar常规的扫描二维码方式,同时可以自定义扫描二维码界面,并且可以生成二维码。 7 | 8 | 9 | 一、常规的扫描二维码方式 10 | ---------------------------------- 11 | 12 | ![github](https://github.com/jaybinhe/JB_ZBarSDK_Demo/raw/master/JB_ZBarSDK_Demo/screenshots/normalScan.gif) 13 | 14 | 15 | 二、自定义扫描二维码 16 | ---------------------------------- 17 | 18 | ![github](https://github.com/jaybinhe/JB_ZBarSDK_Demo/raw/master/JB_ZBarSDK_Demo/screenshots/customScan.gif) 19 | 20 | 21 | 三、生成二维码 22 | ---------------------------------- 23 | 24 | ![github](https://github.com/jaybinhe/JB_ZBarSDK_Demo/raw/master/JB_ZBarSDK_Demo/screenshots/create.gif) 25 | --------------------------------------------------------------------------------