Created
November 16, 2015 08:21
-
-
Save KatagiriSo/928c2b97b65e70062412 to your computer and use it in GitHub Desktop.
画像フィルター
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
// filterの一覧はCore Image Filter Referenceにあり。 | |
func sepiaFilter(image:UIImage) -> UIImage? | |
{ | |
let ciImage = CIImage(image: image) | |
let filter = CIFilter(name: "CISepiaTone") | |
filter.setValue(ciImage, forKey: kCIInputImageKey) | |
filter.setValue(0.8, forKey: "inputIntensity") | |
let ciContext = CIContext(options: nil) | |
let cgimg = ciContext.createCGImage(filter.outputImage, fromRect: filter.outputImage.extent()) | |
let resImage = UIImage(CGImage: cgimg, scale: 1.0, orientation: UIImageOrientation.Up) | |
return resImage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment