Skip to content

Instantly share code, notes, and snippets.

@tonisuter
Created September 20, 2017 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonisuter/5aa502ea1e096ef9d8fa133eef2a40be to your computer and use it in GitHub Desktop.
Save tonisuter/5aa502ea1e096ef9d8fa133eef2a40be to your computer and use it in GitHub Desktop.
Modify pixels of a UIImage
func applyFilter(to image: UIImage) -> UIImage? {
guard let context = prepareContext(for: image),
let pixelBuffer = getPixelBuffer(from: context) else {
return nil
}
// TODO: Hier müssen wir die einzelnen Pixel im pixelBuffer modifizieren und wieder
// zurück in den pixelBuffer schreiben.
guard let outputCGImage = context.makeImage() else {
return nil
}
return UIImage(cgImage: outputCGImage, scale: image.scale, orientation: image.imageOrientation)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment