我如何结合两个或更多的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)

你可以试试这样做:

    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)
    }

您应该使用CIFilter-s:)

教程

相关内容

  • 没有找到相关文章

最新更新