Created
September 20, 2017 09:34
-
-
Save tonisuter/5aa502ea1e096ef9d8fa133eef2a40be to your computer and use it in GitHub Desktop.
Modify pixels of a UIImage
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
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