我尝试使用以下代码行创建一个颜色过滤器
let parameters = [kCIInputColorKey: CIColor(string: "0.5 0.7 0.3 1.0")]
let colorFilter = CIFilter(name: "CIConstantColorGenerator", withInputParameters: parameters)
colorFilter?.outputImage
但调试控制台输出滚动信息
<Error>: CGImageProviderCreate: invalid image provider size: 1.79769e+308 x 1.79769e+308.
<Error>: CGImageCreate: invalid image width.
<Error>: ImageIO: CGImageDestinationFinalize image destination must have at least one image
CGImageDestinationFinalize failed for output type 'public.tiff'
谢谢, 加:我试着在Swift Project中编写这个代码,它运行正常,但在操场上工作时,只显示了这个错误
答案 0 :(得分:4)
尝试澄清您想要获得的输出图像大小:
colorFilter?.outputImage?.imageByCroppingToRect(CGRectMake(0, 0, 200, 200))