为什么我需要UIGraphicsGetImageFromCurrentContext来从CIImage中获取正确的UIImage

时间:2015-03-05 15:54:16

标签: ios swift core-image ciimage

有人可以向我解释为什么这会不正确地显示图像:

var image = UIImage(named: "test-pattern.jpg")
let ciImage = CIImage(image: image)
myUIImageView.image = UIImage(CIImage: ciImage)

但这不是:

var image = UIImage(named: "test-pattern.jpg")
var ciImage = CIImage(image: image)

UIGraphicsBeginImageContext(CGSizeMake(ciImage.extent().size.height,ciImage.extent().size.width))

var testUIImage = UIImage(CIImage: ciImage)

testUIImage?.drawInRect(CGRectMake(0, 0, ciImage.extent().size.height, ciImage.extent().size.width))

let finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext()

var image = UIImage(named: "test-pattern.jpg")
let ciImage = CIImage(image: image)

这是应该完成的方式,还是可以更有效地完成?

0 个答案:

没有答案