Contents

sourceInCompositing()

Subtracts non-overlapping areas of two images, resulting in one image.

Declaration

class func sourceInCompositing() -> any CIFilter & CICompositeOperation

Return Value

The modified image.

Discussion

This method applies the source-in compositing filter to an image. The effect creates the result by overlaying the input image over the background image. The filter then removes the non-overlapping area of both images.

The source-in compositing filter uses the following properties:

inputImage

An image with the type CIImage.

backgroundImage

An image with the type CIImage.

The following code creates a filter that results in an output image that shows the portion of the background image that overlaps with the input:

func sourceInCompositing(inputImage: CIImage, backgroundImage: CIImage) -> CIImage {
    let colorBlendFilter = CIFilter.sourceInCompositing()
    colorBlendFilter.inputImage = inputImage
    colorBlendFilter.backgroundImage = backgroundImage
    return colorBlendFilter.outputImage!
}

[Image]

See Also

Filters