Skip to content

Instantly share code, notes, and snippets.

@quentinfasquel
Last active March 27, 2020 23:30
Show Gist options
  • Save quentinfasquel/5ff09fc720262ac37d7c33ac03735393 to your computer and use it in GitHub Desktop.
Save quentinfasquel/5ff09fc720262ac37d7c33ac03735393 to your computer and use it in GitHub Desktop.
guard let filter = CIFitler(name: "CIBlendWithMask") else {
// Could not find the built-in filter
return nil
}
let backgroundImage = CIImage(color: .clear).cropped(to: inputImage.extent)
filter.setValue(backgroundImage, forKey: kCIInputBackgroundImageKey)
filter.setValue(inputImage, forKey: kCIInputImageKey)
filter.setValue(maskImage, forKey: kCIInputMaskImageKey)
return filter.outputImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment