Created
January 1, 2018 18:44
-
-
Save paskowski/a922c01d36ff6c543f46dd882cf49367 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import UIKit | |
class BlurImageOperation: Operation { | |
var outputImage: UIImage? | |
override func main() { | |
guard let imageProvider = dependencies.first as? ImageProvider, | |
let providedImage = imageProvider.providedImage else { return } | |
let ciImage = CIImage(image: providedImage)! | |
guard let crystallize = CIFilter(name: "CICrystallize", | |
withInputParameters: [kCIInputRadiusKey: 30, | |
kCIInputImageKey: ciImage]) | |
else { return } | |
let ciContext = CIContext() | |
guard let crystallizedImage = crystallize.outputImage else { return } | |
let cgImage = ciContext.createCGImage(crystallizedImage, | |
from: crystallizedImage.extent) | |
outputImage = UIImage(cgImage: cgImage!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment