如何拍照后剪裁图片
展开全部
看下面的代码,希望对你有帮助:-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ //拍照后获取到的照片数据 [picker dismissModalViewControllerAnimated:YES]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; //开个新线程,去裁剪照片,满足尺寸要求(新线程的目的是有效降低内存消耗,避免crash) [NSThread detachNewThreadSelector:@selector(useImage:) toTarget:self withObject:image];}- (void)useImage:(UIImage *)image { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //裁剪指定尺寸的方法 UIImage *sharkenImage = [self imageWithImageSimple:image scaledToSize:CGSizeMake(440, 440)]; //改png格式为jpg格式,以降低容量 NSData* imageData = UIImageJPEGRepresentation(sharkenImage, 0.5); //保存到documents等目录下 [imageData writeToFile:uploadPicPath atomically:YES]; [pool release]; } 查看原帖>>
展开全部
看下面的代码,希望对你有帮助:-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ //拍照后获取到的照片数据 [picker dismissModalViewControllerAnimated:YES]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; //开个新线程,去裁剪照片,满足尺寸要求(新线程的目的是有效降低内存消耗,避免crash) [NSThread detachNewThreadSelector:@selector(useImage:) toTarget:self withObject:image];}- (void)useImage:(UIImage *)image { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //裁剪指定尺寸的方法 UIImage *sharkenImage = [self imageWithImageSimple:image scaledToSize:CGSizeMake(440, 440)]; //改png格式为jpg格式,以降低容量 NSData* imageData = UIImageJPEGRepresentation(sharkenImage, 0.5); //保存到documents等目录下 [imageData writeToFile:uploadPicPath atomically:YES]; [pool release]; }
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询