问题
This is really annoying me. When I convert a UIImage to a CIImage, apply a filter then convert back the image is upside down (for landscape) or rotated anticlockwise 90 degrees (for portrait).
var image:UIImage?
var index:Int?
@IBOutlet weak var photo: UIImageView!
@IBAction func editImage(sender: UIBarButtonItem) {
println("editImage")
let beginImage = CIImage(image: self.image)
let filter = CIFilter(name: "CISepiaTone")
filter.setValue(beginImage, forKey: kCIInputImageKey)
filter.setValue(0.8, forKey: kCIInputIntensityKey)
let newImage = UIImage(CIImage: filter.outputImage)
self.photo.image = newImage
}
回答1:
Set the image orientation and scale of the filtered image back to the original values:
let newImage = UIImage(CIImage:filter.outputImage, scale:self.image.scale, orientation:self.image.imageOrientation)
来源:https://stackoverflow.com/questions/26745026/when-applying-a-filter-to-a-uiimage-the-result-is-upside-down