 import CoreImage
 import Accelerate
 
+/// Due to a bug in Xcode (typecasting Fails only inside the extension block) I created this alias of CIImage
+typealias BFCIImage = CIImage
+
 /// This extesion adds some useful functions to UIImage
 public extension UIImage
 {

        let context: CIContext = CIContext(options: nil)
        let filter: CIFilter = CIFilter(name: "CICircularWrap")
        
        filter.setValue(self.CIImage, forKey: kCIInputImageKey)
        filter.setValue(center, forKey: "inputCenter")
        filter.setValue(NSNumber(float: radius), forKey: "inputRadius")
        filter.setValue(NSNumber(float: angle), forKey: "inputAngle")
        
        let returnImage: UIImage = UIImage(CIImage: filter.outputImage)!
        
        return returnImage
    }

        let context: CIContext = CIContext(options: nil)
        let filter: CIFilter = CIFilter(name: "CIBumpDistortionLinear")
        
        var ciimage: BFCIImage = BFCIImage(image: self)
        
        filter.setValue(ciimage, forKey: kCIInputImageKey)
        filter.setValue(center, forKey: kCIInputCenterKey)
        filter.setValue(radius, forKey: kCIInputRadiusKey)
        filter.setValue(angle, forKey: kCIInputAngleKey)
        filter.setValue(scale, forKey: kCIInputScaleKey)
        
        let returnImage: UIImage = UIImage(CGImage: context.createCGImage(filter.outputImage, fromRect: filter.outputImage.extent()))!
        
        return returnImage
    }
