Skip to content

Instantly share code, notes, and snippets.

@KatagiriSo
Created November 16, 2015 08:21
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 KatagiriSo/928c2b97b65e70062412 to your computer and use it in GitHub Desktop.
Save KatagiriSo/928c2b97b65e70062412 to your computer and use it in GitHub Desktop.
画像フィルター
// 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