2010-10-11 83 views
1

我想复制一个uiimage(最终我计划模糊副本)。现在复制的图像在模拟器中正确显示,但在设备上运行时最终旋转了90度。UIImage复制结束旋转

我使用以下内容来创建ACOPY:

CGImageRef cgImage = [sourceImage CGImage]; 

//使从CG参考 UIImage的新的图像* copyOfImage = [[UIImage的页头] initWithCGImage:cgImage];

源图像来自UIImagePickerController。无论我从图书馆还是相机拿取相同的结果都会发生。

预先感谢任何帮助

回答

0

根据对UIImage的文件,imageOrientation属性包含方位的图像,其默认值为UIImageOrientationUp。但是如果图像有任何方向的EXIF数据,它将返回。 (CGImageRef)cgiImage和initWithCGImage:(CGImageRef)CGImage(在UIImage中)都默认为UIImageOrientationUp方向,如果图像/电影实际上是在例如图像中拍摄的,那么这可能是错误的。风景模式。

但是,如果您使用以上版本的方向以及通过sourceImage.imageOrientation它应该工作。

0

刚刚发生这种情况,特别是模糊使用,我不会建议使用完整的图像。

我发现这个过程太慢了,而且由于原始图像模糊不清,您最好先制作一个小图像,然后将其缩放并将其模糊化。

我没有测试过,因为它与我原来的项目有点不同。

此代码使用UIImage + Resize进行调整大小。

//Creates an autoreleased representing the current screen view 
-(UIImage *)currentBlurredImage:(UIImage *)anImage{ 

CGImageRef imageRef = CGImageCreateWithImageInRect([anImage CGImage], bounds); 
UIImage *coppiedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:anImage.imageOrientation]; 

coppiedImage = [viewImage resizedImage:CGSizeMake(120, 80) interpolationQuality:kCGInterpolationLow]; 
coppiedImage = [viewImage blurredCopyUsingGuassFactor:4 andPixelRadius:4]; 
return coppiedImage ; 

}

模糊处理与代码完成从这里http://iphonedevelopment.blogspot.com/2010/08/uiimage-blur.html(信贷,其应有的!)。但是,我清理它并处理了一堆内存和其他问题。

http://pastebin.com/MaHvvdim