ipad打开相册和调用摄像头的方法跟iPhone 不一样 用 UIPopoverController 显示
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
if(buttonIndex==0){
// 拍照
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;//是否允许编辑
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
UIPopoverController *popover=[[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
[popover presentPopoverFromRect:CGRectMake(0, 0, 800, 800) inView:app.window permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[picker release];
[popover release];
}else if(buttonIndex==1){
// 相册里找
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
UIPopoverController *popover=[[UIPopoverController alloc] initWithContentViewController:imagePickerController];
self.popoverController = popover;
[popover presentPopoverFromRect:CGRectMake(0, 0, 800, 800) inView:app.window permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[imagePickerController release];
[popover release];
}
[actionSheet release];
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *) info{
UIImage *img=[info objectForKey:@"UIImagePickerControllerOriginalImage"];
UIImage *newImg=[self scaleImage:img toScale:1];
[self saveImage:newImg WithName:[NSString stringWithFormat:@"%@%@",[self generateUuidString],@".png"]];
[imageMuArray addObject:newImg];
}
- (void)saveImage:(UIImage *)tempImage WithName:(NSString *)imageName
{
NSData* imageData = UIImagePNGRepresentation(tempImage);
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// Now we get the full path to the file
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
// and then we write it out
NSLog(@"--fullPathToFile:%@",fullPathToFile);
[[MySingletonClassesshareMySingleton].replyImagePathMuArrayaddObject:fullPathToFile];
[imageData writeToFile:fullPathToFile atomically:NO];
}
- (NSString *)generateUuidString
{
// create a new UUID which you own
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
// create a new CFStringRef (toll-free bridged to NSString)
// that you own
NSString *uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
// transfer ownership of the string
// to the autorelease pool
[uuidString autorelease];
// release the UUID
CFRelease(uuid);
return uuidString;
}
-(UIImage *)scaleImage:(UIImage *)image toScale:(float)scaleSize
{
UIGraphicsBeginImageContext(CGSizeMake(image.size.width*scaleSize,image.size.height*scaleSize));
[image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height *scaleSize)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
相关推荐
H5实现调用手机摄像头相册。完美实现图片压缩、预览、删除的功能。
powerbuilder 11.5调用摄像头
本文实例讲述了Android调用摄像头功能的方法。分享给大家供大家参考,具体如下: 我们要调用摄像头的拍照功能,显然 第一步必须加入调用摄像头硬件的权限,拍完照后我们要将图片保存在SD卡中,必须加入SD卡读写权限...
ASP调用摄像头拍照并保存亲测能用!asp调用本地摄像头的组件,能够在线采集头像
WPF 调用摄像头识别二维码 的代码DEMO引用了两个dll1、WPFMediaKit.dll 调用摄像头2、zxing.dll 识别条码
C#调用摄像头,C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头C#调用摄像头
利用MFC搭建简单界面,通过按钮控件实现调用笔记本摄像头功能,后续会实现截图以及视频保存功能,平台为VS2010
1. 拍照主要使用 navigator.mediaDevices.getUserMedia 2. 扫一扫有两种实现方式: a. zepto + qrcode 通过相册图片解析 b. html5-qrcode 通过拍照... 说明: H5调用摄像头要在Https 协议下,PC端和手机端都要测试。
网页调用摄像头实现二维码扫描功能,很强大,,,网上搜的很多H5调用MUI的二维码扫描功能都用不了,不支持,。这个很强大,实现了网页调用摄像头进行二维码扫描功能,帅!
多种方式ASP调用摄像头拍照并保存插件,ASP.NET JSP PHP等插件
uni-app调用摄像头扫码功能示例,拿来即用;
是在320*320屏幕,mdpi上的调用摄像头预览
Qt调用摄像头识别二维码,可实现对各种二维码及条形码的识别,源码利用调用一个摄像头的和一个二维码图片进行识别识别
WPF调用摄像头拍照并保存图片,使用VS打开,完美调用摄像头
PB调用摄像头的工具,简单,方便,功能全可保存照片视频,内含源码,可进行图片的保存,视频的保存,录制视频
Android调用摄像头拍照(兼容7.0)Demo,原博客文章https://blog.csdn.net/u010356768/article/details/70808162
windows系统 程序,安装ipd(windows系统),调用摄像头扫码
关于web调用摄像头和进行反扫二维码等到信息,关于web调用摄像头和进行反扫二维码等到信息。
我写的这个小程序,可以使用labview连续调用摄像头
matlab实现调用电脑摄像头进行gui界面拍摄,简单代码直接运行,可能根据提示安装必要的库,保存图像放在路径文件夹中