拍照有旋转角度,会导致直接存储变成90度
下面的是简单的解决方式,不太齐全,但可以参考图片处理功能
完整的做法参考这个比较好:
http://stackoverflow.com/q...
原创内容如转载请注明:来自 阿权的书房
下面的是简单的解决方式,不太齐全,但可以参考图片处理功能
完整的做法参考这个比较好:
http://stackoverflow.com/q...
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:@"public.image"]) {
UIImage* image=[info objectForKey:UIImagePickerControllerOriginalImage];
UIImageOrientation imageOrientation=image.imageOrientation;
if(imageOrientation!=UIImageOrientationUp)
{
// 原始图片可以根据照相时的角度来显示,但UIImage无法判定,于是出现获取的图片会向左转90度的现象。
// 以下为调整图片角度的部分
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// 调整图片角度完毕
}
[picker dismissViewControllerAnimated:YES completion:nil];
}
}
{
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:@"public.image"]) {
UIImage* image=[info objectForKey:UIImagePickerControllerOriginalImage];
UIImageOrientation imageOrientation=image.imageOrientation;
if(imageOrientation!=UIImageOrientationUp)
{
// 原始图片可以根据照相时的角度来显示,但UIImage无法判定,于是出现获取的图片会向左转90度的现象。
// 以下为调整图片角度的部分
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// 调整图片角度完毕
}
[picker dismissViewControllerAnimated:YES completion:nil];
}
}
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
棒磨机

2015/06/03 14:10
正好用上了····谢谢
分页: 1/1
1

