Created
June 11, 2020 17:02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.beginImage = CIImage(image: UIImage(named: "milk")!) | |
self.context = CIContext(options: nil) | |
let url = Bundle.main.url(forResource: "default", withExtension: "metallib")! | |
let data = try! Data(contentsOf: url) | |
let kernel = try! CIColorKernel(functionName: "myColor", fromMetalLibraryData: data) | |
let output = kernel.apply(extent: beginImage.extent, arguments: [beginImage as Any])! | |
if let cgimg = context.createCGImage(output, from: output.extent) { | |
let processedImage = UIImage(cgImage: cgimg) | |
self.imgView.image = processedImage | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment