码迷,mamicode.com
首页 > 移动开发 > 详细

IOS-闪光灯操作

时间:2014-12-15 11:47:55      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   ar   color   os   sp   for   

AVCaptureDevice.h主要用来获取iphone一些关于相机设备的属性。
前置和后置摄像头
enum {
AVCaptureDevicePositionBack                = 1,
AVCaptureDevicePositionFront               = 2
};
typedef NSInteger AVCaptureDevicePosition;

闪光灯开关
 
enum {
AVCaptureFlashModeOff  = 0,
AVCaptureFlashModeOn   = 1,
AVCaptureFlashModeAuto = 2
};
typedef NSInteger AVCaptureFlashMode;

手电筒开关
 
enum {
AVCaptureTorchModeOff  = 0,
AVCaptureTorchModeOn   = 1,
AVCaptureTorchModeAuto = 2,
};
typedef NSInteger AVCaptureTorchMode;

焦距调整
 
enum {
AVCaptureFocusModeLocked              = 0,
AVCaptureFocusModeAutoFocus           = 1,
AVCaptureFocusModeContinuousAutoFocus = 2,
};
typedef NSInteger AVCaptureFocusMode;

曝光量调节
 
enum {
AVCaptureExposureModeLocked = 0,
AVCaptureExposureModeAutoExpose = 1,
AVCaptureExposureModeContinuousAutoExposure = 2,
};
typedef NSInteger AVCaptureExposureMode;

白平衡
 
enum {
AVCaptureWhiteBalanceModeLocked         = 0,
AVCaptureWhiteBalanceModeAutoWhiteBalance         = 1,
    AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance = 2,
};
typedef NSInteger AVCaptureWhiteBalanceMode;

开启闪光灯:

 1 AVCaptureDevice* d = nil; // find a device by position 
 2 NSArray* allDevices = [AVCaptureDevice devices]; 
 3 for (AVCaptureDevice* currentDevice in allDevices) {   
 4     if (currentDevice.position == AVCaptureDevicePositionBack) { 
 5             d = currentDevice;   
 6     } 
 7 } // at this point, d may still be nil, assuming we found something we like.... 
 8 NSError* err = nil; 
 9 BOOL lockAcquired = [d lockForConfiguration:&err]; 
10 if (!lockAcquired) {    
11     // log err and handle... 
12 } else {    
13     // flip on the flash mode    
14     if ([d hasFlash] && [d isFlashModeSupported:AVCaptureFlashModeOn] ) {       
15     [d setFlashMode:AVCaptureFlashModeOn];    
16     }    
17     [d unlockForConfiguration]; 
18 }

 

IOS-闪光灯操作

标签:des   style   blog   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/wanyakun/p/4164323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!