Ios 从UIImage(Swift)获取CIImage

Ios 从UIImage(Swift)获取CIImage,ios,swift,uikit,Ios,Swift,Uikit,试图从UIImage获取CIImage以将其用于CIFilter,但在最后一行出现以下异常: Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) 我做错了什么 import UIKit UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0) let con:CGContextRef = UIGra

试图从UIImage获取CIImage以将其用于CIFilter,但在最后一行出现以下异常:

Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
我做错了什么

import UIKit

UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0)
let con:CGContextRef = UIGraphicsGetCurrentContext()
CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
CGContextFillPath(con)
let im:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

let ciimage = CIImage(image: im) // <- Exception here
导入UIKit
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100100),false,0)
让con:CGContextRef=UIGraphicsGetCurrentContext()
CGContextAddEllipseInRect(con,CGRectMake(0,0100))
CGContextSetFillColorWithColor(con,UIColor.blueColor().CGColor)
CGContextFillPath(con)
让im:UIImage=UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsSendImageContext()

让ciimage=ciimage(image:im)//如果您尝试使用过滤器,我解决了以下问题:

let pic = UIImage(named: "crumpled.jpg")
let filter = CIFilter(name: "CISepiaTone")
filter.setValue(CIImage(image: pic), forKey: kCIInputImageKey)
filter.setValue(0.8, forKey: kCIInputIntensityKey)
let ctx = CIContext(options:nil)
let cgImage = ctx.createCGImage(filter.outputImage, fromRect:filter.outputImage.extent())

这在一行中是可能的

UIImage>CIImage

let ciimage = CIImage(image: image)
CIImage>UIImage

let image = UIImage(ciImage: ciimage)

这在操场上是失败的,但在编译代码中对我有效——这一定是操场环境的一个怪癖。是的,在编译代码时对我也有效。
let image = UIImage(ciImage: ciimage)