由于某些原因,我需要将图像从 UIImage 转换为 CIImage(用于处理)并再次转换回 UIImage。我是通过 UIImage-CGImage-CIImage-UIImage 来做的。忽略不相关的代码,代码显示在后面。
UIImage *originalPic = [[UIImage alloc]init];//get this from UIImagePickerController
CIImage *originalCIPic = [[CIImage alloc]init];
originalCIPic = [CIImage imageWithCGImage:originalPic.CGImage];
UIImage *finalResultUIImage = [UIImage imageWithCIImage:originalCIPic];
//then I put the image on an Image View(contentMode has been set)
self.viewOfImage.contentMode = UIViewContentModeScaleAspectFit;
self.viewOfImage.image=finalResultUIImage;
//I used NSLog to check the size, but they are the same.(before transforming and after)
NSLog(@"this is the final UIImage,size is %@ ",NSStringFromCGSize(finalResultUIImage.size));
但是屏幕上显示的图像被拉伸了。
我怎么了?或者我有其他选择吗?
非常感谢,我很抱歉我没有足够的声誉来张贴图片。:)