ios - 我如何结合两个或多个 CIImage

标签 ios swift 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)
    }

关于ios - 我如何结合两个或多个 CIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31996715/

相关文章:

ios - Collection View 中的节数

ios - 带有渐变边缘的按钮下方的 BlurView

iOS 8 : Autorotation is not working without storyboard

swift - UIImageView 背景图像上的视差 UIScrollview

swift - 如何在不拉伸(stretch)原始图像的情况下扩展 CIImage 的空间(边界)?

ios - 如何在 SwiftUI 中添加背景图像以完成 View

ios - 如何在不使用 Swift 中的 Storyboard 的情况下以编程方式加载 UIViewController

ios - 在 iOS 中的自定义 View 中播放视频

rotation - 使用 CGAffineTransformMakeRotation 在 Swift 2 中旋转 CIImage

ios - Core Image 中 CIGammaAdjust 滤波器的输入功率值