如何将两个或多个CIImage合并到另一个CIImage中。我尝试使用ciContext.drawImage。我如何从中获得CGImage?我所理解的是,我正在写一个上下文,我应该可以从中获得一个图像。如果我理解错误,请告诉我。
let eaglContext = EAGLContext(API: .OpenGLES2)
let ciContext = CIContext(EAGLContext: eaglContext)
ciContext.drawImage(firstCIImage, inRect: firstRect, fromRect: secondRect)
ciContext.drawImage(secondCIImage, inRect: secondRect, fromRect: secondRect)
答案 0 :(得分:3)
您可以尝试这样的事情:
var outputImage: CIImage?
let images : Array<CIImage> = [] // add all your CIImages that you'd like to combine
for image in images {
outputImage = outputImage == nil ? image : image.imageByCompositingOverImage(outputImage!)
}
var cgImage: CGImageRef
if let image = outputImage {
let eaglContext = EAGLContext(API: .OpenGLES2)
let ciContext = CIContext(EAGLContext: eaglContext)
cgImage = ciContext.createCGImage(image, fromRect: image.extent)
}
答案 1 :(得分:2)
您应该使用CIFilter-s:)