Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

cifilter image preserve orientation

var filterNames: [String] = ["CIPhotoEffectTonal","CIPhotoEffectNoir","CIMaximumComponent","CIMinimumComponent","CIDotScreen", "CISepiaTone", "CIFalseColor", "CIColorInvert", "CIColorPosterize", "CIPhotoEffectChrome", "CIPhotoEffectInstant"]

    let CIfilterName = filterNames[indexPath.row]
    print(CIfilterName)

    let ciContext = CIContext(options: nil)
    let startImage = CIImage(image: originalImage)

    let filter = CIFilter(name: CIfilterName)
    filter!.setDefaults()

    filter!.setValue(startImage, forKey: kCIInputImageKey)
    let filteredImageData = filter!.valueForKey(kCIOutputImageKey) as! CIImage
    let filteredImageRef = ciContext.createCGImage(filteredImageData, fromRect: filteredImageData.extent)

    let originalOrientation: UIImageOrientation = (imageView.image?.imageOrientation)!
    let originalScale: CGFloat = (imageView.image?.scale)!
    let newPtImage: UIImage = UIImage.imageWithCGImage(filteredImageRef, scale: originalScale, orientation: originalOrientation)
    imageView.image = newPtImage

    imageView.image = UIImage(CGImage: filteredImageRef);
Comment

PREVIOUS NEXT
Code Example
Swift :: how to figure out ios vesion swift 
Swift :: xcode combine calayer into an image 
Swift :: flutter create custom appbar 
Ruby :: kill rails 
Ruby :: devise generate controller 
Ruby :: rails send test email 
Ruby :: ruby filename from path 
Ruby :: rspec check array without order 
Ruby :: exit program ruby 
Ruby :: how to check ruby version 
Ruby :: ruby is int 
Ruby :: rails g model references 
Ruby :: ruby capitalize first character of sentence 
Ruby :: rails update without callback 
Ruby :: get date millis rails 
Ruby :: ruby check if value in array 
Ruby :: ruby if 
Ruby :: ruby global variable 
Ruby :: ruby strings 
Ruby :: ruby debugger 
Ruby :: ruby string trmi 
Ruby :: rails 10 times do 
Ruby :: ruby map hash 
Ruby :: how to update model rails 
Ruby :: filter through array of arrays ruby 
Ruby :: how do I update an index in rails 
Ruby :: ruby on rails 4.2 how to add GET route 
Ruby :: rails view method on console 
Ruby :: Replacing consecutive numbers with dash between first and last in a range 
Ruby :: reduce ruby baud rate 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =